-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
163 lines (125 loc) · 7.72 KB
/
Makefile
File metadata and controls
163 lines (125 loc) · 7.72 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
MAKEFILE_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
RUN_TAG = $(shell ls librelane/runs/ | tail -n 1)
TOP = chip_top
FINAL_DIR ?= $(if $(wildcard $(MAKEFILE_DIR)/final/pnl/$(TOP).pnl.v),$(MAKEFILE_DIR)/final,$(MAKEFILE_DIR)/librelane/runs/$(RUN_TAG)/final)
PDK_ROOT ?= $(MAKEFILE_DIR)/gf180mcu
PDK ?= gf180mcuD
PDK_TAG ?= 1.8.0
VENV_DIR ?= $(MAKEFILE_DIR)/.venv
VENV_PYTHON := $(VENV_DIR)/bin/python
COCOTB_PYENV_PYTHON := $(HOME)/.pyenv/versions/cocotb-env/bin/python
ifeq ($(wildcard $(VENV_PYTHON)),$(VENV_PYTHON))
PYTHON ?= $(VENV_PYTHON)
else
ifeq ($(wildcard $(COCOTB_PYENV_PYTHON)),$(COCOTB_PYENV_PYTHON))
PYTHON ?= $(COCOTB_PYENV_PYTHON)
else
PYTHON ?= python3
endif
endif
AVAILABLE_SLOTS = 1x1 0p5x1 1x0p5 0p5x0p5
DEFAULT_SLOT = 1x1
# Slot can be any of AVAILABLE_SLOTS
SLOT ?= $(DEFAULT_SLOT)
ifeq ($(SLOT),default)
SLOT = $(DEFAULT_SLOT)
endif
ifeq ($(filter $(SLOT),$(AVAILABLE_SLOTS)),)
$(error $(SLOT) does not exist in AVAILABLE_SLOTS: $(AVAILABLE_SLOTS))
endif
.DEFAULT_GOAL := help
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
.PHONY: help
all: librelane ## Build the project (runs LibreLane)
.PHONY: all
clone-pdk: ## Clone the GF180MCU PDK repository
rm -rf $(MAKEFILE_DIR)/gf180mcu
git clone https://github.com/wafer-space/gf180mcu.git $(MAKEFILE_DIR)/gf180mcu --depth 1 --branch ${PDK_TAG}
.PHONY: clone-pdk
init-submodules: ## Initialize all git submodules recursively
git submodule update --init --recursive
.PHONY: init-submodules
python-deps: ## Install Python dependencies from requirements.txt into .venv
python3 -m venv $(VENV_DIR)
$(VENV_PYTHON) -m pip install --upgrade pip
$(VENV_PYTHON) -m pip install -r requirements.txt
.PHONY: python-deps
check-riscv-toolchain: ## Check the selected RISC-V GCC toolchain
bash cocotb/tools/check-riscv-toolchain.sh
.PHONY: check-riscv-toolchain
librelane: ## Run LibreLane flow (synthesis, PnR, verification)
librelane librelane/slots/slot_${SLOT}.yaml librelane/config.yaml --save-views-to $(MAKEFILE_DIR)/final --pdk ${PDK} --pdk-root ${PDK_ROOT} --manual-pdk
.PHONY: librelane
librelane-nodrc: ## Run LibreLane flow without DRC checks
librelane librelane/slots/slot_${SLOT}.yaml librelane/config.yaml --save-views-to $(MAKEFILE_DIR)/final --pdk ${PDK} --pdk-root ${PDK_ROOT} --manual-pdk --skip KLayout.Antenna --skip KLayout.DRC --skip Magic.DRC
.PHONY: librelane-nodrc
librelane-klayoutdrc: ## Run LibreLane flow without magic DRC checks
librelane librelane/slots/slot_${SLOT}.yaml librelane/config.yaml --save-views-to $(MAKEFILE_DIR)/final --pdk ${PDK} --pdk-root ${PDK_ROOT} --manual-pdk --skip Magic.DRC
.PHONY: librelane-klayoutdrc
librelane-magicdrc: ## Run LibreLane flow without KLayout DRC checks
librelane librelane/slots/slot_${SLOT}.yaml librelane/config.yaml --save-views-to $(MAKEFILE_DIR)/final --pdk ${PDK} --pdk-root ${PDK_ROOT} --manual-pdk --skip KLayout.DRC
.PHONY: librelane-magicdrc
librelane-openroad: ## Open the last run in OpenROAD
librelane librelane/slots/slot_${SLOT}.yaml librelane/config.yaml --pdk ${PDK} --pdk-root ${PDK_ROOT} --manual-pdk --last-run --flow OpenInOpenROAD
.PHONY: librelane-openroad
librelane-klayout: ## Open the last run in KLayout
librelane librelane/slots/slot_${SLOT}.yaml librelane/config.yaml --pdk ${PDK} --pdk-root ${PDK_ROOT} --manual-pdk --last-run --flow OpenInKLayout
.PHONY: librelane-klayout
librelane-padring: ## Only create the padring
PDK_ROOT=${PDK_ROOT} PDK=${PDK} python3 scripts/padring.py librelane/slots/slot_${SLOT}.yaml librelane/config.yaml
.PHONY: librelane-padring
sim: ## Run RTL simulation with cocotb
cd cocotb; PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} $(PYTHON) chip_top_tb.py
.PHONY: sim
sim-dft-smoke: ## Run chip_core DFT smoke tests for normal/force-IRQ/force-wake modes
cd cocotb; CHIP_TOPLEVEL=chip_core COCOTB_TEST_MODULE=chip_core_dft_tb PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} $(PYTHON) chip_top_tb.py
.PHONY: sim-dft-smoke
sim-gl-dft-smoke: ## Run gate-level chip_top DFT smoke tests (requires completed LibreLane run in final/)
cd cocotb; GL=1 COCOTB_TEST_MODULE=chip_top_dft_tb PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} $(PYTHON) chip_top_tb.py
.PHONY: sim-gl-dft-smoke
sim-gl-chip-top-debug-modes: ## Run gate-level chip_top debug-mode pad checks
cd cocotb; GL=1 COCOTB_TEST_MODULE=chip_top_dft_tb PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} $(PYTHON) chip_top_tb.py
.PHONY: sim-gl-chip-top-debug-modes
repro-firmware-flow: ## Build irq/prod firmware and run reproducible smoke regressions
bash cocotb/tools/repro-firmware-flow.sh
.PHONY: repro-firmware-flow
repro-firmware-build: ## Build irq/prod firmware only
bash cocotb/tools/repro-firmware-flow.sh --build-only
.PHONY: repro-firmware-build
repro-setup: init-submodules python-deps check-riscv-toolchain ## Initialize submodules, Python deps, and toolchain check
.PHONY: repro-setup
build-riscv-toolchain: ## Build bare-metal RISC-V GCC from third_party/riscv-gnu-toolchain
bash cocotb/tools/build-riscv-toolchain.sh
.PHONY: build-riscv-toolchain
sim-gl: ## Run gate-level simulation with cocotb (after copy-final)
cd cocotb; GL=1 FINAL_DIR=$(FINAL_DIR) PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} $(PYTHON) chip_top_tb.py
.PHONY: sim-gl
.PHONY: sim-gl-ml
sim-gl-ml: ## Run gate-level ML pipeline smoke test
cd cocotb; GL=1 FINAL_DIR=$(FINAL_DIR) PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} COCOTB_TEST_MODULE=chip_top_tb COCOTB_TEST_FILTER=test_chip_top_feature_inject $(PYTHON) chip_top_tb.py
.PHONY: test-ml
test-ml: ## Run gate-level ML pipeline equivalent
test-ml: sim-gl-ml
sim-gl-debug-modes: ## Run gate-level chip_top debug-mode pad smoke test
cd cocotb; PYTHONPATH=$(MAKEFILE_DIR)/cocotb/sim/tb GL=1 FINAL_DIR=$(FINAL_DIR) PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} COCOTB_TEST_MODULE=test_chip_core_debug_modes COCOTB_TEST_FILTER=test_chip_top_debug_modes_force_inputs_reach_debug_bus $(PYTHON) chip_top_tb.py
.PHONY: sim-gl-debug-modes
sim-gl-sensor-bridge: ## Run gate-level sensor I2C pad smoke test
cd cocotb; PYTHONPATH=$(MAKEFILE_DIR)/cocotb/sim/tb GL=1 CHIP_TOPLEVEL=sim_chip_top_gl_sensor_bridge_env CHIP_NETLIST_TOP=$(TOP) FINAL_DIR=$(FINAL_DIR) PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} COCOTB_TEST_MODULE=test_chip_top_gl_sensor_bridge COCOTB_TEST_FILTER=test_chip_top_gl_sensor_bridge_reaches_models $(PYTHON) chip_top_tb.py
.PHONY: sim-gl-sensor-bridge
sim-gl-sensor-bridge-smoke: ## Run gate-level sensor bridge connectivity smoke test
cd cocotb; PYTHONPATH=$(MAKEFILE_DIR)/cocotb/sim/tb GL=1 CHIP_TOPLEVEL=sim_chip_top_gl_sensor_bridge_env CHIP_NETLIST_TOP=$(TOP) FINAL_DIR=$(FINAL_DIR) PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} COCOTB_TEST_MODULE=test_chip_top_gl_sensor_bridge COCOTB_TEST_FILTER=test_chip_top_gl_sensor_bridge_reaches_models $(PYTHON) chip_top_tb.py
.PHONY: sim-gl-sensor-bridge-smoke
sim-gl-sensor-bridge-full: ## Run long gate-level sensor I2C debug-feature reference check
cd cocotb; PYTHONPATH=$(MAKEFILE_DIR)/cocotb/sim/tb GL=1 GL_SENSOR_I2C_FULL_FEATURES=1 CHIP_TOPLEVEL=sim_chip_top_gl_sensor_bridge_env CHIP_NETLIST_TOP=$(TOP) FINAL_DIR=$(FINAL_DIR) PDK_ROOT=${PDK_ROOT} PDK=${PDK} SLOT=${SLOT} COCOTB_TEST_MODULE=test_chip_top_gl_sensor_bridge COCOTB_TEST_FILTER=test_chip_top_gl_sensor_bridge_debug_features_match_python_reference $(PYTHON) chip_top_tb.py
.PHONY: sim-gl-sensor-bridge-full
sim-view: ## View simulation waveforms in GTKWave
gtkwave cocotb/sim_build/chip_top.fst
.PHONY: sim-view
render-image: ## Render an image from the final layout (after copy-final)
mkdir -p img/
PDK_ROOT=${PDK_ROOT} PDK=${PDK} python3 scripts/lay2img.py final/gds/${TOP}.gds img/${TOP}.png --width 2048 --oversampling 4
.PHONY: copy-final