manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 1 | # 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 | |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 17 | CARAVEL_ROOT?=$(PWD)/caravel |
manarabdelaty | 2632315 | 2021-09-16 23:11:34 +0200 | [diff] [blame] | 18 | PRECHECK_ROOT?=${HOME}/mpw_precheck |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 19 | SIM ?= RTL |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 20 | |
| 21 | # Install lite version of caravel, (1): caravel-lite, (0): caravel |
| 22 | CARAVEL_LITE?=1 |
| 23 | |
| 24 | ifeq ($(CARAVEL_LITE),1) |
| 25 | CARAVEL_NAME := caravel-lite |
Jeff DiCorpo | 2a3c943 | 2021-12-17 13:40:34 -0800 | [diff] [blame] | 26 | CARAVEL_REPO := https://github.com/efabless/caravel-lite |
Donn | e2c388a | 2022-02-03 18:14:12 +0000 | [diff] [blame] | 27 | CARAVEL_TAG := 'mpw-5a' |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 28 | else |
| 29 | CARAVEL_NAME := caravel |
Jeff DiCorpo | 2a3c943 | 2021-12-17 13:40:34 -0800 | [diff] [blame] | 30 | CARAVEL_REPO := https://github.com/efabless/caravel |
Donn | e2c388a | 2022-02-03 18:14:12 +0000 | [diff] [blame] | 31 | CARAVEL_TAG := 'mpw-5a' |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 32 | endif |
| 33 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 34 | |
| 35 | # Include Caravel Makefile Targets |
manarabdelaty | 2632315 | 2021-09-16 23:11:34 +0200 | [diff] [blame] | 36 | .PHONY: % : check-caravel |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 37 | %: |
manarabdelaty | 2632315 | 2021-09-16 23:11:34 +0200 | [diff] [blame] | 38 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@ |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 39 | |
| 40 | # Verify Target for running simulations |
| 41 | .PHONY: verify |
| 42 | verify: |
| 43 | cd ./verilog/dv/ && \ |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 44 | export SIM=${SIM} && \ |
| 45 | $(MAKE) -j$(THREADS) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 46 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 47 | # Install DV setup |
| 48 | .PHONY: simenv |
| 49 | simenv: |
| 50 | docker pull efabless/dv_setup:latest |
| 51 | |
| 52 | PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d) |
| 53 | DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv)) |
| 54 | TARGET_PATH=$(shell pwd) |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 55 | VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make" |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 56 | $(DV_PATTERNS): verify-% : ./verilog/dv/% |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 57 | docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \ |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 58 | -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \ |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 59 | -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \ |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 60 | -e CARAVEL_ROOT=${CARAVEL_ROOT} \ |
| 61 | -u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \ |
| 62 | sh -c $(VERIFY_COMMAND) |
| 63 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 64 | # Openlane Makefile Targets |
| 65 | BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d) |
| 66 | .PHONY: $(BLOCKS) |
manarabdelaty | 5088e75 | 2021-04-22 02:18:49 +0200 | [diff] [blame] | 67 | $(BLOCKS): %: |
manarabdelaty | a89da3c | 2021-09-20 21:48:00 +0200 | [diff] [blame] | 68 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && cd openlane && $(MAKE) $* |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 69 | |
| 70 | # Install caravel |
| 71 | .PHONY: install |
| 72 | install: |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 73 | @echo "Installing $(CARAVEL_NAME).." |
jeffdi | ad73551 | 2021-12-16 11:19:07 -0800 | [diff] [blame] | 74 | @git clone -b $(CARAVEL_TAG) $(CARAVEL_REPO) $(CARAVEL_ROOT) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 75 | |
| 76 | # Create symbolic links to caravel's main files |
| 77 | .PHONY: simlink |
| 78 | simlink: check-caravel |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 79 | ### 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)) |
manarabdelaty | e542bdf | 2021-04-20 11:15:40 +0200 | [diff] [blame] | 82 | mkdir -p openlane |
| 83 | mkdir -p openlane/user_project_wrapper |
| 84 | cd openlane &&\ |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 85 | ln -sf $(MAKEFILE_PATH) Makefile |
manarabdelaty | e542bdf | 2021-04-20 11:15:40 +0200 | [diff] [blame] | 86 | cd openlane/user_project_wrapper &&\ |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 87 | ln -sf $(PIN_CFG_PATH) pin_order.cfg |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 88 | |
| 89 | # Update Caravel |
| 90 | .PHONY: update_caravel |
| 91 | update_caravel: check-caravel |
jeffdi | 298918f | 2021-12-16 11:15:44 -0800 | [diff] [blame] | 92 | cd $(CARAVEL_ROOT)/ && git checkout $(CARAVEL_TAG) && git pull |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 93 | |
| 94 | # Uninstall Caravel |
| 95 | .PHONY: uninstall |
| 96 | uninstall: |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 97 | rm -rf $(CARAVEL_ROOT) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 98 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 99 | # Install Openlane |
| 100 | .PHONY: openlane |
| 101 | openlane: |
| 102 | cd openlane && $(MAKE) openlane |
| 103 | |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 104 | # Install Pre-check |
| 105 | # Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>" |
| 106 | .PHONY: precheck |
| 107 | precheck: |
a-omla | e14a684 | 2022-01-28 19:49:42 +0200 | [diff] [blame] | 108 | @git clone --depth=1 --branch mpw-5 https://github.com/efabless/mpw_precheck.git $(PRECHECK_ROOT) |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 109 | @docker pull efabless/mpw_precheck:latest |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 110 | |
| 111 | .PHONY: run-precheck |
| 112 | run-precheck: check-precheck check-pdk check-caravel |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 113 | $(eval INPUT_DIRECTORY := $(shell pwd)) |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 114 | cd $(PRECHECK_ROOT) && \ |
a-omla | 5e1f9c7 | 2022-01-28 19:46:02 +0200 | [diff] [blame] | 115 | 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)" |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 117 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 118 | # Clean |
| 119 | .PHONY: clean |
| 120 | clean: |
| 121 | cd ./verilog/dv/ && \ |
| 122 | $(MAKE) -j$(THREADS) clean |
| 123 | |
| 124 | check-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 DiCorpo | fb944f9 | 2021-04-20 00:40:50 +0000 | [diff] [blame] | 128 | fi |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 129 | |
| 130 | check-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 | |
| 136 | check-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; \ |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 140 | fi |
| 141 | |
| 142 | .PHONY: help |
| 143 | help: |
| 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 '^$@$$' |