Skip to content

Commit

Permalink
updated make setup and added comparing tools
Browse files Browse the repository at this point in the history
  • Loading branch information
marwaneltoukhy committed Nov 27, 2023
1 parent 25f10a2 commit 4c591d9
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 63 deletions.
83 changes: 28 additions & 55 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ export DISABLE_LVS?=0

export ROOTLESS

# ifeq ($(PDK),sky130A)
# SKYWATER_COMMIT=f70d8ca46961ff92719d8870a18a076370b85f6c
# export OPEN_PDKS_COMMIT?=78b7bc32ddb4b6f14f76883c2e2dc5b5de9d1cbc
# export OPENLANE_TAG?=2023.07.19-1
# MPW_TAG ?= mpw-9g

ifeq ($(CARAVEL_LITE),1)
CARAVEL_NAME := caravel-lite
CARAVEL_REPO := https://github.com/efabless/caravel-lite
Expand All @@ -57,25 +51,6 @@ else
CARAVEL_TAG := $(MPW_TAG)
endif

# endif

# ifeq ($(PDK),sky130B)
# SKYWATER_COMMIT=f70d8ca46961ff92719d8870a18a076370b85f6c
# export OPEN_PDKS_COMMIT?=78b7bc32ddb4b6f14f76883c2e2dc5b5de9d1cbc
# export OPENLANE_TAG?=2023.07.19-1
# MPW_TAG ?= mpw-9g

# ifeq ($(CARAVEL_LITE),1)
# CARAVEL_NAME := caravel-lite
# CARAVEL_REPO := https://github.com/efabless/caravel-lite
# CARAVEL_TAG := $(MPW_TAG)
# else
# CARAVEL_NAME := caravel
# CARAVEL_REPO := https://github.com/efabless/caravel
# CARAVEL_TAG := $(MPW_TAG)
# endif

# endif

ifeq ($(PDK),gf180mcuD)

Expand All @@ -90,20 +65,9 @@ ifeq ($(PDK),gf180mcuD)
endif

# Include Caravel Makefile Targets
.PHONY: % : check-caravel
%:
export CARAVEL_ROOT=$(CARAVEL_ROOT) && export MPW_TAG=$(MPW_TAG) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@

.PHONY: install
install:
if [ -d "$(CARAVEL_ROOT)" ]; then\
echo "Deleting exisiting $(CARAVEL_ROOT)" && \
rm -rf $(CARAVEL_ROOT) && sleep 2;\
fi
echo "Installing $(CARAVEL_NAME).."
@mkdir -p $(CARAVEL_ROOT)
cd $(CARAVEL_ROOT) && \
curl -L $(CARAVEL_REPO)/tarball/$(CARAVEL_COMMIT) | tar -xvzC . --strip-components=1
# .PHONY: % : check-caravel
# %:
# export CARAVEL_ROOT=$(CARAVEL_ROOT) && export MPW_TAG=$(MPW_TAG) && $(MAKE) -f $(CARAVEL_ROOT)/Makefile $@

# Install DV setup
.PHONY: simenv
Expand All @@ -116,19 +80,17 @@ simenv-cocotb:
docker pull efabless/dv:cocotb

.PHONY: setup
# setup: check_dependencies install check-env install_mcw openlane pdk-with-volare setup-timing-scripts setup-cocotb precheck
setup: check-python check_dependencies setup-cocotb install-volare
# setup:
./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir requests
./venv/bin/$(PYTHON_BIN) -u scripts/get_tools.py --openlane_root $(OPENLANE_ROOT) --precheck_root $(PRECHECK_ROOT) --pdk_root $(PDK_ROOT) --caravel_root $(CARAVEL_ROOT) --mcw_root $(MCW_ROOT) --timing_root $(TIMING_ROOT)

setup: print_message clean_log check-python check_dependencies install-volare
@./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir requests >> setup.log
@./venv/bin/$(PYTHON_BIN) -u scripts/get_tools.py --openlane_root $(OPENLANE_ROOT) --precheck_root $(PRECHECK_ROOT) --pdk_root $(PDK_ROOT) --caravel_root $(CARAVEL_ROOT) --mcw_root $(MCW_ROOT) --timing_root $(TIMING_ROOT)
@$(MAKE) setup-cocotb >> setup.log

.PHONY: install-volare
install-volare:
rm -rf ./venv
$(PYTHON_BIN) -m venv ./venv
./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir pip
./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir volare
@rm -rf ./venv >> setup.log
@$(PYTHON_BIN) -m venv ./venv >> setup.log
@./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir pip >> setup.log
@./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir volare >> setup.log

check-python:
ifeq ($(shell which python3),)
Expand All @@ -138,9 +100,18 @@ endif
# Openlane
blocks=$(shell cd openlane && find * -maxdepth 0 -type d)
.PHONY: $(blocks)
$(blocks): % :
$(blocks): % : check_versions
$(MAKE) -C openlane $*

.PHONY: clean_log
clean_log:
@rm -f setup.log

.PHONY: print_message
print_message:
@echo "Setting up caravel_user_project environment..."
@echo "To check for errors, please see setup.log"

dv_patterns=$(shell cd verilog/dv && find * -maxdepth 0 -type d)
cocotb-dv_patterns=$(shell cd verilog/dv/cocotb && find . -name "*.c" | sed -e 's|^.*/||' -e 's/.c//')
dv-targets-rtl=$(dv_patterns:%=verify-%-rtl)
Expand Down Expand Up @@ -249,7 +220,9 @@ update_caravel: check-caravel
uninstall:
rm -rf $(CARAVEL_ROOT)


