dineshannayya | 62e4632 | 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 | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 16 | MAKEFLAGS+=--warn-undefined-variables |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 17 | |
| 18 | CARAVEL_ROOT?=$(PWD)/caravel |
| 19 | PRECHECK_ROOT?=${HOME}/mpw_precheck |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 20 | MCW_ROOT?=$(PWD)/mgmt_core_wrapper |
| 21 | SIM?=RTL |
| 22 | DUMP?=OFF |
dineshannayya | e853c36 | 2022-02-22 21:24:03 +0530 | [diff] [blame] | 23 | RISC_CORE ?=0 |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 24 | |
dineshannayya | 11a6418 | 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 | 62e4632 | 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 | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 33 | MPW_TAG ?= mpw-5c |
| 34 | |
| 35 | ifeq ($(CARAVEL_LITE),1) |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 36 | CARAVEL_NAME := caravel-lite |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 37 | CARAVEL_REPO := https://github.com/efabless/caravel-lite |
| 38 | CARAVEL_TAG := $(MPW_TAG) |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 39 | else |
| 40 | CARAVEL_NAME := caravel |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 41 | CARAVEL_REPO := https://github.com/efabless/caravel |
| 42 | CARAVEL_TAG := $(MPW_TAG) |
dineshannayya | 62e4632 | 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 | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 63 | %: |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 64 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@ |
| 65 | |
dineshannayya | 11a6418 | 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 | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 74 | |
| 75 | # Install DV setup |
| 76 | .PHONY: simenv |
| 77 | simenv: |
dineshannayya | 96d856d | 2022-02-25 08:14:03 +0530 | [diff] [blame] | 78 | docker pull riscduino/dv_setup:latest |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 79 | |
dineshannayya | 11a6418 | 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 | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 87 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && cd openlane && $(MAKE) $* |
| 88 | |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 89 | |
dineshannayya | 8154f8e | 2022-04-18 17:30:10 +0530 | [diff] [blame] | 90 | PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d) |
| 91 | DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv)) |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 92 | TARGET_PATH=$(shell pwd) |
| 93 | verify_command="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} DUMP=${DUMP} RISC_CORE=${RISC_CORE} && make" |
dineshannayya | 8154f8e | 2022-04-18 17:30:10 +0530 | [diff] [blame] | 94 | $(DV_PATTERNS): verify-% : ./verilog/dv/% check-coremark_repo check-riscv_comp_repo check-riscv_test_repo |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 95 | docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \ |
| 96 | -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \ |
| 97 | -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \ |
dineshannayya | 1ef37a0 | 2022-05-18 20:45:06 +0530 | [diff] [blame] | 98 | -e PDK=${PDK} \ |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 99 | -e CARAVEL_ROOT=${CARAVEL_ROOT} \ |
| 100 | -e TOOLS=/opt/riscv64i \ |
| 101 | -e DESIGNS=$(TARGET_PATH) \ |
| 102 | -e CORE_VERILOG_PATH=$(CARAVEL_ROOT)/mgmt_core_wrapper/verilog \ |
| 103 | -e GCC_PREFIX=riscv64-unknown-elf \ |
| 104 | -e MCW_ROOT=$(MCW_ROOT) \ |
| 105 | -u $$(id -u $$USER):$$(id -g $$USER) riscduino/dv_setup:latest \ |
| 106 | sh -c $(verify_command) |
| 107 | |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 108 | |
| 109 | .PHONY: verify |
dineshannayya | 8154f8e | 2022-04-18 17:30:10 +0530 | [diff] [blame] | 110 | verify: |
| 111 | cd ./verilog/dv/ && \ |
| 112 | export SIM=${SIM} DUMP=${DUMP} && \ |
| 113 | $(MAKE) -j$(THREADS) |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 114 | |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 115 | |
| 116 | # Install Openlane |
| 117 | .PHONY: openlane |
| 118 | openlane: |
| 119 | cd openlane && $(MAKE) openlane |
| 120 | |
| 121 | #### Not sure if the targets following are of any use |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 122 | |
| 123 | # Create symbolic links to caravel's main files |
| 124 | .PHONY: simlink |
| 125 | simlink: check-caravel |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 126 | ### Symbolic links relative path to $CARAVEL_ROOT |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 127 | $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile)) |
| 128 | $(eval PIN_CFG_PATH := $(shell realpath --relative-to=openlane/user_project_wrapper $(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg)) |
| 129 | mkdir -p openlane |
| 130 | mkdir -p openlane/user_project_wrapper |
| 131 | cd openlane &&\ |
| 132 | ln -sf $(MAKEFILE_PATH) Makefile |
| 133 | cd openlane/user_project_wrapper &&\ |
| 134 | ln -sf $(PIN_CFG_PATH) pin_order.cfg |
| 135 | |
| 136 | # Update Caravel |
| 137 | .PHONY: update_caravel |
| 138 | update_caravel: check-caravel |
| 139 | cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull |
| 140 | |
| 141 | # Uninstall Caravel |
| 142 | .PHONY: uninstall |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 143 | uninstall: |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 144 | rm -rf $(CARAVEL_ROOT) |
| 145 | |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 146 | |
| 147 | # Install Pre-check |
| 148 | # Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>" |
| 149 | .PHONY: precheck |
| 150 | precheck: |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 151 | @git clone --depth=1 --branch mpw-5a https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT) |
| 152 | @docker pull efabless/mpw_precheck:latest |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 153 | |
| 154 | .PHONY: run-precheck |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 155 | run-precheck: check-pdk check-precheck |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 156 | $(eval INPUT_DIRECTORY := $(shell pwd)) |
| 157 | cd $(PRECHECK_ROOT) && \ |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 158 | 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) \ |
| 159 | -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 | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 160 | |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 161 | |
| 162 | |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 163 | .PHONY: clean |
| 164 | clean: |
| 165 | cd ./verilog/dv/ && \ |
| 166 | $(MAKE) -j$(THREADS) clean |
| 167 | |
| 168 | check-caravel: |
| 169 | @if [ ! -d "$(CARAVEL_ROOT)" ]; then \ |
| 170 | echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 171 | exit 1; \ |
| 172 | fi |
| 173 | |
| 174 | check-precheck: |
| 175 | @if [ ! -d "$(PRECHECK_ROOT)" ]; then \ |
| 176 | echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 177 | exit 1; \ |
| 178 | fi |
| 179 | |
| 180 | check-pdk: |
| 181 | @if [ ! -d "$(PDK_ROOT)" ]; then \ |
| 182 | echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 183 | exit 1; \ |
| 184 | fi |
| 185 | |
| 186 | check-coremark_repo: |
| 187 | @if [ ! -d "$(COREMARK_DIR)" ]; then \ |
| 188 | echo "Installing Core Mark Repo.."; \ |
| 189 | git clone $(COREMARK_REPO) $(COREMARK_DIR); \ |
| 190 | cd $(COREMARK_DIR); git checkout $(COREMARK_BRANCH); \ |
| 191 | fi |
| 192 | |
| 193 | check-riscv_comp_repo: |
| 194 | @if [ ! -d "$(RISCV_COMP_DIR)" ]; then \ |
| 195 | echo "Installing Risc V Complance Repo.."; \ |
| 196 | git clone $(RISCV_COMP_REPO) $(RISCV_COMP_DIR); \ |
| 197 | cd $(RISCV_COMP_DIR); git checkout $(RISCV_COMP_BRANCH); \ |
| 198 | fi |
| 199 | |
| 200 | check-riscv_test_repo: |
| 201 | @if [ ! -d "$(RISCV_TEST_DIR)" ]; then \ |
| 202 | echo "Installing RiscV Test Repo.."; \ |
| 203 | git clone $(RISCV_TEST_REPO) $(RISCV_TEST_DIR); \ |
| 204 | cd $(RISCV_TEST_DIR); git checkout $(RISCV_TEST_BRANCH); \ |
| 205 | fi |
| 206 | |
dineshannayya | a60df8c | 2022-02-24 21:23:02 +0530 | [diff] [blame] | 207 | zip: |
| 208 | gzip -f def/* |
| 209 | gzip -f lef/* |
| 210 | gzip -f gds/* |
| 211 | gzip -f mag/* |
| 212 | gzip -f maglef/* |
| 213 | gzip -f spef/* |
| 214 | gzip -f spi/lvs/* |
| 215 | |
| 216 | unzip: |
| 217 | gzip -d def/* |
| 218 | gzip -d lef/* |
| 219 | gzip -d gds/* |
| 220 | gzip -d mag/* |
| 221 | gzip -d maglef/* |
| 222 | gzip -d spef/* |
| 223 | gzip -d spi/lvs/* |
| 224 | |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 225 | .PHONY: help |
| 226 | help: |
dineshannayya | 11a6418 | 2022-03-19 08:29:11 +0530 | [diff] [blame] | 227 | cd $(CARAVEL_ROOT) && $(MAKE) help |
dineshannayya | 62e4632 | 2022-02-15 14:19:56 +0530 | [diff] [blame] | 228 | @$(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 '^$@$$' |