blob: 7a99ad4864743a0d432b27077e246d87f1113431 [file] [log] [blame]
manarabdelatyb41301c2021-04-19 23:30:35 +02001# 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
kareem76e8a0f2022-02-25 10:13:53 -080016MAKEFLAGS+=--warn-undefined-variables
manarabdelatyb41301c2021-04-19 23:30:35 +020017
kareemd637b3e2022-07-06 08:19:47 -070018export CARAVEL_ROOT?=$(PWD)/caravel
manarabdelaty26323152021-09-16 23:11:34 +020019PRECHECK_ROOT?=${HOME}/mpw_precheck
jeffdi585ad262022-10-24 21:50:35 -070020export MCW_ROOT?=$(PWD)/mgmt_core_wrapper
kareem76e8a0f2022-02-25 10:13:53 -080021SIM?=RTL
22
manarabdelatyb41301c2021-04-19 23:30:35 +020023# Install lite version of caravel, (1): caravel-lite, (0): caravel
24CARAVEL_LITE?=1
25
Marwan Abbas0a55a1c2022-03-01 03:39:19 -080026# PDK switch varient
Kareem Faridfb0bab42022-11-15 17:16:42 +020027export PDK?=sky130A
Jeff DiCorpofb0bd7f2022-10-27 23:01:14 -070028#export PDK?=gf180mcuC
Marwan Abbas45f97202022-07-01 16:26:21 +020029export PDKPATH?=$(PDK_ROOT)/$(PDK)
Marwan Abbas0a55a1c2022-03-01 03:39:19 -080030
jeffdif7a3d572022-10-12 08:45:05 -070031
Jeff DiCorpo5c041f12022-02-25 17:56:06 -080032
Jeff DiCorpo04ae05f2022-10-27 22:56:37 -070033ifeq ($(PDK),sky130A)
34 SKYWATER_COMMIT=f70d8ca46961ff92719d8870a18a076370b85f6c
35 export OPEN_PDKS_COMMIT?=0059588eebfc704681dc2368bd1d33d96281d10f
Jeff DiCorpo4dd8cd42022-11-19 16:55:39 -080036 export OPENLANE_TAG?=2022.11.19
Jeff DiCorpo4a37c742022-11-19 14:50:12 -080037 MPW_TAG ?= mpw-8a
Jeff DiCorpo04ae05f2022-10-27 22:56:37 -070038
39ifeq ($(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
Jeff DiCorpofb0bd7f2022-10-27 23:01:14 -070049endif
50
jeffdif7a3d572022-10-12 08:45:05 -070051ifeq ($(PDK),sky130B)
52 SKYWATER_COMMIT=f70d8ca46961ff92719d8870a18a076370b85f6c
jeffdi2af30e62022-10-24 21:13:50 -070053 export OPEN_PDKS_COMMIT?=0059588eebfc704681dc2368bd1d33d96281d10f
Jeff DiCorpo4dd8cd42022-11-19 16:55:39 -080054 export OPENLANE_TAG?=2022.11.19
Jeff DiCorpo4a37c742022-11-19 14:50:12 -080055 MPW_TAG ?= mpw-8a
manarabdelatyb41301c2021-04-19 23:30:35 +020056
kareem76e8a0f2022-02-25 10:13:53 -080057ifeq ($(CARAVEL_LITE),1)
manarabdelatyb41301c2021-04-19 23:30:35 +020058 CARAVEL_NAME := caravel-lite
kareem76e8a0f2022-02-25 10:13:53 -080059 CARAVEL_REPO := https://github.com/efabless/caravel-lite
Jeff DiCorpo5c041f12022-02-25 17:56:06 -080060 CARAVEL_TAG := $(MPW_TAG)
manarabdelatyb41301c2021-04-19 23:30:35 +020061else
62 CARAVEL_NAME := caravel
kareem76e8a0f2022-02-25 10:13:53 -080063 CARAVEL_REPO := https://github.com/efabless/caravel
Jeff DiCorpo5c041f12022-02-25 17:56:06 -080064 CARAVEL_TAG := $(MPW_TAG)
manarabdelatyb41301c2021-04-19 23:30:35 +020065endif
66
Jeff DiCorpofb0bd7f2022-10-27 23:01:14 -070067endif
68
69ifeq ($(PDK),gf180mcuC)
jeffdi2d83d672022-10-12 13:45:59 -070070
jeffdi465b6eb2022-10-24 21:47:37 -070071 MPW_TAG ?= gfmpw-0a
jeffdie308dde2022-10-24 19:21:52 -070072 CARAVEL_NAME := caravel
73 CARAVEL_REPO := https://github.com/efabless/caravel-gf180mcu
74 CARAVEL_TAG := $(MPW_TAG)
75 #OPENLANE_TAG=ddfeab57e3e8769ea3d40dda12be0460e09bb6d9
jeffdi2af30e62022-10-24 21:13:50 -070076 export OPEN_PDKS_COMMIT?=0059588eebfc704681dc2368bd1d33d96281d10f
Jeff DiCorpo4dd8cd42022-11-19 16:55:39 -080077 export OPENLANE_TAG?=2022.11.19
jeffdi2d83d672022-10-12 13:45:59 -070078
jeffdif7a3d572022-10-12 08:45:05 -070079endif
80
manarabdelatyb41301c2021-04-19 23:30:35 +020081# Include Caravel Makefile Targets
manarabdelaty26323152021-09-16 23:11:34 +020082.PHONY: % : check-caravel
kareem76e8a0f2022-02-25 10:13:53 -080083%:
manarabdelaty26323152021-09-16 23:11:34 +020084 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
manarabdelatyb41301c2021-04-19 23:30:35 +020085
kareem76e8a0f2022-02-25 10:13:53 -080086.PHONY: install
87install:
88 if [ -d "$(CARAVEL_ROOT)" ]; then\
89 echo "Deleting exisiting $(CARAVEL_ROOT)" && \
90 rm -rf $(CARAVEL_ROOT) && sleep 2;\
91 fi
92 echo "Installing $(CARAVEL_NAME).."
93 git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT) --depth=1
manarabdelatyb41301c2021-04-19 23:30:35 +020094
manarabdelaty340cc4a2021-04-20 18:28:22 +020095# Install DV setup
96.PHONY: simenv
97simenv:
Marwan Abbasbb250682022-07-06 09:43:59 +020098 docker pull efabless/dv:latest
manarabdelaty340cc4a2021-04-20 18:28:22 +020099
kareem76e8a0f2022-02-25 10:13:53 -0800100.PHONY: setup
Kareem Faridd105f682022-11-15 18:07:26 +0200101setup: install check-env install_mcw openlane pdk-with-volare setup-timing-scripts
kareem76e8a0f2022-02-25 10:13:53 -0800102
103# Openlane
104blocks=$(shell cd openlane && find * -maxdepth 0 -type d)
105.PHONY: $(blocks)
Kareem Farid0eb93ef2022-03-02 13:25:37 +0200106$(blocks): % :
kareemd637b3e2022-07-06 08:19:47 -0700107 $(MAKE) -C openlane $*
kareem76e8a0f2022-02-25 10:13:53 -0800108
109dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
110dv-targets-rtl=$(dv_patterns:%=verify-%-rtl)
111dv-targets-gl=$(dv_patterns:%=verify-%-gl)
112dv-targets-gl-sdf=$(dv_patterns:%=verify-%-gl-sdf)
113
manarabdelaty340cc4a2021-04-20 18:28:22 +0200114TARGET_PATH=$(shell pwd)
Marwan Abbas1105cc72022-03-17 10:01:30 -0700115verify_command="source ~/.bashrc && cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
kareem76e8a0f2022-02-25 10:13:53 -0800116dv_base_dependencies=simenv
117docker_run_verify=\
manarabdelatyb6ce4422021-09-16 22:09:24 +0200118 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \
kareemab6cfe12022-02-15 05:36:48 -0800119 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
120 -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \
121 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
Marwan Abbas1105cc72022-03-17 10:01:30 -0700122 -e TOOLS=/foss/tools/riscv-gnu-toolchain-rv32i/217e7f3debe424d61374d31e33a091a630535937 \
kareemab6cfe12022-02-15 05:36:48 -0800123 -e DESIGNS=$(TARGET_PATH) \
Jeff DiCorpofec2ae62022-10-27 22:21:22 -0700124 -e USER_PROJECT_VERILOG=$(TARGET_PATH)/verilog \
Marwan Abbas1b16eff2022-03-02 09:21:34 -0800125 -e PDK=$(PDK) \
Marwan Abbas68788702022-02-15 16:49:02 +0200126 -e CORE_VERILOG_PATH=$(TARGET_PATH)/mgmt_core_wrapper/verilog \
Jeff DiCorpofec2ae62022-10-27 22:21:22 -0700127 -e CARAVEL_VERILOG_PATH=$(TARGET_PATH)/caravel/verilog \
kareemab6cfe12022-02-15 05:36:48 -0800128 -e MCW_ROOT=$(MCW_ROOT) \
Marwan Abbas1105cc72022-03-17 10:01:30 -0700129 -u $$(id -u $$USER):$$(id -g $$USER) efabless/dv:latest \
kareem76e8a0f2022-02-25 10:13:53 -0800130 sh -c $(verify_command)
manarabdelatyb41301c2021-04-19 23:30:35 +0200131
kareem76e8a0f2022-02-25 10:13:53 -0800132.PHONY: harden
133harden: $(blocks)
134
135.PHONY: verify
Jeff DiCorpo76e88e12022-03-19 14:12:29 -0700136verify: $(dv-targets-rtl)
137
Marwan Abbaseda60992022-03-03 19:53:27 +0200138.PHONY: verify-all-rtl
139verify-all-rtl: $(dv-targets-rtl)
140
141.PHONY: verify-all-gl
142verify-all-gl: $(dv-targets-gl)
143
144.PHONY: verify-all-gl-sdf
Marwan Abbas17c43a62022-03-03 21:11:51 +0200145verify-all-gl-sdf: $(dv-targets-gl-sdf)
kareem76e8a0f2022-02-25 10:13:53 -0800146
147$(dv-targets-rtl): SIM=RTL
148$(dv-targets-rtl): verify-%-rtl: $(dv_base_dependencies)
149 $(docker_run_verify)
150
151$(dv-targets-gl): SIM=GL
152$(dv-targets-gl): verify-%-gl: $(dv_base_dependencies)
153 $(docker_run_verify)
154
155$(dv-targets-gl-sdf): SIM=GL_SDF
156$(dv-targets-gl-sdf): verify-%-gl-sdf: $(dv_base_dependencies)
157 $(docker_run_verify)
158
159clean-targets=$(blocks:%=clean-%)
160.PHONY: $(clean-targets)
161$(clean-targets): clean-% :
162 rm -f ./verilog/gl/$*.v
163 rm -f ./spef/$*.spef
164 rm -f ./sdc/$*.sdc
165 rm -f ./sdf/$*.sdf
166 rm -f ./gds/$*.gds
167 rm -f ./mag/$*.mag
168 rm -f ./lef/$*.lef
169 rm -f ./maglef/*.maglef
170
171make_what=setup $(blocks) $(dv-targets-rtl) $(dv-targets-gl) $(dv-targets-gl-sdf) $(clean-targets)
172.PHONY: what
173what:
174 # $(make_what)
175
176# Install Openlane
177.PHONY: openlane
178openlane:
Kareem Farid13edb812022-06-08 13:03:08 +0200179 @if [ "$$(realpath $${OPENLANE_ROOT})" = "$$(realpath $$(pwd)/openlane)" ]; then\
180 echo "OPENLANE_ROOT is set to '$$(pwd)/openlane' which contains openlane config files"; \
181 echo "Please set it to a different directory"; \
182 exit 1; \
183 fi
kareem76e8a0f2022-02-25 10:13:53 -0800184 cd openlane && $(MAKE) openlane
185
186#### Not sure if the targets following are of any use
manarabdelatyb41301c2021-04-19 23:30:35 +0200187
188# Create symbolic links to caravel's main files
189.PHONY: simlink
190simlink: check-caravel
kareem76e8a0f2022-02-25 10:13:53 -0800191### Symbolic links relative path to $CARAVEL_ROOT
manarabdelaty78c1b012021-04-23 17:12:54 +0200192 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
193 $(eval PIN_CFG_PATH := $(shell realpath --relative-to=openlane/user_project_wrapper $(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg))
manarabdelatye542bdf2021-04-20 11:15:40 +0200194 mkdir -p openlane
195 mkdir -p openlane/user_project_wrapper
196 cd openlane &&\
manarabdelaty78c1b012021-04-23 17:12:54 +0200197 ln -sf $(MAKEFILE_PATH) Makefile
manarabdelatye542bdf2021-04-20 11:15:40 +0200198 cd openlane/user_project_wrapper &&\
manarabdelaty78c1b012021-04-23 17:12:54 +0200199 ln -sf $(PIN_CFG_PATH) pin_order.cfg
manarabdelatyb41301c2021-04-19 23:30:35 +0200200
201# Update Caravel
202.PHONY: update_caravel
203update_caravel: check-caravel
jeffdi298918f2021-12-16 11:15:44 -0800204 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
manarabdelatyb41301c2021-04-19 23:30:35 +0200205
206# Uninstall Caravel
207.PHONY: uninstall
kareem76e8a0f2022-02-25 10:13:53 -0800208uninstall:
manarabdelaty78c1b012021-04-23 17:12:54 +0200209 rm -rf $(CARAVEL_ROOT)
manarabdelatyb41301c2021-04-19 23:30:35 +0200210
manarabdelaty340cc4a2021-04-20 18:28:22 +0200211
manarabdelaty78c1b012021-04-23 17:12:54 +0200212# Install Pre-check
213# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
214.PHONY: precheck
215precheck:
Jeff DiCorpo9d5fd022022-03-19 11:01:27 -0700216 @git clone --depth=1 --branch $(MPW_TAG) https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
manarabdelatyb6ce4422021-09-16 22:09:24 +0200217 @docker pull efabless/mpw_precheck:latest
manarabdelaty78c1b012021-04-23 17:12:54 +0200218
219.PHONY: run-precheck
Ahmed El Omla0abd1612022-02-08 19:12:27 +0200220run-precheck: check-pdk check-precheck
manarabdelatyb6ce4422021-09-16 22:09:24 +0200221 $(eval INPUT_DIRECTORY := $(shell pwd))
manarabdelaty78c1b012021-04-23 17:12:54 +0200222 cd $(PRECHECK_ROOT) && \
Marwan Abbasd9bdb822022-04-16 10:34:40 -0700223 docker run -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) \
224 -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) \
225 -v $(PDK_ROOT):$(PDK_ROOT) \
226 -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) \
Ahmed El Omla31cccd52022-07-01 12:35:45 +0200227 -e PDK_PATH=$(PDK_ROOT)/$(PDK) \
Jeff DiCorpoc0695642022-07-08 06:41:16 -0700228 -e PDK_ROOT=$(PDK_ROOT) \
Marwan Abbasd9bdb822022-04-16 10:34:40 -0700229 -e PDKPATH=$(PDKPATH) \
230 -u $(shell id -u $(USER)):$(shell id -g $(USER)) \
Ahmed El Omla42a15462022-07-07 17:01:55 +0200231 efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --input_directory $(INPUT_DIRECTORY) --pdk_path $(PDK_ROOT)/$(PDK)"
manarabdelatyd8dd0102021-04-30 08:40:52 +0200232
manarabdelatyb41301c2021-04-19 23:30:35 +0200233
kareem76e8a0f2022-02-25 10:13:53 -0800234
kareem035ac3d2022-02-25 10:34:26 -0800235.PHONY: clean
236clean:
237 cd ./verilog/dv/ && \
238 $(MAKE) -j$(THREADS) clean
239
manarabdelatyb41301c2021-04-19 23:30:35 +0200240check-caravel:
241 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
242 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
243 exit 1; \
Jeff DiCorpofb944f92021-04-20 00:40:50 +0000244 fi
manarabdelaty78c1b012021-04-23 17:12:54 +0200245
246check-precheck:
247 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
248 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
249 exit 1; \
250 fi
251
252check-pdk:
253 @if [ ! -d "$(PDK_ROOT)" ]; then \
254 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
255 exit 1; \
manarabdelatyd8dd0102021-04-30 08:40:52 +0200256 fi
257
258.PHONY: help
259help:
kareem76e8a0f2022-02-25 10:13:53 -0800260 cd $(CARAVEL_ROOT) && $(MAKE) help
manarabdelatyd8dd0102021-04-30 08:40:52 +0200261 @$(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 '^$@$$'
kareem76e8a0f2022-02-25 10:13:53 -0800262
263
Kareem Farid7fecf2d2022-11-13 18:19:43 +0200264export CUP_ROOT=$(shell pwd)
Kareem Farida1996972022-11-14 20:19:36 +0200265export TIMING_ROOT?=$(shell pwd)/deps/timing-scripts
266export PROJECT_ROOT=$(CUP_ROOT)
Jeff DiCorpo5c41f082022-11-18 19:29:44 -0800267timing-scripts-repo=https://github.com/efabless/timing-scripts.git
Kareem Farid7fecf2d2022-11-13 18:19:43 +0200268
269$(TIMING_ROOT):
Kareem Faridd105f682022-11-15 18:07:26 +0200270 @mkdir -p $(CUP_ROOT)/deps
Kareem Farida1996972022-11-14 20:19:36 +0200271 @git clone $(timing-scripts-repo) $(TIMING_ROOT)
Kareem Farid7fecf2d2022-11-13 18:19:43 +0200272
273.PHONY: setup-timing-scripts
274setup-timing-scripts: $(TIMING_ROOT)
Kareem Farida1996972022-11-14 20:19:36 +0200275 @( cd $(TIMING_ROOT) && git pull )
Kareem Faridd105f682022-11-15 18:07:26 +0200276 @#( cd $(TIMING_ROOT) && git fetch && git checkout $(MPW_TAG); )
Kareem Farida1996972022-11-14 20:19:36 +0200277 @python3 -m venv ./venv
278 . ./venv/bin/activate && \
279 python3 -m pip install --upgrade pip && \
280 python3 -m pip install -r $(TIMING_ROOT)/requirements.txt && \
281 deactivate
Kareem Farid7fecf2d2022-11-13 18:19:43 +0200282
283./verilog/gl/user_project_wrapper.v:
284 $(error you don't have $@)
285
Kareem Faridd105f682022-11-15 18:07:26 +0200286./env/spef-mapping.tcl:
287 @echo "run the following:"
288 @echo "make extract-parasitics"
289 @echo "make create-spef-mapping"
290 exit 1
291
292.PHONY: create-spef-mapping
293create-spef-mapping: ./verilog/gl/user_project_wrapper.v
Kareem Farida1996972022-11-14 20:19:36 +0200294 @. ./venv/bin/activate && \
295 python3 $(TIMING_ROOT)/scripts/generate_spef_mapping.py \
296 -i ./verilog/gl/user_project_wrapper.v \
297 -o ./env/spef-mapping.tcl \
298 --pdk-path $(PDK_ROOT)/$(PDK) \
Kareem Faridd105f682022-11-15 18:07:26 +0200299 --macro-parent mprj \
Kareem Farida1996972022-11-14 20:19:36 +0200300 --project-root "$(CUP_ROOT)" && \
301 deactivate
302
303.PHONY: extract-parasitics
Kareem Faridd105f682022-11-15 18:07:26 +0200304extract-parasitics: ./verilog/gl/user_project_wrapper.v
Kareem Farida1996972022-11-14 20:19:36 +0200305 @. ./venv/bin/activate && \
Kareem Farid12e5b392022-11-15 14:04:25 +0200306 python3 $(TIMING_ROOT)/scripts/get_macros.py \
307 -i ./verilog/gl/user_project_wrapper.v \
308 -o ./tmp-macros-list \
Kareem Faridd105f682022-11-15 18:07:26 +0200309 --project-root "$(CUP_ROOT)" \
Kareem Farid12e5b392022-11-15 14:04:25 +0200310 --pdk-path $(PDK_ROOT)/$(PDK) && \
311 deactivate
312 @cat ./tmp-macros-list | cut -d " " -f2 \
313 | xargs -I % bash -c "$(MAKE) -C $(TIMING_ROOT) \
314 -f $(TIMING_ROOT)/timing.mk rcx-% || echo 'Cannot extract %. Probably no def for this macro'"
Kareem Faridd105f682022-11-15 18:07:26 +0200315 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk rcx-user_project_wrapper
316 @cat ./tmp-macros-list
317 @rm ./tmp-macros-list
Kareem Farida1996972022-11-14 20:19:36 +0200318
Kareem Farid7fecf2d2022-11-13 18:19:43 +0200319.PHONY: caravel-sta
320caravel-sta: ./env/spef-mapping.tcl
Kareem Faridd105f682022-11-15 18:07:26 +0200321 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-typ
Kareem Farida1996972022-11-14 20:19:36 +0200322 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-fast
323 @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-slow
Kareem Faridd105f682022-11-15 18:07:26 +0200324 @echo "You can find results for all corners in $(CUP_ROOT)/signoff/caravel/openlane-signoff/timing/"