-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
156 lines (133 loc) · 3.91 KB
/
Makefile
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
#
# TinyTapeout Blackbox Macro Build Harness
# (mostly for art)
#
# Contributors:
# - watbulb: Dayton Pidhirney
#
TT_PROJECT_NAME ?= tt_um_macro_testing
PDK_ROOT := ${PDK_ROOT}
PDK_MAGICRC := $(PDK_ROOT)/sky130A/libs.tech/magic/sky130A.magicrc
ifeq ($(PDK_ROOT),)
$(error "PDK_ROOT not in environment")
endif
VSRC_PATH ?= $(CURDIR)/src
MAG_MACRO_PATH ?= $(CURDIR)/mag
GDS_MACRO_PATH ?= $(CURDIR)/gds
LEF_MACRO_PATH ?= $(CURDIR)/lef
# The target macro
TARGET_MACRO ?= $(lastword $(MAKECMDGOALS))
# Macro sources
MAG_SOURCES := $(wildcard $(MAG_MACRO_PATH)/*.mag)
GDS_SOURCES := $(wildcard $(GDS_MACRO_PATH)/*.gds)
LEF_SOURCES := $(wildcard $(LEF_MACRO_PATH)/*.lef)
# Find the magic source for the target macro
MAG_MACROS_SRC := $(foreach macro,$(TARGET_MACRO),$(filter %$(macro).mag,$(MAG_SOURCES)))
GDS_MACROS_SRC := $(foreach macro,$(TARGET_MACRO),$(filter %$(macro).gds,$(GDS_SOURCES)))
LEF_MACROS_SRC := $(foreach macro,$(TARGET_MACRO),$(filter %$(macro).lef,$(LEF_SOURCES)))
# Name of top module
TOP_NAME ?= tt_um_macro_test_wrapper
PURE_ART ?= 1
ifeq ($(words $(MAKECMDGOALS)),2)
# check if we have a mag or GDS for the macro
ifeq ($(or $(MAG_MACROS_SRC),$(GDS_MACROS_SRC)),)
$(error "unable to locate a mag for selected macro $(TARGET_MACRO)")
endif
# if we are looking at a GDS macro, we need a LEF for it
ifneq ($(GDS_MACROS_SRC),)
ifeq ($(LEF_MACROS_SRC),)
$(error "unable to locate LEF for GDS specific macro")
endif
endif
# Info
ifneq ($(DEBUG),)
$(info [DEBUG] Variables: )
$(info PDK_ROOT: $(PDK_ROOT))
$(info TT_PROJECT_NAME: $(TT_PROJECT_NAME))
$(info TARGET_MACRO: $(TARGET_MACRO))
$(info MAG_MACROS_SRC: $(MAG_MACROS_SRC))
$(info GDS_MACROS_SRC: $(GDS_MACROS_SRC))
$(info LEF_MACROS_SRC: $(LEF_MACROS_SRC))
endif
endif
# Some helpers we may need
define macro_name
$(firstword $(subst ., ,$(basename $(notdir $(macro)))))
endef
$(TARGET_MACRO):
#
# Conversion targets
#
$(GDS_MACROS_SRC):
./script/gds_add_pnb.py $@
$(GDS_MACRO_PATH)/%.gds: $(MAG_MACRO_PATH)/%.mag
$(info MAG -> GDS)
echo "gds write \"$@\"" | magic -rcfile $(PDK_MAGICRC) -noconsole -dnull $<
./script/gds_add_pnb.py $@
$(LEF_MACRO_PATH)/%.lef: $(MAG_MACRO_PATH)/%.mag
$(info MAG -> LEF)
echo "lef write \"$@\" -pinonly" | magic -rcfile $(PDK_MAGICRC) -noconsole -dnull $<
preproc: \
$(GDS_MACROS_SRC) \
$(patsubst $(MAG_MACRO_PATH)/%.mag,$(GDS_MACRO_PATH)/%.gds,$(MAG_MACROS_SRC)) \
$(patsubst $(MAG_MACRO_PATH)/%.mag,$(LEF_MACRO_PATH)/%.lef,$(MAG_MACROS_SRC))
#
# Harden targets
#
tt_user_config:
./tt/tt_tool.py --create-user-config --openlane2
tt_harden_top: preproc
mkdir -p runs/$(TAGET_MACRO)
ln -sf $(TARGET_MACRO)_config.json src/config.json
./tt/tt_tool.py --harden --openlane2
cp runs/wokwi/final/gds/* gds/final/
cp runs/wokwi/final/mag/* mag/final/
cp runs/wokwi/final/lef/* lef/final/
PURE_ART=$(PURE_ART) TOP_NAME=$(TOP_NAME) MACRO_NAME=$(TARGET_MACRO) magic -noconsole -dnull ./tcl/place_power_pins.tcl
tt_render_final:
mkdir -p render
./tt/tt_tool.py --create-png --openlane2
mv *.png *.svg render/
harden_top: preproc
mkdir -p runs/$(TARGET_MACRO)
openlane --run-tag $(TARGET_MACRO) --force-run-dir runs/$(TARGET_MACRO) src/config_marged.json
#
# Viewers targets
#
open_openroad:
openlane \
-f OpenInOpenROAD \
--run-tag $(TARGET_MACRO) \
--force-run-dir runs/$(TARGET_MACRO) \
src/config_merged.json
open_klayout:
openlane \
-f OpenInKLayout \
--run-tag $(TARGET_MACRO) \
--force-run-dir runs/$(TARGET_MACRO) \
src/config_merged.json
#
# Cleanup targets
#
clean_final:
@rm -f gds/*
@rm -f lef/*
@rm -f png/*
clean_build:
@rm -rf runs/*
@rm -f src/config_merged.json
@rm -rf slpp_all
dist_clean: clean_final clean_build
#
# META
#
.NOTPARALLEL:
.PHONY: \
$(TARGET_MACRO) \
$(GDS_MACROS_SRC) \
preproc \
tt_user_config \
tt_harden_top harden_top \
tt_render_final \
open_openroad open_klayout \
clean_final clean_build dist_clean