blob: 37b341cb66bad2cfa38befb3290daa394d8ba388 [file] [log] [blame]
manarabdelaty6af74082021-04-26 14:56:35 +02001# 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
17CARAVEL_ROOT?=$(PWD)/caravel
manarabdelaty50688bf2021-09-16 23:18:08 +020018PRECHECK_ROOT?=${HOME}/mpw_precheck
manarabdelaty6af74082021-04-26 14:56:35 +020019SIM ?= RTL
20
21# Install lite version of caravel, (1): caravel-lite, (0): caravel
22CARAVEL_LITE?=1
23
Jeff DiCorpod2609d82022-03-19 11:06:20 -070024MPW_TAG ?= mpw-5c
25
26ifeq ($(CARAVEL_LITE),1)
manarabdelaty6af74082021-04-26 14:56:35 +020027 CARAVEL_NAME := caravel-lite
Jeff DiCorpo4afe80a2021-12-17 13:40:01 -080028 CARAVEL_REPO := https://github.com/efabless/caravel-lite
Jeff DiCorpod2609d82022-03-19 11:06:20 -070029 CARAVEL_TAG := $(MPW_TAG)
manarabdelaty6af74082021-04-26 14:56:35 +020030else
31 CARAVEL_NAME := caravel
Jeff DiCorpo4afe80a2021-12-17 13:40:01 -080032 CARAVEL_REPO := https://github.com/efabless/caravel
Jeff DiCorpod2609d82022-03-19 11:06:20 -070033 CARAVEL_TAG := $(MPW_TAG)
manarabdelaty6af74082021-04-26 14:56:35 +020034endif
35
manarabdelaty6af74082021-04-26 14:56:35 +020036# Include Caravel Makefile Targets
manarabdelaty50688bf2021-09-16 23:18:08 +020037.PHONY: % : check-caravel
manarabdelaty6af74082021-04-26 14:56:35 +020038%:
manarabdelaty50688bf2021-09-16 23:18:08 +020039 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
manarabdelaty6af74082021-04-26 14:56:35 +020040
41# Verify Target for running simulations
42.PHONY: verify
43verify:
44 cd ./verilog/dv/ && \
45 export SIM=${SIM} && \
46 $(MAKE) -j$(THREADS)
47
48# Install DV setup
49.PHONY: simenv
50simenv:
51 docker pull efabless/dv_setup:latest
52
53PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
54DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv))
55TARGET_PATH=$(shell pwd)
manarabdelaty6af74082021-04-26 14:56:35 +020056VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
manarabdelaty60e4dcb2021-05-05 23:41:20 +020057$(DV_PATTERNS): verify-% : ./verilog/dv/%
manarabdelaty50688bf2021-09-16 23:18:08 +020058 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \
manarabdelaty6af74082021-04-26 14:56:35 +020059 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
manarabdelaty50688bf2021-09-16 23:18:08 +020060 -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \
manarabdelaty6af74082021-04-26 14:56:35 +020061 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
62 -u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \
63 sh -c $(VERIFY_COMMAND)
64
65# Openlane Makefile Targets
66BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
67.PHONY: $(BLOCKS)
68$(BLOCKS): %:
69 cd openlane && $(MAKE) $*
70
71# Install caravel
72.PHONY: install
73install:
manarabdelaty6af74082021-04-26 14:56:35 +020074 @echo "Installing $(CARAVEL_NAME).."
a-omla74c184c2022-01-28 19:56:44 +020075 @git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT)
manarabdelaty6af74082021-04-26 14:56:35 +020076
77# Create symbolic links to caravel's main files
78.PHONY: simlink
79simlink: check-caravel
80### Symbolic links relative path to $CARAVEL_ROOT
81 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
manarabdelaty6af74082021-04-26 14:56:35 +020082 mkdir -p openlane
manarabdelaty6af74082021-04-26 14:56:35 +020083 cd openlane &&\
84 ln -sf $(MAKEFILE_PATH) Makefile
manarabdelaty6af74082021-04-26 14:56:35 +020085
86# Update Caravel
87.PHONY: update_caravel
88update_caravel: check-caravel
a-omla74c184c2022-01-28 19:56:44 +020089 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
manarabdelaty6af74082021-04-26 14:56:35 +020090
91# Uninstall Caravel
92.PHONY: uninstall
93uninstall:
manarabdelaty6af74082021-04-26 14:56:35 +020094 rm -rf $(CARAVEL_ROOT)
manarabdelaty6af74082021-04-26 14:56:35 +020095
96# Install Openlane
97.PHONY: openlane
98openlane:
99 cd openlane && $(MAKE) openlane
100
101# Install Pre-check
102# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
103.PHONY: precheck
104precheck:
Jeff DiCorpod2609d82022-03-19 11:06:20 -0700105 @git clone --depth=1 --branch $(MPW_TAG) https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
manarabdelaty50688bf2021-09-16 23:18:08 +0200106 @docker pull efabless/mpw_precheck:latest
manarabdelaty6af74082021-04-26 14:56:35 +0200107
108.PHONY: run-precheck
Ahmed El Omla0793e6c2022-02-08 16:15:27 +0200109run-precheck: check-pdk check-precheck
manarabdelaty50688bf2021-09-16 23:18:08 +0200110 $(eval INPUT_DIRECTORY := $(shell pwd))
manarabdelaty6af74082021-04-26 14:56:35 +0200111 cd $(PRECHECK_ROOT) && \
Ahmed El Omla0793e6c2022-02-08 16:15:27 +0200112 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) \
113 -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)"
manarabdelaty60e4dcb2021-05-05 23:41:20 +0200114
manarabdelaty6af74082021-04-26 14:56:35 +0200115# Clean
116.PHONY: clean
117clean:
118 cd ./verilog/dv/ && \
119 $(MAKE) -j$(THREADS) clean
120
121check-caravel:
122 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
123 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
124 exit 1; \
125 fi
126
127check-precheck:
128 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
129 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
130 exit 1; \
131 fi
132
133check-pdk:
134 @if [ ! -d "$(PDK_ROOT)" ]; then \
135 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
136 exit 1; \
manarabdelaty60e4dcb2021-05-05 23:41:20 +0200137 fi
138
139.PHONY: help
140help:
141 cd $(CARAVEL_ROOT) && $(MAKE) help
Jeff DiCorpo517439c2021-06-20 14:12:18 -0700142 @$(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 '^$@$$'