blob: fa42afe2d8fef8e53203208e10355ce38af60071 [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
Marwan Abbas51a10962022-02-11 16:35:19 +020019MCW_ROOT?=$(PWD)/mgmt_core_wrapper
manarabdelaty340cc4a2021-04-20 18:28:22 +020020SIM ?= RTL
manarabdelatyb41301c2021-04-19 23:30:35 +020021
22# Install lite version of caravel, (1): caravel-lite, (0): caravel
23CARAVEL_LITE?=1
24
25ifeq ($(CARAVEL_LITE),1)
26 CARAVEL_NAME := caravel-lite
Jeff DiCorpo2a3c9432021-12-17 13:40:34 -080027 CARAVEL_REPO := https://github.com/efabless/caravel-lite
Donne2c388a2022-02-03 18:14:12 +000028 CARAVEL_TAG := 'mpw-5a'
manarabdelatyb41301c2021-04-19 23:30:35 +020029else
30 CARAVEL_NAME := caravel
Jeff DiCorpo2a3c9432021-12-17 13:40:34 -080031 CARAVEL_REPO := https://github.com/efabless/caravel
Donne2c388a2022-02-03 18:14:12 +000032 CARAVEL_TAG := 'mpw-5a'
manarabdelatyb41301c2021-04-19 23:30:35 +020033endif
34
manarabdelatyb41301c2021-04-19 23:30:35 +020035
36# Include Caravel Makefile Targets
manarabdelaty26323152021-09-16 23:11:34 +020037.PHONY: % : check-caravel
manarabdelatyb41301c2021-04-19 23:30:35 +020038%:
manarabdelaty26323152021-09-16 23:11:34 +020039 export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
manarabdelatyb41301c2021-04-19 23:30:35 +020040
41# Verify Target for running simulations
42.PHONY: verify
43verify:
44 cd ./verilog/dv/ && \
manarabdelaty340cc4a2021-04-20 18:28:22 +020045 export SIM=${SIM} && \
46 $(MAKE) -j$(THREADS)
manarabdelatyb41301c2021-04-19 23:30:35 +020047
manarabdelaty340cc4a2021-04-20 18:28:22 +020048# 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)
manarabdelaty340cc4a2021-04-20 18:28:22 +020056VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
manarabdelatyd8dd0102021-04-30 08:40:52 +020057$(DV_PATTERNS): verify-% : ./verilog/dv/%
manarabdelatyb6ce4422021-09-16 22:09:24 +020058 docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \
manarabdelaty340cc4a2021-04-20 18:28:22 +020059 -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
manarabdelatyb6ce4422021-09-16 22:09:24 +020060 -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \
manarabdelaty340cc4a2021-04-20 18:28:22 +020061 -e CARAVEL_ROOT=${CARAVEL_ROOT} \
Marwan Abbas51a10962022-02-11 16:35:19 +020062 -e MCW_ROOT=$(MCW_ROOT) \
manarabdelaty340cc4a2021-04-20 18:28:22 +020063 -u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \
64 sh -c $(VERIFY_COMMAND)
65
manarabdelatyb41301c2021-04-19 23:30:35 +020066# Openlane Makefile Targets
67BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
68.PHONY: $(BLOCKS)
manarabdelaty5088e752021-04-22 02:18:49 +020069$(BLOCKS): %:
manarabdelatya89da3c2021-09-20 21:48:00 +020070 export CARAVEL_ROOT=$(CARAVEL_ROOT) && cd openlane && $(MAKE) $*
manarabdelatyb41301c2021-04-19 23:30:35 +020071
72# Install caravel
73.PHONY: install
74install:
manarabdelatyb41301c2021-04-19 23:30:35 +020075 @echo "Installing $(CARAVEL_NAME).."
jeffdiad735512021-12-16 11:19:07 -080076 @git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT)
manarabdelatyb41301c2021-04-19 23:30:35 +020077
78# Create symbolic links to caravel's main files
79.PHONY: simlink
80simlink: check-caravel
manarabdelaty78c1b012021-04-23 17:12:54 +020081### Symbolic links relative path to $CARAVEL_ROOT
82 $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
83 $(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 +020084 mkdir -p openlane
85 mkdir -p openlane/user_project_wrapper
86 cd openlane &&\
manarabdelaty78c1b012021-04-23 17:12:54 +020087 ln -sf $(MAKEFILE_PATH) Makefile
manarabdelatye542bdf2021-04-20 11:15:40 +020088 cd openlane/user_project_wrapper &&\
manarabdelaty78c1b012021-04-23 17:12:54 +020089 ln -sf $(PIN_CFG_PATH) pin_order.cfg
manarabdelatyb41301c2021-04-19 23:30:35 +020090
91# Update Caravel
92.PHONY: update_caravel
93update_caravel: check-caravel
jeffdi298918f2021-12-16 11:15:44 -080094 cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull
manarabdelatyb41301c2021-04-19 23:30:35 +020095
96# Uninstall Caravel
97.PHONY: uninstall
98uninstall:
manarabdelaty78c1b012021-04-23 17:12:54 +020099 rm -rf $(CARAVEL_ROOT)
manarabdelatyb41301c2021-04-19 23:30:35 +0200100
manarabdelaty340cc4a2021-04-20 18:28:22 +0200101# Install Openlane
102.PHONY: openlane
103openlane:
104 cd openlane && $(MAKE) openlane
105
manarabdelaty78c1b012021-04-23 17:12:54 +0200106# Install Pre-check
107# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
108.PHONY: precheck
109precheck:
a-omlae14a6842022-01-28 19:49:42 +0200110 @git clone --depth=1 --branch mpw-5 https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT)
manarabdelatyb6ce4422021-09-16 22:09:24 +0200111 @docker pull efabless/mpw_precheck:latest
manarabdelaty78c1b012021-04-23 17:12:54 +0200112
113.PHONY: run-precheck
114run-precheck: check-precheck check-pdk check-caravel
manarabdelatyb6ce4422021-09-16 22:09:24 +0200115 $(eval INPUT_DIRECTORY := $(shell pwd))
manarabdelaty78c1b012021-04-23 17:12:54 +0200116 cd $(PRECHECK_ROOT) && \
a-omla5e1f9c72022-01-28 19:46:02 +0200117 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) \
118 -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 +0200119
manarabdelatyb41301c2021-04-19 23:30:35 +0200120# Clean
121.PHONY: clean
122clean:
123 cd ./verilog/dv/ && \
124 $(MAKE) -j$(THREADS) clean
125
126check-caravel:
127 @if [ ! -d "$(CARAVEL_ROOT)" ]; then \
128 echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
129 exit 1; \
Jeff DiCorpofb944f92021-04-20 00:40:50 +0000130 fi
manarabdelaty78c1b012021-04-23 17:12:54 +0200131
132check-precheck:
133 @if [ ! -d "$(PRECHECK_ROOT)" ]; then \
134 echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
135 exit 1; \
136 fi
137
138check-pdk:
139 @if [ ! -d "$(PDK_ROOT)" ]; then \
140 echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
141 exit 1; \
manarabdelatyd8dd0102021-04-30 08:40:52 +0200142 fi
143
144.PHONY: help
145help:
146 cd $(CARAVEL_ROOT) && $(MAKE) help
147 @$(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 '^$@$$'