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 | 32b6e9f | 2021-04-20 10:49:37 +0200 | [diff] [blame] | 17 | CARAVEL_ROOT?=caravel |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 18 | SIM ?= RTL |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 19 | |
| 20 | # Install lite version of caravel, (1): caravel-lite, (0): caravel |
| 21 | CARAVEL_LITE?=1 |
| 22 | |
| 23 | ifeq ($(CARAVEL_LITE),1) |
| 24 | CARAVEL_NAME := caravel-lite |
manarabdelaty | 9619ef1 | 2021-04-20 11:34:31 +0200 | [diff] [blame] | 25 | CARAVEL_REPO := https://github.com/efabless/caravel-lite |
Russell L Friesenhahn | 2b4bd6b | 2021-04-21 16:37:08 -0500 | [diff] [blame] | 26 | CARAVEL_COMMIT := main |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 27 | else |
| 28 | CARAVEL_NAME := caravel |
| 29 | CARAVEL_REPO := https://github.com/efabless/caravel |
Russell L Friesenhahn | 2b4bd6b | 2021-04-21 16:37:08 -0500 | [diff] [blame] | 30 | CARAVEL_COMMIT := master |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 31 | endif |
| 32 | |
| 33 | # Install caravel as submodule, (1): submodule, (0): clone |
| 34 | SUBMODULE?=1 |
| 35 | |
| 36 | # Include Caravel Makefile Targets |
| 37 | .PHONY: % |
| 38 | %: |
| 39 | $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@ |
| 40 | |
| 41 | # Verify Target for running simulations |
| 42 | .PHONY: verify |
| 43 | verify: |
| 44 | cd ./verilog/dv/ && \ |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 45 | export SIM=${SIM} && \ |
| 46 | $(MAKE) -j$(THREADS) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 47 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 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) |
| 56 | PDK_PATH=${PDK_ROOT}/sky130A |
| 57 | VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make" |
| 58 | $(DV_PATTERNS): verify-% : |
| 59 | docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_PATH}:${PDK_PATH} \ |
| 60 | -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \ |
| 61 | -e TARGET_PATH=${TARGET_PATH} -e PDK_PATH=${PDK_PATH} \ |
| 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 | ac234ea | 2021-04-20 13:16:11 +0200 | [diff] [blame] | 77 | @if [ ! -d $(CARAVEL_ROOT) ]; then git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_ROOT); fi |
Jeff DiCorpo | a2af423 | 2021-04-20 01:23:54 +0000 | [diff] [blame] | 78 | @git submodule update --init |
Russell L Friesenhahn | 2b4bd6b | 2021-04-21 16:37:08 -0500 | [diff] [blame] | 79 | @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_HASH) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 80 | $(MAKE) simlink |
| 81 | else |
| 82 | @echo "Installing $(CARAVEL_NAME).." |
| 83 | @git clone $(CARAVEL_REPO) $(CARAVEL_ROOT) |
Russell L Friesenhahn | 2b4bd6b | 2021-04-21 16:37:08 -0500 | [diff] [blame] | 84 | @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_HASH) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 85 | endif |
| 86 | |
| 87 | # Create symbolic links to caravel's main files |
| 88 | .PHONY: simlink |
| 89 | simlink: check-caravel |
manarabdelaty | e542bdf | 2021-04-20 11:15:40 +0200 | [diff] [blame] | 90 | mkdir -p openlane |
| 91 | mkdir -p openlane/user_project_wrapper |
| 92 | cd openlane &&\ |
| 93 | ln -sf ../$(CARAVEL_ROOT)/openlane/Makefile Makefile |
| 94 | cd openlane/user_project_wrapper &&\ |
| 95 | ln -sf ../../$(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg pin_order.cfg |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 96 | |
| 97 | # Update Caravel |
| 98 | .PHONY: update_caravel |
| 99 | update_caravel: check-caravel |
Jeff DiCorpo | a2af423 | 2021-04-20 01:23:54 +0000 | [diff] [blame] | 100 | ifeq ($(SUBMODULE),1) |
| 101 | @git submodule update --init |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 102 | else |
| 103 | cd $(CARAVEL_ROOT)/ && \ |
Russell L Friesenhahn | 54d8215 | 2021-04-21 16:38:35 -0500 | [diff] [blame] | 104 | git checkout $(CARAVEL_COMMIT) && \ |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 105 | git pull |
| 106 | endif |
| 107 | |
| 108 | # Uninstall Caravel |
| 109 | .PHONY: uninstall |
| 110 | uninstall: |
| 111 | ifeq ($(SUBMODULE),1) |
| 112 | git submodule deinit -f $(CARAVEL_ROOT) |
Russell L Friesenhahn | 5ac961e | 2021-04-21 16:39:04 -0500 | [diff] [blame] | 113 | sed -ie '/\[submodule \"caravel\"\]/,/\url =/d' .gitmodules |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 114 | rm -rf .git/modules/$(CARAVEL_NAME) |
| 115 | git rm -f $(CARAVEL_ROOT) |
| 116 | else |
| 117 | rm -rf $(CARAVEL_ROOT) |
| 118 | endif |
| 119 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame] | 120 | # Install Openlane |
| 121 | .PHONY: openlane |
| 122 | openlane: |
| 123 | cd openlane && $(MAKE) openlane |
| 124 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 125 | # Clean |
| 126 | .PHONY: clean |
| 127 | clean: |
| 128 | cd ./verilog/dv/ && \ |
| 129 | $(MAKE) -j$(THREADS) clean |
| 130 | |
| 131 | check-caravel: |
| 132 | @if [ ! -d "$(CARAVEL_ROOT)" ]; then \ |
| 133 | echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 134 | exit 1; \ |
Jeff DiCorpo | fb944f9 | 2021-04-20 00:40:50 +0000 | [diff] [blame] | 135 | fi |