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 |
manarabdelaty | 9619ef1 | 2021-04-20 11:34:31 +0200 | [diff] [blame] | 26 | CARAVEL_REPO := https://github.com/efabless/caravel-lite |
Russell L Friesenhahn | 42af8dc | 2021-04-27 22:03:21 -0500 | [diff] [blame] | 27 | CARAVEL_BRANCH := main |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 28 | else |
| 29 | CARAVEL_NAME := caravel |
| 30 | CARAVEL_REPO := https://github.com/efabless/caravel |
Russell L Friesenhahn | 42af8dc | 2021-04-27 22:03:21 -0500 | [diff] [blame] | 31 | CARAVEL_BRANCH := master |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 32 | endif |
| 33 | |
| 34 | # Install caravel as submodule, (1): submodule, (0): clone |
| 35 | SUBMODULE?=1 |
| 36 | |
| 37 | # Include Caravel Makefile Targets |
manarabdelaty | 2632315 | 2021-09-16 23:11:34 +0200 | [diff] [blame] | 38 | .PHONY: % : check-caravel |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 39 | %: |
manarabdelaty | 2632315 | 2021-09-16 23:11:34 +0200 | [diff] [blame] | 40 | export CARAVEL_ROOT=$(CARAVEL_ROOT) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@ |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 41 | |
| 42 | # Verify Target for running simulations |
| 43 | .PHONY: verify |
| 44 | verify: |
| 45 | cd ./verilog/dv/ && \ |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 46 | export SIM=${SIM} && \ |
| 47 | $(MAKE) -j$(THREADS) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 48 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 49 | # Install DV setup |
| 50 | .PHONY: simenv |
| 51 | simenv: |
| 52 | docker pull efabless/dv_setup:latest |
| 53 | |
| 54 | PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d) |
| 55 | DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv)) |
| 56 | TARGET_PATH=$(shell pwd) |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 57 | VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make" |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 58 | $(DV_PATTERNS): verify-% : ./verilog/dv/% |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 59 | docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_ROOT}:${PDK_ROOT} \ |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 60 | -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \ |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 61 | -e TARGET_PATH=${TARGET_PATH} -e PDK_ROOT=${PDK_ROOT} \ |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 62 | -e CARAVEL_ROOT=${CARAVEL_ROOT} \ |
| 63 | -u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \ |
| 64 | sh -c $(VERIFY_COMMAND) |
| 65 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 66 | # Openlane Makefile Targets |
| 67 | BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d) |
| 68 | .PHONY: $(BLOCKS) |
manarabdelaty | 5088e75 | 2021-04-22 02:18:49 +0200 | [diff] [blame] | 69 | $(BLOCKS): %: |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 70 | cd openlane && $(MAKE) $* |
| 71 | |
| 72 | # Install caravel |
| 73 | .PHONY: install |
| 74 | install: |
| 75 | ifeq ($(SUBMODULE),1) |
| 76 | @echo "Installing $(CARAVEL_NAME) as a submodule.." |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 77 | # Convert CARAVEL_ROOT to relative path because .gitmodules doesn't accept '/' |
| 78 | $(eval CARAVEL_PATH := $(shell realpath --relative-to=$(shell pwd) $(CARAVEL_ROOT))) |
| 79 | @if [ ! -d $(CARAVEL_ROOT) ]; then git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_PATH); fi |
Jeff DiCorpo | a2af423 | 2021-04-20 01:23:54 +0000 | [diff] [blame] | 80 | @git submodule update --init |
Russell L Friesenhahn | 42af8dc | 2021-04-27 22:03:21 -0500 | [diff] [blame] | 81 | @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 82 | $(MAKE) simlink |
| 83 | else |
| 84 | @echo "Installing $(CARAVEL_NAME).." |
| 85 | @git clone $(CARAVEL_REPO) $(CARAVEL_ROOT) |
Russell L Friesenhahn | 42af8dc | 2021-04-27 22:03:21 -0500 | [diff] [blame] | 86 | @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 87 | endif |
| 88 | |
| 89 | # Create symbolic links to caravel's main files |
| 90 | .PHONY: simlink |
| 91 | simlink: check-caravel |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 92 | ### Symbolic links relative path to $CARAVEL_ROOT |
| 93 | $(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile)) |
| 94 | $(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] | 95 | mkdir -p openlane |
| 96 | mkdir -p openlane/user_project_wrapper |
| 97 | cd openlane &&\ |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 98 | ln -sf $(MAKEFILE_PATH) Makefile |
manarabdelaty | e542bdf | 2021-04-20 11:15:40 +0200 | [diff] [blame] | 99 | cd openlane/user_project_wrapper &&\ |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 100 | ln -sf $(PIN_CFG_PATH) pin_order.cfg |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 101 | |
| 102 | # Update Caravel |
| 103 | .PHONY: update_caravel |
| 104 | update_caravel: check-caravel |
Jeff DiCorpo | a2af423 | 2021-04-20 01:23:54 +0000 | [diff] [blame] | 105 | ifeq ($(SUBMODULE),1) |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 106 | @git submodule update --init --recursive |
| 107 | cd $(CARAVEL_ROOT) && \ |
| 108 | git checkout $(CARAVEL_BRANCH) && \ |
| 109 | git pull |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 110 | else |
| 111 | cd $(CARAVEL_ROOT)/ && \ |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 112 | git checkout $(CARAVEL_BRANCH) && \ |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 113 | git pull |
| 114 | endif |
| 115 | |
| 116 | # Uninstall Caravel |
| 117 | .PHONY: uninstall |
| 118 | uninstall: |
| 119 | ifeq ($(SUBMODULE),1) |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 120 | git config -f .gitmodules --remove-section "submodule.$(CARAVEL_NAME)" |
| 121 | git add .gitmodules |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 122 | git submodule deinit -f $(CARAVEL_ROOT) |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 123 | git rm --cached $(CARAVEL_ROOT) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 124 | rm -rf .git/modules/$(CARAVEL_NAME) |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 125 | rm -rf $(CARAVEL_ROOT) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 126 | else |
| 127 | rm -rf $(CARAVEL_ROOT) |
| 128 | endif |
| 129 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 130 | # Install Openlane |
| 131 | .PHONY: openlane |
| 132 | openlane: |
| 133 | cd openlane && $(MAKE) openlane |
| 134 | |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 135 | # Install Pre-check |
| 136 | # Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>" |
| 137 | .PHONY: precheck |
| 138 | precheck: |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 139 | @git clone https://github.com/efabless/mpw_precheck.git --depth=1 $(PRECHECK_ROOT) |
| 140 | @docker pull efabless/mpw_precheck:latest |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 141 | |
| 142 | .PHONY: run-precheck |
| 143 | run-precheck: check-precheck check-pdk check-caravel |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 144 | $(eval INPUT_DIRECTORY := $(shell pwd)) |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 145 | cd $(PRECHECK_ROOT) && \ |
manarabdelaty | b6ce442 | 2021-09-16 22:09:24 +0200 | [diff] [blame] | 146 | docker run -e INPUT_DIRECTORY=$(INPUT_DIRECTORY) -e PDK_ROOT=$(PDK_ROOT) -e CARAVEL_ROOT=$(CARAVEL_ROOT) -v $(PRECHECK_ROOT):$(PRECHECK_ROOT) -v $(INPUT_DIRECTORY):$(INPUT_DIRECTORY) -v $(PDK_ROOT):$(PDK_ROOT) -v $(CARAVEL_ROOT):$(CARAVEL_ROOT) \ |
| 147 | -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) --caravel_root $(CARAVEL_ROOT)" |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 148 | |
| 149 | # Install PDK using OL's Docker Image |
| 150 | .PHONY: pdk-nonnative |
| 151 | pdk-nonnative: skywater-pdk skywater-library skywater-timing open_pdks |
| 152 | docker run --rm -v $(PDK_ROOT):$(PDK_ROOT) -v $(pwd):/user_project -v $(CARAVEL_ROOT):$(CARAVEL_ROOT) -e CARAVEL_ROOT=$(CARAVEL_ROOT) -e PDK_ROOT=$(PDK_ROOT) -u $(shell id -u $(USER)):$(shell id -g $(USER)) efabless/openlane:current sh -c "cd $(CARAVEL_ROOT); make build-pdk; make gen-sources" |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 153 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 154 | # Clean |
| 155 | .PHONY: clean |
| 156 | clean: |
| 157 | cd ./verilog/dv/ && \ |
| 158 | $(MAKE) -j$(THREADS) clean |
| 159 | |
| 160 | check-caravel: |
| 161 | @if [ ! -d "$(CARAVEL_ROOT)" ]; then \ |
| 162 | echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 163 | exit 1; \ |
Jeff DiCorpo | fb944f9 | 2021-04-20 00:40:50 +0000 | [diff] [blame] | 164 | fi |
manarabdelaty | 78c1b01 | 2021-04-23 17:12:54 +0200 | [diff] [blame] | 165 | |
| 166 | check-precheck: |
| 167 | @if [ ! -d "$(PRECHECK_ROOT)" ]; then \ |
| 168 | echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 169 | exit 1; \ |
| 170 | fi |
| 171 | |
| 172 | check-pdk: |
| 173 | @if [ ! -d "$(PDK_ROOT)" ]; then \ |
| 174 | echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 175 | exit 1; \ |
manarabdelaty | d8dd010 | 2021-04-30 08:40:52 +0200 | [diff] [blame] | 176 | fi |
| 177 | |
| 178 | .PHONY: help |
| 179 | help: |
| 180 | cd $(CARAVEL_ROOT) && $(MAKE) help |
| 181 | @$(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 '^$@$$' |