Skip to content

Commit 27c3c0b

Browse files
committed
makefile: move more variables setup to bash
Signed-off-by: Øyvind Harboe <[email protected]>
1 parent eaba9c1 commit 27c3c0b

File tree

3 files changed

+45
-36
lines changed

3 files changed

+45
-36
lines changed

flow/Makefile

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -159,42 +159,6 @@ ifneq ($(BLOCKS),)
159159
endif
160160
endif
161161

162-
#-------------------------------------------------------------------------------
163-
ifeq (,$(strip $(NUM_CORES)))
164-
# Linux (utility program)
165-
NUM_CORES := $(shell nproc 2>/dev/null)
166-
167-
ifeq (,$(strip $(NUM_CORES)))
168-
# Linux (generic)
169-
NUM_CORES := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
170-
endif
171-
ifeq (,$(strip $(NUM_CORES)))
172-
# BSD (at least FreeBSD and Mac OSX)
173-
NUM_CORES := $(shell sysctl -n hw.ncpu 2>/dev/null)
174-
endif
175-
ifeq (,$(strip $(NUM_CORES)))
176-
# Fallback
177-
NUM_CORES := 1
178-
endif
179-
endif
180-
export NUM_CORES
181-
182-
export YOSYS_FLAGS += -v 3
183-
184-
# The following determine the executable location for each tool used by this flow.
185-
# Priority is given to
186-
# 1 user explicit set with variable in Makefile or command line, for instance setting OPENROAD_EXE
187-
# 2 ORFS compiled tools: openroad, yosys
188-
export OPENROAD_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/OpenROAD/bin/openroad)
189-
export OPENSTA_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/OpenROAD/bin/sta)
190-
191-
export OPENROAD_ARGS = -no_init -threads $(NUM_CORES) $(OR_ARGS)
192-
export OPENROAD_CMD = $(OPENROAD_EXE) -exit $(OPENROAD_ARGS)
193-
export OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE) $(OPENROAD_ARGS)
194-
export OPENROAD_GUI_CMD = $(OPENROAD_EXE) -gui $(OR_ARGS)
195-
196-
export YOSYS_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/yosys/bin/yosys)
197-
198162
# Use locally installed and built klayout if it exists, otherwise use klayout in path
199163
KLAYOUT_DIR = $(abspath $(FLOW_HOME)/../tools/install/klayout/)
200164
KLAYOUT_BIN_FROM_DIR = $(KLAYOUT_DIR)/klayout

flow/scripts/config.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,46 @@ while IFS= read -r line; do
4949
# Replace "__SPACE__" with an actual space in the line
5050
eval "${line//__SPACE__/ }"
5151
done < <("${FLOW_HOME}/scripts/defaults.py")
52+
53+
54+
# Determine the number of cores (NUM_CORES)
55+
if [[ -z "${NUM_CORES:-}" ]]; then
56+
# Linux (utility program)
57+
NUM_CORES=$(nproc 2>/dev/null || true)
58+
59+
if [[ -z "$NUM_CORES" ]]; then
60+
# Linux (generic)
61+
NUM_CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || true)
62+
fi
63+
64+
if [[ -z "$NUM_CORES" ]]; then
65+
# BSD (at least FreeBSD and macOS)
66+
NUM_CORES=$(sysctl -n hw.ncpu 2>/dev/null || true)
67+
fi
68+
69+
if [[ -z "$NUM_CORES" ]]; then
70+
# Fallback
71+
NUM_CORES=1
72+
fi
73+
fi
74+
export NUM_CORES
75+
76+
# Determine the executable location for each tool used by this flow.
77+
# Priority is given to:
78+
# 1. User explicitly setting the variable in the environment or command line (e.g., OPENROAD_EXE).
79+
# 2. Default ORFS compiled tools: openroad, yosys.
80+
81+
# Set default paths for executables if not already set
82+
export OPENROAD_EXE="${OPENROAD_EXE:-$(realpath "${FLOW_HOME}/../tools/install/OpenROAD/bin/openroad")}"
83+
export OPENSTA_EXE="${OPENSTA_EXE:-$(realpath "${FLOW_HOME}/../tools/install/OpenROAD/bin/sta")}"
84+
export YOSYS_EXE="${YOSYS_EXE:-$(realpath "${FLOW_HOME}/../tools/install/yosys/bin/yosys")}"
85+
86+
export OR_ARGS="${OR_ARGS:-}"
87+
88+
# Define OpenROAD command-line arguments
89+
export OPENROAD_ARGS="-no_init -threads ${NUM_CORES} ${OR_ARGS}"
90+
91+
# Define OpenROAD commands
92+
export OPENROAD_CMD="${OPENROAD_EXE} -exit ${OPENROAD_ARGS}"
93+
export OPENROAD_NO_EXIT_CMD="${OPENROAD_EXE} ${OPENROAD_ARGS}"
94+
export OPENROAD_GUI_CMD="${OPENROAD_EXE} -gui ${OR_ARGS}"

flow/scripts/synth.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
set -u -eo pipefail
33
mkdir -p $RESULTS_DIR $LOG_DIR $REPORTS_DIR $OBJECTS_DIR
44

5+
export YOSYS_FLAGS="${YOSYS_FLAGS:-} -v 3"
6+
57
# Not normally adjusted by user
68
export SYNTH_OPERATIONS_ARGS="${SYNTH_OPERATIONS_ARGS:--extra-map ${FLOW_HOME}/platforms/common/lcu_kogge_stone.v}"
79
export SYNTH_FULL_ARGS="${SYNTH_FULL_ARGS:=${SYNTH_ARGS} ${SYNTH_OPERATIONS_ARGS}}"

0 commit comments

Comments
 (0)