forked from The-OpenROAD-Project/OpenROAD-flow-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvariables.mk
More file actions
219 lines (178 loc) · 8.55 KB
/
Copy pathvariables.mk
File metadata and controls
219 lines (178 loc) · 8.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Sets up ORFS variables using make variable support, relying
# on makefile features such as defaults, forward references,
# lazy evaluation, conditional code, include statements,
# etc.
export DESIGN_NICKNAME?=$(DESIGN_NAME)
#-------------------------------------------------------------------------------
# Setup variables to point to other location for the following sub directory
# - designs - default is under current directory
# - platforms - default is under current directory
# - utils, scripts, test - default is under current directory
export DESIGN_HOME ?= $(FLOW_HOME)/designs
export PLATFORM_HOME ?= $(FLOW_HOME)/platforms
export UTILS_DIR ?= $(FLOW_HOME)/util
export SCRIPTS_DIR ?= $(FLOW_HOME)/scripts
export TEST_DIR ?= $(FLOW_HOME)/test
PUBLIC=nangate45 sky130hd sky130hs asap7 ihp-sg13g2 gf180
ifeq ($(origin PLATFORM), undefined)
$(error PLATFORM variable not set.)
endif
ifeq ($(origin DESIGN_NAME), undefined)
$(error DESIGN_NAME variable not set.)
endif
ifneq ($(PLATFORM_DIR),)
else ifneq ($(wildcard $(PLATFORM_HOME)/$(PLATFORM)),)
export PLATFORM_DIR = $(PLATFORM_HOME)/$(PLATFORM)
else ifneq ($(findstring $(PLATFORM),$(PUBLIC)),)
export PLATFORM_DIR = ./platforms/$(PLATFORM)
else ifneq ($(wildcard ../../$(PLATFORM)),)
export PLATFORM_DIR = ../../$(PLATFORM)
else
$(error [ERROR][FLOW] Platform '$(PLATFORM)' not found.)
endif
include $(PLATFORM_DIR)/config.mk
# __SPACE__ is a workaround for whitespace hell in "foreach"; there
# is no way to escape space in defaults.py and get "foreach" to work.
$(foreach line,$(shell $(PYTHON_EXE) $(SCRIPTS_DIR)/defaults.py),$(eval export $(subst __SPACE__, ,$(line))))
export LOG_DIR = $(WORK_HOME)/logs/$(PLATFORM)/$(DESIGN_NICKNAME)/$(FLOW_VARIANT)
export OBJECTS_DIR = $(WORK_HOME)/objects/$(PLATFORM)/$(DESIGN_NICKNAME)/$(FLOW_VARIANT)
export REPORTS_DIR = $(WORK_HOME)/reports/$(PLATFORM)/$(DESIGN_NICKNAME)/$(FLOW_VARIANT)
export RESULTS_DIR = $(WORK_HOME)/results/$(PLATFORM)/$(DESIGN_NICKNAME)/$(FLOW_VARIANT)
#-------------------------------------------------------------------------------
ifeq (,$(strip $(NUM_CORES)))
# Linux (utility program)
NUM_CORES := $(shell nproc 2>/dev/null)
ifeq (,$(strip $(NUM_CORES)))
# Linux (generic)
NUM_CORES := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
endif
ifeq (,$(strip $(NUM_CORES)))
# BSD (at least FreeBSD and Mac OSX)
NUM_CORES := $(shell sysctl -n hw.ncpu 2>/dev/null)
endif
ifeq (,$(strip $(NUM_CORES)))
# Fallback
NUM_CORES := 1
endif
endif
export NUM_CORES
#-------------------------------------------------------------------------------
# setup all commands used within this flow
PYTHON_EXE ?= $(shell command -v python3)
export PYTHON_EXE := $(PYTHON_EXE)
export RUN_CMD = $(PYTHON_EXE) $(FLOW_HOME)/scripts/run_command.py
# The following determine the executable location for each tool used by this flow.
# Priority is given to
# 1 user explicit set with variable in Makefile or command line, for instance setting OPENROAD_EXE
# 2 either
# 2.1 if in Nix shell: openroad, yosys from the environment
# 2.2 ORFS compiled tools: openroad, yosys
ifneq (${IN_NIX_SHELL},)
OPENROAD_EXE ?= $(shell command -v openroad)
else
OPENROAD_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/OpenROAD/bin/openroad)
endif
ifneq (${IN_NIX_SHELL},)
OPENSTA_EXE ?= $(shell command -v sta)
else
OPENSTA_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/OpenROAD/bin/sta)
endif
export OPENROAD_EXE := $(OPENROAD_EXE)
export OPENSTA_EXE := $(OPENSTA_EXE)
OPENROAD_IS_VALID := $(if $(OPENROAD_EXE),$(shell test -x $(OPENROAD_EXE) && echo "true"),)
export OPENROAD_ARGS = -no_init -threads $(NUM_CORES) $(OR_ARGS)
export OPENROAD_CMD = $(OPENROAD_EXE) -exit $(OPENROAD_ARGS)
export OPENROAD_NO_EXIT_CMD = $(OPENROAD_EXE) $(OPENROAD_ARGS)
export OPENROAD_GUI_CMD = $(OPENROAD_EXE) -gui $(OR_ARGS)
ifneq (${IN_NIX_SHELL},)
YOSYS_EXE ?= $(shell command -v yosys)
else
YOSYS_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/yosys/bin/yosys)
endif
export YOSYS_EXE := $(YOSYS_EXE)
YOSYS_IS_VALID := $(if $(YOSYS_EXE),$(shell test -x $(YOSYS_EXE) && echo "true"),)
# Use locally installed and built klayout if it exists, otherwise use klayout in path
KLAYOUT_DIR = $(abspath $(FLOW_HOME)/../tools/install/klayout/)
KLAYOUT_BIN_FROM_DIR = $(KLAYOUT_DIR)/klayout
KEPLER_FORMAL_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/kepler-formal/bin/kepler-formal)
export KEPLER_FORMAL_EXE
ifeq ($(wildcard $(KLAYOUT_BIN_FROM_DIR)), $(KLAYOUT_BIN_FROM_DIR))
KLAYOUT_CMD ?= sh -c 'LD_LIBRARY_PATH=$(dir $(KLAYOUT_BIN_FROM_DIR)) $$0 "$$@"' $(KLAYOUT_BIN_FROM_DIR)
else
ifeq ($(KLAYOUT_CMD),)
KLAYOUT_CMD ?= $(shell command -v klayout)
endif
endif
export KLAYOUT_CMD := $(KLAYOUT_CMD)
#-------------------------------------------------------------------------------
WRAPPED_LEFS = $(foreach lef,$(notdir $(WRAP_LEFS)),$(OBJECTS_DIR)/lef/$(lef:.lef=_mod.lef))
WRAPPED_LIBS = $(foreach lib,$(notdir $(WRAP_LIBS)),$(OBJECTS_DIR)/$(lib:.lib=_mod.lib))
export ADDITIONAL_LEFS += $(WRAPPED_LEFS) $(WRAP_LEFS)
export LIB_FILES += $(WRAP_LIBS) $(WRAPPED_LIBS)
# Stream system used for final result (GDS is default): GDS, GSDII, GDS2, OASIS, or OAS
STREAM_SYSTEM ?= GDS
ifneq ($(findstring GDS,$(shell echo $(STREAM_SYSTEM) | tr '[:lower:]' '[:upper:]')),)
export STREAM_SYSTEM_EXT := gds
GDSOAS_FILES = $(GDS_FILES)
ADDITIONAL_GDSOAS = $(ADDITIONAL_GDS)
SEAL_GDSOAS = $(SEAL_GDS)
else
export STREAM_SYSTEM_EXT := oas
GDSOAS_FILES = $(OAS_FILES)
ADDITIONAL_GDSOAS = $(ADDITIONAL_OAS)
SEAL_GDSOAS = $(SEAL_OAS)
endif
export WRAPPED_GDSOAS = $(foreach lef,$(notdir $(WRAP_LEFS)),$(OBJECTS_DIR)/$(lef:.lef=_mod.$(STREAM_SYSTEM_EXT)))
# If we are running headless use offscreen rendering for save_image
ifeq ($(DISPLAY),)
export QT_QPA_PLATFORM ?= offscreen
endif
# Create Macro wrappers (if necessary)
export WRAP_CFG = $(PLATFORM_DIR)/wrapper.cfg
export TCLLIBPATH := util/cell-veneer $(TCLLIBPATH)
export SYNTH_SCRIPT ?= $(SCRIPTS_DIR)/synth.tcl
export SDC_FILE_CLOCK_PERIOD = $(RESULTS_DIR)/clock_period.txt
export YOSYS_DEPENDENCIES=$(LIB_FILES) $(WRAPPED_LIBS) $(DFF_LIB_FILE) $(VERILOG_FILES) $(SYNTH_NETLIST_FILES) $(LATCH_MAP_FILE) $(ADDER_MAP_FILE) $(SDC_FILE_CLOCK_PERIOD)
# Ubuntu 22.04 ships with older than 0.28.11, so support older versions
# for a while still.
export KLAYOUT_ENV_VAR_IN_PATH_VERSION = 0.28.11
export KLAYOUT_VERSION := $(if $(KLAYOUT_CMD),$(shell $(KLAYOUT_CMD) -v 2>/dev/null | grep 'KLayout' | cut -d ' ' -f2),)
export KLAYOUT_ENV_VAR_IN_PATH = $(shell \
if [ -z "$(KLAYOUT_VERSION)" ]; then \
echo "not_found"; \
elif [ "$$(echo -e "$(KLAYOUT_VERSION)\n$(KLAYOUT_ENV_VAR_IN_PATH_VERSION)" | sort -V | head -n1)" = "$(KLAYOUT_VERSION)" ] && [ "$(KLAYOUT_VERSION)" != "$(KLAYOUT_ENV_VAR_IN_PATH_VERSION)" ]; then \
echo "invalid"; \
else \
echo "valid"; \
fi)
export GDS_FINAL_FILE = $(RESULTS_DIR)/6_final.$(STREAM_SYSTEM_EXT)
export RESULTS_ODB = $(notdir $(sort $(wildcard $(RESULTS_DIR)/*.odb)))
export RESULTS_DEF = $(notdir $(sort $(wildcard $(RESULTS_DIR)/*.def)))
export RESULTS_GDS = $(notdir $(sort $(wildcard $(RESULTS_DIR)/*.gds)))
export RESULTS_OAS = $(notdir $(sort $(wildcard $(RESULTS_DIR)/*.oas)))
export RESULTS_V = $(notdir $(sort $(wildcard $(RESULTS_DIR)/*.v)))
export GDS_MERGED_FILE = $(RESULTS_DIR)/6_1_merged.$(STREAM_SYSTEM_EXT)
define get_variables
$(foreach V, $(.VARIABLES),$(if $(filter-out $(1), $(origin $V)), $(if $(filter-out .% %QT_QPA_PLATFORM% KLAYOUT% OPENROAD% OPENSTA% PYTHON% YOSYS% GENERATE_ABSTRACT_RULE% do-step% do-copy% OPEN_GUI% OPEN_GUI_SHORTCUT% SUB_MAKE% UNSET_VARS% export%, $(V)), $V$ )))
endef
export UNSET_VARIABLES_NAMES := $(call get_variables,command% line environment% default automatic)
export ISSUE_VARIABLES_NAMES := $(sort $(filter-out \n get_variables, $(call get_variables,environment% default automatic)))
# This is Makefile's way to define a macro that expands to a single newline.
define newline
endef
export ISSUE_VARIABLES := $(foreach V, $(ISSUE_VARIABLES_NAMES), $(if $($V),$V=$($V),$V='')$(newline))
export COMMAND_LINE_ARGS := $(foreach V,$(.VARIABLES),$(if $(filter command% line, $(origin $V)),$(V)))
# Set yosys-abc clock period to first "clk_period" value or "-period" value found in sdc file
ifeq ($(origin ABC_CLOCK_PERIOD_IN_PS), undefined)
ifneq ($(wildcard $(SDC_FILE)),)
export ABC_CLOCK_PERIOD_IN_PS := $(shell sed -nE "s/^set\s+clk_period\s+(\S+).*|.*-period\s+(\S+).*/\1\2/p" $(SDC_FILE) | head -1 | awk '{print $$1}')
endif
endif
.PHONY: vars
vars:
mkdir -p $(OBJECTS_DIR)
$(UTILS_DIR)/generate-vars.sh $(OBJECTS_DIR)/vars
.PHONY: print-%
print-%:
$(info $*: $($*))
@true