From d7a20bc69bfe6b554ad6b7b7d862464ff2ed10f1 Mon Sep 17 00:00:00 2001 From: mrg Date: Tue, 2 Nov 2021 15:07:18 -0700 Subject: [PATCH] Debug initial docker run scripts --- Makefile | 84 ++++++++++++++++-------------- macros/Makefile | 21 +++++++- macros/configs/sky130_sram_tiny.py | 21 ++++++++ openram.mk | 8 +++ technology/sky130/__init__.py | 2 +- 5 files changed, 93 insertions(+), 43 deletions(-) create mode 100644 macros/configs/sky130_sram_tiny.py create mode 100644 openram.mk diff --git a/Makefile b/Makefile index cd09060a..cdd7efe6 100644 --- a/Makefile +++ b/Makefile @@ -3,68 +3,76 @@ include $(TOP_DIR)/openram.mk .DEFAULT_GOAL := install +# Keep it locally if they didn't specify +PDK_ROOT ?= $(TOP_DIR) + # Skywater PDK SRAM library -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 +SRAM_LIB_DIR ?= $(PDK_ROOT)/sky130_fd_bd_sram +SRAM_LIB_GIT_REPO ?= https://github.com/google/skywater-pdk-libs-sky130_fd_bd_sram.git +SRAM_LIB_GIT_COMMIT ?= main # Open PDKs -PDK_ROOT ?= $(TOP_DIR)/open_pdks -OPEN_PDKS_REPO ?= https://github.com/RTimothyEdwards/open_pdks.git -OPEN_PDKS ?= $(PDK_ROOT)/sky130/sky130A - +OPEN_PDKS_DIR ?= $(PDK_ROOT)/open_pdks +OPEN_PDKS_GIT_REPO ?= https://github.com/RTimothyEdwards/open_pdks.git +OPEN_PDKS_GIT_COMMIT ?= 1.0.156 +SKY130_PDK ?= $(PDK_ROOT)/share/pdk/sky130A # Create lists of all the files to copy/link -GDS_FILES := $(sort $(wildcard $(SRAM_LIBRARY)/cells/*/*.gds)) -MAG_FILES := $(sort $(wildcard $(SRAM_LIBRARY)/cells/*/*.mag)) +GDS_FILES := $(sort $(wildcard $(SRAM_LIB_DIR)/cells/*/*.gds)) +MAG_FILES := $(sort $(wildcard $(SRAM_LIB_DIR)/cells/*/*.mag)) SPICE_SUFFIX := spice SPICE_LVS_SUFFIX := lvs.$(SPICE_SUFFIX) SPICE_CALIBRE_SUFFIX := lvs.calibre.$(SPICE_SUFFIX) SPICE_BASE_SUFFIX := base.$(SPICE_SUFFIX) -ALL_SPICE_FILES := $(sort $(wildcard $(SRAM_LIBRARY)/cells/*/*.$(SPICE_SUFFIX))) +ALL_SPICE_FILES := $(sort $(wildcard $(SRAM_LIB_DIR)/cells/*/*.$(SPICE_SUFFIX))) MAGLEF_SUFFIX := maglef -MAGLEF_FILES := $(sort $(wildcard $(SRAM_LIBRARY)/cells/*/*.$(MAGLEF_SUFFIX))) +MAGLEF_FILES := $(sort $(wildcard $(SRAM_LIB_DIR)/cells/*/*.$(MAGLEF_SUFFIX))) -MAGICRC_FILE := $(OPEN_PDKS)/libs.tech/magic/sky130A.magicrc +MAGICRC_FILE := $(SKY130_PDK)/libs.tech/magic/sky130A.magicrc ALL_FILES := $(ALL_SPICE_FILES) $(GDS_FILES) $(MAG_FILES) $(MAGLEF_FILES) -INSTALL_BASE_DIRS := gds_lib mag_lib sp_lib lvs_lib calibre_lvs_lib lef_lib maglef_lib +INSTALL_BASE_DIRS := gds_lib mag_lib sp_lib lvs_lib calibre_lvs_lib maglef_lib INSTALL_BASE := $(OPENRAM_HOME)/../technology/sky130 INSTALL_DIRS := $(addprefix $(INSTALL_BASE)/,$(INSTALL_BASE_DIRS)) +$(OPEN_PDKS_DIR): + @echo "Cloning open_pdks..." + git clone $(OPEN_PDKS_GIT_REPO) $(OPEN_PDKS_DIR) + cd $(OPEN_PDKS_DIR) && git checkout $(OPEN_PDKS_GIT_COMMIT) -$(OPEN_PDKS): - git clone $(OPEN_PDKS_REPO) $(PDK_ROOT) - cd $(PDK_ROOT) &&\ - $(PDK_ROOT)/configure --enable-sky130-pdk - make -C $(PDK_ROOT) +$(SKY130_PDK): $(OPEN_PDKS_DIR) + @echo "Installing open_pdks..." + cd $(OPEN_PDKS_DIR) &&\ + ./configure --prefix=$(PDK_ROOT) --enable-sky130-pdk \ + --disable-openlane --disable-irsim --disable-xschem --disable-qflow + @sleep 5 + make -C $(OPEN_PDKS_DIR) install -.PHONY: $(SRAM_LIBRARY) $(OPEN_PDKS) $(INSTALL_DIRS) install - -install: $(SRAM_LIBRARY) $(INSTALL_DIRS) $(OPEN_PDKS) +install: $(SRAM_LIB_DIR) $(SKY130_PDK) $(INSTALL_DIRS) @echo "Installing sky130 SRAM PDK..." @echo "PDK_ROOT='$(PDK_ROOT)'" - @echo "SRAM_LIBRARY='$(SRAM_LIBRARY)'" - @echo "OPEN_PDKS='$(OPEN_PDKS)'" - make install + @echo "SRAM_LIB_DIR='$(SRAM_LIB_DIR)'" + @echo "SKY130_PDK='$(SKY130_PDK)'" @true +.PHONY: install -$(SRAM_LIBRARY): - git clone $(SRAM_GIT_REPO) $(SRAM_LIBRARY) - -.PHONY: $(SRAM_LIBRARY) $(INSTALL_DIRS) install +$(SRAM_LIB_DIR): + @echo "Cloning SRAM library..." + git clone $(SRAM_LIB_GIT_REPO) $(SRAM_LIB_DIR) + cd $(SRAM_LIB_DIR) && git checkout $(SRAM_LIB_GIT_COMMIT) +.PHONY: $(INSTALL_DIRS) $(INSTALL_BASE)/gds_lib: $(GDS_FILES) @echo @echo "Setting up GDS cell library for OpenRAM." @echo "==================================================================" mkdir -p $@ - @cp -va $? $@ + cp -va $? $@ @echo "==================================================================" @echo @@ -146,20 +154,16 @@ tests: .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) +clean: + rm -rf $(SKY130_PDK) rm -f $(INSTALL_BASE)/tech/.magicrc rm -f $(INSTALL_BASE)/mag_lib/.magicrc rm -f $(INSTALL_BASE)/lef_lib/.magicrc rm -f $(INSTALL_BASE)/maglef_lib/.magicrc rm -rf $(INSTALL_DIRS) +.PHONY: clean + +uninstall: clean + rm -rf $(SRAM_LIB_DIR) + rm -rf $(OPEN_PDKS_DIR) .PHONY: uninstall diff --git a/macros/Makefile b/macros/Makefile index 2e0ecc0f..f10ab19e 100644 --- a/macros/Makefile +++ b/macros/Makefile @@ -2,8 +2,13 @@ MACRO_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) TOP_DIR := $(realpath $(MACRO_DIR)/..) include $(TOP_DIR)/openram.mk +UID = $(shell id -u) +GID = $(shell id -g) + .DEFAULT_GOAL := all +SKY130_PDK ?= $(PDK_ROOT)/share/pdk/sky130A + OPENRAM_OPTS := $(OPENRAM_OPTS) # Define `OPENRAM_FULL` in your environment to run a full characterize ifeq ($(OPENRAM_FULL),) @@ -51,14 +56,26 @@ all: | configs @echo "Building $*" @mkdir -p $* docker run -v $(TOP_DIR):/openram \ - -v $(PDK_ROOT)/share/sky130A:/sky130A \ - -e PDK_ROOT=/ \ + -v $(SKY130_PDK):$(SKY130_PDK) \ + -e PDK_ROOT=$(PDK_ROOT) \ -e OPENRAM_HOME=/openram/compiler \ -e OPENRAM_TECH=/openram/technology \ -e OPENRAM_TMP=/openram/macros/$*/tmp \ + --user $(UID):$(GID) \ vlsida/openram-ubuntu:latest \ python3 -u /openram/compiler/openram.py $(OPENRAM_OPTS) -o $* -p /openram/macros/$* /openram/macros/$< && touch $@ +mount: + docker run -it -v $(TOP_DIR):/openram \ + -v $(SKY130_PDK):$(SKY130_PDK) \ + -e PDK_ROOT=$(PDK_ROOT) \ + -e OPENRAM_HOME=/openram/compiler \ + -e OPENRAM_TECH=/openram/technology \ + --user $(UID):$(GID) \ + vlsida/openram-ubuntu:latest +.PHONY: macros + + .DELETE_ON_ERROR: $(STAMPS) $(DIRS): diff --git a/macros/configs/sky130_sram_tiny.py b/macros/configs/sky130_sram_tiny.py new file mode 100644 index 00000000..95bfd61f --- /dev/null +++ b/macros/configs/sky130_sram_tiny.py @@ -0,0 +1,21 @@ +""" +Dual port (1 read/write + 1 read only) 1 kbytes SRAM with byte write. + +FIXME: What is this useful for? +FIXME: Why would you want byte write on this? +""" +word_size = 8 # Bits +num_words = 16 +human_byte_size = "{:.0f}kbytes".format((word_size * num_words)/1024/8) + +# Allow byte writes +write_size = 2 # Bits + +# Dual port +num_rw_ports = 1 +num_r_ports = 1 +num_w_ports = 0 +ports_human = '1rw1r' + +import os +exec(open(os.path.join(os.path.dirname(__file__), 'sky130_sram_common.py')).read()) diff --git a/openram.mk b/openram.mk new file mode 100644 index 00000000..1bd95897 --- /dev/null +++ b/openram.mk @@ -0,0 +1,8 @@ +OPENRAM_HOME := $(abspath $(TOP_DIR)/compiler) +OPENRAM_TECH := $(abspath $(TOP_DIR)/technology) +OPENRAM_COMPILER := $(OPENRAM_HOME)/openram.py +ifeq (,$(wildcard $(OPENRAM_COMPILER))) +$(error Did not find '$(OPENRAM_COMPILER)' in '$(OPENRAM_HOME)' (from $$OPENRAM_HOME)) +endif +export OPENRAM_HOME +export OPENRAM_TECH diff --git a/technology/sky130/__init__.py b/technology/sky130/__init__.py index 3df3f555..c17c62d8 100644 --- a/technology/sky130/__init__.py +++ b/technology/sky130/__init__.py @@ -21,7 +21,7 @@ os.environ["MGC_TMPDIR"] = "/tmp" # OpenPDK needed for magicrc, tech file and spice models of transistors if 'PDK_ROOT' in os.environ: - open_pdks = os.path.join(os.environ['PDK_ROOT'], 'sky130A', 'libs.tech') + open_pdks = os.path.join(os.environ['PDK_ROOT'], 'share', 'pdk', 'sky130A', 'libs.tech') else: raise SystemError("Unable to find open_pdks tech file. Set PDK_ROOT.")