Skip to content

Commit 25ef574

Browse files
committed
variables: move code from Makefile to scripts/defaults.py
ported platforms/nangate45/config.mk to config.py. Next up is porting all the rest of the platforms/**/config.mk files to config.py, after which more stuff from Makefile can be moved into scripts/config.py The flow.sh and synth.sh scripts and they won't be ready before all platforms/**/config.mk are ported to config.py. The interface will probably be something like: $ make DESIGN_CONFIG=designs/nangate45/config.mk clean_synth floorplan $ DESIGN_NAME=gcd CORE_UTILIZATION=55 PLACE_DENSITY_LB_ADDON=0.20 PLATFORM=nangate45 PLATFORM_DIR=platforms/nangate45 scripts/flow.sh 2_1_floorplan floorplan Running floorplan.tcl, stage 2_1_floorplan [deleted] Design area 650 u^2 57% utilization. Elapsed time: 0:00.40[h:]min:sec. CPU time: user 0.33 sys 0.09 (106%). Peak memory: 121724KB. $ Signed-off-by: Øyvind Harboe <[email protected]>
1 parent 1841ad2 commit 25ef574

File tree

7 files changed

+394
-201
lines changed

7 files changed

+394
-201
lines changed

flow/Makefile

Lines changed: 33 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ DESIGN_CONFIG ?= ./designs/nangate45/gcd/config.mk
9090
# this file.
9191
include $(DESIGN_CONFIG)
9292
export 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.)
175176
endif
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
256211
KLAYOUT_FOUND = $(if $(KLAYOUT_CMD),,$(error KLayout not found in PATH))
257212

258213
ifneq ($(shell command -v stdbuf),)
@@ -444,13 +399,11 @@ yosys-dependencies: $(YOSYS_DEPENDENCIES)
444399

445400
.PHONY: do-yosys
446401
do-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
451405
do-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)
559512
do-$(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)
567514
endef
568515

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

flow/platforms/nangate45/config.mk

Lines changed: 0 additions & 107 deletions
This file was deleted.

