blob: ac33829459d6975132eb39bedf60ed7d45a89d6e [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 Euphrosineb68622f2022-12-03 22:00:18 +090070 MPW_TAG ?= gfmpw-0d
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 Euphrosineb68622f2022-12-03 22:00:18 +090074 #OPENLANE_TAG=ddfeab57e3e8769ea3d40dda12be0460e09bb6d9
75 #export OPEN_PDKS_COMMIT?=0059588eebfc704681dc2368bd1d33d96281d10f
76 export OPEN_PDKS_COMMIT?=35c7265f51749ad8d9fdbb575af22c7c8fab974e
77 export OPENLANE_TAG?=2022.11.29
Johan Euphrosine51fc5092022-11-13 00:07:05 +090078endif
79
Johan Euphrosinede371102022-11-30 23:54:00 +090080PRECHECK_TAG ?= $(MPW_TAG)
81
Johan Euphrosine80ce8782022-09-06 10:57:14 +090082# Include Caravel Makefile Targets
83.PHONY: % : check-caravel
84%:
85 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
86
87.PHONY: install
88install:
89 if [ -d "$(CARAVEL_ROOT)" ]; then\
90 echo "Deleting exisiting $(CARAVEL_ROOT)" && \
91 rm -rf $(CARAVEL_ROOT) && sleep 2;\
92 fi
93 echo "Installing $(CARAVEL_NAME).."
94 git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT) --depth=1
95
96# Install DV setup
97.PHONY: simenv
98simenv:
99 docker pull efabless/dv:latest
100
101.PHONY: setup
Johan Euphrosine2cde6e42022-11-18 11:58:10 +0900102setup: install check-env install_mcw openlane pdk-with-volare setup-timing-scripts
Johan Euphrosine80ce8782022-09-06 10:57:14 +0900103
104# Openlane
105blocks=$(shell cd openlane && find * -maxdepth 0 -type d)
106.PHONY: $(blocks)
107$(blocks): % :
108 $(MAKE) -C openlane $*
109
110dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
111dv-targets-rtl=$(dv_patterns:%=verify-%-rtl)
112dv-targets-gl=$(dv_patterns:%=verify-%-gl)
113dv-targets-gl-sdf=$(dv_patterns:%=verify-%-gl-sdf)
114
115TARGET_PATH=$(shell pwd)
116verify_command="source ~/.bashrc && cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
117dv_base_dependencies=simenv
118docker_run_verify=\
119 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \
120 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
121 -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \
122 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
123 -e TOOLS=/foss/tools/riscv-gnu-toolchain-rv32i/217e7f3debe424d61374d31e33a091a630535937 \
124 -e DESIGNS=$(TARGET_PATH) \
Johan Euphrosine51fc5092022-11-13 00:07:05 +0900125 -e USER_PROJECT_VERILOG=$(TARGET_PATH)/verilog \
Johan Euphrosine80ce8782022-09-06 10:57:14 +0900126 -e PDK=$(PDK) \
127 -e CORE_VERILOG_PATH=$(TARGET_PATH)/mgmt_core_wrapper/verilog \
Johan Euphrosine51fc5092022-11-13 00:07:05 +0900128 -e CARAVEL_VERILOG_PATH=$(TARGET_PATH)/caravel/verilog \
Johan Euphrosine80ce8782022-09-06 10:57:14 +0900129 -e MCW_ROOT=$(MCW_ROOT) \
130 -u $$(id -u $$USER):$$(id -g $$USER) efabless/dv:latest \
131 sh -c $(verify_command)
132
133.PHONY: harden
134harden: $(blocks)
135
136.PHONY: verify
137verify: $(dv-targets-rtl)
138
139.PHONY: verify-all-rtl
140verify-all-rtl: $(dv-targets-rtl)
141
142.PHONY: verify-all-gl
143verify-all-gl: $(dv-targets-gl)
144
145.PHONY: verify-all-gl-sdf
146verify-all-gl-sdf: $(dv-targets-gl-sdf)
147
148$(dv-targets-rtl): SIM=RTL
149$(dv-targets-rtl): verify-%-rtl: $(dv_base_dependencies)
150 $(docker_run_verify)
151
152$(dv-targets-gl): SIM=GL
153$(dv-targets-gl): verify-%-gl: $(dv_base_dependencies)
154 $(docker_run_verify)
155
156$(dv-targets-gl-sdf): SIM=GL_SDF
157$(dv-targets-gl-sdf): verify-%-gl-sdf: $(dv_base_dependencies)
158 $(docker_run_verify)
159
160clean-targets=$(blocks:%=clean-%)
161.PHONY: $(clean-targets)
162$(clean-targets): clean-% :
163 rm -f ./verilog/gl/$*.v
164 rm -f ./spef/$*.spef
165 rm -f ./sdc/$*.sdc
166 rm -f ./sdf/$*.sdf
167 rm -f ./gds/$*.gds
168 rm -f ./mag/$*.mag
169 rm -f ./lef/$*.lef
170 rm -f ./maglef/*.maglef
171
172make_what=setup $(blocks) $(dv-targets-rtl) $(dv-targets-gl) $(dv-targets-gl-sdf) $(clean-targets)
173.PHONY: what
174what:
175 # $(make_what)
176
177# Install Openlane
178.PHONY: openlane
179openlane:
180 @if [ "$$(realpath $${OPENLANE_ROOT})" = "$$(realpath $$(pwd)/openlane)" ]; then\
181 echo "OPENLANE_ROOT is set to '$$(pwd)/openlane' which contains openlane config files"; \
182 echo "Please set it to a different directory"; \
183 exit 1; \
184 fi
185 cd openlane && $(MAKE) openlane
186
187#### Not sure if the targets following are of any use
188
189# Create symbolic links to caravel's main files
190.PHONY: simlink
191simlink: check-caravel
192### Symbolic links relative path to $CARAVEL_ROOT
193 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
194 $(eval PIN_CFG_PATH := $(shell realpath --relative-to=openlane/user_project_wrapper $(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg))
195 mkdir -p openlane
196 mkdir -p openlane/user_project_wrapper
197 cd openlane &&\
198 ln -sf $(MAKEFILE_PATH) Makefile
199 cd openlane/user_project_wrapper &&\
200 ln -sf $(PIN_CFG_PATH) pin_order.cfg
201
202# Update Caravel
203.PHONY: update_caravel
204update_caravel: check-caravel
205 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
206
207# Uninstall Caravel
208.PHONY: uninstall
209uninstall:
210 rm -rf $(CARAVEL_ROOT)
211
212
213# Install Pre-check
214# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
215.PHONY: precheck
216precheck:
Johan Euphrosinede371102022-11-30 23:54:00 +0900217 @git clone --depth=1 --branch $(PRECHECK_TAG) https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
Johan Euphrosine2f8419f2022-12-02 01:46:39 +0900218 curl -L -o $(PRECHECK_ROOT)/checks/tech-files/gf180mcuC_mr.drc https://github.com/efabless/globalfoundries-pdk-libs-gf180mcu_fd_pr/blob/56d5539de75a7fadf9d9d712592bb5b0d4c22b79/rules/klayout/drc/gf180mcu.drc
Johan Euphrosine80ce8782022-09-06 10:57:14 +0900219 @docker pull efabless/mpw_precheck:latest
220
221.PHONY: run-precheck
222run-precheck: check-pdk check-precheck
223 $(eval INPUT_DIRECTORY := $(shell pwd))
224 cd $(PRECHECK_ROOT) && \
225 docker run -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) \
226 -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) \
227 -v $(PDK_ROOT):$(PDK_ROOT) \
228 -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) \
229 -e PDK_PATH=$(PDK_ROOT)/$(PDK) \
230 -e PDK_ROOT=$(PDK_ROOT) \
231 -e PDKPATH=$(PDKPATH) \
232 -u $(shell id -u $(USER)):$(shell id -g $(USER)) \
233 efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --input_directory $(INPUT_DIRECTORY) --pdk_path $(PDK_ROOT)/$(PDK)"
234
235
236
237.PHONY: clean
238clean:
239 cd ./verilog/dv/ && \
240 $(MAKE) -j$(THREADS) clean
241
242check-caravel:
243 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
244 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
245 exit 1; \
246 fi
247
248check-precheck:
249 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
250 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
251 exit 1; \
252 fi
253
254check-pdk:
255 @if [ ! -d "$(PDK_ROOT)" ]; then \
256 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
257 exit 1; \
258 fi
259
260.PHONY: help
261help:
262 cd $(CARAVEL_ROOT) && $(MAKE) help
263 @$(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 '^$@$$'
264
265
Johan Euphrosine2cde6e42022-11-18 11:58:10 +0900266export CUP_ROOT=$(shell pwd)
267export TIMING_ROOT?=$(shell pwd)/deps/timing-scripts
268export PROJECT_ROOT=$(CUP_ROOT)
Johan Euphrosine5ae06b52022-11-19 03:49:46 +0900269timing-scripts-repo=https://github.com/efabless/timing-scripts.git
Johan Euphrosine2cde6e42022-11-18 11:58:10 +0900270
271$(TIMING_ROOT):
272 @mkdir -p $(CUP_ROOT)/deps
273 @git clone $(timing-scripts-repo) $(TIMING_ROOT)
274
275.PHONY: setup-timing-scripts
276setup-timing-scripts: $(TIMING_ROOT)
277 @( cd $(TIMING_ROOT) && git pull )
278 @#( cd $(TIMING_ROOT) && git fetch && git checkout $(MPW_TAG); )
279 @python3 -m venv ./venv
280 . ./venv/bin/activate && \
281 python3 -m pip install --upgrade pip && \
282 python3 -m pip install -r $(TIMING_ROOT)/requirements.txt && \
283 deactivate
284
285./verilog/gl/user_project_wrapper.v:
286 $(error you don't have $@)
287
288./env/spef-mapping.tcl:
289 @echo "run the following:"
290 @echo "make extract-parasitics"
291 @echo "make create-spef-mapping"
292 exit 1
293
294.PHONY: create-spef-mapping
295create-spef-mapping: ./verilog/gl/user_project_wrapper.v
296 @. ./venv/bin/activate && \
297 python3 $(TIMING_ROOT)/scripts/generate_spef_mapping.py \
298 -i ./verilog/gl/user_project_wrapper.v \
299 -o ./env/spef-mapping.tcl \
300 --pdk-path $(PDK_ROOT)/$(PDK) \
301 --macro-parent mprj \
302 --project-root "$(CUP_ROOT)" && \
303 deactivate
304
305.PHONY: extract-parasitics
306extract-parasitics: ./verilog/gl/user_project_wrapper.v
307 @. ./venv/bin/activate && \
308 python3 $(TIMING_ROOT)/scripts/get_macros.py \
309 -i ./verilog/gl/user_project_wrapper.v \
310 -o ./tmp-macros-list \
311 --project-root "$(CUP_ROOT)" \
312 --pdk-path $(PDK_ROOT)/$(PDK) && \
313 deactivate
314 @cat ./tmp-macros-list | cut -d " " -f2 \
315 | xargs -I % bash -c "$(MAKE) -C $(TIMING_ROOT) \
316 -f $(TIMING_ROOT)/timing.mk rcx-% || echo 'Cannot extract %. Probably no def for this macro'"
317 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk rcx-user_project_wrapper
318 @cat ./tmp-macros-list
319 @rm ./tmp-macros-list
320
321.PHONY: caravel-sta
322caravel-sta: ./env/spef-mapping.tcl
323 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-typ
324 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-fast
325 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-slow
326 @echo "You can find results for all corners in $(CUP_ROOT)/signoff/caravel/openlane-signoff/timing/"