diff --git a/Makefile b/Makefile index d585d52a..cd09060a 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,11 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 Regents of the University of California -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -# The top directory where environment will be created. TOP_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) +include $(TOP_DIR)/openram.mk -.DEFAULT_GOAL := all +.DEFAULT_GOAL := install # Skywater PDK SRAM library -#SRAM_LIBRARY ?= $(PDK_ROOT)/skywater-pdk/libraries/sky130_fd_bd_sram SRAM_GIT_REPO ?= https://github.com/google/skywater-pdk-libs-sky130_fd_bd_sram.git +SRAM_GIT_COMMIT ?= 9fa642baaf01110b59ac2783beba9a4fda03aeaf SRAM_LIBRARY ?= $(TOP_DIR)/sky130_fd_bd_sram # Open PDKs @@ -55,11 +37,6 @@ INSTALL_BASE := $(OPENRAM_HOME)/../technology/sky130 INSTALL_DIRS := $(addprefix $(INSTALL_BASE)/,$(INSTALL_BASE_DIRS)) -install: $(INSTALL_DIRS) - -$(SRAM_LIBRARY): - git clone $(SRAM_GIT_REPO) $(SRAM_LIBRARY) - $(OPEN_PDKS): git clone $(OPEN_PDKS_REPO) $(PDK_ROOT) cd $(PDK_ROOT) &&\ @@ -68,7 +45,7 @@ $(OPEN_PDKS): .PHONY: $(SRAM_LIBRARY) $(OPEN_PDKS) $(INSTALL_DIRS) install -all: $(SRAM_LIBRARY) $(OPEN_PDKS) +install: $(SRAM_LIBRARY) $(INSTALL_DIRS) $(OPEN_PDKS) @echo "Installing sky130 SRAM PDK..." @echo "PDK_ROOT='$(PDK_ROOT)'" @echo "SRAM_LIBRARY='$(SRAM_LIBRARY)'" @@ -76,6 +53,12 @@ all: $(SRAM_LIBRARY) $(OPEN_PDKS) make install @true +$(SRAM_LIBRARY): + git clone $(SRAM_GIT_REPO) $(SRAM_LIBRARY) + +.PHONY: $(SRAM_LIBRARY) $(INSTALL_DIRS) install + + $(INSTALL_BASE)/gds_lib: $(GDS_FILES) @echo @echo "Setting up GDS cell library for OpenRAM." @@ -149,7 +132,29 @@ $(INSTALL_BASE)/sp_lib: $(filter-out %.$(SPICE_LVS_SUFFIX) %.$(SPICE_CALIBRE_SUF @echo "==================================================================" @echo -clean: +macros: + cd macros && make + +.PHONY: macros + +tests: + docker run -v $(TOP_DIR):/openram \ + -e OPENRAM_HOME=/openram/compiler \ + -e OPENRAM_TECH=/openram/technology \ + vlsida/openram-ubuntu:latest \ + sh -c "cd /openram/compiler/tests && ./regress.py -v -k" +.PHONY: tests + + +mount: + docker run -it -v $(TOP_DIR):/openram \ + -e OPENRAM_HOME=/openram/compiler \ + -e OPENRAM_TECH=/openram/technology \ + vlsida/openram-ubuntu:latest +.PHONY: macros + + +uninstall: rm -rf $(SRAM_LIBRARY) rm -rf $(PDK_ROOT) rm -f $(INSTALL_BASE)/tech/.magicrc @@ -157,3 +162,4 @@ clean: rm -f $(INSTALL_BASE)/lef_lib/.magicrc rm -f $(INSTALL_BASE)/maglef_lib/.magicrc rm -rf $(INSTALL_DIRS) +.PHONY: uninstall diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..939b911b --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,94 @@ +FROM ubuntu:20.04 + +ENV DEBIAN_FRONTEND noninteractive +RUN ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime +RUN echo "America/Los_Angeles" > /etc/timezone + +RUN apt-get update +RUN apt-get --no-install-recommends -y upgrade + +### Dependencies ### +# General tools for building etc. +RUN apt-get install --no-install-recommends -y build-essential git ssh vim gosu autoconf automake libtool bison flex +# Use bash instead of dash +RUN rm /bin/sh && ln -s /bin/bash /bin/sh +# Needed by OpenRAM +RUN apt-get install --no-install-recommends -y python3 python3-numpy python3-scipy python3-pip python3-matplotlib python3-venv python3-sklearn python3-subunit python3-coverage +# Needed by Netgen +RUN apt-get install --no-install-recommends -y m4 csh tk tk-dev tcl-dev +# Needed by ngspice +RUN apt-get install --no-install-recommends -y libxaw7-dev libreadline8 libreadline-dev +# X11 +RUN apt-get install --no-install-recommends -y libx11-dev libcairo2-dev +# Klayout +RUN apt-get install --no-install-recommends -y qt5-default qtcreator ruby-full ruby-dev python3-dev qtmultimedia5-dev libqt5multimediawidgets5 libqt5multimedia5-plugins libqt5multimedia5 libqt5svg5-dev libqt5designer5 libqt5designercomponents5 libqt5xmlpatterns5-dev qttools5-dev + +### Klayout ### +ARG KLAYOUT_COMMIT=ea1bf40a1ee1c1c934e47a0020417503ab3d7e7e +WORKDIR /root +RUN git clone https://github.com/KLayout/klayout +WORKDIR /root/klayout +RUN git checkout ${KLAYOUT_COMMIT} +RUN ./build.sh -qt5 \ + && cp -r bin-release /usr/local/klayout +RUN rm -rf /root/klayout + +### Magic ### +ARG MAGIC_COMMIT=8.3.221 +WORKDIR /root +RUN git clone git://opencircuitdesign.com/magic-8.3 magic +WORKDIR /root/magic +RUN git checkout ${MAGIC_COMMIT} +RUN ./configure \ + && make \ + && make install +RUN rm -rf /root/magic + +### Ngspice ### +ARG NGSPICE_COMIT=032b1c32c4dbad45ff132bcfac1dbecadbd8abb0 +WORKDIR /root +RUN git clone git://git.code.sf.net/p/ngspice/ngspice +WORKDIR /root/ngspice +RUN git checkout ${NGSPICE_COMMIT} +RUN ./autogen.sh \ + && ./configure --enable-openmp --with-readline \ + && make \ + && make install +RUN rm -rf /root/ngspice + +### Netgen ### +ARG NETGEN_COMMIT=1.5.194 +WORKDIR /root +RUN git clone git://opencircuitdesign.com/netgen-1.5 netgen +WORKDIR /root/netgen +RUN git checkout ${NETGEN_COMMIT} +RUN ./configure \ + && make -j$(nproc) \ + && make install +RUN rm -rf /root/netgen + +#ARG XYCE_COMMIT=b7bb12d81f11d8b50141262537299b09d64b5565 +#ARG TRILINOS_COMIT= + +# ### SET UP A GENERIC USER ### +# WORKDIR / +# RUN echo "cd ~" >> /etc/skel/.bashrc +# RUN echo "source /set-paths.sh" >> /etc/skel/.bashrc +# ADD set-paths.sh /set-paths.sh +# RUN chmod 755 /set-paths.sh + +### CLEAN UP ### + +# Remove development tools to save space +RUN apt-get remove -y build-essential autoconf automake libtool bison flex tcl-dev tk-dev +# Cleanup to save some space +RUN apt-get clean +RUN rm -rf /var/lib/apt/lists/* + +WORKDIR / + +### ADD ENTRY POINT ### +# COPY entrypoint.sh /usr/local/bin/entrypoint.sh +# RUN chmod 755 /usr/local/bin/entrypoint.sh +# ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] +# CMD ["/bin/bash"] diff --git a/docker/Makefile b/docker/Makefile new file mode 100644 index 00000000..067cf49c --- /dev/null +++ b/docker/Makefile @@ -0,0 +1,17 @@ + +TAG_DATE := $(shell date +%F) +all: build push + +.PHONY: build +build: + docker build -t vlsida/openram-ubuntu:${TAG_DATE} -f Dockerfile . | tee -i openram-ubuntu.log + docker tag vlsida/openram-ubuntu:${TAG_DATE} vlsida/openram-ubuntu:latest + +.PHONY: push +push: + docker login + docker push vlsida/openram-ubuntu:latest + +.PHONY: pull +pull: + docker pull vlsida/openram-ubuntu:latest diff --git a/docker/set-paths.sh b/docker/set-paths.sh new file mode 100644 index 00000000..96582dbd --- /dev/null +++ b/docker/set-paths.sh @@ -0,0 +1,20 @@ + +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin + +export SWROOT=/software + +# Klayout +export PATH=$PATH:/usr/local/klayout/bin + +# Xyce +export XYCE_HOME=$SWROOT/Xyce/Parallel +export XYCE_PATH=$XYCE_HOME/bin +export PATH=$PATH:$XYCE_PATH +export XYCE_LIB=$XYCE_HOME/lib +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$XYCE_LIB +export XYCE_NO_TRACKING="anything at all" + +# PDKs +export FREEPDK45=/home/PDKs/FreePDK45 +# Set to the PDK you want to use +export PDK_DIR=$FREEPDK45 diff --git a/macros/Makefile b/macros/Makefile new file mode 100644 index 00000000..2e0ecc0f --- /dev/null +++ b/macros/Makefile @@ -0,0 +1,72 @@ +MACRO_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) +TOP_DIR := $(realpath $(MACRO_DIR)/..) +include $(TOP_DIR)/openram.mk + +.DEFAULT_GOAL := all + +OPENRAM_OPTS := $(OPENRAM_OPTS) +# Define `OPENRAM_FULL` in your environment to run a full characterize +ifeq ($(OPENRAM_FULL),) +# Do not characterize (default) +else +# Characterize +OPTS += -c +endif +# Verbosity +OPENRAM_OPTS += -v --keeptemp + +CONFIG_DIR = configs +SRCS=$(filter-out disabled-% %_common.py,$(sort $(notdir $(wildcard $(CONFIG_DIR)/*.py)))) +DIRS=$(basename $(SRCS)) +STAMPS=$(addsuffix .ok,$(DIRS)) + +configs: + @echo + @echo "Using OpenRAM at $(OPENRAM_HOME)" + @echo " (which is version $$(cd $(OPENRAM_HOME); git describe --tags))" + @echo + @echo "Configurations:" + @for D in $(DIRS); do echo " - $$D"; done + @echo + +.PHONY: configs + +BROKEN := \ + sky130_sram_1kbyte_1r1w_8x1024_8 \ + sky130_sram_1kbyte_1rw_32x256_8 \ + sky130_sram_2kbyte_1rw_32x512_8 \ + sky130_sram_4kbyte_1rw_32x1024_8 \ + +WORKING_STAMPS=$(filter-out $(addsuffix .ok, (BROKEN)), $(STAMPS)) + +all: | configs + @echo + @echo "Building following working configs" + @for S in $(WORKING_STAMPS); do echo " - $$S"; done + @sleep 5 + $(MAKE) $(WORKING_STAMPS) + @echo "Built all macros." + +%.ok: configs/%.py + @echo "Building $*" + @mkdir -p $* + docker run -v $(TOP_DIR):/openram \ + -v $(PDK_ROOT)/share/sky130A:/sky130A \ + -e PDK_ROOT=/ \ + -e OPENRAM_HOME=/openram/compiler \ + -e OPENRAM_TECH=/openram/technology \ + -e OPENRAM_TMP=/openram/macros/$*/tmp \ + vlsida/openram-ubuntu:latest \ + python3 -u /openram/compiler/openram.py $(OPENRAM_OPTS) -o $* -p /openram/macros/$* /openram/macros/$< && touch $@ + +.DELETE_ON_ERROR: $(STAMPS) + +$(DIRS): + @$(MAKE) --no-print-directory $@.ok + +.PHONY: $(DIRS) + +clean: + rm -rf $(STAMPS) + rm -rf $(DIRS) +.PHONY: clean diff --git a/compiler/example_configs/big_config_scn4m_subm.py b/macros/configs/big_config_scn4m_subm.py similarity index 100% rename from compiler/example_configs/big_config_scn4m_subm.py rename to macros/configs/big_config_scn4m_subm.py diff --git a/compiler/example_configs/example_config_1rw_1r_scn4m_subm.py b/macros/configs/example_config_1rw_1r_scn4m_subm.py similarity index 100% rename from compiler/example_configs/example_config_1rw_1r_scn4m_subm.py rename to macros/configs/example_config_1rw_1r_scn4m_subm.py diff --git a/compiler/example_configs/example_config_1rw_1w_scn4m_subm.py b/macros/configs/example_config_1rw_1w_scn4m_subm.py similarity index 100% rename from compiler/example_configs/example_config_1rw_1w_scn4m_subm.py rename to macros/configs/example_config_1rw_1w_scn4m_subm.py diff --git a/compiler/example_configs/example_config_1rw_2mux_scn4m_subm.py b/macros/configs/example_config_1rw_2mux_scn4m_subm.py similarity index 100% rename from compiler/example_configs/example_config_1rw_2mux_scn4m_subm.py rename to macros/configs/example_config_1rw_2mux_scn4m_subm.py diff --git a/compiler/example_configs/example_config_1w_1r_scn4m_subm.py b/macros/configs/example_config_1w_1r_scn4m_subm.py similarity index 100% rename from compiler/example_configs/example_config_1w_1r_scn4m_subm.py rename to macros/configs/example_config_1w_1r_scn4m_subm.py diff --git a/compiler/example_configs/example_config_2rw_scn4m_subm.py b/macros/configs/example_config_2rw_scn4m_subm.py similarity index 100% rename from compiler/example_configs/example_config_2rw_scn4m_subm.py rename to macros/configs/example_config_2rw_scn4m_subm.py diff --git a/compiler/example_configs/example_config_freepdk45.py b/macros/configs/example_config_freepdk45.py similarity index 100% rename from compiler/example_configs/example_config_freepdk45.py rename to macros/configs/example_config_freepdk45.py diff --git a/compiler/example_configs/example_config_scn4m_subm.py b/macros/configs/example_config_scn4m_subm.py similarity index 100% rename from compiler/example_configs/example_config_scn4m_subm.py rename to macros/configs/example_config_scn4m_subm.py diff --git a/compiler/example_configs/giant_config_scn4m_subm.py b/macros/configs/giant_config_scn4m_subm.py similarity index 100% rename from compiler/example_configs/giant_config_scn4m_subm.py rename to macros/configs/giant_config_scn4m_subm.py diff --git a/compiler/example_configs/medium_config_scn4m_subm.py b/macros/configs/medium_config_scn4m_subm.py similarity index 100% rename from compiler/example_configs/medium_config_scn4m_subm.py rename to macros/configs/medium_config_scn4m_subm.py diff --git a/compiler/example_configs/riscv_freepdk45_8kbyte.py b/macros/configs/riscv_freepdk45_8kbyte.py similarity index 100% rename from compiler/example_configs/riscv_freepdk45_8kbyte.py rename to macros/configs/riscv_freepdk45_8kbyte.py diff --git a/compiler/example_configs/riscv_scn4m_subm_16kbyte_1rw1r.py b/macros/configs/riscv_scn4m_subm_16kbyte_1rw1r.py similarity index 100% rename from compiler/example_configs/riscv_scn4m_subm_16kbyte_1rw1r.py rename to macros/configs/riscv_scn4m_subm_16kbyte_1rw1r.py diff --git a/compiler/example_configs/riscv_scn4m_subm_1kbyte_1rw1r.py b/macros/configs/riscv_scn4m_subm_1kbyte_1rw1r.py similarity index 100% rename from compiler/example_configs/riscv_scn4m_subm_1kbyte_1rw1r.py rename to macros/configs/riscv_scn4m_subm_1kbyte_1rw1r.py diff --git a/compiler/example_configs/riscv_scn4m_subm_2kbyte_1rw1r.py b/macros/configs/riscv_scn4m_subm_2kbyte_1rw1r.py similarity index 100% rename from compiler/example_configs/riscv_scn4m_subm_2kbyte_1rw1r.py rename to macros/configs/riscv_scn4m_subm_2kbyte_1rw1r.py diff --git a/compiler/example_configs/riscv_scn4m_subm_32kbyte_1rw1r.py b/macros/configs/riscv_scn4m_subm_32kbyte_1rw1r.py similarity index 100% rename from compiler/example_configs/riscv_scn4m_subm_32kbyte_1rw1r.py rename to macros/configs/riscv_scn4m_subm_32kbyte_1rw1r.py diff --git a/compiler/example_configs/riscv_scn4m_subm_4kbyte_1rw1r.py b/macros/configs/riscv_scn4m_subm_4kbyte_1rw1r.py similarity index 100% rename from compiler/example_configs/riscv_scn4m_subm_4kbyte_1rw1r.py rename to macros/configs/riscv_scn4m_subm_4kbyte_1rw1r.py diff --git a/compiler/example_configs/riscv_scn4m_subm_8kbyte_1rw1r.py b/macros/configs/riscv_scn4m_subm_8kbyte_1rw1r.py similarity index 100% rename from compiler/example_configs/riscv_scn4m_subm_8kbyte_1rw1r.py rename to macros/configs/riscv_scn4m_subm_8kbyte_1rw1r.py diff --git a/compiler/example_configs/riscv_sky130_1kbyte_1rw.py b/macros/configs/riscv_sky130_1kbyte_1rw.py similarity index 100% rename from compiler/example_configs/riscv_sky130_1kbyte_1rw.py rename to macros/configs/riscv_sky130_1kbyte_1rw.py diff --git a/compiler/example_configs/riscv_sky130_1kbyte_1rw1r.py b/macros/configs/riscv_sky130_1kbyte_1rw1r.py similarity index 100% rename from compiler/example_configs/riscv_sky130_1kbyte_1rw1r.py rename to macros/configs/riscv_sky130_1kbyte_1rw1r.py diff --git a/compiler/example_configs/riscv_sky130_2kbyte_1rw.py b/macros/configs/riscv_sky130_2kbyte_1rw.py similarity index 100% rename from compiler/example_configs/riscv_sky130_2kbyte_1rw.py rename to macros/configs/riscv_sky130_2kbyte_1rw.py diff --git a/compiler/example_configs/riscv_sky130_2kbyte_1rw1r.py b/macros/configs/riscv_sky130_2kbyte_1rw1r.py similarity index 100% rename from compiler/example_configs/riscv_sky130_2kbyte_1rw1r.py rename to macros/configs/riscv_sky130_2kbyte_1rw1r.py diff --git a/compiler/example_configs/riscv_sky130_4kbyte_1rw.py b/macros/configs/riscv_sky130_4kbyte_1rw.py similarity index 100% rename from compiler/example_configs/riscv_sky130_4kbyte_1rw.py rename to macros/configs/riscv_sky130_4kbyte_1rw.py diff --git a/compiler/example_configs/riscv_sky130_4kbyte_1rw1r.py b/macros/configs/riscv_sky130_4kbyte_1rw1r.py similarity index 100% rename from compiler/example_configs/riscv_sky130_4kbyte_1rw1r.py rename to macros/configs/riscv_sky130_4kbyte_1rw1r.py diff --git a/compiler/example_configs/sky130_sram_1kbyte_1r1w_8x1024_8.py b/macros/configs/sky130_sram_1kbyte_1r1w_8x1024_8.py similarity index 100% rename from compiler/example_configs/sky130_sram_1kbyte_1r1w_8x1024_8.py rename to macros/configs/sky130_sram_1kbyte_1r1w_8x1024_8.py diff --git a/compiler/example_configs/sky130_sram_1kbyte_1rw1r_32x256_8.py b/macros/configs/sky130_sram_1kbyte_1rw1r_32x256_8.py similarity index 100% rename from compiler/example_configs/sky130_sram_1kbyte_1rw1r_32x256_8.py rename to macros/configs/sky130_sram_1kbyte_1rw1r_32x256_8.py diff --git a/compiler/example_configs/sky130_sram_1kbyte_1rw1r_8x1024_8.py b/macros/configs/sky130_sram_1kbyte_1rw1r_8x1024_8.py similarity index 100% rename from compiler/example_configs/sky130_sram_1kbyte_1rw1r_8x1024_8.py rename to macros/configs/sky130_sram_1kbyte_1rw1r_8x1024_8.py diff --git a/compiler/example_configs/sky130_sram_1kbyte_1rw_32x256_8.py b/macros/configs/sky130_sram_1kbyte_1rw_32x256_8.py similarity index 100% rename from compiler/example_configs/sky130_sram_1kbyte_1rw_32x256_8.py rename to macros/configs/sky130_sram_1kbyte_1rw_32x256_8.py diff --git a/compiler/example_configs/sky130_sram_2kbyte_1rw1r_32x512_8.py b/macros/configs/sky130_sram_2kbyte_1rw1r_32x512_8.py similarity index 100% rename from compiler/example_configs/sky130_sram_2kbyte_1rw1r_32x512_8.py rename to macros/configs/sky130_sram_2kbyte_1rw1r_32x512_8.py diff --git a/compiler/example_configs/sky130_sram_2kbyte_1rw_32x512_8.py b/macros/configs/sky130_sram_2kbyte_1rw_32x512_8.py similarity index 100% rename from compiler/example_configs/sky130_sram_2kbyte_1rw_32x512_8.py rename to macros/configs/sky130_sram_2kbyte_1rw_32x512_8.py diff --git a/compiler/example_configs/sky130_sram_4kbyte_1rw1r_32x1024_8.py b/macros/configs/sky130_sram_4kbyte_1rw1r_32x1024_8.py similarity index 100% rename from compiler/example_configs/sky130_sram_4kbyte_1rw1r_32x1024_8.py rename to macros/configs/sky130_sram_4kbyte_1rw1r_32x1024_8.py diff --git a/compiler/example_configs/sky130_sram_4kbyte_1rw_32x1024_8.py b/macros/configs/sky130_sram_4kbyte_1rw_32x1024_8.py similarity index 100% rename from compiler/example_configs/sky130_sram_4kbyte_1rw_32x1024_8.py rename to macros/configs/sky130_sram_4kbyte_1rw_32x1024_8.py diff --git a/compiler/example_configs/sky130_sram_common.py b/macros/configs/sky130_sram_common.py similarity index 100% rename from compiler/example_configs/sky130_sram_common.py rename to macros/configs/sky130_sram_common.py diff --git a/setpaths.sh b/setpaths.sh index 44485f14..e4d0ff90 100755 --- a/setpaths.sh +++ b/setpaths.sh @@ -4,5 +4,5 @@ # like this: # source setpaths.sh -export OPENRAM_HOME="`pwd`/compiler" -export OPENRAM_TECH="`pwd`/technology" +export OPENRAM_HOME="/openram/compiler" +export OPENRAM_TECH="/openram/technology"