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