From d274405a1b4ea70a006724fccef15cd0e0a2dc51 Mon Sep 17 00:00:00 2001 From: kareefardi Date: Thu, 17 Aug 2023 15:31:09 +0300 Subject: [PATCH] initial integration of openlane2 --- Makefile | 24 ++++++++++++++++-------- openlane/Makefile | 48 +++++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 23c19b465..f27a6805f 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ export ROOTLESS ifeq ($(PDK),sky130A) SKYWATER_COMMIT=f70d8ca46961ff92719d8870a18a076370b85f6c export OPEN_PDKS_COMMIT?=78b7bc32ddb4b6f14f76883c2e2dc5b5de9d1cbc - export OPENLANE_TAG?=2023.07.19 + export OPENLANE_TAG?=2.0.0-b4 MPW_TAG ?= mpw-9d ifeq ($(CARAVEL_LITE),1) @@ -187,13 +187,21 @@ what: # Install Openlane .PHONY: openlane -openlane: - @if [ "$$(realpath $${OPENLANE_ROOT})" = "$$(realpath $$(pwd)/openlane)" ]; then\ - echo "OPENLANE_ROOT is set to '$$(pwd)/openlane' which contains openlane config files"; \ - echo "Please set it to a different directory"; \ - exit 1; \ - fi - cd openlane && $(MAKE) openlane +openlane: openlane-venv openlane-docker-container + # openlane installed + +OPENLANE_TAG_DOCKER=$(subst -,,$(OPENLANE_TAG)) +.PHONY: openlane-docker-container +openlane-docker-container: + docker pull ghcr.io/efabless/openlane2:$(OPENLANE_TAG_DOCKER) + +.PHONY: openlane-venv +openlane-venv: venv/manifest.txt +venv/manifest.txt: + rm -rf openlane-venv + python3 -m venv ./openlane-venv + PYTHONPATH= ./openlane-venv/bin/python3 -m pip install openlane==$(OPENLANE_TAG) + PYTHONPATH= ./openlane-venv/bin/python3 -m pip freeze > $@ #### Not sure if the targets following are of any use diff --git a/openlane/Makefile b/openlane/Makefile index 87dcbbe82..405016410 100644 --- a/openlane/Makefile +++ b/openlane/Makefile @@ -16,43 +16,44 @@ MAKEFLAGS+=--warn-undefined-variables export OPENLANE_RUN_TAG = $(shell date '+%y_%m_%d_%H_%M') +export CARAVEL_ROOT:=$(CARAVEL_ROOT) +export PDK:=$(PDK) +export PDK_ROOT:=$(PDK_ROOT) OPENLANE_TAG ?= 2023.07.19 OPENLANE_IMAGE_NAME ?= efabless/openlane:$(OPENLANE_TAG) designs = $(shell find * -maxdepth 0 -type d) current_design = null - +OPENLANE_USE_NIX ?= 0 ROOTLESS ?= 0 USER_ARGS = -u $$(id -u $$USER):$$(id -g $$USER) ifeq ($(ROOTLESS), 1) USER_ARGS = endif -openlane_cmd = \ - "flow.tcl \ - -design $$(realpath ./$*) \ - -save_path $$(realpath ..) \ - -save \ - -tag $(OPENLANE_RUN_TAG) \ - -overwrite \ - -ignore_mismatches" -openlane_cmd_interactive = "flow.tcl -it -file $$(realpath ./$*/interactive.tcl)" +openlane_args = \ + --run-tag $(OPENLANE_RUN_TAG) \ + --manual-pdk \ + --pdk-root $(PDK_ROOT) \ + $$(realpath ./$*)/config.json docker_mounts = \ - -v $$(realpath $(PWD)/..):$$(realpath $(PWD)/..) \ - -v $(PDK_ROOT):$(PDK_ROOT) \ - -v $(CARAVEL_ROOT):$(CARAVEL_ROOT) \ - -v $(OPENLANE_ROOT):/openlane + -m $$(realpath $(PWD)/..) \ + -m $(PDK_ROOT) \ + -m $(CARAVEL_ROOT) docker_env = \ -e PDK_ROOT=$(PDK_ROOT) \ -e PDK=$(PDK) \ - -e MISMATCHES_OK=1 \ -e CARAVEL_ROOT=$(CARAVEL_ROOT) \ -e OPENLANE_RUN_TAG=$(OPENLANE_RUN_TAG) ifneq ($(MCW_ROOT),) docker_env += -e MCW_ROOT=$(MCW_ROOT) -docker_mounts += -v $(MCW_ROOT):$(MCW_ROOT) +export MCW_ROOT:=$(MCW_ROOT) +docker_mounts += -m $(MCW_ROOT) +endif + +ifeq ($(OPENLANE_USE_NIX),0) endif docker_startup_mode = $(shell test -t 0 && echo "-it" || echo "--rm" ) @@ -68,17 +69,16 @@ list: .PHONY: $(designs) $(designs) : export current_design=$@ $(designs) : % : ./%/config.json -ifneq (,$(wildcard ./$(current_design)/interactive.tcl)) - $(docker_run) \ - $(OPENLANE_IMAGE_NAME) sh -c $(openlane_cmd_interactive) -else # $(current_design) - mkdir -p ./$*/runs/$(OPENLANE_RUN_TAG) + rm -rf ./$*/runs/$(OPENLANE_RUN_TAG) +ifeq ($(OPENLANE_USE_NIX),1) + nix-shell --pure --command "openlane $(openlane_args)" +else + ../openlane-venv/bin/python3 -m openlane $(docker_mounts) --dockerized $(openlane_args) +endif + mkdir -p ./$*/runs/$(OPENLANE_RUN_TAG) rm -rf ./$*/runs/$* ln -s $$(realpath ./$*/runs/$(OPENLANE_RUN_TAG)) ./$*/runs/$* - $(docker_run) \ - $(OPENLANE_IMAGE_NAME) sh -c $(openlane_cmd) -endif @mkdir -p ../signoff/$*/ @cp ./$*/runs/$*/OPENLANE_VERSION ../signoff/$*/ @cp ./$*/runs/$*/PDK_SOURCES ../signoff/$*/