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