blob: bc049d44da25b0ae0372f977af7d55e0d437f49a [file] [log] [blame]
chrische1136fcf2022-07-22 21:28:05 +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
18PRECHECK_ROOT?=${HOME}/mpw_precheck
19SIM ?= RTL
20
21export OPEN_PDKS_COMMIT?=41c0908b47130d5675ff8484255b43f66463a7d6
22export PDK?=sky130B
23export PDKPATH?=$(PDK_ROOT)/$(PDK)
24# Install lite version of caravel, (1): caravel-lite, (0): caravel
25CARAVEL_LITE?=1
26
27MPW_TAG ?= mpw-7a
28
29ifeq ($(CARAVEL_LITE),1)
30 CARAVEL_NAME := caravel-lite
31 CARAVEL_REPO := https://github.com/efabless/caravel-lite
32 CARAVEL_TAG := $(MPW_TAG)
33else
34 CARAVEL_NAME := caravel
35 CARAVEL_REPO := https://github.com/efabless/caravel
36 CARAVEL_TAG := $(MPW_TAG)
37endif
38
39# Include Caravel Makefile Targets
40.PHONY: % : check-caravel
41%:
42 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
43
44# Verify Target for running simulations
45.PHONY: verify
46verify:
47 cd ./verilog/dv/ && \
48 export SIM=${SIM} && \
49 $(MAKE) -j$(THREADS)
50
51# Install DV setup
52.PHONY: simenv
53simenv:
54 docker pull efabless/dv_setup:latest
55
56PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
57DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv))
58TARGET_PATH=$(shell pwd)
59VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
60$(DV_PATTERNS): verify-% : ./verilog/dv/%
61 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \
62 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
63 -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \
64 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
65 -u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \
66 sh -c $(VERIFY_COMMAND)
67
68# Openlane Makefile Targets
69BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
70.PHONY: $(BLOCKS)
71$(BLOCKS): %:
72 cd openlane && $(MAKE) $*
73
74# Install caravel
75.PHONY: install
76install:
77 @echo "Installing $(CARAVEL_NAME).."
78 @git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT)
79
80# Create symbolic links to caravel's main files
81.PHONY: simlink
82simlink: check-caravel
83### Symbolic links relative path to $CARAVEL_ROOT
84 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
85 mkdir -p openlane
86 cd openlane &&\
87 ln -sf $(MAKEFILE_PATH) Makefile
88
89# Update Caravel
90.PHONY: update_caravel
91update_caravel: check-caravel
92 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
93
94# Uninstall Caravel
95.PHONY: uninstall
96uninstall:
97 rm -rf $(CARAVEL_ROOT)
98
99# Install Openlane
100.PHONY: openlane
101openlane:
102 cd openlane && $(MAKE) openlane
103
104# Install Pre-check
105# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
106.PHONY: precheck
107precheck:
108 @git clone --depth=1 --branch $(MPW_TAG) https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
109 @docker pull efabless/mpw_precheck:latest
110
111.PHONY: run-precheck
112run-precheck: check-pdk check-precheck
113 $(eval INPUT_DIRECTORY := $(shell pwd))
114 cd $(PRECHECK_ROOT) && \
115 docker run -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) \
116 -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) \
117 -v $(PDK_ROOT):$(PDK_ROOT) \
118 -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) \
119 -e PDK_PATH=$(PDK_ROOT)/$(PDK) \
120 -e PDK_ROOT=$(PDK_ROOT) \
121 -e PDKPATH=$(PDKPATH) \
122 -u $(shell id -u $(USER)):$(shell id -g $(USER)) \
123 efabless/mpw_precheck:latest bash -c "cd $(PRECHECK_ROOT) ; python3 mpw_precheck.py --input_directory $(INPUT_DIRECTORY) --pdk_path $(PDK_ROOT)/$(PDK)"
124
125# Clean
126.PHONY: clean
127clean:
128 cd ./verilog/dv/ && \
129 $(MAKE) -j$(THREADS) clean
130
131check-caravel:
132 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
133 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
134 exit 1; \
135 fi
136
137check-precheck:
138 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
139 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
140 exit 1; \
141 fi
142
143check-pdk:
144 @if [ ! -d "$(PDK_ROOT)" ]; then \
145 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
146 exit 1; \
147 fi
148
149.PHONY: help
150help:
151 cd $(CARAVEL_ROOT) && $(MAKE) help
152 @$(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 '^$@$$'