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