@@ -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.
@@ -174,85 +175,39 @@ else
174175 $(error [ERROR][FLOW] Platform '$(PLATFORM)' not found.)
175176endif
176177
177- include $(PLATFORM_DIR ) /config.mk
178+ ifneq ($(wildcard $(PLATFORM_DIR ) /config.mk) ,)
179+ include $(PLATFORM_DIR ) /config.mk
180+ endif
178181
179182# __SPACE__ is a workaround for whitespace hell in "foreach"; there
180183# 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- export DESIGN_CONFIG
184- export DESIGN_DIR = $(dir $(DESIGN_CONFIG ) )
185- export LOG_DIR = $(WORK_HOME ) /logs/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
186- export OBJECTS_DIR = $(WORK_HOME ) /objects/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
187- export REPORTS_DIR = $(WORK_HOME ) /reports/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
188- export RESULTS_DIR = $(WORK_HOME ) /results/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
189-
190- # -------------------------------------------------------------------------------
191- ifeq (,$(strip $(NUM_CORES ) ) )
192- # Linux (utility program)
193- NUM_CORES := $(shell nproc 2>/dev/null)
194-
195- ifeq (,$(strip $(NUM_CORES)))
196- # Linux (generic)
197- NUM_CORES := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
198- endif
199- ifeq (,$(strip $(NUM_CORES)))
200- # BSD (at least FreeBSD and Mac OSX)
201- NUM_CORES := $(shell sysctl -n hw.ncpu 2>/dev/null)
202- endif
203- ifeq (,$(strip $(NUM_CORES)))
204- # Fallback
205- NUM_CORES := 1
206- endif
207- endif
208- export NUM_CORES
209-
210- # -------------------------------------------------------------------------------
211- # setup all commands used within this flow
212- export TIME_BIN ?= env time
213- TIME_CMD = $(TIME_BIN ) -f 'Elapsed time: %E[h:]min:sec. CPU time: user %U sys %S (%P). Peak memory: %MKB.'
214- TIME_TEST = $(shell $(TIME_CMD ) echo foo 2>/dev/null)
215- ifeq (,$(strip $(TIME_TEST ) ) )
216- TIME_CMD = $(TIME_BIN )
217- endif
218-
219- # The following determine the executable location for each tool used by this flow.
220- # Priority is given to
221- # 1 user explicit set with variable in Makefile or command line, for instance setting OPENROAD_EXE
222- # 2 ORFS compiled tools: openroad, yosys
223- ifneq (${IN_NIX_SHELL},)
224- export OPENROAD_EXE := $(shell command -v openroad)
225- else
226- export OPENROAD_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/OpenROAD/bin/openroad)
227- endif
228- ifneq (${IN_NIX_SHELL},)
229- export OPENSTA_EXE := $(shell command -v sta)
230- else
231- export OPENSTA_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/OpenROAD/bin/sta)
232- endif
233-
234- OPENROAD_ARGS = -no_init -threads $(NUM_CORES ) $(OR_ARGS )
235- OPENROAD_CMD = $(OPENROAD_EXE ) -exit $(OPENROAD_ARGS )
236- OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE ) $(OPENROAD_ARGS )
237- OPENROAD_GUI_CMD = $(OPENROAD_EXE ) -gui $(OR_ARGS )
238-
239- ifneq (${IN_NIX_SHELL},)
240- YOSYS_EXE := $(shell command -v yosys)
241- else
242- YOSYS_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/yosys/bin/yosys)
243- endif
244-
245- # Use locally installed and built klayout if it exists, otherwise use klayout in path
246- KLAYOUT_DIR = $(abspath $(FLOW_HOME ) /../tools/install/klayout/)
247- KLAYOUT_BIN_FROM_DIR = $(KLAYOUT_DIR ) /klayout
184+ #
185+ # Note! We need to explicitly pass in the environment variables that
186+ # defaults.py *uses* to compute the list of default values. We do NOT
187+ # need to pass in *all* environment variables. defaults.py does not
188+ # use the default value to modify the environment, it computes default
189+ # values for environment variables and has options to print out
190+ # the information in different formats.
191+ $(foreach line,$(shell \
192+ PLATFORM_DIR =$(PLATFORM_DIR ) \
193+ FLOW_HOME=$(FLOW_HOME ) \
194+ DESIGN_NAME=$(DESIGN_NAME ) \
195+ DESIGN_NICKNAME=$(DESIGN_NICKNAME ) \
196+ WORK_HOME=$(WORK_HOME ) \
197+ PLATFORM=$(PLATFORM ) \
198+ NUM_CORES=$(NUM_CORES ) \
199+ TIME_BIN=$(TIME_BIN ) \
200+ IN_NIX_SHELL=$(IN_NIX_SHELL ) \
201+ OPENROAD_EXE=$(OPENROAD_EXE ) \
202+ OPENSTA_EXE=$(OPENSTA_EXE ) \
203+ YOSYS_EXE=$(YOSYS_EXE ) \
204+ KLAYOUT_CMD=$(KLAYOUT_CMD ) \
205+ SCRIPTS_DIR=$(SCRIPTS_DIR ) \
206+ ADDITIONAL_LIBS="$(ADDITIONAL_LIBS ) " \
207+ ADDITIONAL_GDS="$(ADDITIONAL_GDS ) " \
208+ ADDITIONAL_LEFS="$(ADDITIONAL_LEFS ) " \
209+ $(SCRIPTS_DIR ) /defaults.py make),$(eval export $(subst __SPACE__, ,$(line ) ) ) )
248210
249- ifeq ($(wildcard $(KLAYOUT_BIN_FROM_DIR ) ) , $(KLAYOUT_BIN_FROM_DIR ) )
250- KLAYOUT_CMD ?= sh -c 'LD_LIBRARY_PATH=$(dir $(KLAYOUT_BIN_FROM_DIR ) ) $$0 "$$@ "' $(KLAYOUT_BIN_FROM_DIR )
251- else
252- ifeq ($(KLAYOUT_CMD ) ,)
253- KLAYOUT_CMD := $(shell command -v klayout)
254- endif
255- endif
256211KLAYOUT_FOUND = $(if $(KLAYOUT_CMD ) ,,$(error KLayout not found in PATH) )
257212
258213ifneq ($(shell command -v stdbuf) ,)
@@ -444,13 +399,11 @@ yosys-dependencies: $(YOSYS_DEPENDENCIES)
444399
445400.PHONY : do-yosys
446401do-yosys : $(DONT_USE_SC_LIB )
447- mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
448- ($( TIME_CMD) $( YOSYS_EXE) $( YOSYS_FLAGS) -c $( SYNTH_SCRIPT) ) 2>&1 | tee $(abspath $(LOG_DIR ) /1_1_yosys.log)
402+ $(SCRIPTS_DIR ) /synth.sh $(SYNTH_SCRIPT ) $(LOG_DIR ) /1_1_yosys.log
449403
450404.PHONY : do-yosys-canonicalize
451405do-yosys-canonicalize : yosys-dependencies $(DONT_USE_SC_LIB )
452- mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
453- ($( TIME_CMD) $( YOSYS_EXE) $( YOSYS_FLAGS) -c $( SCRIPTS_DIR) /synth_canonicalize.tcl) 2>&1 | tee $(abspath $(LOG_DIR ) /1_1_yosys_canonicalize.log)
406+ $(SCRIPTS_DIR ) /synth.sh $(SCRIPTS_DIR ) /synth_canonicalize.tcl $(LOG_DIR ) /1_1_yosys_canonicalize.log
454407
455408$(RESULTS_DIR ) /1_synth.rtlil : $(YOSYS_DEPENDENCIES )
456409 $(UNSET_AND_MAKE ) do-yosys-canonicalize
@@ -557,13 +510,7 @@ endif
557510
558511.PHONY: do-$(1 )
559512do-$(1 ) : $(OBJECTS_DIR ) /copyright.txt
560- @mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
561- @echo Running $(3 ) .tcl, stage $(1 )
562- @(set -eo pipefail; \
563- trap 'mv $(LOG_DIR ) /$(1 ) .tmp.log $(LOG_DIR ) /$(1 ) .log' EXIT; \
564- $(OPENROAD_EXE ) $(OPENROAD_ARGS ) -exit $(SCRIPTS_DIR ) /noop.tcl 2>&1 >$(LOG_DIR ) /$(1 ) .tmp.log; \
565- $(TIME_CMD ) $(OPENROAD_CMD ) -no_splash $(SCRIPTS_DIR ) /$(3 ) .tcl -metrics $(LOG_DIR ) /$(1 ) .json 2>&1 | \
566- tee -a $(abspath $(LOG_DIR ) /$(1 ) .tmp.log) )
513+ $(SCRIPTS_DIR ) /flow.sh $(1 ) $(3 )
567514endef
568515
569516# generate make rules to copy a file, if a dependency change and
0 commit comments