manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 1 | # 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 |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 16 | MAKEFLAGS+=--warn-undefined-variables |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 17 | |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 18 | CARAVEL_ROOT?=$(PWD)/caravel |
manarabdelaty | 2632315 | 2021-09-16 23:11:34 +0200 | [diff] [blame] | 19 | PRECHECK_ROOT?=${HOME}/mpw_precheck |
Marwan Abbas | 51a1096 | 2022-02-11 16:35:19 +0200 | [diff] [blame] | 20 | MCW_ROOT?=$(PWD)/mgmt_core_wrapper |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 21 | SIM?=RTL |
| 22 | |
| 23 | export SKYWATER_COMMIT=c094b6e83a4f9298e47f696ec5a7fd53535ec5eb |
Marwan Abbas | f1d98ff | 2022-04-07 17:19:31 +0200 | [diff] [blame] | 24 | export OPEN_PDKS_COMMIT?=7519dfb04400f224f140749cda44ee7de6f5e095 |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 25 | export PDK_MAGIC_COMMIT=7d601628e4e05fd17fcb80c3552dacb64e9f6e7b |
Jeff DiCorpo | 52a2396 | 2022-04-13 18:15:36 -0700 | [diff] [blame] | 26 | export OPENLANE_TAG=2022.02.23_02.50.41 |
Jeff DiCorpo | a0edf64 | 2022-04-13 12:25:28 -0700 | [diff] [blame] | 27 | export MISMATCHES_OK=1 |
Marwan Abbas | d9bdb82 | 2022-04-16 10:34:40 -0700 | [diff] [blame] | 28 | export PDKPATH?=$(PDK_ROOT)/sky130A |
Jeff DiCorpo | a11292b | 2022-05-03 11:47:55 -0700 | [diff] [blame] | 29 | export PDK?=sky130A |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 30 | |
| 31 | # Install lite version of caravel, (1): caravel-lite, (0): caravel |
| 32 | CARAVEL_LITE?=1 |
| 33 | |
Jeff DiCorpo | 83395c0 | 2022-04-29 10:17:40 -0700 | [diff] [blame] | 34 | MPW_TAG ?= mpw-6c |
Jeff DiCorpo | 5c041f1 | 2022-02-25 17:56:06 -0800 | [diff] [blame] | 35 | |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 36 | ifeq ($(CARAVEL_LITE),1) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 37 | CARAVEL_NAME := caravel-lite |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 38 | CARAVEL_REPO := https://github.com/efabless/caravel-lite |
Jeff DiCorpo | 5c041f1 | 2022-02-25 17:56:06 -0800 | [diff] [blame] | 39 | CARAVEL_TAG := $(MPW_TAG) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 40 | else |
| 41 | CARAVEL_NAME := caravel |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 42 | CARAVEL_REPO := https://github.com/efabless/caravel |
Jeff DiCorpo | 5c041f1 | 2022-02-25 17:56:06 -0800 | [diff] [blame] | 43 | CARAVEL_TAG := $(MPW_TAG) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 44 | endif |
| 45 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 46 | # Include Caravel Makefile Targets |
manarabdelaty | 2632315 | 2021-09-16 23:11:34 +0200 | [diff] [blame] | 47 | .PHONY: % : check-caravel |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 48 | %: |
manarabdelaty | 2632315 | 2021-09-16 23:11:34 +0200 | [diff] [blame] | 49 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@ |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 50 | |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 51 | .PHONY: install |
| 52 | install: |
| 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 |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 59 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 60 | # Install DV setup |
| 61 | .PHONY: simenv |
| 62 | simenv: |
| 63 | docker pull efabless/dv_setup:latest |
| 64 | |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 65 | .PHONY: setup |
Marwan Abbas | 073ecab | 2022-04-03 14:52:46 +0200 | [diff] [blame] | 66 | setup: install check-env install_mcw openlane pdk-with-volare |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 67 | |
| 68 | # Openlane |
| 69 | blocks=$(shell cd openlane && find * -maxdepth 0 -type d) |
| 70 | .PHONY: $(blocks) |
Kareem Farid | 0eb93ef | 2022-03-02 13:25:37 +0200 | [diff] [blame] | 71 | $(blocks): % : |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 72 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && cd openlane && $(MAKE) $* |
| 73 | |
| 74 | dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d) |
| 75 | dv-targets-rtl=$(dv_patterns:%=verify-%-rtl) |
| 76 | dv-targets-gl=$(dv_patterns:%=verify-%-gl) |
| 77 | dv-targets-gl-sdf=$(dv_patterns:%=verify-%-gl-sdf) |
| 78 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 79 | TARGET_PATH=$(shell pwd) |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 80 | verify_command="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make" |
| 81 | dv_base_dependencies=simenv |
| 82 | docker_run_verify=\ |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 83 | docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \ |
kareem | ab6cfe1 | 2022-02-15 05:36:48 -0800 | [diff] [blame] | 84 | -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 DiCorpo | a11292b | 2022-05-03 11:47:55 -0700 | [diff] [blame] | 89 | -e PDK=$(PDK) \ |
Marwan Abbas | 6878870 | 2022-02-15 16:49:02 +0200 | [diff] [blame] | 90 | -e CORE_VERILOG_PATH=$(TARGET_PATH)/mgmt_core_wrapper/verilog \ |
| 91 | -e GCC_PREFIX=riscv32-unknown-elf \ |
kareem | ab6cfe1 | 2022-02-15 05:36:48 -0800 | [diff] [blame] | 92 | -e MCW_ROOT=$(MCW_ROOT) \ |
| 93 | -u $$(id -u $$USER):$$(id -g $$USER) efabless/dv_setup:latest \ |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 94 | sh -c $(verify_command) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 95 | |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 96 | .PHONY: harden |
| 97 | harden: $(blocks) |
| 98 | |
Jeff DiCorpo | 76e88e1 | 2022-03-19 14:12:29 -0700 | [diff] [blame] | 99 | .PHONY: verify |
| 100 | verify: $(dv-targets-rtl) |
| 101 | |
Marwan Abbas | eda6099 | 2022-03-03 19:53:27 +0200 | [diff] [blame] | 102 | .PHONY: verify-all-rtl |
| 103 | verify-all-rtl: $(dv-targets-rtl) |
| 104 | |
| 105 | .PHONY: verify-all-gl |
| 106 | verify-all-gl: $(dv-targets-gl) |
| 107 | |
| 108 | .PHONY: verify-all-gl-sdf |
Marwan Abbas | 17c43a6 | 2022-03-03 21:11:51 +0200 | [diff] [blame] | 109 | verify-all-gl-sdf: $(dv-targets-gl-sdf) |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 110 | |
| 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 | |
| 123 | clean-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 | |
| 135 | make_what=setup $(blocks) $(dv-targets-rtl) $(dv-targets-gl) $(dv-targets-gl-sdf) $(clean-targets) |
| 136 | .PHONY: what |
| 137 | what: |
| 138 | # $(make_what) |
| 139 | |
| 140 | # Install Openlane |
| 141 | .PHONY: openlane |
| 142 | openlane: |
Kareem Farid | 13edb81 | 2022-06-08 13:03:08 +0200 | [diff] [blame^] | 143 | @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 |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 148 | cd openlane && $(MAKE) openlane |
| 149 | |
| 150 | #### Not sure if the targets following are of any use |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 151 | |
| 152 | # Create symbolic links to caravel's main files |
| 153 | .PHONY: simlink |
| 154 | simlink: check-caravel |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 155 | ### Symbolic links relative path to $CARAVEL_ROOT |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 156 | $(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)) |
manarabdelaty | e542bdf | 2021-04-20 11:15:40 +0200 | [diff] [blame] | 158 | mkdir -p openlane |
| 159 | mkdir -p openlane/user_project_wrapper |
| 160 | cd openlane &&\ |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 161 | ln -sf $(MAKEFILE_PATH) Makefile |
manarabdelaty | e542bdf | 2021-04-20 11:15:40 +0200 | [diff] [blame] | 162 | cd openlane/user_project_wrapper &&\ |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 163 | ln -sf $(PIN_CFG_PATH) pin_order.cfg |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 164 | |
| 165 | # Update Caravel |
| 166 | .PHONY: update_caravel |
| 167 | update_caravel: check-caravel |
jeffdi | 298918f | 2021-12-16 11:15:44 -0800 | [diff] [blame] | 168 | cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 169 | |
| 170 | # Uninstall Caravel |
| 171 | .PHONY: uninstall |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 172 | uninstall: |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 173 | rm -rf $(CARAVEL_ROOT) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 174 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 175 | |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 176 | # Install Pre-check |
| 177 | # Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>" |
| 178 | .PHONY: precheck |
| 179 | precheck: |
Jeff DiCorpo | 9d5fd02 | 2022-03-19 11:01:27 -0700 | [diff] [blame] | 180 | @git clone --depth=1 --branch $(MPW_TAG) https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT) |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 181 | @docker pull efabless/mpw_precheck:latest |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 182 | |
| 183 | .PHONY: run-precheck |
Ahmed El Omla | 0abd161 | 2022-02-08 19:12:27 +0200 | [diff] [blame] | 184 | run-precheck: check-pdk check-precheck |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 185 | $(eval INPUT_DIRECTORY := $(shell pwd)) |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 186 | cd $(PRECHECK_ROOT) && \ |
Marwan Abbas | d9bdb82 | 2022-04-16 10:34:40 -0700 | [diff] [blame] | 187 | 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)" |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 195 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 196 | |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 197 | |
kareem | 035ac3d | 2022-02-25 10:34:26 -0800 | [diff] [blame] | 198 | .PHONY: clean |
| 199 | clean: |
| 200 | cd ./verilog/dv/ && \ |
| 201 | $(MAKE) -j$(THREADS) clean |
| 202 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 203 | check-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 DiCorpo | fb944f9 | 2021-04-20 00:40:50 +0000 | [diff] [blame] | 207 | fi |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 208 | |
| 209 | check-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 Abbas | 073ecab | 2022-04-03 14:52:46 +0200 | [diff] [blame] | 215 | check-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 |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 220 | |
| 221 | .PHONY: help |
| 222 | help: |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 223 | cd $(CARAVEL_ROOT) && $(MAKE) help |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 224 | @$(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 '^$@$$' |
kareem | 76e8a0f | 2022-02-25 10:13:53 -0800 | [diff] [blame] | 225 | |
| 226 | |