@@ -113,61 +113,36 @@ MAKEFLAGS += --no-builtin-rules
113113SHELL := /usr/bin/env bash
114114.SHELLFLAGS := -o pipefail -c
115115
116- # -------------------------------------------------------------------------------
117- # Setup variables to point to root / head of the OpenROAD directory
118- # - the following settings allowed user to point OpenROAD binaries to different
119- # location
120- # - default is current install / clone directory
121116ifeq ($(origin FLOW_HOME ) , undefined)
122117FLOW_HOME := $(abspath $(dir $(firstword $(MAKEFILE_LIST ) ) ) )
123118endif
124119export FLOW_HOME
125120
126- # -------------------------------------------------------------------------------
127- # Setup variables to point to other location for the following sub directory
128- # - designs - default is under current directory
129- # - platforms - default is under current directory
130- # - work home - default is current directory
131- # - utils, scripts, test - default is under current directory
132- export DESIGN_HOME ?= $(FLOW_HOME ) /designs
133- export PLATFORM_HOME ?= $(FLOW_HOME ) /platforms
134- export WORK_HOME ?= .
135-
136- export UTILS_DIR ?= $(FLOW_HOME ) /util
137- export SCRIPTS_DIR ?= $(FLOW_HOME ) /scripts
138- export TEST_DIR ?= $(FLOW_HOME ) /test
139-
140- PUBLIC =nangate45 sky130hd sky130hs asap7 ihp-sg13g2 gf180
141-
142- ifneq ($(wildcard $(PLATFORM_HOME ) /$(PLATFORM ) ) ,)
143- export PLATFORM_DIR = $(PLATFORM_HOME ) /$(PLATFORM )
144- else ifneq ($(findstring $(PLATFORM),$(PUBLIC)),)
145- export PLATFORM_DIR = ./platforms/$(PLATFORM )
146- else ifneq ($(wildcard ../../$(PLATFORM)),)
147- export PLATFORM_DIR = ../../$(PLATFORM )
148- else
149- $(error [ERROR][FLOW] Platform '$(PLATFORM)' not found.)
150- endif
151-
152- include $(PLATFORM_DIR ) /config.mk
153-
121+ # The plan is to migrate all variables to .sh so that
122+ # ORFS is no longer dependent on make.
123+ #
124+ # Explicitly enumerate the environment variables we need $SCRIPTS/config.sh
125+ # to see since make doesn't pass its environment to subshells.
126+ #
154127# __SPACE__ is a workaround for whitespace hell in "foreach"; there
155128# is no way to escape space in defaults.py and get "foreach" to work.
156- $(foreach line,$(shell $(SCRIPTS_DIR)/defaults.py),$(eval export $(subst __SPACE__, ,$(line))))
157-
158- # Not normally adjusted by user
159- export SYNTH_OPERATIONS_ARGS ?= -extra-map $(FLOW_HOME ) /platforms/common/lcu_kogge_stone.v
160- export SYNTH_FULL_ARGS ?= $(SYNTH_ARGS ) $(SYNTH_OPERATIONS_ARGS )
161-
162- # Setup working directories
163- export DESIGN_NICKNAME ?= $(DESIGN_NAME )
164-
165- export DESIGN_CONFIG
166- export DESIGN_DIR = $(dir $(DESIGN_CONFIG ) )
167- export LOG_DIR = $(WORK_HOME ) /logs/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
168- export OBJECTS_DIR = $(WORK_HOME ) /objects/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
169- export REPORTS_DIR = $(WORK_HOME ) /reports/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
170- export RESULTS_DIR = $(WORK_HOME ) /results/$(PLATFORM ) /$(DESIGN_NICKNAME ) /$(FLOW_VARIANT )
129+ $(foreach line,$(shell \
130+ DESIGN_NAME =$(DESIGN_NAME ) \
131+ FLOW_HOME=$(FLOW_HOME ) \
132+ DESIGN_CONFIG=$(DESIGN_CONFIG ) \
133+ PLATFORM=$(PLATFORM ) \
134+ FLOW_VARIANT=$(FLOW_VARIANT ) \
135+ $(FLOW_HOME ) /scripts/env.sh $(FLOW_HOME ) /scripts/config.sh),$(eval $(subst __SPACE__, ,$(line ) ) ) )
136+
137+ # check some critical variables in a loop
138+ $(foreach var,DESIGN_NAME DESIGN_NICKNAME PLATFORM,\
139+ $(if $(strip $($(var))),,$(error $(var) is not set)))
140+
141+ # The plan is to move all config.mk variables into $(PLATFORM_DIR)/config.sh and
142+ # delete this include below
143+ ifneq ($(wildcard $(PLATFORM_DIR ) /config.mk) ,)
144+ include $(PLATFORM_DIR ) /config.mk
145+ endif
171146
172147ifneq ($(BLOCKS ) ,)
173148 $(foreach block,$(BLOCKS),$(eval BLOCK_LEFS += ./results/$(PLATFORM)/$(DESIGN_NICKNAME)_$(block)/$(FLOW_VARIANT)/${block}.lef))
@@ -208,16 +183,7 @@ ifeq (,$(strip $(NUM_CORES)))
208183endif
209184export NUM_CORES
210185
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
186+ export YOSYS_FLAGS += -v 3
221187
222188# The following determine the executable location for each tool used by this flow.
223189# Priority is given to
@@ -226,12 +192,12 @@ endif
226192export OPENROAD_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/OpenROAD/bin/openroad)
227193export OPENSTA_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/OpenROAD/bin/sta)
228194
229- OPENROAD_ARGS = -no_init -threads $(NUM_CORES ) $(OR_ARGS )
230- OPENROAD_CMD = $(OPENROAD_EXE ) -exit $(OPENROAD_ARGS )
231- OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE ) $(OPENROAD_ARGS )
232- OPENROAD_GUI_CMD = $(OPENROAD_EXE ) -gui $(OR_ARGS )
195+ export OPENROAD_ARGS = -no_init -threads $(NUM_CORES ) $(OR_ARGS )
196+ export OPENROAD_CMD = $(OPENROAD_EXE ) -exit $(OPENROAD_ARGS )
197+ export OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE ) $(OPENROAD_ARGS )
198+ export OPENROAD_GUI_CMD = $(OPENROAD_EXE ) -gui $(OR_ARGS )
233199
234- YOSYS_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/yosys/bin/yosys)
200+ export YOSYS_EXE ?= $(abspath $(FLOW_HOME ) /../tools/install/yosys/bin/yosys)
235201
236202# Use locally installed and built klayout if it exists, otherwise use klayout in path
237203KLAYOUT_DIR = $(abspath $(FLOW_HOME ) /../tools/install/klayout/)
@@ -435,14 +401,11 @@ yosys-dependencies: $(YOSYS_DEPENDENCIES)
435401
436402.PHONY : do-yosys
437403do-yosys : $(DONT_USE_SC_LIB )
438- mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
439- (export VERILOG_FILES=$( RESULTS_DIR) /1_synth.rtlil; \
440- $(TIME_CMD ) $(YOSYS_EXE ) $(YOSYS_FLAGS ) -c $(SYNTH_SCRIPT ) ) 2>&1 | tee $(abspath $(LOG_DIR ) /1_1_yosys.log)
404+ $(SCRIPTS_DIR ) /synth.sh $(SYNTH_SCRIPT ) $(LOG_DIR ) /1_1_yosys.log
441405
442406.PHONY : do-yosys-canonicalize
443407do-yosys-canonicalize : yosys-dependencies $(DONT_USE_SC_LIB )
444- mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
445- ($( TIME_CMD) $( YOSYS_EXE) $( YOSYS_FLAGS) -c $( SCRIPTS_DIR) /synth_canonicalize.tcl) 2>&1 | tee $(abspath $(LOG_DIR ) /1_1_yosys_canonicalize.log)
408+ $(SCRIPTS_DIR ) /synth.sh $(SCRIPTS_DIR ) /synth_canonicalize.tcl $(LOG_DIR ) /1_1_yosys_canonicalize.log
446409
447410$(RESULTS_DIR ) /1_synth.rtlil : $(YOSYS_DEPENDENCIES )
448411 $(UNSET_AND_MAKE ) do-yosys-canonicalize
@@ -555,13 +518,7 @@ endif
555518
556519.PHONY: do-$(1 )
557520do-$(1 ) : $(OBJECTS_DIR ) /copyright.txt
558- @mkdir -p $(RESULTS_DIR ) $(LOG_DIR ) $(REPORTS_DIR ) $(OBJECTS_DIR )
559- @echo Running $(3 ) .tcl, stage $(1 )
560- @(set -eo pipefail; \
561- trap 'mv $(LOG_DIR ) /$(1 ) .tmp.log $(LOG_DIR ) /$(1 ) .log' EXIT; \
562- $(OPENROAD_EXE ) $(OPENROAD_ARGS ) -exit $(SCRIPTS_DIR ) /noop.tcl 2>&1 >$(LOG_DIR ) /$(1 ) .tmp.log; \
563- $(TIME_CMD ) $(OPENROAD_CMD ) -no_splash $(SCRIPTS_DIR ) /$(3 ) .tcl -metrics $(LOG_DIR ) /$(1 ) .json 2>&1 | \
564- tee -a $(abspath $(LOG_DIR ) /$(1 ) .tmp.log) )
521+ $(SCRIPTS_DIR ) /flow.sh $(1 ) $(3 )
565522endef
566523
567524# generate make rules to copy a file, if a dependency change and
0 commit comments