blob: 00444a40942a52f68119cf5a8f1ad1072d81531a [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
manarabdelaty60e4dcb2021-05-05 23:41:20 +020018PRECHECK_ROOT?=${HOME}/open_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
38.PHONY: %
39%:
40 $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
41
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)
57PDK_PATH=${PDK_ROOT}/sky130A
58VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
manarabdelaty60e4dcb2021-05-05 23:41:20 +020059$(DV_PATTERNS): verify-% : ./verilog/dv/%
manarabdelaty6af74082021-04-26 14:56:35 +020060 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_PATH}:${PDK_PATH} \
61 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
62 -e TARGET_PATH=${TARGET_PATH} -e PDK_PATH=${PDK_PATH} \
63 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
64 -u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \
65 sh -c $(VERIFY_COMMAND)
66
67# Openlane Makefile Targets
68BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
69.PHONY: $(BLOCKS)
70$(BLOCKS): %:
71 cd openlane && $(MAKE) $*
72
73# Install caravel
74.PHONY: install
75install:
76ifeq ($(SUBMODULE),1)
77 @echo "Installing $(CARAVEL_NAME) as a submodule.."
78# Convert CARAVEL_ROOT to relative path because .gitmodules doesn't accept '/'
79 $(eval CARAVEL_PATH := $(shell realpath --relative-to=$(shell pwd) $(CARAVEL_ROOT)))
80 @if [ ! -d $(CARAVEL_ROOT) ]; then git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_PATH); fi
81 @git submodule update --init
manarabdelaty60e4dcb2021-05-05 23:41:20 +020082 @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH)
manarabdelaty6af74082021-04-26 14:56:35 +020083 $(MAKE) simlink
84else
85 @echo "Installing $(CARAVEL_NAME).."
86 @git clone $(CARAVEL_REPO) $(CARAVEL_ROOT)
manarabdelaty60e4dcb2021-05-05 23:41:20 +020087 @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH)
manarabdelaty6af74082021-04-26 14:56:35 +020088endif
89
90# Create symbolic links to caravel's main files
91.PHONY: simlink
92simlink: check-caravel
93### Symbolic links relative path to $CARAVEL_ROOT
94 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
manarabdelaty6af74082021-04-26 14:56:35 +020095 mkdir -p openlane
manarabdelaty6af74082021-04-26 14:56:35 +020096 cd openlane &&\
97 ln -sf $(MAKEFILE_PATH) Makefile
manarabdelaty6af74082021-04-26 14:56:35 +020098
99# Update Caravel
100.PHONY: update_caravel
101update_caravel: check-caravel
102ifeq ($(SUBMODULE),1)
103 @git submodule update --init --recursive
104 cd $(CARAVEL_ROOT) && \
105 git checkout $(CARAVEL_BRANCH) && \
106 git pull
107else
108 cd $(CARAVEL_ROOT)/ && \
109 git checkout $(CARAVEL_BRANCH) && \
110 git pull
111endif
112
113# Uninstall Caravel
114.PHONY: uninstall
115uninstall:
116ifeq ($(SUBMODULE),1)
117 git config -f .gitmodules --remove-section "submodule.$(CARAVEL_NAME)"
118 git add .gitmodules
119 git submodule deinit -f $(CARAVEL_ROOT)
120 git rm --cached $(CARAVEL_ROOT)
121 rm -rf .git/modules/$(CARAVEL_NAME)
122 rm -rf $(CARAVEL_ROOT)
123else
124 rm -rf $(CARAVEL_ROOT)
125endif
126
127# Install Openlane
128.PHONY: openlane
129openlane:
130 cd openlane && $(MAKE) openlane
131
132# Install Pre-check
133# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
134.PHONY: precheck
135precheck:
136 @git clone https://github.com/efabless/open_mpw_precheck.git --depth=1 $(PRECHECK_ROOT)
137 @docker pull efabless/open_mpw_precheck:latest
138
139.PHONY: run-precheck
140run-precheck: check-precheck check-pdk check-caravel
manarabdelaty892f0d22021-05-07 19:46:08 +0200141 rm -rf $(PWD)/checks
manarabdelaty6af74082021-04-26 14:56:35 +0200142 $(eval TARGET_PATH := $(shell pwd))
143 cd $(PRECHECK_ROOT) && \
144 docker run -v $(PRECHECK_ROOT):/usr/local/bin -v $(TARGET_PATH):$(TARGET_PATH) -v $(PDK_ROOT):$(PDK_ROOT) -v $(CARAVEL_ROOT):$(CARAVEL_ROOT) \
manarabdelaty3f75a892021-05-07 23:49:05 +0200145 -u $(shell id -u $(USER)):$(shell id -g $(USER)) efabless/open_mpw_precheck:latest bash -c "python3 open_mpw_prechecker.py --pdk_root $(PDK_ROOT) --target_path $(TARGET_PATH) -rfc -c $(CARAVEL_ROOT)"
manarabdelaty60e4dcb2021-05-05 23:41:20 +0200146
147# Install PDK using OL's Docker Image
148.PHONY: pdk-nonnative
149pdk-nonnative: skywater-pdk skywater-library skywater-timing open_pdks
150 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 +0200151
152# Clean
153.PHONY: clean
154clean:
155 cd ./verilog/dv/ && \
156 $(MAKE) -j$(THREADS) clean
157
158check-caravel:
159 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
160 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
161 exit 1; \
162 fi
163
164check-precheck:
165 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
166 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
167 exit 1; \
168 fi
169
170check-pdk:
171 @if [ ! -d "$(PDK_ROOT)" ]; then \
172 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
173 exit 1; \
manarabdelaty60e4dcb2021-05-05 23:41:20 +0200174 fi
175
176.PHONY: help
177help:
178 cd $(CARAVEL_ROOT) && $(MAKE) help
179 @$(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 '^$@$$'