flow/platforms/nangate45/config.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import glob
2+
import os
3+
4+
5+
def get_defaults(variables):
6+
gds_files = (
7+
" ".join(
8+
sorted(glob.glob(os.path.join(variables["PLATFORM_DIR"], "gds", "*.gds")))
9+
)
10+
+ " "
11+
+ variables.get("ADDITIONAL_GDS", "")
12+
).strip()
13+
return {
14+
"PROCESS": "45",
15+
# -----------------------------------------------------
16+
# Tech/Libs
17+
# -----------------------------------------------------
18+
"TECH_LEF": f"{variables['PLATFORM_DIR']}/lef/NangateOpenCellLibrary.tech.lef",
19+
"SC_LEF": f"{variables['PLATFORM_DIR']}/lef/NangateOpenCellLibrary.macro.mod.lef",
20+
"LIB_FILES": f"{variables['PLATFORM_DIR']}/lib/NangateOpenCellLibrary_typical.lib {variables.get('ADDITIONAL_LIBS', '')}",
21+
"GDS_FILES": gds_files,
22+
# Don't use cells to ease congestion
23+
# Specify at least one filler cell if none
24+
"DONT_USE_CELLS": "TAPCELL_X1 FILLCELL_X1 AOI211_X1 OAI211_X1",
25+
# Fill cells used in fill cell insertion
26+
"FILL_CELLS": "FILLCELL_X1 FILLCELL_X2 FILLCELL_X4 FILLCELL_X8 FILLCELL_X16 FILLCELL_X32",
27+
# -----------------------------------------------------
28+
# Yosys
29+
# -----------------------------------------------------
30+
# Ungroup size for hierarchical synthesis
31+
"SYNTH_MINIMUM_KEEP_SIZE": 10000,
32+
# Set the TIEHI/TIELO cells
33+
# These are used in yosys synthesis to avoid logical 1/0's in the netlist
34+
"TIEHI_CELL_AND_PORT": "LOGIC1_X1 Z",
35+
"TIELO_CELL_AND_PORT": "LOGIC0_X1 Z",
36+
# Used in synthesis
37+
"MIN_BUF_CELL_AND_PORTS": "BUF_X1 A Z",
38+
# Yosys mapping files
39+
"LATCH_MAP_FILE": f"{variables['PLATFORM_DIR']}/cells_latch.v",
40+
"CLKGATE_MAP_FILE": f"{variables['PLATFORM_DIR']}/cells_clkgate.v",
41+
"ADDER_MAP_FILE": f"{variables['PLATFORM_DIR']}/cells_adders.v",
42+
"ABC_DRIVER_CELL": "BUF_X1",
43+
# BUF_X1, pin (A) = 0.974659. Arbitrarily multiply by 4
44+
"ABC_LOAD_IN_FF": 3.898,
45+
# --------------------------------------------------------
46+
# Floorplan
47+
# --------------------------------------------------------
48+
# Placement site for core cells
49+
# This can be found in the technology lef
50+
"PLACE_SITE": "FreePDK45_38x28_10R_NP_162NW_34O",
51+
# IO Placer pin layers
52+
"IO_PLACER_H": "metal5",
53+
"IO_PLACER_V": "metal6",
54+
# Define default PDN config
55+
"PDN_TCL": f"{variables['PLATFORM_DIR']}/grid_strategy-M1-M4-M7.tcl",
56+
# Endcap and Welltie cells
57+
"TAPCELL_TCL": f"{variables['PLATFORM_DIR']}/tapcell.tcl",
58+
"TAP_CELL_NAME": "TAPCELL_X1",
59+
"MACRO_PLACE_HALO": "22.4 15.12",
60+
# ---------------------------------------------------------
61+
# Place
62+
# ---------------------------------------------------------
63+
"PLACE_DENSITY": 0.30,
64+
# ---------------------------------------------------------
65+
# Route
66+
# ---------------------------------------------------------
67+
# FastRoute options
68+
"MIN_ROUTING_LAYER": "metal2",
69+
"MAX_ROUTING_LAYER": "metal10",
70+
# Define fastRoute tcl
71+
"FASTROUTE_TCL": f"{variables['PLATFORM_DIR']}/fastroute.tcl",
72+
# KLayout technology file
73+
"KLAYOUT_TECH_FILE": f"{variables['PLATFORM_DIR']}/FreePDK45.lyt",
74+
# KLayout DRC ruledeck
75+
"KLAYOUT_DRC_FILE": f"{variables['PLATFORM_DIR']}/drc/FreePDK45.lydrc",
76+
# KLayout LVS ruledeck
77+
"KLAYOUT_LVS_FILE": f"{variables['PLATFORM_DIR']}/lvs/FreePDK45.lylvs",
78+
# Allow empty GDS cell
79+
"GDS_ALLOW_EMPTY": "fakeram.*",
80+
"CDL_FILE": f"{variables['PLATFORM_DIR']}/cdl/NangateOpenCellLibrary.cdl",
81+
# Template definition for power grid analysis
82+
"TEMPLATE_PGA_CFG": f"{variables['PLATFORM_DIR']}/template_pga.cfg",
83+
# OpenRCX extRules
84+
"RCX_RULES": f"{variables['PLATFORM_DIR']}/rcx_patterns.rules",
85+
# ---------------------------------------------------------
86+
# IR Drop
87+
# ---------------------------------------------------------
88+
# IR drop estimation supply net name to be analyzed and supply voltage variable
89+
# For multiple nets: PWR_NETS_VOLTAGES = "VDD1 1.8 VDD2 1.2"
90+
"PWR_NETS_VOLTAGES": "VDD 1.1",
91+
"GND_NETS_VOLTAGES": "VSS 0.0",
92+
"IR_DROP_LAYER": "metal1",
93+
}

0 commit comments

Comments
 (0)