dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [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 |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 16 | MAKEFLAGS+=--warn-undefined-variables |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 17 | |
| 18 | CARAVEL_ROOT?=$(PWD)/caravel |
| 19 | PRECHECK_ROOT?=${HOME}/mpw_precheck |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 20 | MCW_ROOT?=$(PWD)/mgmt_core_wrapper |
| 21 | SIM?=RTL |
| 22 | DUMP?=OFF |
dineshannayya | 7ebf326 | 2022-02-22 21:24:03 +0530 | [diff] [blame] | 23 | RISC_CORE ?=0 |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 24 | |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 25 | export SKYWATER_COMMIT=c094b6e83a4f9298e47f696ec5a7fd53535ec5eb |
| 26 | export OPEN_PDKS_COMMIT=7519dfb04400f224f140749cda44ee7de6f5e095 |
| 27 | export PDK_MAGIC_COMMIT=7d601628e4e05fd17fcb80c3552dacb64e9f6e7b |
| 28 | export OPENLANE_TAG=2022.02.23_02.50.41 |
| 29 | |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 30 | # Install lite version of caravel, (1): caravel-lite, (0): caravel |
| 31 | CARAVEL_LITE?=1 |
| 32 | |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 33 | MPW_TAG ?= mpw-5c |
| 34 | |
| 35 | ifeq ($(CARAVEL_LITE),1) |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 36 | CARAVEL_NAME := caravel-lite |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 37 | CARAVEL_REPO := https://github.com/efabless/caravel-lite |
| 38 | CARAVEL_TAG := $(MPW_TAG) |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 39 | else |
| 40 | CARAVEL_NAME := caravel |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 41 | CARAVEL_REPO := https://github.com/efabless/caravel |
| 42 | CARAVEL_TAG := $(MPW_TAG) |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 43 | endif |
| 44 | |
| 45 | # Install caravel as submodule, (1): submodule, (0): clone |
| 46 | SUBMODULE?=1 |
| 47 | |
| 48 | #RISCV COMPLIANCE test Environment |
| 49 | COREMARK_DIR = verilog/dv/riscv_regress/dependencies/coremark |
| 50 | RISCV_COMP_DIR = verilog/dv/riscv_regress/dependencies/riscv-compliance |
| 51 | RISCV_TEST_DIR = verilog/dv/riscv_regress/dependencies/riscv-tests |
| 52 | |
| 53 | COREMARK_REPO = https://github.com/eembc/coremark |
| 54 | RISCV_COMP_REPO = https://github.com/riscv/riscv-compliance |
| 55 | RISCV_TEST_REPO = https://github.com/riscv/riscv-tests |
| 56 | |
| 57 | COREMARK_BRANCH = 7f420b6bdbff436810ef75381059944e2b0d79e8 |
| 58 | RISCV_COMP_BRANCH = d51259b2a949be3af02e776c39e135402675ac9b |
| 59 | RISCV_TEST_BRANCH = e30978a71921159aec38eeefd848fca4ed39a826 |
| 60 | |
| 61 | # Include Caravel Makefile Targets |
| 62 | .PHONY: % : check-caravel |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 63 | %: |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 64 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@ |
| 65 | |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 66 | .PHONY: install |
| 67 | install: |
| 68 | if [ -d "$(CARAVEL_ROOT)" ]; then\ |
| 69 | echo "Deleting exisiting $(CARAVEL_ROOT)" && \ |
| 70 | rm -rf $(CARAVEL_ROOT) && sleep 2;\ |
| 71 | fi |
| 72 | echo "Installing $(CARAVEL_NAME).." |
| 73 | git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT) --depth=1 |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 74 | |
| 75 | # Install DV setup |
| 76 | .PHONY: simenv |
| 77 | simenv: |
dineshannayya | a3c7f87 | 2022-02-25 08:14:03 +0530 | [diff] [blame] | 78 | docker pull riscduino/dv_setup:latest |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 79 | |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 80 | .PHONY: setup |
| 81 | setup: install check-env install_mcw pdk openlane |
| 82 | |
| 83 | # Openlane |
| 84 | blocks=$(shell cd openlane && find * -maxdepth 0 -type d) |
| 85 | .PHONY: $(blocks) |
| 86 | $(blocks): % : |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 87 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && cd openlane && $(MAKE) $* |
| 88 | |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 89 | dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d) |
| 90 | dv-targets-rtl=$(dv_patterns:%=verify-%-rtl) |
| 91 | dv-targets-gl=$(dv_patterns:%=verify-%-gl) |
| 92 | dv-targets-gl-sdf=$(dv_patterns:%=verify-%-gl-sdf) |
| 93 | |
| 94 | TARGET_PATH=$(shell pwd) |
| 95 | verify_command="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} DUMP=${DUMP} RISC_CORE=${RISC_CORE} && make" |
| 96 | dv_base_dependencies= ./verilog/dv/% check-coremark_repo check-riscv_comp_repo check-riscv_test_repo |
| 97 | docker_run_verify=\ |
| 98 | docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \ |
| 99 | -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \ |
| 100 | -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \ |
| 101 | -e CARAVEL_ROOT=${CARAVEL_ROOT} \ |
| 102 | -e TOOLS=/opt/riscv64i \ |
| 103 | -e DESIGNS=$(TARGET_PATH) \ |
| 104 | -e CORE_VERILOG_PATH=$(CARAVEL_ROOT)/mgmt_core_wrapper/verilog \ |
| 105 | -e GCC_PREFIX=riscv64-unknown-elf \ |
| 106 | -e MCW_ROOT=$(MCW_ROOT) \ |
| 107 | -u $$(id -u $$USER):$$(id -g $$USER) riscduino/dv_setup:latest \ |
| 108 | sh -c $(verify_command) |
| 109 | |
| 110 | .PHONY: harden |
| 111 | harden: $(blocks) |
| 112 | |
| 113 | .PHONY: verify |
| 114 | verify: $(dv-targets) |
| 115 | |
| 116 | $(dv-targets-rtl): SIM=RTL |
| 117 | $(dv-targets-rtl): verify-%-rtl: $(dv_base_dependencies) |
| 118 | $(docker_run_verify) |
| 119 | |
| 120 | $(dv-targets-gl): SIM=GL |
| 121 | $(dv-targets-gl): verify-%-gl: $(dv_base_dependencies) |
| 122 | $(docker_run_verify) |
| 123 | |
| 124 | $(dv-targets-gl-sdf): SIM=GL_SDF |
| 125 | $(dv-targets-gl-sdf): verify-%-gl-sdf: $(dv_base_dependencies) |
| 126 | $(docker_run_verify) |
| 127 | |
| 128 | clean-targets=$(blocks:%=clean-%) |
| 129 | .PHONY: $(clean-targets) |
| 130 | $(clean-targets): clean-% : |
| 131 | rm -f ./verilog/gl/$*.v |
| 132 | rm -f ./spef/$*.spef |
| 133 | rm -f ./sdc/$*.sdc |
| 134 | rm -f ./sdf/$*.sdf |
| 135 | rm -f ./gds/$*.gds |
| 136 | rm -f ./mag/$*.mag |
| 137 | rm -f ./lef/$*.lef |
| 138 | rm -f ./maglef/*.maglef |
| 139 | |
| 140 | make_what=setup $(blocks) $(dv-targets-rtl) $(dv-targets-gl) $(dv-targets-gl-sdf) $(clean-targets) |
| 141 | .PHONY: what |
| 142 | what: |
| 143 | # $(make_what) |
| 144 | |
| 145 | # Install Openlane |
| 146 | .PHONY: openlane |
| 147 | openlane: |
| 148 | cd openlane && $(MAKE) openlane |
| 149 | |
| 150 | #### Not sure if the targets following are of any use |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 151 | |
| 152 | # Create symbolic links to caravel's main files |
| 153 | .PHONY: simlink |
| 154 | simlink: check-caravel |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 155 | ### Symbolic links relative path to $CARAVEL_ROOT |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [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)) |
| 158 | mkdir -p openlane |
| 159 | mkdir -p openlane/user_project_wrapper |
| 160 | cd openlane &&\ |
| 161 | ln -sf $(MAKEFILE_PATH) Makefile |
| 162 | cd openlane/user_project_wrapper &&\ |
| 163 | ln -sf $(PIN_CFG_PATH) pin_order.cfg |
| 164 | |
| 165 | # Update Caravel |
| 166 | .PHONY: update_caravel |
| 167 | update_caravel: check-caravel |
| 168 | cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull |
| 169 | |
| 170 | # Uninstall Caravel |
| 171 | .PHONY: uninstall |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 172 | uninstall: |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 173 | rm -rf $(CARAVEL_ROOT) |
| 174 | |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 175 | |
| 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: |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 180 | @git clone --depth=1 --branch mpw-5a https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT) |
| 181 | @docker pull efabless/mpw_precheck:latest |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 182 | |
| 183 | .PHONY: run-precheck |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 184 | run-precheck: check-pdk check-precheck |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 185 | $(eval INPUT_DIRECTORY := $(shell pwd)) |
| 186 | cd $(PRECHECK_ROOT) && \ |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 187 | docker run -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) -v $(PDK_ROOT):$(PDK_ROOT) -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) -e PDK_ROOT=$(PDK_ROOT) \ |
| 188 | -u $(shell id -u $(USER)):$(shell id -g $(USER)) efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --input_directory $(INPUT_DIRECTORY) --pdk_root $(PDK_ROOT)" |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 189 | |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 190 | |
| 191 | |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 192 | .PHONY: clean |
| 193 | clean: |
| 194 | cd ./verilog/dv/ && \ |
| 195 | $(MAKE) -j$(THREADS) clean |
| 196 | |
| 197 | check-caravel: |
| 198 | @if [ ! -d "$(CARAVEL_ROOT)" ]; then \ |
| 199 | echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 200 | exit 1; \ |
| 201 | fi |
| 202 | |
| 203 | check-precheck: |
| 204 | @if [ ! -d "$(PRECHECK_ROOT)" ]; then \ |
| 205 | echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 206 | exit 1; \ |
| 207 | fi |
| 208 | |
| 209 | check-pdk: |
| 210 | @if [ ! -d "$(PDK_ROOT)" ]; then \ |
| 211 | echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 212 | exit 1; \ |
| 213 | fi |
| 214 | |
| 215 | check-coremark_repo: |
| 216 | @if [ ! -d "$(COREMARK_DIR)" ]; then \ |
| 217 | echo "Installing Core Mark Repo.."; \ |
| 218 | git clone $(COREMARK_REPO) $(COREMARK_DIR); \ |
| 219 | cd $(COREMARK_DIR); git checkout $(COREMARK_BRANCH); \ |
| 220 | fi |
| 221 | |
| 222 | check-riscv_comp_repo: |
| 223 | @if [ ! -d "$(RISCV_COMP_DIR)" ]; then \ |
| 224 | echo "Installing Risc V Complance Repo.."; \ |
| 225 | git clone $(RISCV_COMP_REPO) $(RISCV_COMP_DIR); \ |
| 226 | cd $(RISCV_COMP_DIR); git checkout $(RISCV_COMP_BRANCH); \ |
| 227 | fi |
| 228 | |
| 229 | check-riscv_test_repo: |
| 230 | @if [ ! -d "$(RISCV_TEST_DIR)" ]; then \ |
| 231 | echo "Installing RiscV Test Repo.."; \ |
| 232 | git clone $(RISCV_TEST_REPO) $(RISCV_TEST_DIR); \ |
| 233 | cd $(RISCV_TEST_DIR); git checkout $(RISCV_TEST_BRANCH); \ |
| 234 | fi |
| 235 | |
dineshannayya | 7019c5b | 2022-02-24 21:23:02 +0530 | [diff] [blame] | 236 | zip: |
| 237 | gzip -f def/* |
| 238 | gzip -f lef/* |
| 239 | gzip -f gds/* |
| 240 | gzip -f mag/* |
| 241 | gzip -f maglef/* |
| 242 | gzip -f spef/* |
| 243 | gzip -f spi/lvs/* |
| 244 | |
| 245 | unzip: |
| 246 | gzip -d def/* |
| 247 | gzip -d lef/* |
| 248 | gzip -d gds/* |
| 249 | gzip -d mag/* |
| 250 | gzip -d maglef/* |
| 251 | gzip -d spef/* |
| 252 | gzip -d spi/lvs/* |
| 253 | |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 254 | .PHONY: help |
| 255 | help: |
dineshannayya | 97fea3b | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 256 | cd $(CARAVEL_ROOT) && $(MAKE) help |
dineshannayya | 52e8a34 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 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 '^$@$$' |