blob: baaf69656f6166a9e188818b6ed07e56ca667108 [file] [log] [blame]
Johan Euphrosine80ce8782022-09-06 10:57:14 +09001# SPDX-FileCopyrightText: 2020 Efabless Corporation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15# SPDX-License-Identifier: Apache-2.0
16MAKEFLAGS+=--warn-undefined-variables
17
18export CARAVEL_ROOT?=$(PWD)/caravel
19PRECHECK_ROOT?=${HOME}/mpw_precheck
Johan Euphrosine51fc5092022-11-13 00:07:05 +090020export MCW_ROOT?=$(PWD)/mgmt_core_wrapper
Johan Euphrosine80ce8782022-09-06 10:57:14 +090021SIM?=RTL
22
Johan Euphrosine80ce8782022-09-06 10:57:14 +090023# Install lite version of caravel, (1): caravel-lite, (0): caravel
24CARAVEL_LITE?=1
25
26# PDK switch varient
Marwan Abbas0d39d4a2022-11-21 08:26:21 -080027export PDK?=gf180mcuC
Johan Euphrosineb9403c62022-11-13 01:37:08 +090028#export PDK?=gf180mcuC
Johan Euphrosine80ce8782022-09-06 10:57:14 +090029export PDKPATH?=$(PDK_ROOT)/$(PDK)
30
Johan Euphrosine80ce8782022-09-06 10:57:14 +090031
32
Johan Euphrosine51fc5092022-11-13 00:07:05 +090033ifeq ($(PDK),sky130A)
34 SKYWATER_COMMIT=f70d8ca46961ff92719d8870a18a076370b85f6c
35 export OPEN_PDKS_COMMIT?=0059588eebfc704681dc2368bd1d33d96281d10f
36 export OPENLANE_TAG?=2022.10.20
37 MPW_TAG ?= mpw-7d
38
Johan Euphrosine80ce8782022-09-06 10:57:14 +090039ifeq ($(CARAVEL_LITE),1)
40 CARAVEL_NAME := caravel-lite
41 CARAVEL_REPO := https://github.com/efabless/caravel-lite
42 CARAVEL_TAG := $(MPW_TAG)
43else
44 CARAVEL_NAME := caravel
45 CARAVEL_REPO := https://github.com/efabless/caravel
46 CARAVEL_TAG := $(MPW_TAG)
47endif
48
Johan Euphrosine51fc5092022-11-13 00:07:05 +090049endif
50
51ifeq ($(PDK),sky130B)
52 SKYWATER_COMMIT=f70d8ca46961ff92719d8870a18a076370b85f6c
53 export OPEN_PDKS_COMMIT?=0059588eebfc704681dc2368bd1d33d96281d10f
54 export OPENLANE_TAG?=2022.10.20
55 MPW_TAG ?= mpw-7d
56
57ifeq ($(CARAVEL_LITE),1)
58 CARAVEL_NAME := caravel-lite
59 CARAVEL_REPO := https://github.com/efabless/caravel-lite
60 CARAVEL_TAG := $(MPW_TAG)
61else
62 CARAVEL_NAME := caravel
63 CARAVEL_REPO := https://github.com/efabless/caravel
64 CARAVEL_TAG := $(MPW_TAG)
65endif
66
67endif
68
69ifeq ($(PDK),gf180mcuC)
Johan Euphrosinefefe62c2022-11-25 02:12:59 +090070 MPW_TAG ?= gfmpw-0b
Johan Euphrosine51fc5092022-11-13 00:07:05 +090071 CARAVEL_NAME := caravel
72 CARAVEL_REPO := https://github.com/efabless/caravel-gf180mcu
73 CARAVEL_TAG := $(MPW_TAG)
Johan Euphrosine2cde6e42022-11-18 11:58:10 +090074 export OPENLANE_TAG?=2022.11.17
Johan Euphrosine51fc5092022-11-13 00:07:05 +090075endif
76
Johan Euphrosinede371102022-11-30 23:54:00 +090077PRECHECK_TAG ?= $(MPW_TAG)
78
Johan Euphrosine80ce8782022-09-06 10:57:14 +090079# Include Caravel Makefile Targets
80.PHONY: % : check-caravel
81%:
82 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
83
84.PHONY: install
85install:
86 if [ -d "$(CARAVEL_ROOT)" ]; then\
87 echo "Deleting exisiting $(CARAVEL_ROOT)" && \
88 rm -rf $(CARAVEL_ROOT) && sleep 2;\
89 fi
90 echo "Installing $(CARAVEL_NAME).."
91 git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT) --depth=1
92
93# Install DV setup
94.PHONY: simenv
95simenv:
96 docker pull efabless/dv:latest
97
98.PHONY: setup
Johan Euphrosine2cde6e42022-11-18 11:58:10 +090099setup: install check-env install_mcw openlane pdk-with-volare setup-timing-scripts
Johan Euphrosine80ce8782022-09-06 10:57:14 +0900100
101# Openlane
102blocks=$(shell cd openlane && find * -maxdepth 0 -type d)
103.PHONY: $(blocks)
104$(blocks): % :
105 $(MAKE) -C openlane $*
106
107dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
108dv-targets-rtl=$(dv_patterns:%=verify-%-rtl)
109dv-targets-gl=$(dv_patterns:%=verify-%-gl)
110dv-targets-gl-sdf=$(dv_patterns:%=verify-%-gl-sdf)
111
112TARGET_PATH=$(shell pwd)
113verify_command="source ~/.bashrc && cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
114dv_base_dependencies=simenv
115docker_run_verify=\
116 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \
117 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
118 -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \
119 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
120 -e TOOLS=/foss/tools/riscv-gnu-toolchain-rv32i/217e7f3debe424d61374d31e33a091a630535937 \
121 -e DESIGNS=$(TARGET_PATH) \
Johan Euphrosine51fc5092022-11-13 00:07:05 +0900122 -e USER_PROJECT_VERILOG=$(TARGET_PATH)/verilog \
Johan Euphrosine80ce8782022-09-06 10:57:14 +0900123 -e PDK=$(PDK) \
124 -e CORE_VERILOG_PATH=$(TARGET_PATH)/mgmt_core_wrapper/verilog \
Johan Euphrosine51fc5092022-11-13 00:07:05 +0900125 -e CARAVEL_VERILOG_PATH=$(TARGET_PATH)/caravel/verilog \
Johan Euphrosine80ce8782022-09-06 10:57:14 +0900126 -e MCW_ROOT=$(MCW_ROOT) \
127 -u $$(id -u $$USER):$$(id -g $$USER) efabless/dv:latest \
128 sh -c $(verify_command)
129
130.PHONY: harden
131harden: $(blocks)
132
133.PHONY: verify
134verify: $(dv-targets-rtl)
135
136.PHONY: verify-all-rtl
137verify-all-rtl: $(dv-targets-rtl)
138
139.PHONY: verify-all-gl
140verify-all-gl: $(dv-targets-gl)
141
142.PHONY: verify-all-gl-sdf
143verify-all-gl-sdf: $(dv-targets-gl-sdf)
144
145$(dv-targets-rtl): SIM=RTL
146$(dv-targets-rtl): verify-%-rtl: $(dv_base_dependencies)
147 $(docker_run_verify)
148
149$(dv-targets-gl): SIM=GL
150$(dv-targets-gl): verify-%-gl: $(dv_base_dependencies)
151 $(docker_run_verify)
152
153$(dv-targets-gl-sdf): SIM=GL_SDF
154$(dv-targets-gl-sdf): verify-%-gl-sdf: $(dv_base_dependencies)
155 $(docker_run_verify)
156
157clean-targets=$(blocks:%=clean-%)
158.PHONY: $(clean-targets)
159$(clean-targets): clean-% :
160 rm -f ./verilog/gl/$*.v
161 rm -f ./spef/$*.spef
162 rm -f ./sdc/$*.sdc
163 rm -f ./sdf/$*.sdf
164 rm -f ./gds/$*.gds
165 rm -f ./mag/$*.mag
166 rm -f ./lef/$*.lef
167 rm -f ./maglef/*.maglef
168
169make_what=setup $(blocks) $(dv-targets-rtl) $(dv-targets-gl) $(dv-targets-gl-sdf) $(clean-targets)
170.PHONY: what
171what:
172 # $(make_what)
173
174# Install Openlane
175.PHONY: openlane
176openlane:
177 @if [ "$$(realpath $${OPENLANE_ROOT})" = "$$(realpath $$(pwd)/openlane)" ]; then\
178 echo "OPENLANE_ROOT is set to '$$(pwd)/openlane' which contains openlane config files"; \
179 echo "Please set it to a different directory"; \
180 exit 1; \
181 fi
182 cd openlane && $(MAKE) openlane
183
184#### Not sure if the targets following are of any use
185
186# Create symbolic links to caravel's main files
187.PHONY: simlink
188simlink: check-caravel
189### Symbolic links relative path to $CARAVEL_ROOT
190 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
191 $(eval PIN_CFG_PATH := $(shell realpath --relative-to=openlane/user_project_wrapper $(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg))
192 mkdir -p openlane
193 mkdir -p openlane/user_project_wrapper
194 cd openlane &&\
195 ln -sf $(MAKEFILE_PATH) Makefile
196 cd openlane/user_project_wrapper &&\
197 ln -sf $(PIN_CFG_PATH) pin_order.cfg
198
199# Update Caravel
200.PHONY: update_caravel
201update_caravel: check-caravel
202 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
203
204# Uninstall Caravel
205.PHONY: uninstall
206uninstall:
207 rm -rf $(CARAVEL_ROOT)
208
209
210# Install Pre-check
211# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
212.PHONY: precheck
213precheck:
Johan Euphrosinede371102022-11-30 23:54:00 +0900214 @git clone --depth=1 --branch $(PRECHECK_TAG) https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
Johan Euphrosine80ce8782022-09-06 10:57:14 +0900215 @docker pull efabless/mpw_precheck:latest
216
217.PHONY: run-precheck
218run-precheck: check-pdk check-precheck
219 $(eval INPUT_DIRECTORY := $(shell pwd))
220 cd $(PRECHECK_ROOT) && \
221 docker run -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) \
222 -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) \
223 -v $(PDK_ROOT):$(PDK_ROOT) \
224 -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) \
225 -e PDK_PATH=$(PDK_ROOT)/$(PDK) \
226 -e PDK_ROOT=$(PDK_ROOT) \
227 -e PDKPATH=$(PDKPATH) \
228 -u $(shell id -u $(USER)):$(shell id -g $(USER)) \
229 efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --input_directory $(INPUT_DIRECTORY) --pdk_path $(PDK_ROOT)/$(PDK)"
230
231
232
233.PHONY: clean
234clean:
235 cd ./verilog/dv/ && \
236 $(MAKE) -j$(THREADS) clean
237
238check-caravel:
239 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
240 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
241 exit 1; \
242 fi
243
244check-precheck:
245 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
246 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
247 exit 1; \
248 fi
249
250check-pdk:
251 @if [ ! -d "$(PDK_ROOT)" ]; then \
252 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
253 exit 1; \
254 fi
255
256.PHONY: help
257help:
258 cd $(CARAVEL_ROOT) && $(MAKE) help
259 @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
260
261
Johan Euphrosine2cde6e42022-11-18 11:58:10 +0900262export CUP_ROOT=$(shell pwd)
263export TIMING_ROOT?=$(shell pwd)/deps/timing-scripts
264export PROJECT_ROOT=$(CUP_ROOT)
Johan Euphrosine5ae06b52022-11-19 03:49:46 +0900265timing-scripts-repo=https://github.com/efabless/timing-scripts.git
Johan Euphrosine2cde6e42022-11-18 11:58:10 +0900266
267$(TIMING_ROOT):
268 @mkdir -p $(CUP_ROOT)/deps
269 @git clone $(timing-scripts-repo) $(TIMING_ROOT)
270
271.PHONY: setup-timing-scripts
272setup-timing-scripts: $(TIMING_ROOT)
273 @( cd $(TIMING_ROOT) && git pull )
274 @#( cd $(TIMING_ROOT) && git fetch && git checkout $(MPW_TAG); )
275 @python3 -m venv ./venv
276 . ./venv/bin/activate && \
277 python3 -m pip install --upgrade pip && \
278 python3 -m pip install -r $(TIMING_ROOT)/requirements.txt && \
279 deactivate
280
281./verilog/gl/user_project_wrapper.v:
282 $(error you don't have $@)
283
284./env/spef-mapping.tcl:
285 @echo "run the following:"
286 @echo "make extract-parasitics"
287 @echo "make create-spef-mapping"
288 exit 1
289
290.PHONY: create-spef-mapping
291create-spef-mapping: ./verilog/gl/user_project_wrapper.v
292 @. ./venv/bin/activate && \
293 python3 $(TIMING_ROOT)/scripts/generate_spef_mapping.py \
294 -i ./verilog/gl/user_project_wrapper.v \
295 -o ./env/spef-mapping.tcl \
296 --pdk-path $(PDK_ROOT)/$(PDK) \
297 --macro-parent mprj \
298 --project-root "$(CUP_ROOT)" && \
299 deactivate
300
301.PHONY: extract-parasitics
302extract-parasitics: ./verilog/gl/user_project_wrapper.v
303 @. ./venv/bin/activate && \
304 python3 $(TIMING_ROOT)/scripts/get_macros.py \
305 -i ./verilog/gl/user_project_wrapper.v \
306 -o ./tmp-macros-list \
307 --project-root "$(CUP_ROOT)" \
308 --pdk-path $(PDK_ROOT)/$(PDK) && \
309 deactivate
310 @cat ./tmp-macros-list | cut -d " " -f2 \
311 | xargs -I % bash -c "$(MAKE) -C $(TIMING_ROOT) \
312 -f $(TIMING_ROOT)/timing.mk rcx-% || echo 'Cannot extract %. Probably no def for this macro'"
313 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk rcx-user_project_wrapper
314 @cat ./tmp-macros-list
315 @rm ./tmp-macros-list
316
317.PHONY: caravel-sta
318caravel-sta: ./env/spef-mapping.tcl
319 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-typ
320 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-fast
321 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-slow
322 @echo "You can find results for all corners in $(CUP_ROOT)/signoff/caravel/openlane-signoff/timing/"