blob: 6de652c3f5f0eb78eab9cb6fab190435c7b136f7 [file] [log] [blame]
manarabdelatyb41301c2021-04-19 23:30: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
manarabdelaty78c1b012021-04-23 17:12:54 +020017CARAVEL_ROOT?=$(PWD)/caravel
manarabdelaty26323152021-09-16 23:11:34 +020018PRECHECK_ROOT?=${HOME}/mpw_precheck
manarabdelaty340cc4a2021-04-20 18:28:22 +020019SIM ?= RTL
manarabdelatyb41301c2021-04-19 23:30:35 +020020
21# Install lite version of caravel, (1): caravel-lite, (0): caravel
22CARAVEL_LITE?=1
23
24ifeq ($(CARAVEL_LITE),1)
25 CARAVEL_NAME := caravel-lite
Jeff DiCorpo2a3c9432021-12-17 13:40:34 -080026 CARAVEL_REPO := https://github.com/efabless/caravel-lite
Donne2c388a2022-02-03 18:14:12 +000027 CARAVEL_TAG := 'mpw-5a'
manarabdelatyb41301c2021-04-19 23:30:35 +020028else
29 CARAVEL_NAME := caravel
Jeff DiCorpo2a3c9432021-12-17 13:40:34 -080030 CARAVEL_REPO := https://github.com/efabless/caravel
Donne2c388a2022-02-03 18:14:12 +000031 CARAVEL_TAG := 'mpw-5a'
manarabdelatyb41301c2021-04-19 23:30:35 +020032endif
33
manarabdelatyb41301c2021-04-19 23:30:35 +020034
35# Include Caravel Makefile Targets
manarabdelaty26323152021-09-16 23:11:34 +020036.PHONY: % : check-caravel
manarabdelatyb41301c2021-04-19 23:30:35 +020037%:
manarabdelaty26323152021-09-16 23:11:34 +020038 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
manarabdelatyb41301c2021-04-19 23:30:35 +020039
40# Verify Target for running simulations
41.PHONY: verify
42verify:
43 cd ./verilog/dv/ && \
manarabdelaty340cc4a2021-04-20 18:28:22 +020044 export SIM=${SIM} && \
45 $(MAKE) -j$(THREADS)
manarabdelatyb41301c2021-04-19 23:30:35 +020046
manarabdelaty340cc4a2021-04-20 18:28:22 +020047# Install DV setup
48.PHONY: simenv
49simenv:
50 docker pull efabless/dv_setup:latest
51
52PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
53DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv))
54TARGET_PATH=$(shell pwd)
manarabdelaty340cc4a2021-04-20 18:28:22 +020055VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
manarabdelatyd8dd0102021-04-30 08:40:52 +020056$(DV_PATTERNS): verify-% : ./verilog/dv/%
manarabdelatyb6ce4422021-09-16 22:09:24 +020057 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \
manarabdelaty340cc4a2021-04-20 18:28:22 +020058 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
manarabdelatyb6ce4422021-09-16 22:09:24 +020059 -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \
manarabdelaty340cc4a2021-04-20 18:28:22 +020060 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
61 -u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \
62 sh -c $(VERIFY_COMMAND)
63
manarabdelatyb41301c2021-04-19 23:30:35 +020064# Openlane Makefile Targets
65BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
66.PHONY: $(BLOCKS)
manarabdelaty5088e752021-04-22 02:18:49 +020067$(BLOCKS): %:
manarabdelatya89da3c2021-09-20 21:48:00 +020068 export CARAVEL_ROOT=$(CARAVEL_ROOT) && cd openlane && $(MAKE) $*
manarabdelatyb41301c2021-04-19 23:30:35 +020069
70# Install caravel
71.PHONY: install
72install:
manarabdelatyb41301c2021-04-19 23:30:35 +020073 @echo "Installing $(CARAVEL_NAME).."
jeffdiad735512021-12-16 11:19:07 -080074 @git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT)
manarabdelatyb41301c2021-04-19 23:30:35 +020075
76# Create symbolic links to caravel's main files
77.PHONY: simlink
78simlink: check-caravel
manarabdelaty78c1b012021-04-23 17:12:54 +020079### Symbolic links relative path to $CARAVEL_ROOT
80 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
81 $(eval PIN_CFG_PATH := $(shell realpath --relative-to=openlane/user_project_wrapper $(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg))
manarabdelatye542bdf2021-04-20 11:15:40 +020082 mkdir -p openlane
83 mkdir -p openlane/user_project_wrapper
84 cd openlane &&\
manarabdelaty78c1b012021-04-23 17:12:54 +020085 ln -sf $(MAKEFILE_PATH) Makefile
manarabdelatye542bdf2021-04-20 11:15:40 +020086 cd openlane/user_project_wrapper &&\
manarabdelaty78c1b012021-04-23 17:12:54 +020087 ln -sf $(PIN_CFG_PATH) pin_order.cfg
manarabdelatyb41301c2021-04-19 23:30:35 +020088
89# Update Caravel
90.PHONY: update_caravel
91update_caravel: check-caravel
jeffdi298918f2021-12-16 11:15:44 -080092 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
manarabdelatyb41301c2021-04-19 23:30:35 +020093
94# Uninstall Caravel
95.PHONY: uninstall
96uninstall:
manarabdelaty78c1b012021-04-23 17:12:54 +020097 rm -rf $(CARAVEL_ROOT)
manarabdelatyb41301c2021-04-19 23:30:35 +020098
manarabdelaty340cc4a2021-04-20 18:28:22 +020099# Install Openlane
100.PHONY: openlane
101openlane:
102 cd openlane && $(MAKE) openlane
103
manarabdelaty78c1b012021-04-23 17:12:54 +0200104# Install Pre-check
105# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
106.PHONY: precheck
107precheck:
a-omlae14a6842022-01-28 19:49:42 +0200108 @git clone --depth=1 --branch mpw-5 https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
manarabdelatyb6ce4422021-09-16 22:09:24 +0200109 @docker pull efabless/mpw_precheck:latest
manarabdelaty78c1b012021-04-23 17:12:54 +0200110
111.PHONY: run-precheck
112run-precheck: check-precheck check-pdk check-caravel
manarabdelatyb6ce4422021-09-16 22:09:24 +0200113 $(eval INPUT_DIRECTORY := $(shell pwd))
manarabdelaty78c1b012021-04-23 17:12:54 +0200114 cd $(PRECHECK_ROOT) && \
a-omla5e1f9c72022-01-28 19:46:02 +0200115 docker run -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) -e PDK_ROOT=$(PDK_ROOT) -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) -v $(PDK_ROOT):$(PDK_ROOT) \
116 -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)"
manarabdelatyd8dd0102021-04-30 08:40:52 +0200117
manarabdelatyb41301c2021-04-19 23:30:35 +0200118# Clean
119.PHONY: clean
120clean:
121 cd ./verilog/dv/ && \
122 $(MAKE) -j$(THREADS) clean
123
124check-caravel:
125 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
126 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
127 exit 1; \
Jeff DiCorpofb944f92021-04-20 00:40:50 +0000128 fi
manarabdelaty78c1b012021-04-23 17:12:54 +0200129
130check-precheck:
131 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
132 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
133 exit 1; \
134 fi
135
136check-pdk:
137 @if [ ! -d "$(PDK_ROOT)" ]; then \
138 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
139 exit 1; \
manarabdelatyd8dd0102021-04-30 08:40:52 +0200140 fi
141
142.PHONY: help
143help:
144 cd $(CARAVEL_ROOT) && $(MAKE) help
145 @$(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 '^$@$$'