blob: 0ab55ca89641955a27edeb81eab11c463c9015ed [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
24ifeq ($(CARAVEL_LITE),1)
25 CARAVEL_NAME := caravel-lite
26 CARAVEL_REPO := https://github.com/efabless/caravel-lite
manarabdelaty60e4dcb2021-05-05 23:41:20 +020027 CARAVEL_BRANCH := main
manarabdelaty6af74082021-04-26 14:56:35 +020028else
29 CARAVEL_NAME := caravel
30 CARAVEL_REPO := https://github.com/efabless/caravel
manarabdelaty60e4dcb2021-05-05 23:41:20 +020031 CARAVEL_BRANCH := master
manarabdelaty6af74082021-04-26 14:56:35 +020032endif
33
34# Install caravel as submodule, (1): submodule, (0): clone
35SUBMODULE?=1
36
37# Include Caravel Makefile Targets
manarabdelaty50688bf2021-09-16 23:18:08 +020038.PHONY: % : check-caravel
manarabdelaty6af74082021-04-26 14:56:35 +020039%:
manarabdelaty50688bf2021-09-16 23:18:08 +020040 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
manarabdelaty6af74082021-04-26 14:56:35 +020041
42# Verify Target for running simulations
43.PHONY: verify
44verify:
45 cd ./verilog/dv/ && \
46 export SIM=${SIM} && \
47 $(MAKE) -j$(THREADS)
48
49# Install DV setup
50.PHONY: simenv
51simenv:
52 docker pull efabless/dv_setup:latest
53
54PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
55DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv))
56TARGET_PATH=$(shell pwd)
manarabdelaty6af74082021-04-26 14:56:35 +020057VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
manarabdelaty60e4dcb2021-05-05 23:41:20 +020058$(DV_PATTERNS): verify-% : ./verilog/dv/%
manarabdelaty50688bf2021-09-16 23:18:08 +020059 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \
manarabdelaty6af74082021-04-26 14:56:35 +020060 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
manarabdelaty50688bf2021-09-16 23:18:08 +020061 -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \
manarabdelaty6af74082021-04-26 14:56:35 +020062 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
63 -u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \
64 sh -c $(VERIFY_COMMAND)
65
66# Openlane Makefile Targets
67BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
68.PHONY: $(BLOCKS)
69$(BLOCKS): %:
70 cd openlane && $(MAKE) $*
71
72# Install caravel
73.PHONY: install
74install:
75ifeq ($(SUBMODULE),1)
76 @echo "Installing $(CARAVEL_NAME) as a submodule.."
77# Convert CARAVEL_ROOT to relative path because .gitmodules doesn't accept '/'
78 $(eval CARAVEL_PATH := $(shell realpath --relative-to=$(shell pwd) $(CARAVEL_ROOT)))
79 @if [ ! -d $(CARAVEL_ROOT) ]; then git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_PATH); fi
80 @git submodule update --init
manarabdelaty60e4dcb2021-05-05 23:41:20 +020081 @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH)
manarabdelaty6af74082021-04-26 14:56:35 +020082 $(MAKE) simlink
83else
84 @echo "Installing $(CARAVEL_NAME).."
85 @git clone $(CARAVEL_REPO) $(CARAVEL_ROOT)
manarabdelaty60e4dcb2021-05-05 23:41:20 +020086 @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH)
manarabdelaty6af74082021-04-26 14:56:35 +020087endif
88
89# Create symbolic links to caravel's main files
90.PHONY: simlink
91simlink: check-caravel
92### Symbolic links relative path to $CARAVEL_ROOT
93 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
manarabdelaty6af74082021-04-26 14:56:35 +020094 mkdir -p openlane
manarabdelaty6af74082021-04-26 14:56:35 +020095 cd openlane &&\
96 ln -sf $(MAKEFILE_PATH) Makefile
manarabdelaty6af74082021-04-26 14:56:35 +020097
98# Update Caravel
99.PHONY: update_caravel
100update_caravel: check-caravel
101ifeq ($(SUBMODULE),1)
102 @git submodule update --init --recursive
103 cd $(CARAVEL_ROOT) && \
104 git checkout $(CARAVEL_BRANCH) && \
105 git pull
106else
107 cd $(CARAVEL_ROOT)/ && \
108 git checkout $(CARAVEL_BRANCH) && \
109 git pull
110endif
111
112# Uninstall Caravel
113.PHONY: uninstall
114uninstall:
115ifeq ($(SUBMODULE),1)
116 git config -f .gitmodules --remove-section "submodule.$(CARAVEL_NAME)"
117 git add .gitmodules
118 git submodule deinit -f $(CARAVEL_ROOT)
119 git rm --cached $(CARAVEL_ROOT)
120 rm -rf .git/modules/$(CARAVEL_NAME)
121 rm -rf $(CARAVEL_ROOT)
122else
123 rm -rf $(CARAVEL_ROOT)
124endif
125
126# Install Openlane
127.PHONY: openlane
128openlane:
129 cd openlane && $(MAKE) openlane
130
131# Install Pre-check
132# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
133.PHONY: precheck
134precheck:
manarabdelaty50688bf2021-09-16 23:18:08 +0200135 @git clone https://github.com/efabless/mpw_precheck.git --depth=1 $(PRECHECK_ROOT)
136 @docker pull efabless/mpw_precheck:latest
manarabdelaty6af74082021-04-26 14:56:35 +0200137
138.PHONY: run-precheck
139run-precheck: check-precheck check-pdk check-caravel
manarabdelaty50688bf2021-09-16 23:18:08 +0200140 $(eval INPUT_DIRECTORY := $(shell pwd))
manarabdelaty6af74082021-04-26 14:56:35 +0200141 cd $(PRECHECK_ROOT) && \
manarabdelaty50688bf2021-09-16 23:18:08 +0200142 docker run -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) -e PDK_ROOT=$(PDK_ROOT) -e CARAVEL_ROOT=$(CARAVEL_ROOT) -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) -v $(PDK_ROOT):$(PDK_ROOT) -v $(CARAVEL_ROOT):$(CARAVEL_ROOT) \
143 -u $(shell id -u $(USER)):$(shell id -g $(USER)) efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --pdk_root $(PDK_ROOT) --input_directory $(INPUT_DIRECTORY) --caravel_root $(CARAVEL_ROOT)"
manarabdelaty60e4dcb2021-05-05 23:41:20 +0200144
145# Install PDK using OL's Docker Image
146.PHONY: pdk-nonnative
147pdk-nonnative: skywater-pdk skywater-library skywater-timing open_pdks
148 docker run --rm -v $(PDK_ROOT):$(PDK_ROOT) -v $(pwd):/user_project -v $(CARAVEL_ROOT):$(CARAVEL_ROOT) -e CARAVEL_ROOT=$(CARAVEL_ROOT) -e PDK_ROOT=$(PDK_ROOT) -u $(shell id -u $(USER)):$(shell id -g $(USER)) efabless/openlane:current sh -c "cd $(CARAVEL_ROOT); make build-pdk; make gen-sources"
manarabdelaty6af74082021-04-26 14:56:35 +0200149
150# Clean
151.PHONY: clean
152clean:
153 cd ./verilog/dv/ && \
154 $(MAKE) -j$(THREADS) clean
155
156check-caravel:
157 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
158 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
159 exit 1; \
160 fi
161
162check-precheck:
163 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
164 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
165 exit 1; \
166 fi
167
168check-pdk:
169 @if [ ! -d "$(PDK_ROOT)" ]; then \
170 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
171 exit 1; \
manarabdelaty60e4dcb2021-05-05 23:41:20 +0200172 fi
173
174.PHONY: help
175help:
176 cd $(CARAVEL_ROOT) && $(MAKE) help
Jeff DiCorpo517439c2021-06-20 14:12:18 -0700177 @$(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 '^$@$$'