blob: ba36e31a0251a0292d280e4bfe30ec9772431526 [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
manarabdelaty78c1b012021-04-23 17:12:54 +020018CARAVEL_ROOT?=$(PWD)/caravel
manarabdelaty26323152021-09-16 23:11:34 +020019PRECHECK_ROOT?=${HOME}/mpw_precheck
Marwan Abbas51a10962022-02-11 16:35:19 +020020MCW_ROOT?=$(PWD)/mgmt_core_wrapper
kareem76e8a0f2022-02-25 10:13:53 -080021SIM?=RTL
22
23export SKYWATER_COMMIT=c094b6e83a4f9298e47f696ec5a7fd53535ec5eb
Marwan Abbasf1d98ff2022-04-07 17:19:31 +020024export OPEN_PDKS_COMMIT?=7519dfb04400f224f140749cda44ee7de6f5e095
kareem76e8a0f2022-02-25 10:13:53 -080025export PDK_MAGIC_COMMIT=7d601628e4e05fd17fcb80c3552dacb64e9f6e7b
Jeff DiCorpo52a23962022-04-13 18:15:36 -070026export OPENLANE_TAG=2022.02.23_02.50.41
Jeff DiCorpoa0edf642022-04-13 12:25:28 -070027export MISMATCHES_OK=1
Marwan Abbasd9bdb822022-04-16 10:34:40 -070028export PDKPATH?=$(PDK_ROOT)/sky130A
Jeff DiCorpoa11292b2022-05-03 11:47:55 -070029export PDK?=sky130A
manarabdelatyb41301c2021-04-19 23:30:35 +020030
31# Install lite version of caravel, (1): caravel-lite, (0): caravel
32CARAVEL_LITE?=1
33
Jeff DiCorpo83395c02022-04-29 10:17:40 -070034MPW_TAG ?= mpw-6c
Jeff DiCorpo5c041f12022-02-25 17:56:06 -080035
kareem76e8a0f2022-02-25 10:13:53 -080036ifeq ($(CARAVEL_LITE),1)
manarabdelatyb41301c2021-04-19 23:30:35 +020037 CARAVEL_NAME := caravel-lite
kareem76e8a0f2022-02-25 10:13:53 -080038 CARAVEL_REPO := https://github.com/efabless/caravel-lite
Jeff DiCorpo5c041f12022-02-25 17:56:06 -080039 CARAVEL_TAG := $(MPW_TAG)
manarabdelatyb41301c2021-04-19 23:30:35 +020040else
41 CARAVEL_NAME := caravel
kareem76e8a0f2022-02-25 10:13:53 -080042 CARAVEL_REPO := https://github.com/efabless/caravel
Jeff DiCorpo5c041f12022-02-25 17:56:06 -080043 CARAVEL_TAG := $(MPW_TAG)
manarabdelatyb41301c2021-04-19 23:30:35 +020044endif
45
manarabdelatyb41301c2021-04-19 23:30:35 +020046# Include Caravel Makefile Targets
manarabdelaty26323152021-09-16 23:11:34 +020047.PHONY: % : check-caravel
kareem76e8a0f2022-02-25 10:13:53 -080048%:
manarabdelaty26323152021-09-16 23:11:34 +020049 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
manarabdelatyb41301c2021-04-19 23:30:35 +020050
kareem76e8a0f2022-02-25 10:13:53 -080051.PHONY: install
52install:
53 if [ -d "$(CARAVEL_ROOT)" ]; then\
54 echo "Deleting exisiting $(CARAVEL_ROOT)" && \
55 rm -rf $(CARAVEL_ROOT) && sleep 2;\
56 fi
57 echo "Installing $(CARAVEL_NAME).."
58 git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT) --depth=1
manarabdelatyb41301c2021-04-19 23:30:35 +020059
manarabdelaty340cc4a2021-04-20 18:28:22 +020060# Install DV setup
61.PHONY: simenv
62simenv:
63 docker pull efabless/dv_setup:latest
64
kareem76e8a0f2022-02-25 10:13:53 -080065.PHONY: setup
Marwan Abbas073ecab2022-04-03 14:52:46 +020066setup: install check-env install_mcw openlane pdk-with-volare
kareem76e8a0f2022-02-25 10:13:53 -080067
68# Openlane
69blocks=$(shell cd openlane && find * -maxdepth 0 -type d)
70.PHONY: $(blocks)
Kareem Farid0eb93ef2022-03-02 13:25:37 +020071$(blocks): % :
kareem76e8a0f2022-02-25 10:13:53 -080072 export CARAVEL_ROOT=$(CARAVEL_ROOT) && cd openlane && $(MAKE) $*
73
74dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
75dv-targets-rtl=$(dv_patterns:%=verify-%-rtl)
76dv-targets-gl=$(dv_patterns:%=verify-%-gl)
77dv-targets-gl-sdf=$(dv_patterns:%=verify-%-gl-sdf)
78
manarabdelaty340cc4a2021-04-20 18:28:22 +020079TARGET_PATH=$(shell pwd)
kareem76e8a0f2022-02-25 10:13:53 -080080verify_command="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
81dv_base_dependencies=simenv
82docker_run_verify=\
manarabdelatyb6ce4422021-09-16 22:09:24 +020083 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \
kareemab6cfe12022-02-15 05:36:48 -080084 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
85 -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \
86 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
87 -e TOOLS=/opt/riscv32i \
88 -e DESIGNS=$(TARGET_PATH) \
Jeff DiCorpoa11292b2022-05-03 11:47:55 -070089 -e PDK=$(PDK) \
Marwan Abbas68788702022-02-15 16:49:02 +020090 -e CORE_VERILOG_PATH=$(TARGET_PATH)/mgmt_core_wrapper/verilog \
91 -e GCC_PREFIX=riscv32-unknown-elf \
kareemab6cfe12022-02-15 05:36:48 -080092 -e MCW_ROOT=$(MCW_ROOT) \
93 -u $$(id -u $$USER):$$(id -g $$USER) efabless/dv_setup:latest \
kareem76e8a0f2022-02-25 10:13:53 -080094 sh -c $(verify_command)
manarabdelatyb41301c2021-04-19 23:30:35 +020095
kareem76e8a0f2022-02-25 10:13:53 -080096.PHONY: harden
97harden: $(blocks)
98
Jeff DiCorpo76e88e12022-03-19 14:12:29 -070099.PHONY: verify
100verify: $(dv-targets-rtl)
101
Marwan Abbaseda60992022-03-03 19:53:27 +0200102.PHONY: verify-all-rtl
103verify-all-rtl: $(dv-targets-rtl)
104
105.PHONY: verify-all-gl
106verify-all-gl: $(dv-targets-gl)
107
108.PHONY: verify-all-gl-sdf
Marwan Abbas17c43a62022-03-03 21:11:51 +0200109verify-all-gl-sdf: $(dv-targets-gl-sdf)
kareem76e8a0f2022-02-25 10:13:53 -0800110
111$(dv-targets-rtl): SIM=RTL
112$(dv-targets-rtl): verify-%-rtl: $(dv_base_dependencies)
113 $(docker_run_verify)
114
115$(dv-targets-gl): SIM=GL
116$(dv-targets-gl): verify-%-gl: $(dv_base_dependencies)
117 $(docker_run_verify)
118
119$(dv-targets-gl-sdf): SIM=GL_SDF
120$(dv-targets-gl-sdf): verify-%-gl-sdf: $(dv_base_dependencies)
121 $(docker_run_verify)
122
123clean-targets=$(blocks:%=clean-%)
124.PHONY: $(clean-targets)
125$(clean-targets): clean-% :
126 rm -f ./verilog/gl/$*.v
127 rm -f ./spef/$*.spef
128 rm -f ./sdc/$*.sdc
129 rm -f ./sdf/$*.sdf
130 rm -f ./gds/$*.gds
131 rm -f ./mag/$*.mag
132 rm -f ./lef/$*.lef
133 rm -f ./maglef/*.maglef
134
135make_what=setup $(blocks) $(dv-targets-rtl) $(dv-targets-gl) $(dv-targets-gl-sdf) $(clean-targets)
136.PHONY: what
137what:
138 # $(make_what)
139
140# Install Openlane
141.PHONY: openlane
142openlane:
Kareem Farid13edb812022-06-08 13:03:08 +0200143 @if [ "$$(realpath $${OPENLANE_ROOT})" = "$$(realpath $$(pwd)/openlane)" ]; then\
144 echo "OPENLANE_ROOT is set to '$$(pwd)/openlane' which contains openlane config files"; \
145 echo "Please set it to a different directory"; \
146 exit 1; \
147 fi
kareem76e8a0f2022-02-25 10:13:53 -0800148 cd openlane && $(MAKE) openlane
149
150#### Not sure if the targets following are of any use
manarabdelatyb41301c2021-04-19 23:30:35 +0200151
152# Create symbolic links to caravel's main files
153.PHONY: simlink
154simlink: check-caravel
kareem76e8a0f2022-02-25 10:13:53 -0800155### Symbolic links relative path to $CARAVEL_ROOT
manarabdelaty78c1b012021-04-23 17:12:54 +0200156 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
157 $(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 +0200158 mkdir -p openlane
159 mkdir -p openlane/user_project_wrapper
160 cd openlane &&\
manarabdelaty78c1b012021-04-23 17:12:54 +0200161 ln -sf $(MAKEFILE_PATH) Makefile
manarabdelatye542bdf2021-04-20 11:15:40 +0200162 cd openlane/user_project_wrapper &&\
manarabdelaty78c1b012021-04-23 17:12:54 +0200163 ln -sf $(PIN_CFG_PATH) pin_order.cfg
manarabdelatyb41301c2021-04-19 23:30:35 +0200164
165# Update Caravel
166.PHONY: update_caravel
167update_caravel: check-caravel
jeffdi298918f2021-12-16 11:15:44 -0800168 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
manarabdelatyb41301c2021-04-19 23:30:35 +0200169
170# Uninstall Caravel
171.PHONY: uninstall
kareem76e8a0f2022-02-25 10:13:53 -0800172uninstall:
manarabdelaty78c1b012021-04-23 17:12:54 +0200173 rm -rf $(CARAVEL_ROOT)
manarabdelatyb41301c2021-04-19 23:30:35 +0200174
manarabdelaty340cc4a2021-04-20 18:28:22 +0200175
manarabdelaty78c1b012021-04-23 17:12:54 +0200176# Install Pre-check
177# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
178.PHONY: precheck
179precheck:
Jeff DiCorpo9d5fd022022-03-19 11:01:27 -0700180 @git clone --depth=1 --branch $(MPW_TAG) https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
manarabdelatyb6ce4422021-09-16 22:09:24 +0200181 @docker pull efabless/mpw_precheck:latest
manarabdelaty78c1b012021-04-23 17:12:54 +0200182
183.PHONY: run-precheck
Ahmed El Omla0abd1612022-02-08 19:12:27 +0200184run-precheck: check-pdk check-precheck
manarabdelatyb6ce4422021-09-16 22:09:24 +0200185 $(eval INPUT_DIRECTORY := $(shell pwd))
manarabdelaty78c1b012021-04-23 17:12:54 +0200186 cd $(PRECHECK_ROOT) && \
Marwan Abbasd9bdb822022-04-16 10:34:40 -0700187 docker run -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) \
188 -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) \
189 -v $(PDK_ROOT):$(PDK_ROOT) \
190 -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) \
191 -e PDK_ROOT=$(PDK_ROOT) \
192 -e PDKPATH=$(PDKPATH) \
193 -u $(shell id -u $(USER)):$(shell id -g $(USER)) \
194 efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --input_directory $(INPUT_DIRECTORY) --pdk_root $(PDK_ROOT)"
manarabdelatyd8dd0102021-04-30 08:40:52 +0200195
manarabdelatyb41301c2021-04-19 23:30:35 +0200196
kareem76e8a0f2022-02-25 10:13:53 -0800197
kareem035ac3d2022-02-25 10:34:26 -0800198.PHONY: clean
199clean:
200 cd ./verilog/dv/ && \
201 $(MAKE) -j$(THREADS) clean
202
manarabdelatyb41301c2021-04-19 23:30:35 +0200203check-caravel:
204 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
205 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
206 exit 1; \
Jeff DiCorpofb944f92021-04-20 00:40:50 +0000207 fi
manarabdelaty78c1b012021-04-23 17:12:54 +0200208
209check-precheck:
210 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
211 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
212 exit 1; \
213 fi
214
Marwan Abbas073ecab2022-04-03 14:52:46 +0200215check-pdk:
216 @if [ ! -d "$(PDK_ROOT)" ]; then \
217 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
218 exit 1; \
219 fi
manarabdelatyd8dd0102021-04-30 08:40:52 +0200220
221.PHONY: help
222help:
kareem76e8a0f2022-02-25 10:13:53 -0800223 cd $(CARAVEL_ROOT) && $(MAKE) help
manarabdelatyd8dd0102021-04-30 08:40:52 +0200224 @$(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 -0800225
226