blob: 16104a7f02c787dcae896f78561f512cd5a0e2e8 [file] [log] [blame]
manarabdelatyb41301c2021-04-19 23:30:35 +02001# 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
manarabdelaty32b6e9f2021-04-20 10:49:37 +020017CARAVEL_ROOT?=caravel
manarabdelaty340cc4a2021-04-20 18:28:22 +020018SIM ?= RTL
manarabdelatyb41301c2021-04-19 23:30:35 +020019
20# Install lite version of caravel, (1): caravel-lite, (0): caravel
21CARAVEL_LITE?=1
22
23ifeq ($(CARAVEL_LITE),1)
24 CARAVEL_NAME := caravel-lite
manarabdelaty9619ef12021-04-20 11:34:31 +020025 CARAVEL_REPO := https://github.com/efabless/caravel-lite
manarabdelatyb41301c2021-04-19 23:30:35 +020026else
27 CARAVEL_NAME := caravel
28 CARAVEL_REPO := https://github.com/efabless/caravel
29endif
30
31# Install caravel as submodule, (1): submodule, (0): clone
32SUBMODULE?=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
41verify:
42 cd ./verilog/dv/ && \
manarabdelaty340cc4a2021-04-20 18:28:22 +020043 export SIM=${SIM} && \
44 $(MAKE) -j$(THREADS)
manarabdelatyb41301c2021-04-19 23:30:35 +020045
manarabdelaty340cc4a2021-04-20 18:28:22 +020046# Install DV setup
47.PHONY: simenv
48simenv:
49 docker pull efabless/dv_setup:latest
50
51PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
52DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv))
53TARGET_PATH=$(shell pwd)
54PDK_PATH=${PDK_ROOT}/sky130A
55VERIFY_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
manarabdelatyb41301c2021-04-19 23:30:35 +020064# Openlane Makefile Targets
65BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
66.PHONY: $(BLOCKS)
67$(BLOCKS):
68 cd openlane && $(MAKE) $*
69
70# Install caravel
71.PHONY: install
72install:
73ifeq ($(SUBMODULE),1)
74 @echo "Installing $(CARAVEL_NAME) as a submodule.."
manarabdelatyac234ea2021-04-20 13:16:11 +020075 @if [ ! -d $(CARAVEL_ROOT) ]; then git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_ROOT); fi
Jeff DiCorpoa2af4232021-04-20 01:23:54 +000076 @git submodule update --init
manarabdelatyb41301c2021-04-19 23:30:35 +020077 $(MAKE) simlink
78else
79 @echo "Installing $(CARAVEL_NAME).."
80 @git clone $(CARAVEL_REPO) $(CARAVEL_ROOT)
81endif
82
83# Create symbolic links to caravel's main files
84.PHONY: simlink
85simlink: check-caravel
manarabdelatye542bdf2021-04-20 11:15:40 +020086 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
manarabdelatyb41301c2021-04-19 23:30:35 +020092
93# Update Caravel
94.PHONY: update_caravel
95update_caravel: check-caravel
Jeff DiCorpoa2af4232021-04-20 01:23:54 +000096ifeq ($(SUBMODULE),1)
97 @git submodule update --init
manarabdelatyb41301c2021-04-19 23:30:35 +020098else
99 cd $(CARAVEL_ROOT)/ && \
100 git checkout master && \
101 git pull
102endif
103
104# Uninstall Caravel
105.PHONY: uninstall
106uninstall:
107ifeq ($(SUBMODULE),1)
108 git submodule deinit -f $(CARAVEL_ROOT)
109 rm -rf .git/modules/$(CARAVEL_NAME)
110 git rm -f $(CARAVEL_ROOT)
111else
112 rm -rf $(CARAVEL_ROOT)
113endif
114
manarabdelaty340cc4a2021-04-20 18:28:22 +0200115# Install Openlane
116.PHONY: openlane
117openlane:
118 cd openlane && $(MAKE) openlane
119
manarabdelatyb41301c2021-04-19 23:30:35 +0200120# Clean
121.PHONY: clean
122clean:
123 cd ./verilog/dv/ && \
124 $(MAKE) -j$(THREADS) clean
125
126check-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 DiCorpofb944f92021-04-20 00:40:50 +0000130 fi