.PHONY: check_versions
check_versions:
./venv/bin/$(PYTHON_BIN) -u scripts/compare_versions.py
# Install Pre-check
# Default installs to the user home directory, override by "export PRECHECK_ROOT=<precheck-installation-path>"
.PHONY: precheck
Expand All @@ -263,7 +236,7 @@ precheck:
@docker pull efabless/mpw_precheck:latest

.PHONY: run-precheck
run-precheck: check-pdk check-precheck
run-precheck: check_versions check-pdk check-precheck
@if [ "$$DISABLE_LVS" = "1" ]; then\
$(eval INPUT_DIRECTORY := $(shell pwd)) \
cd $(PRECHECK_ROOT) && \
Expand Down Expand Up @@ -391,7 +364,7 @@ $(cocotb-dv-targets-gl): cocotb-verify-%-gl:
exit 1

.PHONY: create-spef-mapping
create-spef-mapping: ./verilog/gl/user_project_wrapper.v
create-spef-mapping: check_versions ./verilog/gl/user_project_wrapper.v
docker run \
--rm \
$(USER_ARGS) \
Expand All @@ -411,7 +384,7 @@ create-spef-mapping: ./verilog/gl/user_project_wrapper.v


.PHONY: extract-parasitics
extract-parasitics: ./verilog/gl/user_project_wrapper.v
extract-parasitics: check_versions ./verilog/gl/user_project_wrapper.v
docker run \
--rm \
$(USER_ARGS) \
Expand All @@ -435,7 +408,7 @@ extract-parasitics: ./verilog/gl/user_project_wrapper.v
@rm ./tmp-macros-list

.PHONY: caravel-sta
caravel-sta: ./env/spef-mapping.tcl
caravel-sta: check_versions ./env/spef-mapping.tcl
@$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-typ -j3
@$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-fast -j3
@$(MAKE) -C $(TIMING_ROOT) -f $(TIMING_ROOT)/timing.mk caravel-timing-slow -j3
Expand Down
25 changes: 25 additions & 0 deletions scripts/compare_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import requests
import json


def compare_json(tool_versions_json_path):
# Get the upstream JSON from the URL
upstream_url = 'https://raw.githubusercontent.com/efabless/central_CI/main/tools.json'
response = requests.get(upstream_url)
if response.status_code != 200:
raise ValueError(f'Failed to get upstream JSON from {upstream_url}: {response.status_code}')
upstream_json = response.json()

# Load the tool_versions.json
with open(tool_versions_json_path, 'r') as tool_versions_file:
tool_versions_json = json.load(tool_versions_file)

# Compare the two JSON objects
if upstream_json == tool_versions_json:
print("The upstream JSON is the same as tool_versions.json")
else:
print("The upstream JSON is different from tool_versions.json, please update by running make setup")
exit(1)


compare_json("./tool_versions.json")
28 changes: 20 additions & 8 deletions scripts/get_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
import json
import os
import shutil
import subprocess
import tarfile
import requests
import volare
from rich.progress import Progress
from rich.progress import (
Progress,
TextColumn,
BarColumn,
MofNCompleteColumn,
TimeElapsedColumn,
)


def parse_json_file(url):
Expand Down Expand Up @@ -35,33 +42,38 @@ def download_tools(openlane_root, precheck_root, pdk_root, caravel_root, mcw_roo
"""
url = 'https://raw.githubusercontent.com/efabless/central_CI/main/tools.json'
data = parse_json_file(url)
with Progress() as progress:
f = open("setup.log", "a")
with Progress(TextColumn("[progress.description]{task.description}"), BarColumn(), MofNCompleteColumn(), TimeElapsedColumn()) as progress:
task = progress.add_task("[cyan]Downloading Tools...", total=6)
for key, value in data.items():
if key == "OpenLane":
progress.update(task, description="[cyan]Downloading OpenLane...")
download_tar("OpenLane", value['commit'], value['url'], openlane_root)
progress.update(task, completed=1)
progress.update(task, description="[cyan]Downloading OpenLane Docker...")
os.environ['OPENLANE_IMAGE_NAME'] = f"efabless/openlane:{value['commit']}"
os.environ['IMAGE_NAME'] = f"efabless/openlane:{value['commit']}"
subprocess.run(["make", "pull-openlane"], cwd=openlane_root, env=os.environ, stderr=subprocess.STDOUT, text=True, check=True, stdout=f)
progress.update(task, advance=1)
elif key == "pdk":
progress.update(task, description="[cyan]Downloading pdk...")
volare.enable(pdk_root, "sky130", value['commit'])
progress.update(task, completed=1)
progress.update(task, advance=1)
elif key == "precheck":
progress.update(task, description="[cyan]Downloading precheck...")
download_tar("precheck", value['commit'], value['url'], precheck_root)
progress.update(task, completed=1)
progress.update(task, advance=1)
elif key == "caravel":
progress.update(task, description="[cyan]Downloading caravel...")
download_tar("caravel", value['commit'], value['url'], caravel_root)
progress.update(task, completed=1)
progress.update(task, advance=1)
elif key == "mgmt_core_wrapper":
progress.update(task, description="[cyan]Downloading mgmt_core_wrapper...")
download_tar("mgmt_core_wrapper", value['commit'], value['url'], mcw_root)
progress.update(task, completed=1)
progress.update(task, advance=1)
elif key == "timing_scripts":
progress.update(task, description="[cyan]Downloading timing_scripts...")
download_tar("timing_scripts", value['commit'], value['url'], timing_root)
progress.update(task, completed=1)
progress.update(task, advance=1)


def download_tar(tool, version, url, tool_path):
Expand Down

0 comments on commit 4c591d9

Please sign in to comment.