blob: b89e69f0895783d996d646c61601a404bd163ddb [file] [log] [blame]
dineshannayya52e8a342022-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
dineshannayya97fea3b2022-03-19 08:29:11 +053016MAKEFLAGS+=--warn-undefined-variables
dineshannayya52e8a342022-02-15 14:19:56 +053017
18CARAVEL_ROOT?=$(PWD)/caravel
19PRECHECK_ROOT?=${HOME}/mpw_precheck
dineshannayya97fea3b2022-03-19 08:29:11 +053020MCW_ROOT?=$(PWD)/mgmt_core_wrapper
21SIM?=RTL
22DUMP?=OFF
dineshannayya7ebf3262022-02-22 21:24:03 +053023RISC_CORE ?=0
dineshannayya52e8a342022-02-15 14:19:56 +053024
dineshannayya97fea3b2022-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
dineshannayya52e8a342022-02-15 14:19:56 +053030# Install lite version of caravel, (1): caravel-lite, (0): caravel
31CARAVEL_LITE?=1
32
dineshannayya97fea3b2022-03-19 08:29:11 +053033MPW_TAG ?= mpw-5c
34
35ifeq ($(CARAVEL_LITE),1)
dineshannayya52e8a342022-02-15 14:19:56 +053036 CARAVEL_NAME := caravel-lite
dineshannayya97fea3b2022-03-19 08:29:11 +053037 CARAVEL_REPO := https://github.com/efabless/caravel-lite
38 CARAVEL_TAG := $(MPW_TAG)
dineshannayya52e8a342022-02-15 14:19:56 +053039else
40 CARAVEL_NAME := caravel
dineshannayya97fea3b2022-03-19 08:29:11 +053041 CARAVEL_REPO := https://github.com/efabless/caravel
42 CARAVEL_TAG := $(MPW_TAG)
dineshannayya52e8a342022-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
dineshannayya97fea3b2022-03-19 08:29:11 +053063%:
dineshannayya52e8a342022-02-15 14:19:56 +053064 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
65
dineshannayya97fea3b2022-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
dineshannayya52e8a342022-02-15 14:19:56 +053074
75# Install DV setup
76.PHONY: simenv
77simenv:
dineshannayyaa3c7f872022-02-25 08:14:03 +053078 docker pull riscduino/dv_setup:latest
dineshannayya52e8a342022-02-15 14:19:56 +053079
dineshannayya97fea3b2022-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): % :
dineshannayya52e8a342022-02-15 14:19:56 +053087 export CARAVEL_ROOT=$(CARAVEL_ROOT) && cd openlane && $(MAKE) $*
88
dineshannayya97fea3b2022-03-19 08:29:11 +053089dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
90dv-targets-rtl=$(dv_patterns:%=verify-%-rtl)
91dv-targets-gl=$(dv_patterns:%=verify-%-gl)
92dv-targets-gl-sdf=$(dv_patterns:%=verify-%-gl-sdf)
93
94TARGET_PATH=$(shell pwd)
95verify_command="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} DUMP=${DUMP} RISC_CORE=${RISC_CORE} && make"
96dv_base_dependencies= ./verilog/dv/% check-coremark_repo check-riscv_comp_repo check-riscv_test_repo
97docker_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
111harden: $(blocks)
112
113.PHONY: verify
114verify: $(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
128clean-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
140make_what=setup $(blocks) $(dv-targets-rtl) $(dv-targets-gl) $(dv-targets-gl-sdf) $(clean-targets)
141.PHONY: what
142what:
143 # $(make_what)
144
145# Install Openlane
146.PHONY: openlane
147openlane:
148 cd openlane && $(MAKE) openlane
149
150#### Not sure if the targets following are of any use
dineshannayya52e8a342022-02-15 14:19:56 +0530151
152# Create symbolic links to caravel's main files
153.PHONY: simlink
154simlink: check-caravel
dineshannayya97fea3b2022-03-19 08:29:11 +0530155### Symbolic links relative path to $CARAVEL_ROOT
dineshannayya52e8a342022-02-15 14:19:56 +0530156 $(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
167update_caravel: check-caravel
168 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
169
170# Uninstall Caravel
171.PHONY: uninstall
dineshannayya97fea3b2022-03-19 08:29:11 +0530172uninstall:
dineshannayya52e8a342022-02-15 14:19:56 +0530173 rm -rf $(CARAVEL_ROOT)
174
dineshannayya52e8a342022-02-15 14:19:56 +0530175
176# Install Pre-check
177# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
178.PHONY: precheck
179precheck:
dineshannayya97fea3b2022-03-19 08:29:11 +0530180 @git clone --depth=1 --branch mpw-5a https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
181 @docker pull efabless/mpw_precheck:latest
dineshannayya52e8a342022-02-15 14:19:56 +0530182
183.PHONY: run-precheck
dineshannayya97fea3b2022-03-19 08:29:11 +0530184run-precheck: check-pdk check-precheck
dineshannayya52e8a342022-02-15 14:19:56 +0530185 $(eval INPUT_DIRECTORY := $(shell pwd))
186 cd $(PRECHECK_ROOT) && \
dineshannayya97fea3b2022-03-19 08:29:11 +0530187 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)"
dineshannayya52e8a342022-02-15 14:19:56 +0530189
dineshannayya97fea3b2022-03-19 08:29:11 +0530190
191
dineshannayya52e8a342022-02-15 14:19:56 +0530192.PHONY: clean
193clean:
194 cd ./verilog/dv/ && \
195 $(MAKE) -j$(THREADS) clean
196
197check-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
203check-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
209check-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
215check-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
222check-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
229check-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
dineshannayya7019c5b2022-02-24 21:23:02 +0530236zip:
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
245unzip:
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
dineshannayya52e8a342022-02-15 14:19:56 +0530254.PHONY: help
255help:
dineshannayya97fea3b2022-03-19 08:29:11 +0530256 cd $(CARAVEL_ROOT) && $(MAKE) help
dineshannayya52e8a342022-02-15 14:19:56 +0530257 @$(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 '^$@$$'