# SPDX-FileCopyrightText: 2020 Efabless Corporation
|
# SPDX-FileCopyrightText: 2020 Efabless Corporation
|
#
|
#
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
#
|
#
|
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
#
|
#
|
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
# limitations under the License.
|
# limitations under the License.
|
#
|
#
|
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
CARAVEL_ROOT?=$(PWD)/caravel
|
CARAVEL_ROOT?=$(PWD)/caravel
|
PRECHECK_ROOT?=${HOME}/open_mpw_precheck
|
PRECHECK_ROOT?=${HOME}/open_mpw_precheck
|
SIM ?= RTL
|
SIM ?= RTL
|
|
|
# Install lite version of caravel, (1): caravel-lite, (0): caravel
|
# Install lite version of caravel, (1): caravel-lite, (0): caravel
|
CARAVEL_LITE?=1
|
CARAVEL_LITE?=1
|
|
|
ifeq ($(CARAVEL_LITE),1)
|
ifeq ($(CARAVEL_LITE),1)
|
CARAVEL_NAME := caravel-lite
|
CARAVEL_NAME := caravel-lite
|
CARAVEL_REPO := https://github.com/efabless/caravel-lite
|
CARAVEL_REPO := https://github.com/efabless/caravel-lite
|
CARAVEL_BRANCH := main
|
CARAVEL_BRANCH := main
|
else
|
else
|
CARAVEL_NAME := caravel
|
CARAVEL_NAME := caravel
|
CARAVEL_REPO := https://github.com/efabless/caravel
|
CARAVEL_REPO := https://github.com/efabless/caravel
|
CARAVEL_BRANCH := master
|
CARAVEL_BRANCH := master
|
endif
|
endif
|
|
|
# Install caravel as submodule, (1): submodule, (0): clone
|
# Install caravel as submodule, (1): submodule, (0): clone
|
SUBMODULE?=1
|
SUBMODULE?=1
|
|
|
# Include Caravel Makefile Targets
|
# Include Caravel Makefile Targets
|
.PHONY: %
|
.PHONY: %
|
%:
|
%:
|
$(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
|
$(MAKE) -f $(CARAVEL_ROOT)/Makefile $@
|
|
|
# Verify Target for running simulations
|
# Verify Target for running simulations
|
.PHONY: verify
|
.PHONY: verify
|
verify:
|
verify:
|
cd ./verilog/dv/ && \
|
cd ./verilog/dv/ && \
|
export SIM=${SIM} && \
|
export SIM=${SIM} && \
|
$(MAKE) -j$(THREADS)
|
$(MAKE) -j$(THREADS)
|
|
|
# Install DV setup
|
# Install DV setup
|
.PHONY: simenv
|
.PHONY: simenv
|
simenv:
|
simenv:
|
docker pull efabless/dv_setup:latest
|
docker pull efabless/dv_setup:latest
|
|
|
PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
|
PATTERNS=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
|
DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv))
|
DV_PATTERNS = $(foreach dv, $(PATTERNS), verify-$(dv))
|
TARGET_PATH=$(shell pwd)
|
TARGET_PATH=$(shell pwd)
|
PDK_PATH=${PDK_ROOT}/sky130A
|
PDK_PATH=${PDK_ROOT}/sky130A
|
VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
|
#dinesh-a: iverilog version inside the docker is not able to compile the rtl code
|
|
# So We are running upto hex file generation inside docker and iverilog outside the docker
|
|
#VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make"
|
|
VERIFY_COMMAND="cd ${TARGET_PATH}/verilog/dv/$* && export SIM=${SIM} && make hex"
|
$(DV_PATTERNS): verify-% : ./verilog/dv/%
|
$(DV_PATTERNS): verify-% : ./verilog/dv/%
|
docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_PATH}:${PDK_PATH} \
|
docker run -v ${TARGET_PATH}:${TARGET_PATH} -v ${PDK_PATH}:${PDK_PATH} \
|
-v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
|
-v ${CARAVEL_ROOT}:${CARAVEL_ROOT} \
|
-e TARGET_PATH=${TARGET_PATH} -e PDK_PATH=${PDK_PATH} \
|
-e TARGET_PATH=${TARGET_PATH} -e PDK_PATH=${PDK_PATH} \
|
-e CARAVEL_ROOT=${CARAVEL_ROOT} \
|
-e CARAVEL_ROOT=${CARAVEL_ROOT} \
|
-u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \
|
-u $(id -u $$USER):$(id -g $$USER) efabless/dv_setup:latest \
|
sh -c $(VERIFY_COMMAND)
|
sh -c $(VERIFY_COMMAND)
|
|
cd ${TARGET_PATH}/verilog/dv/$* && $(MAKE) all
|
|
|
# Openlane Makefile Targets
|
# Openlane Makefile Targets
|
BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
|
BLOCKS = $(shell cd openlane && find * -maxdepth 0 -type d)
|
.PHONY: $(BLOCKS)
|
.PHONY: $(BLOCKS)
|
$(BLOCKS): %:
|
$(BLOCKS): %:
|
cd openlane && $(MAKE) $*
|
cd openlane && $(MAKE) $*
|
|
|
# Install caravel
|
# Install caravel
|
.PHONY: install
|
.PHONY: install
|
install:
|
install:
|
ifeq ($(SUBMODULE),1)
|
ifeq ($(SUBMODULE),1)
|
@echo "Installing $(CARAVEL_NAME) as a submodule.."
|
@echo "Installing $(CARAVEL_NAME) as a submodule.."
|
# Convert CARAVEL_ROOT to relative path because .gitmodules doesn't accept '/'
|
# Convert CARAVEL_ROOT to relative path because .gitmodules doesn't accept '/'
|
$(eval CARAVEL_PATH := $(shell realpath --relative-to=$(shell pwd) $(CARAVEL_ROOT)))
|
$(eval CARAVEL_PATH := $(shell realpath --relative-to=$(shell pwd) $(CARAVEL_ROOT)))
|
@if [ ! -d $(CARAVEL_ROOT) ]; then git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_PATH); fi
|
@if [ ! -d $(CARAVEL_ROOT) ]; then git submodule add --name $(CARAVEL_NAME) $(CARAVEL_REPO) $(CARAVEL_PATH); fi
|
@git submodule update --init
|
@git submodule update --init
|
@cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH)
|
@cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH)
|
$(MAKE) simlink
|
$(MAKE) simlink
|
else
|
else
|
@echo "Installing $(CARAVEL_NAME).."
|
@echo "Installing $(CARAVEL_NAME).."
|
@git clone $(CARAVEL_REPO) $(CARAVEL_ROOT)
|
@git clone $(CARAVEL_REPO) $(CARAVEL_ROOT)
|
@cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH)
|
@cd $(CARAVEL_ROOT); git checkout $(CARAVEL_BRANCH)
|
endif
|
endif
|
|
|
# Create symbolic links to caravel's main files
|
# Create symbolic links to caravel's main files
|
.PHONY: simlink
|
.PHONY: simlink
|
simlink: check-caravel
|
simlink: check-caravel
|
### Symbolic links relative path to $CARAVEL_ROOT
|
### Symbolic links relative path to $CARAVEL_ROOT
|
$(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
|
$(eval MAKEFILE_PATH := $(shell realpath --relative-to=openlane $(CARAVEL_ROOT)/openlane/Makefile))
|
$(eval PIN_CFG_PATH := $(shell realpath --relative-to=openlane/user_project_wrapper $(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg))
|
$(eval PIN_CFG_PATH := $(shell realpath --relative-to=openlane/user_project_wrapper $(CARAVEL_ROOT)/openlane/user_project_wrapper_empty/pin_order.cfg))
|
mkdir -p openlane
|
mkdir -p openlane
|
mkdir -p openlane/user_project_wrapper
|
mkdir -p openlane/user_project_wrapper
|
cd openlane &&\
|
cd openlane &&\
|
ln -sf $(MAKEFILE_PATH) Makefile
|
ln -sf $(MAKEFILE_PATH) Makefile
|
cd openlane/user_project_wrapper &&\
|
cd openlane/user_project_wrapper &&\
|
ln -sf $(PIN_CFG_PATH) pin_order.cfg
|
ln -sf $(PIN_CFG_PATH) pin_order.cfg
|
|
|
# Update Caravel
|
# Update Caravel
|
.PHONY: update_caravel
|
.PHONY: update_caravel
|
update_caravel: check-caravel
|
update_caravel: check-caravel
|
ifeq ($(SUBMODULE),1)
|
ifeq ($(SUBMODULE),1)
|
@git submodule update --init --recursive
|
@git submodule update --init --recursive
|
cd $(CARAVEL_ROOT) && \
|
cd $(CARAVEL_ROOT) && \
|
git checkout $(CARAVEL_BRANCH) && \
|
git checkout $(CARAVEL_BRANCH) && \
|
git pull
|
git pull
|
else
|
else
|
cd $(CARAVEL_ROOT)/ && \
|
cd $(CARAVEL_ROOT)/ && \
|
git checkout $(CARAVEL_BRANCH) && \
|
git checkout $(CARAVEL_BRANCH) && \
|
git pull
|
git pull
|
endif
|
endif
|
|
|
# Uninstall Caravel
|
# Uninstall Caravel
|
.PHONY: uninstall
|
.PHONY: uninstall
|
uninstall:
|
uninstall:
|
ifeq ($(SUBMODULE),1)
|
ifeq ($(SUBMODULE),1)
|
git config -f .gitmodules --remove-section "submodule.$(CARAVEL_NAME)"
|
git config -f .gitmodules --remove-section "submodule.$(CARAVEL_NAME)"
|
git add .gitmodules
|
git add .gitmodules
|
git submodule deinit -f $(CARAVEL_ROOT)
|
git submodule deinit -f $(CARAVEL_ROOT)
|
git rm --cached $(CARAVEL_ROOT)
|
git rm --cached $(CARAVEL_ROOT)
|
rm -rf .git/modules/$(CARAVEL_NAME)
|
rm -rf .git/modules/$(CARAVEL_NAME)
|
rm -rf $(CARAVEL_ROOT)
|
rm -rf $(CARAVEL_ROOT)
|
else
|
else
|
rm -rf $(CARAVEL_ROOT)
|
rm -rf $(CARAVEL_ROOT)
|
endif
|
endif
|
|
|
# Install Openlane
|
# Install Openlane
|
.PHONY: openlane
|
.PHONY: openlane
|
openlane:
|
openlane:
|
cd openlane && $(MAKE) openlane
|
cd openlane && $(MAKE) openlane
|
|
|
# Install Pre-check
|
# Install Pre-check
|
# Default installs to the user home directory, override by "export PRECHECK_ROOT="
|
# Default installs to the user home directory, override by "export PRECHECK_ROOT="
|
.PHONY: precheck
|
.PHONY: precheck
|
precheck:
|
precheck:
|
@git clone https://github.com/efabless/open_mpw_precheck.git --depth=1 $(PRECHECK_ROOT)
|
@git clone https://github.com/efabless/open_mpw_precheck.git --depth=1 $(PRECHECK_ROOT)
|
@docker pull efabless/open_mpw_precheck:latest
|
@docker pull efabless/open_mpw_precheck:latest
|
|
|
.PHONY: run-precheck
|
.PHONY: run-precheck
|
run-precheck: check-precheck check-pdk check-caravel
|
run-precheck: check-precheck check-pdk check-caravel
|
$(eval TARGET_PATH := $(shell pwd))
|
$(eval TARGET_PATH := $(shell pwd))
|
cd $(PRECHECK_ROOT) && \
|
cd $(PRECHECK_ROOT) && \
|
docker run -v $(PRECHECK_ROOT):/usr/local/bin -v $(TARGET_PATH):$(TARGET_PATH) -v $(PDK_ROOT):$(PDK_ROOT) -v $(CARAVEL_ROOT):$(CARAVEL_ROOT) \
|
docker run -v $(PRECHECK_ROOT):/usr/local/bin -v $(TARGET_PATH):$(TARGET_PATH) -v $(PDK_ROOT):$(PDK_ROOT) -v $(CARAVEL_ROOT):$(CARAVEL_ROOT) \
|
-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) "
|
-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) "
|
|
|
# Install PDK using OL's Docker Image
|
# Install PDK using OL's Docker Image
|
.PHONY: pdk-nonnative
|
.PHONY: pdk-nonnative
|
pdk-nonnative: skywater-pdk skywater-library skywater-timing open_pdks
|
pdk-nonnative: skywater-pdk skywater-library skywater-timing open_pdks
|
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"
|
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"
|
|
|
# Clean
|
# Clean
|
.PHONY: clean
|
.PHONY: clean
|
clean:
|
clean:
|
cd ./verilog/dv/ && \
|
cd ./verilog/dv/ && \
|
$(MAKE) -j$(THREADS) clean
|
$(MAKE) -j$(THREADS) clean
|
|
|
check-caravel:
|
check-caravel:
|
@if [ ! -d "$(CARAVEL_ROOT)" ]; then \
|
@if [ ! -d "$(CARAVEL_ROOT)" ]; then \
|
echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
|
echo "Caravel Root: "$(CARAVEL_ROOT)" doesn't exists, please export the correct path before running make. "; \
|
exit 1; \
|
exit 1; \
|
fi
|
fi
|
|
|
check-precheck:
|
check-precheck:
|
@if [ ! -d "$(PRECHECK_ROOT)" ]; then \
|
@if [ ! -d "$(PRECHECK_ROOT)" ]; then \
|
echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
|
echo "Pre-check Root: "$(PRECHECK_ROOT)" doesn't exists, please export the correct path before running make. "; \
|
exit 1; \
|
exit 1; \
|
fi
|
fi
|
|
|
check-pdk:
|
check-pdk:
|
@if [ ! -d "$(PDK_ROOT)" ]; then \
|
@if [ ! -d "$(PDK_ROOT)" ]; then \
|
echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
|
echo "PDK Root: "$(PDK_ROOT)" doesn't exists, please export the correct path before running make. "; \
|
exit 1; \
|
exit 1; \
|
fi
|
fi
|
|
|
.PHONY: help
|
.PHONY: help
|
help:
|
help:
|
cd $(CARAVEL_ROOT) && $(MAKE) help
|
cd $(CARAVEL_ROOT) && $(MAKE) help
|
@$(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 '^$@$$'
|
@$(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 '^$@$$'
|
|
|