@@ -90,6 +90,7 @@ DESIGN_CONFIG ?= ./designs/nangate45/gcd/config.mk
9090# this file.
9191include $(DESIGN_CONFIG )
9292export DESIGN_NICKNAME? =$(DESIGN_NAME )
93+ export DESIGN_DIR = $(dir $(DESIGN_CONFIG ) )
9394# default value "base" is duplicated from variables.yaml because we need it
9495# earlier in the flow for BLOCKS. BLOCKS is a feature specific to Makefile
9596# that will not be ported to bazel-orfs.
@@ -178,85 +179,34 @@ include $(PLATFORM_DIR)/config.mk
178179
179180# __SPACE__ is a workaround for whitespace hell in "foreach"; there
180181# is no way to escape space in defaults.py and get "foreach" to work.
181- $(foreach line,$(shell $(SCRIPTS_DIR)/defaults.py),$(eval export $(subst __SPACE__, ,$(line))))
182+ #
183+ # Note! We need to explicitly pass in the environment variables that
184+ # defaults.py *uses* to compute the list of default values. We do NOT
185+ # need to pass in *all* environment variables. defaults.py does not
186+ # use the default value to modify the environment, it computes default
187+ # values for environment variables and has options to print out
188+ # the information in different formats.
189+ $(foreach line,$(shell \
190+ PLATFORM_DIR =$(PLATFORM_DIR ) \
191+ FLOW_HOME=$(FLOW_HOME ) \
192+ DESIGN_NAME=$(DESIGN_NAME ) \
193+ DESIGN_NICKNAME=$(DESIGN_NICKNAME ) \
194+ WORK_HOME=$(WORK_HOME ) \
195+ PLATFORM=$(PLATFORM ) \
196+ NUM_CORES=$(NUM_CORES ) \
197+ TIME_BIN=$(TIME_BIN ) \
198+ IN_NIX_SHELL=$(IN_NIX_SHELL ) \
199+ OPENROAD_EXE=$(OPENROAD_EXE ) \
200+ OPENSTA_EXE=$(OPENSTA_EXE ) \
201+ YOSYS_EXE=$(YOSYS_EXE ) \
202+ KLAYOUT_CMD=$(KLAYOUT_CMD ) \
203+ SCRIPTS_DIR=$(SCRIPTS_DIR ) \
204+ $(SCRIPTS_DIR ) /defaults.py make),$(eval export $(subst __SPACE__, ,$(line ) ) ) )
182205
183206# Not normally adjusted by user
184207export SYNTH_OPERATIONS_ARGS ?= -extra-map $(FLOW_HOME ) /platforms/common/lcu_kogge_stone.v
185208export SYNTH_FULL_ARGS ?= $(SYNTH_ARGS ) $(SYNTH_OPERATIONS_ARGS )
186209
187- export DESIGN_CONFIG
188- export DESIGN_DIR = $(dir $(DESIGN_CONFIG ) )
189- export LOG_DIR = $(WORK_HOME ) /logs/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
190- export OBJECTS_DIR = $(WORK_HOME ) /objects/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
191- export REPORTS_DIR = $(WORK_HOME ) /reports/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
192- export RESULTS_DIR = $(WORK_HOME ) /results/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
193-
194- # -------------------------------------------------------------------------------
195- ifeq (,$(strip $(NUM_CORES ) ) )
196- # Linux (utility program)
197- NUM_CORES := $(shell nproc 2>/dev/null)
198-
199- ifeq (,$(strip $(NUM_CORES)))
200- # Linux (generic)
201- NUM_CORES := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
202- endif
203- ifeq (,$(strip $(NUM_CORES)))
204- # BSD (at least FreeBSD and Mac OSX)
205- NUM_CORES := $(shell sysctl -n hw.ncpu 2>/dev/null)
206- endif
207- ifeq (,$(strip $(NUM_CORES)))
208- # Fallback
209- NUM_CORES := 1
210- endif
211- endif
212- export NUM_CORES
213-
214- # -------------------------------------------------------------------------------
215- # setup all commands used within this flow
216- export TIME_BIN ?= env time
217- TIME_CMD = $(TIME_BIN ) -f 'Elapsed time: %E[h:]min:sec. CPU time: user %U sys %S (%P). Peak memory: %MKB.'
218- TIME_TEST = $(shell $(TIME_CMD ) echo foo 2>/dev/null)
219- ifeq (,$(strip $(TIME_TEST ) ) )
220- TIME_CMD = $(TIME_BIN )
221- endif
222-
223- # The following determine the executable location for each tool used by this flow.
224- # Priority is given to
225- # 1 user explicit set with variable in Makefile or command line, for instance setting OPENROAD_EXE
226- # 2 ORFS compiled tools: openroad, yosys
227- ifneq (${IN_NIX_SHELL},)
228- export OPENROAD_EXE := $(shell command -v openroad)
229- else
230- export OPENROAD_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/OpenROAD/bin/openroad)
231- endif
232- ifneq (${IN_NIX_SHELL},)
233- export OPENSTA_EXE := $(shell command -v sta)
234- else
235- export OPENSTA_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/OpenROAD/bin/sta)
236- endif
237-
238- OPENROAD_ARGS = -no_init -threads $(NUM_CORES ) $(OR_ARGS )
239- OPENROAD_CMD = $(OPENROAD_EXE ) -exit $(OPENROAD_ARGS )
240- OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE ) $(OPENROAD_ARGS )
241- OPENROAD_GUI_CMD = $(OPENROAD_EXE ) -gui $(OR_ARGS )
242-
243- ifneq (${IN_NIX_SHELL},)
244- YOSYS_EXE := $(shell command -v yosys)
245- else
246- YOSYS_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/yosys/bin/yosys)
247- endif
248-
249- # Use locally installed and built klayout if it exists, otherwise use klayout in path
250- KLAYOUT_DIR = $(abspath $(FLOW_HOME ) /../tools/install/klayout/)
251- KLAYOUT_BIN_FROM_DIR = $(KLAYOUT_DIR ) /klayout
252-
253- ifeq ($(wildcard $(KLAYOUT_BIN_FROM_DIR ) ) , $(KLAYOUT_BIN_FROM_DIR ) )
254- KLAYOUT_CMD ?= sh -c 'LD_LIBRARY_PATH=$(dir $(KLAYOUT_BIN_FROM_DIR ) ) $$0 "$$@ "' $(KLAYOUT_BIN_FROM_DIR )
255- else
256- ifeq ($(KLAYOUT_CMD ) ,)
257- KLAYOUT_CMD := $(shell command -v klayout)
258- endif
259- endif
260210KLAYOUT_FOUND = $(if $(KLAYOUT_CMD ) ,,$(error KLayout not found in PATH) )
261211
262212ifneq ($(shell command -v stdbuf) ,)
@@ -448,13 +398,11 @@ yosys-dependencies: $(YOSYS_DEPENDENCIES)
448398
449399.PHONY : do-yosys
450400do-yosys : $(DONT_USE_SC_LIB )
451- mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
452- ($( TIME_CMD) $( YOSYS_EXE) $( YOSYS_FLAGS) -c $( SYNTH_SCRIPT) ) 2>&1 | tee $(abspath $(LOG_DIR ) /1_1_yosys.log)
401+ $(SCRIPTS_DIR ) /synth.sh $(SYNTH_SCRIPT ) $(LOG_DIR ) /1_1_yosys.log
453402
454403.PHONY : do-yosys-canonicalize
455404do-yosys-canonicalize : yosys-dependencies $(DONT_USE_SC_LIB )
456- mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
457- ($( TIME_CMD) $( YOSYS_EXE) $( YOSYS_FLAGS) -c $( SCRIPTS_DIR) /synth_canonicalize.tcl) 2>&1 | tee $(abspath $(LOG_DIR ) /1_1_yosys_canonicalize.log)
405+ $(SCRIPTS_DIR ) /synth.sh $(SCRIPTS_DIR ) /synth_canonicalize.tcl $(LOG_DIR ) /1_1_yosys_canonicalize.log
458406
459407$(RESULTS_DIR ) /1_synth.rtlil : $(YOSYS_DEPENDENCIES )
460408 $(UNSET_AND_MAKE ) do-yosys-canonicalize
@@ -561,13 +509,7 @@ endif
561509
562510.PHONY: do-$(1 )
563511do-$(1 ) : $(OBJECTS_DIR ) /copyright.txt
564- @mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
565- @echo Running $(3 ) .tcl, stage $(1 )
566- @(set -eo pipefail; \
567- trap 'mv $(LOG_DIR ) /$(1 ) .tmp.log $(LOG_DIR ) /$(1 ) .log' EXIT; \
568- $(OPENROAD_EXE ) $(OPENROAD_ARGS ) -exit $(SCRIPTS_DIR ) /noop.tcl 2>&1 >$(LOG_DIR ) /$(1 ) .tmp.log; \
569- $(TIME_CMD ) $(OPENROAD_CMD ) -no_splash $(SCRIPTS_DIR ) /$(3 ) .tcl -metrics $(LOG_DIR ) /$(1 ) .json 2>&1 | \
570- tee -a $(abspath $(LOG_DIR ) /$(1 ) .tmp.log) )
512+ $(SCRIPTS_DIR ) /flow.sh $(1 ) $(3 )
571513endef
572514
573515# generate make rules to copy a file, if a dependency change and
0 commit comments