urielcho | 3b4f5b8 | 2022-12-05 02:19:34 -0600 | [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 |
| 20 | export MCW_ROOT?=$(PWD)/mgmt_core_wrapper |
| 21 | SIM?=RTL |
| 22 | |
| 23 | # Install lite version of caravel, (1): caravel-lite, (0): caravel |
| 24 | CARAVEL_LITE?=1 |
| 25 | |
| 26 | # PDK switch varient |
| 27 | export PDK?=gf180mcuC |
| 28 | #export PDK?=gf180mcuC |
| 29 | export PDKPATH?=$(PDK_ROOT)/$(PDK) |
| 30 | |
| 31 | |
| 32 | |
| 33 | ifeq ($(PDK),sky130A) |
| 34 | SKYWATER_COMMIT=f70d8ca46961ff92719d8870a18a076370b85f6c |
| 35 | export OPEN_PDKS_COMMIT?=0059588eebfc704681dc2368bd1d33d96281d10f |
| 36 | export OPENLANE_TAG?=2022.11.19 |
| 37 | MPW_TAG ?= mpw-8a |
| 38 | |
| 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 | |
| 49 | endif |
| 50 | |
| 51 | ifeq ($(PDK),sky130B) |
| 52 | SKYWATER_COMMIT=f70d8ca46961ff92719d8870a18a076370b85f6c |
| 53 | export OPEN_PDKS_COMMIT?=0059588eebfc704681dc2368bd1d33d96281d10f |
| 54 | export OPENLANE_TAG?=2022.11.19 |
| 55 | MPW_TAG ?= mpw-8a |
| 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) |
| 70 | |
| 71 | MPW_TAG ?= gfmpw-0d |
| 72 | CARAVEL_NAME := caravel |
| 73 | CARAVEL_REPO := https://github.com/efabless/caravel-gf180mcu |
| 74 | CARAVEL_TAG := $(MPW_TAG) |
| 75 | #OPENLANE_TAG=ddfeab57e3e8769ea3d40dda12be0460e09bb6d9 |
| 76 | #export OPEN_PDKS_COMMIT?=0059588eebfc704681dc2368bd1d33d96281d10f |
| 77 | export OPEN_PDKS_COMMIT?=35c7265f51749ad8d9fdbb575af22c7c8fab974e |
| 78 | export OPENLANE_TAG?=2022.11.29 |
| 79 | |
| 80 | endif |
| 81 | |
| 82 | # Include Caravel Makefile Targets |
| 83 | .PHONY: % : check-caravel |
| 84 | %: |
| 85 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@ |
| 86 | |
| 87 | .PHONY: install |
| 88 | install: |
| 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 |
| 98 | simenv: |
| 99 | docker pull efabless/dv:latest |
| 100 | |
| 101 | .PHONY: setup |
| 102 | setup: install check-env install_mcw openlane pdk-with-volare setup-timing-scripts |
| 103 | |
| 104 | # Openlane |
| 105 | blocks=$(shell cd openlane && find * -maxdepth 0 -type d) |
| 106 | .PHONY: $(blocks) |
| 107 | $(blocks): % : |
| 108 | $(MAKE) -C openlane $* |
| 109 | |
| 110 | dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d) |
| 111 | dv-targets-rtl=$(dv_patterns:%=verify-%-rtl) |
| 112 | dv-targets-gl=$(dv_patterns:%=verify-%-gl) |
| 113 | dv-targets-gl-sdf=$(dv_patterns:%=verify-%-gl-sdf) |
| 114 | |
| 115 | TARGET_PATH=$(shell pwd) |
| 116 | verify_command="source ~/.bashrc && cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make" |
| 117 | dv_base_dependencies=simenv |
| 118 | docker_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) \ |
| 125 | -e USER_PROJECT_VERILOG=$(TARGET_PATH)/verilog \ |
| 126 | -e PDK=$(PDK) \ |
| 127 | -e CORE_VERILOG_PATH=$(TARGET_PATH)/mgmt_core_wrapper/verilog \ |
| 128 | -e CARAVEL_VERILOG_PATH=$(TARGET_PATH)/caravel/verilog \ |
| 129 | -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 |
| 134 | harden: $(blocks) |
| 135 | |
| 136 | .PHONY: verify |
| 137 | verify: $(dv-targets-rtl) |
| 138 | |
| 139 | .PHONY: verify-all-rtl |
| 140 | verify-all-rtl: $(dv-targets-rtl) |
| 141 | |
| 142 | .PHONY: verify-all-gl |
| 143 | verify-all-gl: $(dv-targets-gl) |
| 144 | |
| 145 | .PHONY: verify-all-gl-sdf |
| 146 | verify-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 | |
| 160 | clean-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 | |
| 172 | make_what=setup $(blocks) $(dv-targets-rtl) $(dv-targets-gl) $(dv-targets-gl-sdf) $(clean-targets) |
| 173 | .PHONY: what |
| 174 | what: |
| 175 | # $(make_what) |
| 176 | |
| 177 | # Install Openlane |
| 178 | .PHONY: openlane |
| 179 | openlane: |
| 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 |
| 191 | simlink: 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 |
| 204 | update_caravel: check-caravel |
| 205 | cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull |
| 206 | |
| 207 | # Uninstall Caravel |
| 208 | .PHONY: uninstall |
| 209 | uninstall: |
| 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 |
| 216 | precheck: |
| 217 | @git clone --depth=1 --branch $(MPW_TAG) https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT) |
| 218 | @docker pull efabless/mpw_precheck:latest |
| 219 | |
| 220 | .PHONY: run-precheck |
| 221 | run-precheck: check-pdk check-precheck |
| 222 | $(eval INPUT_DIRECTORY := $(shell pwd)) |
| 223 | cd $(PRECHECK_ROOT) && \ |
| 224 | docker run -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) \ |
| 225 | -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) \ |
| 226 | -v $(PDK_ROOT):$(PDK_ROOT) \ |
| 227 | -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) \ |
| 228 | -e PDK_PATH=$(PDK_ROOT)/$(PDK) \ |
| 229 | -e PDK_ROOT=$(PDK_ROOT) \ |
| 230 | -e PDKPATH=$(PDKPATH) \ |
| 231 | -u $(shell id -u $(USER)):$(shell id -g $(USER)) \ |
| 232 | efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --input_directory $(INPUT_DIRECTORY) --pdk_path $(PDK_ROOT)/$(PDK)" |
| 233 | |
| 234 | |
| 235 | |
| 236 | .PHONY: clean |
| 237 | clean: |
| 238 | cd ./verilog/dv/ && \ |
| 239 | $(MAKE) -j$(THREADS) clean |
| 240 | |
| 241 | check-caravel: |
| 242 | @if [ ! -d "$(CARAVEL_ROOT)" ]; then \ |
| 243 | echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 244 | exit 1; \ |
| 245 | fi |
| 246 | |
| 247 | check-precheck: |
| 248 | @if [ ! -d "$(PRECHECK_ROOT)" ]; then \ |
| 249 | echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 250 | exit 1; \ |
| 251 | fi |
| 252 | |
| 253 | check-pdk: |
| 254 | @if [ ! -d "$(PDK_ROOT)" ]; then \ |
| 255 | echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 256 | exit 1; \ |
| 257 | fi |
| 258 | |
| 259 | .PHONY: help |
| 260 | help: |
| 261 | cd $(CARAVEL_ROOT) && $(MAKE) help |
| 262 | @$(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 '^$@$$' |
| 263 | |
| 264 | |
| 265 | export CUP_ROOT=$(shell pwd) |
| 266 | export TIMING_ROOT?=$(shell pwd)/deps/timing-scripts |
| 267 | export PROJECT_ROOT=$(CUP_ROOT) |
| 268 | timing-scripts-repo=https://github.com/efabless/timing-scripts.git |
| 269 | |
| 270 | $(TIMING_ROOT): |
| 271 | @mkdir -p $(CUP_ROOT)/deps |
| 272 | @git clone $(timing-scripts-repo) $(TIMING_ROOT) |
| 273 | |
| 274 | .PHONY: setup-timing-scripts |
| 275 | setup-timing-scripts: $(TIMING_ROOT) |
| 276 | @( cd $(TIMING_ROOT) && git pull ) |
| 277 | @#( cd $(TIMING_ROOT) && git fetch && git checkout $(MPW_TAG); ) |
| 278 | @python3 -m venv ./venv |
| 279 | . ./venv/bin/activate && \ |
| 280 | python3 -m pip install --upgrade pip && \ |
| 281 | python3 -m pip install -r $(TIMING_ROOT)/requirements.txt && \ |
| 282 | deactivate |
| 283 | |
| 284 | ./verilog/gl/user_project_wrapper.v: |
| 285 | $(error you don't have $@) |
| 286 | |
| 287 | ./env/spef-mapping.tcl: |
| 288 | @echo "run the following:" |
| 289 | @echo "make extract-parasitics" |
| 290 | @echo "make create-spef-mapping" |
| 291 | exit 1 |
| 292 | |
| 293 | .PHONY: create-spef-mapping |
| 294 | create-spef-mapping: ./verilog/gl/user_project_wrapper.v |
| 295 | @. ./venv/bin/activate && \ |
| 296 | python3 $(TIMING_ROOT)/scripts/generate_spef_mapping.py \ |
| 297 | -i ./verilog/gl/user_project_wrapper.v \ |
| 298 | -o ./env/spef-mapping.tcl \ |
| 299 | --pdk-path $(PDK_ROOT)/$(PDK) \ |
| 300 | --macro-parent mprj \ |
| 301 | --project-root "$(CUP_ROOT)" && \ |
| 302 | deactivate |
| 303 | |
| 304 | .PHONY: extract-parasitics |
| 305 | extract-parasitics: ./verilog/gl/user_project_wrapper.v |
| 306 | @. ./venv/bin/activate && \ |
| 307 | python3 $(TIMING_ROOT)/scripts/get_macros.py \ |
| 308 | -i ./verilog/gl/user_project_wrapper.v \ |
| 309 | -o ./tmp-macros-list \ |
| 310 | --project-root "$(CUP_ROOT)" \ |
| 311 | --pdk-path $(PDK_ROOT)/$(PDK) && \ |
| 312 | deactivate |
| 313 | @cat ./tmp-macros-list | cut -d " " -f2 \ |
| 314 | | xargs -I % bash -c "$(MAKE) -C $(TIMING_ROOT) \ |
| 315 | -f $(TIMING_ROOT)/timing.mk rcx-% || echo 'Cannot extract %. Probably no def for this macro'" |
| 316 | @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk rcx-user_project_wrapper |
| 317 | @cat ./tmp-macros-list |
| 318 | @rm ./tmp-macros-list |
| 319 | |
| 320 | .PHONY: caravel-sta |
| 321 | caravel-sta: ./env/spef-mapping.tcl |
| 322 | @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-typ |
| 323 | @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-fast |
| 324 | @$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-slow |
| 325 | @echo "You can find results for all corners in $(CUP_ROOT)/signoff/caravel/openlane-signoff/timing/" |