blob: 876913760ccfae8fc239819eb88b2b7d196b325a [file] [log] [blame]
dineshannayya62e46322022-02-15 14:19:56 +05301# 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
dineshannayya11a64182022-03-19 08:29:11 +053016MAKEFLAGS+=--warn-undefined-variables
dineshannayya62e46322022-02-15 14:19:56 +053017
18CARAVEL_ROOT?=$(PWD)/caravel
19PRECHECK_ROOT?=${HOME}/mpw_precheck
dineshannayya11a64182022-03-19 08:29:11 +053020MCW_ROOT?=$(PWD)/mgmt_core_wrapper
21SIM?=RTL
22DUMP?=OFF
dineshannayyae853c362022-02-22 21:24:03 +053023RISC_CORE ?=0
dineshannayya62e46322022-02-15 14:19:56 +053024
dineshannayya11a64182022-03-19 08:29:11 +053025export SKYWATER_COMMIT=c094b6e83a4f9298e47f696ec5a7fd53535ec5eb
26export OPEN_PDKS_COMMIT=7519dfb04400f224f140749cda44ee7de6f5e095
27export PDK_MAGIC_COMMIT=7d601628e4e05fd17fcb80c3552dacb64e9f6e7b
28export OPENLANE_TAG=2022.02.23_02.50.41
29
dineshannayya62e46322022-02-15 14:19:56 +053030# Install lite version of caravel, (1): caravel-lite, (0): caravel
31CARAVEL_LITE?=1
32
dineshannayya11a64182022-03-19 08:29:11 +053033MPW_TAG ?= mpw-5c
34
35ifeq ($(CARAVEL_LITE),1)
dineshannayya62e46322022-02-15 14:19:56 +053036 CARAVEL_NAME := caravel-lite
dineshannayya11a64182022-03-19 08:29:11 +053037 CARAVEL_REPO := https://github.com/efabless/caravel-lite
38 CARAVEL_TAG := $(MPW_TAG)
dineshannayya62e46322022-02-15 14:19:56 +053039else
40 CARAVEL_NAME := caravel
dineshannayya11a64182022-03-19 08:29:11 +053041 CARAVEL_REPO := https://github.com/efabless/caravel
42 CARAVEL_TAG := $(MPW_TAG)
dineshannayya62e46322022-02-15 14:19:56 +053043endif
44
45# Install caravel as submodule, (1): submodule, (0): clone
46SUBMODULE?=1
47
48#RISCV COMPLIANCE test Environment
49COREMARK_DIR = verilog/dv/riscv_regress/dependencies/coremark
50RISCV_COMP_DIR = verilog/dv/riscv_regress/dependencies/riscv-compliance
51RISCV_TEST_DIR = verilog/dv/riscv_regress/dependencies/riscv-tests
52
53COREMARK_REPO = https://github.com/eembc/coremark
54RISCV_COMP_REPO = https://github.com/riscv/riscv-compliance
55RISCV_TEST_REPO = https://github.com/riscv/riscv-tests
56
57COREMARK_BRANCH = 7f420b6bdbff436810ef75381059944e2b0d79e8
58RISCV_COMP_BRANCH = d51259b2a949be3af02e776c39e135402675ac9b
59RISCV_TEST_BRANCH = e30978a71921159aec38eeefd848fca4ed39a826
60
61# Include Caravel Makefile Targets
62.PHONY: % : check-caravel
dineshannayya11a64182022-03-19 08:29:11 +053063%:
dineshannayya62e46322022-02-15 14:19:56 +053064 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
65
dineshannayya11a64182022-03-19 08:29:11 +053066.PHONY: install
67install:
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
dineshannayya62e46322022-02-15 14:19:56 +053074
75# Install DV setup
76.PHONY: simenv
77simenv:
dineshannayya96d856d2022-02-25 08:14:03 +053078 docker pull riscduino/dv_setup:latest
dineshannayya62e46322022-02-15 14:19:56 +053079
dineshannayya11a64182022-03-19 08:29:11 +053080.PHONY: setup
81setup: install check-env install_mcw pdk openlane
82
83# Openlane
84blocks=$(shell cd openlane && find * -maxdepth 0 -type d)
85.PHONY: $(blocks)
86$(blocks): % :
dineshannayya62e46322022-02-15 14:19:56 +053087 export CARAVEL_ROOT=$(CARAVEL_ROOT) && cd openlane && $(MAKE) $*
88
dineshannayya11a64182022-03-19 08:29:11 +053089
dineshannayya8154f8e2022-04-18 17:30:10 +053090PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
91DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv))
dineshannayya11a64182022-03-19 08:29:11 +053092TARGET_PATH=$(shell pwd)
93verify_command="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} DUMP=${DUMP} RISC_CORE=${RISC_CORE} && make"
dineshannayya8154f8e2022-04-18 17:30:10 +053094$(DV_PATTERNS): verify-% : ./verilog/dv/% check-coremark_repo check-riscv_comp_repo check-riscv_test_repo
dineshannayya11a64182022-03-19 08:29:11 +053095 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} \
dineshannayya1ef37a02022-05-18 20:45:06 +053098 -e PDK=${PDK} \
dineshannayya11a64182022-03-19 08:29:11 +053099 -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
dineshannayya11a64182022-03-19 08:29:11 +0530108
109.PHONY: verify
dineshannayya8154f8e2022-04-18 17:30:10 +0530110verify:
111 cd ./verilog/dv/ && \
112 export SIM=${SIM} DUMP=${DUMP} && \
113 $(MAKE) -j$(THREADS)
dineshannayya11a64182022-03-19 08:29:11 +0530114
dineshannayya11a64182022-03-19 08:29:11 +0530115
116# Install Openlane
117.PHONY: openlane
118openlane:
119 cd openlane && $(MAKE) openlane
120
121#### Not sure if the targets following are of any use
dineshannayya62e46322022-02-15 14:19:56 +0530122
123# Create symbolic links to caravel's main files
124.PHONY: simlink
125simlink: check-caravel
dineshannayya11a64182022-03-19 08:29:11 +0530126### Symbolic links relative path to $CARAVEL_ROOT
dineshannayya62e46322022-02-15 14:19:56 +0530127 $(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
138update_caravel: check-caravel
139 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
140
141# Uninstall Caravel
142.PHONY: uninstall
dineshannayya11a64182022-03-19 08:29:11 +0530143uninstall:
dineshannayya62e46322022-02-15 14:19:56 +0530144 rm -rf $(CARAVEL_ROOT)
145
dineshannayya62e46322022-02-15 14:19:56 +0530146
147# Install Pre-check
148# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
149.PHONY: precheck
150precheck:
dineshannayya11a64182022-03-19 08:29:11 +0530151 @git clone --depth=1 --branch mpw-5a https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
152 @docker pull efabless/mpw_precheck:latest
dineshannayya62e46322022-02-15 14:19:56 +0530153
154.PHONY: run-precheck
dineshannayya11a64182022-03-19 08:29:11 +0530155run-precheck: check-pdk check-precheck
dineshannayya62e46322022-02-15 14:19:56 +0530156 $(eval INPUT_DIRECTORY := $(shell pwd))
157 cd $(PRECHECK_ROOT) && \
dineshannayya11a64182022-03-19 08:29:11 +0530158 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)"
dineshannayya62e46322022-02-15 14:19:56 +0530160
dineshannayya11a64182022-03-19 08:29:11 +0530161
162
dineshannayya62e46322022-02-15 14:19:56 +0530163.PHONY: clean
164clean:
165 cd ./verilog/dv/ && \
166 $(MAKE) -j$(THREADS) clean
167
168check-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
174check-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
180check-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
186check-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
193check-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
200check-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
dineshannayyaa60df8c2022-02-24 21:23:02 +0530207zip:
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
216unzip:
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
dineshannayya62e46322022-02-15 14:19:56 +0530225.PHONY: help
226help:
dineshannayya11a64182022-03-19 08:29:11 +0530227 cd $(CARAVEL_ROOT) && $(MAKE) help
dineshannayya62e46322022-02-15 14:19:56 +0530228 @$(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 '^$@$$'