Skip to content

Commit 9981923

Browse files
authored
Merge pull request #3017 from Pinata-Consulting/makefile-break-out-synth-and-flow-scripts
makefile: break out scripts/synth.sh and scripts/flow.sh utilities
2 parents ed6a858 + 62e0803 commit 9981923

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

flow/Makefile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ yosys-dependencies: $(YOSYS_DEPENDENCIES)
285285
.PHONY: do-yosys
286286
do-yosys: $(DONT_USE_SC_LIB)
287287
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
288-
($(TIME_CMD) $(YOSYS_EXE) $(YOSYS_FLAGS) -c $(SYNTH_SCRIPT)) 2>&1 | tee $(abspath $(LOG_DIR)/1_1_yosys.log)
288+
$(SCRIPTS_DIR)/synth.sh $(SYNTH_SCRIPT) $(LOG_DIR)/1_1_yosys.log
289289

290290
.PHONY: do-yosys-canonicalize
291291
do-yosys-canonicalize: yosys-dependencies $(DONT_USE_SC_LIB)
292292
mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
293-
($(TIME_CMD) $(YOSYS_EXE) $(YOSYS_FLAGS) -c $(SCRIPTS_DIR)/synth_canonicalize.tcl) 2>&1 | tee $(abspath $(LOG_DIR)/1_1_yosys_canonicalize.log)
293+
$(SCRIPTS_DIR)/synth.sh $(SCRIPTS_DIR)/synth_canonicalize.tcl $(LOG_DIR)/1_1_yosys_canonicalize.log
294294

295295
$(RESULTS_DIR)/1_synth.rtlil: $(YOSYS_DEPENDENCIES)
296296
$(UNSET_AND_MAKE) do-yosys-canonicalize
@@ -397,13 +397,7 @@ endif
397397

398398
.PHONY: do-$(1)
399399
do-$(1): $(OBJECTS_DIR)/copyright.txt
400-
@mkdir -p $(RESULTS_DIR) $(LOG_DIR) $(REPORTS_DIR) $(OBJECTS_DIR)
401-
@echo Running $(3).tcl, stage $(1)
402-
@(set -eo pipefail; \
403-
trap 'mv $(LOG_DIR)/$(1).tmp.log $(LOG_DIR)/$(1).log' EXIT; \
404-
$(OPENROAD_EXE) $(OPENROAD_ARGS) -exit $(SCRIPTS_DIR)/noop.tcl 2>&1 >$(LOG_DIR)/$(1).tmp.log; \
405-
$(TIME_CMD) $(OPENROAD_CMD) -no_splash $(SCRIPTS_DIR)/$(3).tcl -metrics $(LOG_DIR)/$(1).json 2>&1 | \
406-
tee -a $(abspath $(LOG_DIR)/$(1).tmp.log))
400+
$(SCRIPTS_DIR)/flow.sh $(1) $(3)
407401
endef
408402

409403
# generate make rules to copy a file, if a dependency change and

flow/scripts/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ It is also possible to evaluate the variables without using the ORFS `Makefile`,
5757
Design area 38 u^2 19% utilization.
5858
$
5959

60+
### flow.sh and synth.sh
61+
62+
Utility scripts that can be used in combination with `variables.mk` to invoke synthesis and flow steps without going through the ORFS `Makefile`.
63+
6064
## make run-yosys
6165

6266
Sets up all the ORFS environment variables and launches Yosys.

flow/scripts/flow.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -u -eo pipefail
3+
mkdir -p $RESULTS_DIR $LOG_DIR $REPORTS_DIR $OBJECTS_DIR
4+
echo Running $2.tcl, stage $1
5+
(trap 'mv $LOG_DIR/$1.tmp.log $LOG_DIR/$1.log' EXIT; \
6+
$OPENROAD_EXE $OPENROAD_ARGS -exit $SCRIPTS_DIR/noop.tcl 2>&1 >$LOG_DIR/$1.tmp.log; \
7+
eval "$TIME_CMD $OPENROAD_CMD -no_splash $SCRIPTS_DIR/$2.tcl -metrics $LOG_DIR/$1.json" 2>&1 | \
8+
tee -a $(realpath $LOG_DIR/$1.tmp.log))

flow/scripts/synth.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -u -eo pipefail
3+
mkdir -p $RESULTS_DIR $LOG_DIR $REPORTS_DIR $OBJECTS_DIR
4+
eval "$TIME_CMD $YOSYS_EXE $YOSYS_FLAGS -c $1" 2>&1 | tee $(realpath $2)

flow/scripts/variables.mk

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ TIME_TEST = $(shell $(TIME_CMD) echo foo 2>/dev/null)
8686
ifeq (,$(strip $(TIME_TEST)))
8787
TIME_CMD = $(TIME_BIN)
8888
endif
89+
export TIME_CMD
8990

9091
# The following determine the executable location for each tool used by this flow.
9192
# Priority is given to
@@ -102,16 +103,17 @@ else
102103
export OPENSTA_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/OpenROAD/bin/sta)
103104
endif
104105

105-
OPENROAD_ARGS = -no_init -threads $(NUM_CORES) $(OR_ARGS)
106-
OPENROAD_CMD = $(OPENROAD_EXE) -exit $(OPENROAD_ARGS)
107-
OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE) $(OPENROAD_ARGS)
108-
OPENROAD_GUI_CMD = $(OPENROAD_EXE) -gui $(OR_ARGS)
106+
export OPENROAD_ARGS = -no_init -threads $(NUM_CORES) $(OR_ARGS)
107+
export OPENROAD_CMD = $(OPENROAD_EXE) -exit $(OPENROAD_ARGS)
108+
export OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE) $(OPENROAD_ARGS)
109+
export OPENROAD_GUI_CMD = $(OPENROAD_EXE) -gui $(OR_ARGS)
109110

110111
ifneq (${IN_NIX_SHELL},)
111112
YOSYS_EXE := $(shell command -v yosys)
112113
else
113114
YOSYS_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/yosys/bin/yosys)
114115
endif
116+
export YOSYS_EXE
115117

116118
# Use locally installed and built klayout if it exists, otherwise use klayout in path
117119
KLAYOUT_DIR = $(abspath $(FLOW_HOME)/../tools/install/klayout/)

0 commit comments

Comments
 (0)