blob: 60065654fdd5fa53b7b1851f24081855b4ffb554 [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
Russell L Friesenhahn2b4bd6b2021-04-21 16:37:08 -050026 CARAVEL_COMMIT := main
manarabdelatyb41301c2021-04-19 23:30:35 +020027else
28 CARAVEL_NAME := caravel
29 CARAVEL_REPO := https://github.com/efabless/caravel
Russell L Friesenhahn2b4bd6b2021-04-21 16:37:08 -050030 CARAVEL_COMMIT := master
manarabdelatyb41301c2021-04-19 23:30:35 +020031endif
32
33# Install caravel as submodule, (1): submodule, (0): clone
34SUBMODULE?=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
43verify:
44 cd ./verilog/dv/ && \
manarabdelaty340cc4a2021-04-20 18:28:22 +020045 export SIM=${SIM} && \
46 $(MAKE) -j$(THREADS)
manarabdelatyb41301c2021-04-19 23:30:35 +020047
manarabdelaty340cc4a2021-04-20 18:28:22 +020048# Install DV setup
49.PHONY: simenv
50simenv:
51 docker pull efabless/dv_setup:latest
52
53PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
54DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv))
55TARGET_PATH=$(shell pwd)
56PDK_PATH=${PDK_ROOT}/sky130A
57VERIFY_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
manarabdelatyb41301c2021-04-19 23:30:35 +020066# Openlane Makefile Targets
67BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
68.PHONY: $(BLOCKS)
manarabdelaty5088e752021-04-22 02:18:49 +020069$(BLOCKS): %:
manarabdelatyb41301c2021-04-19 23:30:35 +020070 cd openlane && $(MAKE) $*
71
72# Install caravel
73.PHONY: install
74install:
75ifeq ($(SUBMODULE),1)
76 @echo "Installing $(CARAVEL_NAME) as a submodule.."
manarabdelatyac234ea2021-04-20 13:16:11 +020077 @if [ ! -d $(CARAVEL_ROOT) ]; then git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_ROOT); fi
Jeff DiCorpoa2af4232021-04-20 01:23:54 +000078 @git submodule update --init
Russell L Friesenhahn2b4bd6b2021-04-21 16:37:08 -050079 @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_HASH)
manarabdelatyb41301c2021-04-19 23:30:35 +020080 $(MAKE) simlink
81else
82 @echo "Installing $(CARAVEL_NAME).."
83 @git clone $(CARAVEL_REPO) $(CARAVEL_ROOT)
Russell L Friesenhahn2b4bd6b2021-04-21 16:37:08 -050084 @cd $(CARAVEL_ROOT); git checkout $(CARAVEL_HASH)
manarabdelatyb41301c2021-04-19 23:30:35 +020085endif
86
87# Create symbolic links to caravel's main files
88.PHONY: simlink
89simlink: check-caravel
manarabdelatye542bdf2021-04-20 11:15:40 +020090 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
manarabdelatyb41301c2021-04-19 23:30:35 +020096
97# Update Caravel
98.PHONY: update_caravel
99update_caravel: check-caravel
Jeff DiCorpoa2af4232021-04-20 01:23:54 +0000100ifeq ($(SUBMODULE),1)
101 @git submodule update --init
manarabdelatyb41301c2021-04-19 23:30:35 +0200102else
103 cd $(CARAVEL_ROOT)/ && \
Russell L Friesenhahn54d82152021-04-21 16:38:35 -0500104 git checkout $(CARAVEL_COMMIT) && \
manarabdelatyb41301c2021-04-19 23:30:35 +0200105 git pull
106endif
107
108# Uninstall Caravel
109.PHONY: uninstall
110uninstall:
111ifeq ($(SUBMODULE),1)
112 git submodule deinit -f $(CARAVEL_ROOT)
Russell L Friesenhahn5ac961e2021-04-21 16:39:04 -0500113 sed -ie '/\[submodule \"caravel\"\]/,/\url =/d' .gitmodules
manarabdelatyb41301c2021-04-19 23:30:35 +0200114 rm -rf .git/modules/$(CARAVEL_NAME)
115 git rm -f $(CARAVEL_ROOT)
116else
117 rm -rf $(CARAVEL_ROOT)
118endif
119
manarabdelaty340cc4a2021-04-20 18:28:22 +0200120# Install Openlane
121.PHONY: openlane
122openlane:
123 cd openlane && $(MAKE) openlane
124
manarabdelatyb41301c2021-04-19 23:30:35 +0200125# Clean
126.PHONY: clean
127clean:
128 cd ./verilog/dv/ && \
129 $(MAKE) -j$(THREADS) clean
130
131check-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 DiCorpofb944f92021-04-20 00:40:50 +0000135 fi