@@ -89,6 +89,24 @@ DESIGN_CONFIG ?= ./designs/nangate45/gcd/config.mk
8989# in this file. This allows the DESIGN_CONFIG to set different defaults than
9090# this file.
9191include $(DESIGN_CONFIG )
92+ export DESIGN_NICKNAME? =$(DESIGN_NAME )
93+ export FLOW_VARIANT? =base
94+ ifneq ($(BLOCKS ) ,)
95+ # Normally this comes from variables.yaml, but we need it here to set up these variables
96+ # which are part of the DESIGN_CONFIG. BLOCKS is a Makefile specific concept.
97+ $(foreach block,$(BLOCKS),$(eval BLOCK_LEFS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lef))
98+ $(foreach block,$(BLOCKS),$(eval BLOCK_LIBS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lib))
99+ $(foreach block,$(BLOCKS),$(eval BLOCK_GDS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.gds))
100+ $(foreach block,$(BLOCKS),$(eval BLOCK_CDL += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.cdl))
101+ $(foreach block,$(BLOCKS),$(eval BLOCK_LOG_FOLDERS += ./logs/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/))
102+ export ADDITIONAL_LEFS += $(BLOCK_LEFS )
103+ export ADDITIONAL_LIBS += $(BLOCK_LIBS )
104+ export ADDITIONAL_GDS += $(BLOCK_GDS )
105+ export GDS_FILES += $(BLOCK_GDS )
106+ ifneq ($(CDL_FILES),)
107+ export CDL_FILES += $(BLOCK_CDL )
108+ endif
109+ endif
92110
93111# If we are running headless use offscreen rendering for save_image
94112ifeq ($(DISPLAY ) ,)
@@ -117,151 +135,40 @@ MAKEFLAGS += --no-builtin-rules
117135SHELL := /usr/bin/env bash
118136.SHELLFLAGS := -o pipefail -c
119137
120- # -------------------------------------------------------------------------------
121- # Setup variables to point to root / head of the OpenROAD directory
122- # - the following settings allowed user to point OpenROAD binaries to different
123- # location
124- # - default is current install / clone directory
125138ifeq ($(origin FLOW_HOME ) , undefined)
126139FLOW_HOME := $(abspath $(dir $(firstword $(MAKEFILE_LIST ) ) ) )
127140endif
128141export FLOW_HOME
129142
130- # -------------------------------------------------------------------------------
131- # Setup variables to point to other location for the following sub directory
132- # - designs - default is under current directory
133- # - platforms - default is under current directory
134- # - work home - default is current directory
135- # - utils, scripts, test - default is under current directory
136- export DESIGN_HOME ?= $(FLOW_HOME ) /designs
137- export PLATFORM_HOME ?= $(FLOW_HOME ) /platforms
138- export WORK_HOME ?= .
139-
140- export UTILS_DIR ?= $(FLOW_HOME ) /util
141- export SCRIPTS_DIR ?= $(FLOW_HOME ) /scripts
142- export TEST_DIR ?= $(FLOW_HOME ) /test
143-
144- PUBLIC =nangate45 sky130hd sky130hs asap7 ihp-sg13g2 gf180
145-
146- ifneq ($(wildcard $(PLATFORM_HOME ) /$(PLATFORM ) ) ,)
147- export PLATFORM_DIR = $(PLATFORM_HOME ) /$(PLATFORM )
148- else ifneq ($(findstring $(PLATFORM),$(PUBLIC)),)
149- export PLATFORM_DIR = ./platforms/$(PLATFORM )
150- else ifneq ($(wildcard ../../$(PLATFORM)),)
151- export PLATFORM_DIR = ../../$(PLATFORM )
152- else
153- $(error [ERROR][FLOW] Platform '$(PLATFORM)' not found.)
154- endif
155-
156- include $(PLATFORM_DIR ) /config.mk
157-
143+ # The plan is to migrate all variables to .sh so that
144+ # ORFS is no longer dependent on make.
145+ #
146+ # Explicitly enumerate the environment variables we need $SCRIPTS/config.sh
147+ # to see since make doesn't pass its environment to subshells.
148+ #
158149# __SPACE__ is a workaround for whitespace hell in "foreach"; there
159150# is no way to escape space in defaults.py and get "foreach" to work.
160- $(foreach line,$(shell $(SCRIPTS_DIR)/defaults.py),$(eval export $(subst __SPACE__, ,$(line))))
161-
162- # Not normally adjusted by user
163- export SYNTH_OPERATIONS_ARGS ?= -extra-map $(FLOW_HOME ) /platforms/common/lcu_kogge_stone.v
164- export SYNTH_FULL_ARGS ?= $(SYNTH_ARGS ) $(SYNTH_OPERATIONS_ARGS )
165-
166- # Setup working directories
167- export DESIGN_NICKNAME ?= $(DESIGN_NAME )
168-
169- export DESIGN_CONFIG
170- export DESIGN_DIR = $(dir $(DESIGN_CONFIG ) )
171- export LOG_DIR = $(WORK_HOME ) /logs/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
172- export OBJECTS_DIR = $(WORK_HOME ) /objects/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
173- export REPORTS_DIR = $(WORK_HOME ) /reports/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
174- export RESULTS_DIR = $(WORK_HOME ) /results/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
175-
176- ifneq ($(BLOCKS ) ,)
177- $(foreach block,$(BLOCKS),$(eval BLOCK_LEFS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lef))
178- $(foreach block,$(BLOCKS),$(eval BLOCK_LIBS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lib))
179- $(foreach block,$(BLOCKS),$(eval BLOCK_GDS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.gds))
180- $(foreach block,$(BLOCKS),$(eval BLOCK_CDL += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/6_final.cdl))
181- $(foreach block,$(BLOCKS),$(eval BLOCK_LOG_FOLDERS += ./logs/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/))
182- export ADDITIONAL_LEFS += $(BLOCK_LEFS )
183- export ADDITIONAL_LIBS += $(BLOCK_LIBS )
184- export ADDITIONAL_GDS += $(BLOCK_GDS )
185- export GDS_FILES += $(BLOCK_GDS )
186- ifneq ($(CDL_FILES),)
187- export CDL_FILES += $(BLOCK_CDL )
188- endif
189- endif
190-
191- # -------------------------------------------------------------------------------
192- ifeq (,$(strip $(NUM_CORES ) ) )
193- # Linux (utility program)
194- NUM_CORES := $(shell nproc 2>/dev/null)
195-
196- ifeq (,$(strip $(NUM_CORES)))
197- # Linux (generic)
198- NUM_CORES := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
199- endif
200- ifeq (,$(strip $(NUM_CORES)))
201- # BSD (at least FreeBSD and Mac OSX)
202- NUM_CORES := $(shell sysctl -n hw.ncpu 2>/dev/null)
203- endif
204- ifeq (,$(strip $(NUM_CORES)))
205- # Fallback
206- NUM_CORES := 1
207- endif
208- endif
209- export NUM_CORES
210-
211- YOSYS_FLAGS += -v 3
212-
213- # -------------------------------------------------------------------------------
214- # setup all commands used within this flow
215- export TIME_BIN ?= env time
216- TIME_CMD = $(TIME_BIN ) -f 'Elapsed time: %E[h:]min:sec. CPU time: user %U sys %S (%P). Peak memory: %MKB.'
217- TIME_TEST = $(shell $(TIME_CMD ) echo foo 2>/dev/null)
218- ifeq (,$(strip $(TIME_TEST ) ) )
219- TIME_CMD = $(TIME_BIN )
220- endif
221-
222- # The following determine the executable location for each tool used by this flow.
223- # Priority is given to
224- # 1 user explicit set with variable in Makefile or command line, for instance setting OPENROAD_EXE
225- # 2 ORFS compiled tools: openroad, yosys
226- ifneq (${IN_NIX_SHELL},)
227- export OPENROAD_EXE := $(shell command -v openroad)
228- else
229- export OPENROAD_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/OpenROAD/bin/openroad)
151+ $(foreach line,$(shell \
152+ DESIGN_NAME =$(DESIGN_NAME ) \
153+ FLOW_HOME=$(FLOW_HOME ) \
154+ DESIGN_CONFIG=$(DESIGN_CONFIG ) \
155+ PLATFORM=$(PLATFORM ) \
156+ FLOW_VARIANT=$(FLOW_VARIANT ) \
157+ DESIGN_NICKNAME=$(DESIGN_NICKNAME ) \
158+ $(FLOW_HOME ) /scripts/env.sh $(FLOW_HOME ) /scripts/config.sh),$(eval $(subst __SPACE__, ,$(line ) ) ) )
159+
160+ # check some critical variables in a loop
161+ $(foreach var,DESIGN_NAME DESIGN_NICKNAME PLATFORM,\
162+ $(if $(strip $($(var))),,$(error $(var) is not set)))
163+
164+ # The plan is to move all config.mk variables into $(PLATFORM_DIR)/config.sh and
165+ # delete this include below
166+ ifneq ($(wildcard $(PLATFORM_DIR ) /config.mk) ,)
167+ include $(PLATFORM_DIR ) /config.mk
230168endif
231- ifneq (${IN_NIX_SHELL},)
232- export OPENSTA_EXE := $(shell command -v sta)
233- else
234- export OPENSTA_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/OpenROAD/bin/sta)
235- endif
236-
237- OPENROAD_ARGS = -no_init -threads $(NUM_CORES ) $(OR_ARGS )
238- OPENROAD_CMD = $(OPENROAD_EXE ) -exit $(OPENROAD_ARGS )
239- OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE ) $(OPENROAD_ARGS )
240- OPENROAD_GUI_CMD = $(OPENROAD_EXE ) -gui $(OR_ARGS )
241-
242- ifneq (${IN_NIX_SHELL},)
243- YOSYS_EXE := $(shell command -v yosys)
244- else
245- YOSYS_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/yosys/bin/yosys)
246- endif
247-
248- # Use locally installed and built klayout if it exists, otherwise use klayout in path
249- KLAYOUT_DIR = $(abspath $(FLOW_HOME ) /../tools/install/klayout/)
250- KLAYOUT_BIN_FROM_DIR = $(KLAYOUT_DIR ) /klayout
251169
252- ifeq ($(wildcard $(KLAYOUT_BIN_FROM_DIR ) ) , $(KLAYOUT_BIN_FROM_DIR ) )
253- KLAYOUT_CMD ?= sh -c 'LD_LIBRARY_PATH=$(dir $(KLAYOUT_BIN_FROM_DIR ) ) $$0 "$$@ "' $(KLAYOUT_BIN_FROM_DIR )
254- else
255- ifeq ($(KLAYOUT_CMD ) ,)
256- KLAYOUT_CMD := $(shell command -v klayout)
257- endif
258- endif
259170KLAYOUT_FOUND = $(if $(KLAYOUT_CMD ) ,,$(error KLayout not found in PATH) )
260171
261- ifneq ($(shell command -v stdbuf) ,)
262- STDBUF_CMD ?= stdbuf -o L
263- endif
264-
265172# -------------------------------------------------------------------------------
266173WRAPPED_LEFS = $(foreach lef,$(notdir $(WRAP_LEFS ) ) ,$(OBJECTS_DIR ) /lef/$(lef:.lef=_mod.lef ) )
267174WRAPPED_LIBS = $(foreach lib,$(notdir $(WRAP_LIBS ) ) ,$(OBJECTS_DIR ) /$(lib:.lib=_mod.lib ) )
@@ -432,10 +339,6 @@ memory:
432339
433340# Run Synthesis using yosys
434341# -------------------------------------------------------------------------------
435-
436- export SYNTH_SCRIPT ?= $(SCRIPTS_DIR ) /synth.tcl
437- export SDC_FILE_CLOCK_PERIOD = $(RESULTS_DIR ) /clock_period.txt
438-
439342$(SDC_FILE_CLOCK_PERIOD ) : $(SDC_FILE )
440343 mkdir -p $(dir $@ )
441344 echo $(ABC_CLOCK_PERIOD_IN_PS ) > $@
@@ -447,13 +350,11 @@ yosys-dependencies: $(YOSYS_DEPENDENCIES)
447350
448351.PHONY : do-yosys
449352do-yosys : $(DONT_USE_SC_LIB )
450- mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
451- ($( TIME_CMD) $( YOSYS_EXE) $( YOSYS_FLAGS) -c $( SYNTH_SCRIPT) ) 2>&1 | tee $(abspath $(LOG_DIR ) /1_1_yosys.log)
353+ $(SCRIPTS_DIR ) /synth.sh $(SYNTH_SCRIPT ) $(LOG_DIR ) /1_1_yosys.log
452354
453355.PHONY : do-yosys-canonicalize
454356do-yosys-canonicalize : yosys-dependencies $(DONT_USE_SC_LIB )
455- mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
456- ($( TIME_CMD) $( YOSYS_EXE) $( YOSYS_FLAGS) -c $( SCRIPTS_DIR) /synth_canonicalize.tcl) 2>&1 | tee $(abspath $(LOG_DIR ) /1_1_yosys_canonicalize.log)
357+ $(SCRIPTS_DIR ) /synth.sh $(SCRIPTS_DIR ) /synth_canonicalize.tcl $(LOG_DIR ) /1_1_yosys_canonicalize.log
457358
458359$(RESULTS_DIR ) /1_synth.rtlil : $(YOSYS_DEPENDENCIES )
459360 $(UNSET_AND_MAKE ) do-yosys-canonicalize
@@ -560,13 +461,7 @@ endif
560461
561462.PHONY: do-$(1 )
562463do-$(1 ) : $(OBJECTS_DIR ) /copyright.txt
563- @mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
564- @echo Running $(3 ) .tcl, stage $(1 )
565- @(set -eo pipefail; \
566- trap 'mv $(LOG_DIR ) /$(1 ) .tmp.log $(LOG_DIR ) /$(1 ) .log' EXIT; \
567- $(OPENROAD_EXE ) $(OPENROAD_ARGS ) -exit $(SCRIPTS_DIR ) /noop.tcl 2>&1 >$(LOG_DIR ) /$(1 ) .tmp.log; \
568- $(TIME_CMD ) $(OPENROAD_CMD ) -no_splash $(SCRIPTS_DIR ) /$(3 ) .tcl -metrics $(LOG_DIR ) /$(1 ) .json 2>&1 | \
569- tee -a $(abspath $(LOG_DIR ) /$(1 ) .tmp.log) )
464+ $(SCRIPTS_DIR ) /flow.sh $(1 ) $(3 )
570465endef
571466
572467# generate make rules to copy a file, if a dependency change and
0 commit comments