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 |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 26 | else |
| 27 | CARAVEL_NAME := caravel |
| 28 | CARAVEL_REPO := https://github.com/efabless/caravel |
| 29 | endif |
| 30 | |
| 31 | # Install caravel as submodule, (1): submodule, (0): clone |
| 32 | SUBMODULE?=1 |
| 33 | |
| 34 | # Include Caravel Makefile Targets |
| 35 | .PHONY: % |
| 36 | %: |
| 37 | $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@ |
| 38 | |
| 39 | # Verify Target for running simulations |
| 40 | .PHONY: verify |
| 41 | verify: |
| 42 | cd ./verilog/dv/ && \ |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame^] | 43 | export SIM=${SIM} && \ |
| 44 | $(MAKE) -j$(THREADS) |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 45 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame^] | 46 | # Install DV setup |
| 47 | .PHONY: simenv |
| 48 | simenv: |
| 49 | docker pull efabless/dv_setup:latest |
| 50 | |
| 51 | PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d) |
| 52 | DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv)) |
| 53 | TARGET_PATH=$(shell pwd) |
| 54 | PDK_PATH=${PDK_ROOT}/sky130A |
| 55 | VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make" |
| 56 | $(DV_PATTERNS): verify-% : |
| 57 | docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_PATH}:${PDK_PATH} \ |
| 58 | -v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \ |
| 59 | -e TARGET_PATH=${TARGET_PATH} -e PDK_PATH=${PDK_PATH} \ |
| 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) |
| 67 | $(BLOCKS): |
| 68 | cd openlane && $(MAKE) $* |
| 69 | |
| 70 | # Install caravel |
| 71 | .PHONY: install |
| 72 | install: |
| 73 | ifeq ($(SUBMODULE),1) |
| 74 | @echo "Installing $(CARAVEL_NAME) as a submodule.." |
manarabdelaty | ac234ea | 2021-04-20 13:16:11 +0200 | [diff] [blame] | 75 | @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] | 76 | @git submodule update --init |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 77 | $(MAKE) simlink |
| 78 | else |
| 79 | @echo "Installing $(CARAVEL_NAME).." |
| 80 | @git clone $(CARAVEL_REPO) $(CARAVEL_ROOT) |
| 81 | endif |
| 82 | |
| 83 | # Create symbolic links to caravel's main files |
| 84 | .PHONY: simlink |
| 85 | simlink: check-caravel |
manarabdelaty | e542bdf | 2021-04-20 11:15:40 +0200 | [diff] [blame] | 86 | mkdir -p openlane |
| 87 | mkdir -p openlane/user_project_wrapper |
| 88 | cd openlane &&\ |
| 89 | ln -sf ../$(CARAVEL_ROOT)/openlane/Makefile Makefile |
| 90 | cd openlane/user_project_wrapper &&\ |
| 91 | 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] | 92 | |
| 93 | # Update Caravel |
| 94 | .PHONY: update_caravel |
| 95 | update_caravel: check-caravel |
Jeff DiCorpo | a2af423 | 2021-04-20 01:23:54 +0000 | [diff] [blame] | 96 | ifeq ($(SUBMODULE),1) |
| 97 | @git submodule update --init |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 98 | else |
| 99 | cd $(CARAVEL_ROOT)/ && \ |
| 100 | git checkout master && \ |
| 101 | git pull |
| 102 | endif |
| 103 | |
| 104 | # Uninstall Caravel |
| 105 | .PHONY: uninstall |
| 106 | uninstall: |
| 107 | ifeq ($(SUBMODULE),1) |
| 108 | git submodule deinit -f $(CARAVEL_ROOT) |
| 109 | rm -rf .git/modules/$(CARAVEL_NAME) |
| 110 | git rm -f $(CARAVEL_ROOT) |
| 111 | else |
| 112 | rm -rf $(CARAVEL_ROOT) |
| 113 | endif |
| 114 | |
manarabdelaty | 340cc4a | 2021-04-20 18:28:22 +0200 | [diff] [blame^] | 115 | # Install Openlane |
| 116 | .PHONY: openlane |
| 117 | openlane: |
| 118 | cd openlane && $(MAKE) openlane |
| 119 | |
manarabdelaty | b41301c | 2021-04-19 23:30:35 +0200 | [diff] [blame] | 120 | # Clean |
| 121 | .PHONY: clean |
| 122 | clean: |
| 123 | cd ./verilog/dv/ && \ |
| 124 | $(MAKE) -j$(THREADS) clean |
| 125 | |
| 126 | check-caravel: |
| 127 | @if [ ! -d "$(CARAVEL_ROOT)" ]; then \ |
| 128 | echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \ |
| 129 | exit 1; \ |
Jeff DiCorpo | fb944f9 | 2021-04-20 00:40:50 +0000 | [diff] [blame] | 130 | fi |