Skip to content

Commit 0429c23

Browse files
committed
~ update Makefile
1 parent e14e45b commit 0429c23

File tree

9 files changed

+268
-31
lines changed

9 files changed

+268
-31
lines changed

Makefile

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,50 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616
MAKEFLAGS+=--warn-undefined-variables
17+
export FRIGATE_ROOT?=$(PWD)/frigate
18+
export FRIGATE_REPO_URL?=https://github.com/efabless/frigate-os.git
19+
export FRIGATE_BRANCH?=main
1720
export MGMT_ROOT?=$(PWD)/dependencies/caravel_mgmt_soc
1821
export MGMT_REPO_URL?=https://github.com/efabless/caravel_mgmt_soc_litex.git
1922
export MGMT_BRANCH?=Add_newfill
2023
export PDK_ROOT?=$(PWD)/dependencies/pdks
24+
export OPEN_PDKS_COMMIT?=0fe599b2afb6708d281543108caf8310912f54af
2125

2226
export PROJECT_ROOT=$(shell pwd)
2327

2428
SIM?=RTL
29+
PYTHON_BIN=python3
2530

2631
# PDK switch varient
2732
export PDK?=sky130A
2833
#export PDK?=gf180mcuC
2934
export PDKPATH?=$(PDK_ROOT)/$(PDK)
3035

36+
.PHONY: setup
37+
setup: check_dependencies install-mcw install-frigate pdk-with-volare setup-cocotb
38+
39+
.PHONY: check_dependencies
40+
check_dependencies:
41+
@if [ ! -d "$(PWD)/dependencies" ]; then \
42+
mkdir $(PWD)/dependencies; \
43+
fi
44+
45+
.PHONY: pdk-with-volare
46+
pdk-with-volare: check-python install-volare
47+
./venv/bin/volare enable ${OPEN_PDKS_COMMIT}
48+
49+
check-python:
50+
ifeq ($(shell which python3),)
51+
$(error Please install python 3.6+)
52+
endif
53+
54+
.PHONY: install-volare
55+
install-volare:
56+
rm -rf ./venv
57+
$(PYTHON_BIN) -m venv ./venv
58+
./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir pip
59+
./venv/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir volare
60+
3161
# Include mgmt
3262
.PHONY: install-mcw
3363
install-mcw:
@@ -42,7 +72,38 @@ install-mcw:
4272
git clone -b $(MGMT_BRANCH) $(MGMT_REPO_URL) $(MGMT_ROOT) --depth=1 --single-branch; \
4373
fi
4474

45-
PYTHON_BIN=python3
75+
# Include frigate
76+
.PHONY: install-frigate
77+
install-frigate:
78+
if [ -d "$(FRIGATE_ROOT)" ]; then\
79+
MAKE_DIR="$(PWD)"; \
80+
echo "Updating $(FRIGATE_ROOT)"; \
81+
cd $(FRIGATE_ROOT) && \
82+
git checkout $(FRIGATE_BRANCH) && git pull; \
83+
cd "$$MAKE_DIR"; \
84+
else \
85+
echo "Cloning $(FRIGATE_REPO_URL) -b $(FRIGATE_BRANCH)"; \
86+
git clone -b $(FRIGATE_BRANCH) $(FRIGATE_REPO_URL) $(FRIGATE_ROOT) --depth=1 --single-branch; \
87+
fi
88+
89+
.PHONY: install-caravel-cocotb
90+
install-caravel-cocotb:
91+
rm -rf ./venv-cocotb
92+
$(PYTHON_BIN) -m venv ./venv-cocotb
93+
./venv-cocotb/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir pip
94+
./venv-cocotb/bin/$(PYTHON_BIN) -m pip install --upgrade --no-cache-dir caravel-cocotb
95+
96+
.PHONY: setup-cocotb-env
97+
setup-cocotb-env:
98+
@(python3 $(PROJECT_ROOT)/verilog/dv/setup-cocotb.py $(FRIGATE_ROOT) $(MGMT_ROOT) $(PDK_ROOT) $(PDK) $(PROJECT_ROOT))
99+
100+
# Install cocotb docker
101+
.PHONY: simenv-cocotb
102+
simenv-cocotb:
103+
docker pull efabless/dv:cocotb
104+
105+
.PHONY: setup-cocotb
106+
setup-cocotb: install-caravel-cocotb setup-cocotb-env simenv-cocotb
46107

47108
check-pdk:
48109
@if [ ! -d "$(PDK_ROOT)" ]; then \
@@ -59,7 +120,7 @@ echo-var:
59120
OPENLANE2_TAG ?= 2.3.3
60121
OPENLANE2_IMAGE_NAME ?= efabless/openlane:$(OPENLANE2_TAG)
61122
OPENLANE2_RUN_TAG = $(shell date '+%y_%m_%d_%H_%M')
62-
OPENLANE2_USE_NIX ?= 0
123+
OPENLANE2_USE_NIX ?= 1
63124
ROOTLESS ?= 0
64125
USER_ARGS = -u $$(id -u $$USER):$$(id -g $$USER)
65126
designs = $(shell cd $(PROJECT_ROOT)/openlane && find * -maxdepth 0 -type d)
@@ -69,6 +130,23 @@ ifeq ($(ROOTLESS), 1)
69130
USER_ARGS =
70131
endif
71132

133+
# Install Openlane
134+
.PHONY: openlane
135+
openlane: openlane2-venv openlane2-docker-container
136+
# openlane installed
137+
138+
OPENLANE2_TAG_DOCKER=$(subst -,,$(OPENLANE2_TAG))
139+
.PHONY: openlane2-docker-container
140+
openlane2-docker-container:
141+
docker pull ghcr.io/efabless/openlane2:$(OPENLANE2_TAG_DOCKER)
142+
143+
openlane2-venv: $(PROJECT_ROOT)/openlane2-venv/manifest.txt
144+
$(PROJECT_ROOT)/openlane2-venv/manifest.txt:
145+
rm -rf openlane2-venv
146+
python3 -m venv $(PROJECT_ROOT)/openlane2-venv
147+
PYTHONPATH= $(PROJECT_ROOT)/openlane2-venv/bin/python3 -m pip install openlane==$(OPENLANE2_TAG)
148+
PYTHONPATH= $(PROJECT_ROOT)/openlane2-venv/bin/python3 -m pip freeze > $(PROJECT_ROOT)/openlane2-venv/manifest.txt
149+
72150
openlane_args = \
73151
--run-tag $(OPENLANE2_RUN_TAG) \
74152
--manual-pdk \
@@ -86,10 +164,10 @@ docker_env = \
86164
-e PDK=$(PDK) \
87165
-e OPENLANE2_RUN_TAG=$(OPENLANE2_RUN_TAG)
88166

89-
ifneq ($(MCW_ROOT),)
90-
docker_env += -e MCW_ROOT=$(MCW_ROOT)
91-
export MCW_ROOT:=$(MCW_ROOT)
92-
docker_mounts += -m $(MCW_ROOT)
167+
ifneq ($(MGMT_ROOT),)
168+
docker_env += -e MGMT_ROOT=$(MGMT_ROOT)
169+
export MGMT_ROOT:=$(MGMT_ROOT)
170+
docker_mounts += -m $(MGMT_ROOT)
93171
endif
94172

95173
docker_startup_mode = $(shell test -t 0 && echo "-it" || echo "--rm" )
@@ -110,9 +188,11 @@ $(designs) : % : $(PROJECT_ROOT)/openlane/%/config.yaml
110188
# $(current_design)
111189
@rm -rf $(PROJECT_ROOT)/openlane/$*/runs/$(OPENLANE2_RUN_TAG)
112190
ifeq ($(OPENLANE2_USE_NIX),1)
113-
nix run github:efabless/openlane2/$(OPENLANE2_TAG) -- $(openlane_args) $(openlane_extra_args)
191+
nix develop --command openlane $(openlane_args) $(openlane_extra_args)
114192
else
115193
$(PROJECT_ROOT)/openlane2-venv/bin/python3 -m openlane $(docker_mounts) $(openlane_extra_args) --dockerized $(openlane_args) $(openlane_extra_args)
116194
endif
117195
@sh $(PROJECT_ROOT)/openlane/copy_views.sh $(PROJECT_ROOT) $* $(OPENLANE2_RUN_TAG)
118196

197+
.PHONY: harden
198+
harden: $(designs)

flake.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
inputs = {
3+
openlane = {
4+
url = github:efabless/openlane2/dev;
5+
};
6+
};
7+
8+
outputs = {
9+
self,
10+
openlane,
11+
...
12+
}: let
13+
nix-eda = openlane.inputs.nix-eda;
14+
devshell = openlane.inputs.devshell;
15+
nixpkgs = nix-eda.inputs.nixpkgs;
16+
lib = nixpkgs.lib;
17+
in {
18+
# Outputs
19+
legacyPackages = nix-eda.forAllSystems (
20+
system:
21+
import nixpkgs {
22+
inherit system;
23+
overlays = [
24+
nix-eda.overlays.default
25+
devshell.overlays.default
26+
openlane.overlays.default
27+
(nix-eda.composePythonOverlay (pkgs': pkgs: pypkgs': pypkgs: let
28+
callPythonPackage = lib.callPackageWith (pkgs' // pkgs'.python3.pkgs);
29+
in {
30+
openlane-plugin-frigate = callPythonPackage ./openlane_plugin_frigate/default.nix {};
31+
}))
32+
];
33+
}
34+
);
35+
36+
devShells = nix-eda.forAllSystems (system: let
37+
pkgs = self.legacyPackages.${system};
38+
in {
39+
default = lib.callPackageWith pkgs (openlane.createOpenLaneShell {
40+
openlane-plugins = [
41+
pkgs.python3.pkgs.openlane-plugin-frigate
42+
];
43+
extra-packages = [
44+
pkgs.verilog
45+
pkgs.gtkwave
46+
];
47+
}) {};
48+
});
49+
};
50+
}

openlane_plugin_Frigate/__init__.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

openlane_plugin_Frigate/default.nix

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
buildPythonPackage,
3+
openlane,
4+
nix-gitignore,
5+
poetry-core,
6+
setuptools,
7+
ruby,
8+
}: let
9+
self = buildPythonPackage {
10+
pname = "openlane-plugin-frigate";
11+
12+
version = (builtins.fromTOML (builtins.readFile ./pyproject.toml)).tool.poetry.version;
13+
14+
src = nix-gitignore.gitignoreSourcePure ./.gitignore ./.;
15+
16+
doCheck = false;
17+
18+
format = "pyproject";
19+
20+
nativeBuildInputs = [
21+
poetry-core
22+
setuptools
23+
];
24+
25+
includedTools = [
26+
ruby
27+
];
28+
29+
propagatedBuildInputs =
30+
self.includedTools
31+
++ [
32+
openlane
33+
];
34+
};
35+
in
36+
self

openlane_plugin_Frigate/openlane_plugin_Frigate/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import os
2+
from typing import List, Optional
3+
24
from openlane.steps import Step
35
from openlane.steps.odb import ApplyDEFTemplate
4-
from .__version__ import __version__
5-
from typing import List, Optional
66
from openlane.config import Variable
77
from openlane.common import get_script_dir
88

9+
from .__version__ import __version__
910

1011
@Step.factory.register()
1112
class CustomApplyDEFTemplate(ApplyDEFTemplate):

openlane_plugin_Frigate/openlane_plugin_Frigate/__version__.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,31 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
__version__ = "1.0.0"
14+
import os
15+
import importlib.metadata
16+
import sys
17+
18+
19+
def __get_version():
20+
try:
21+
return importlib.metadata.version(__package__ or __name__)
22+
except importlib.metadata.PackageNotFoundError:
23+
import re
24+
25+
rx = re.compile(r"version\s*=\s*\"([^\"]+)\"")
26+
openlane_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
27+
pyproject_path = os.path.join(openlane_directory, "pyproject.toml")
28+
try:
29+
match = rx.search(open(pyproject_path, encoding="utf8").read())
30+
assert match is not None, "pyproject.toml found, but without a version"
31+
return match[1]
32+
except FileNotFoundError:
33+
print("Warning: Failed to extract plugin version.", file=sys.stderr)
34+
return "UNKNOWN"
35+
36+
37+
__version__ = __get_version()
38+
1539

1640
if __name__ == "__main__":
17-
print(__version__, end="")
41+
print(__version__, end="")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[tool.poetry]
2+
name = "openlane-plugin-frigate"
3+
version = "1.0.0"
4+
description = "Internal plugin for Misc Frigate Functions"
5+
authors = ["Efabless Corporation <marwan.abbas@efabless.com>"]
6+
license = "Apache-2.0"
7+
classifiers = [
8+
"License :: OSI Approved :: Apache Software License",
9+
"Programming Language :: Python :: 3",
10+
"Intended Audience :: Developers",
11+
"Operating System :: POSIX :: Linux",
12+
"Operating System :: MacOS :: MacOS X",
13+
]
14+
15+
[tool.poetry.dependencies]
16+
python = ">=3.8"
17+
openlane = ">=2.3.*"
18+
19+
[build-system]
20+
requires = ["poetry-core"]
21+
build-backend = "poetry.core.masonry.api"

verilog/dv/cocotb/design_info.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CARAVEL_ROOT: /home/passant/efabless/frigate-upw-example/frigate
2+
MCW_ROOT: /home/passant/efabless/frigate-upw-example/dependencies/caravel_mgmt_soc
3+
PDK: sky130A
4+
PDK_ROOT: /home/passant/efabless/frigate-upw-example/dependencies/pdks
5+
USER_PROJECT_ROOT: /home/passant/efabless/frigate-upw-example
6+
caravan: false
7+
clk: 20
8+
emailto:
9+
- null

verilog/dv/setup-cocotb.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import click
2+
import yaml
3+
4+
5+
@click.command()
6+
@click.argument('caravel_root', type=click.Path(exists=True))
7+
@click.argument('mcw_root', type=click.Path(exists=True))
8+
@click.argument('pdk_root', type=click.Path(exists=True))
9+
@click.argument('pdk')
10+
@click.argument('user_project_root', type=click.Path(exists=True))
11+
def update_design_info(caravel_root, mcw_root, pdk_root, pdk, user_project_root):
12+
data = {
13+
'CARAVEL_ROOT': caravel_root,
14+
'MCW_ROOT': mcw_root,
15+
'USER_PROJECT_ROOT': user_project_root,
16+
'PDK_ROOT': pdk_root,
17+
'PDK': pdk,
18+
'clk': 20,
19+
'caravan': False,
20+
'emailto': [None]
21+
}
22+
23+
with open(f'{user_project_root}/verilog/dv/cocotb/design_info.yaml', 'w') as file:
24+
yaml.dump(data, file)
25+
print("design_info.yaml updated")
26+
27+
28+
if __name__ == "__main__":
29+
update_design_info()
30+
31+
# paths = EnvironmentPaths("/home/rady/caravel/caravel_orginal/caravel/",
32+
# "/home/rady/caravel/caravel_orginal/caravel_mgmt_soc_litex/",
33+
# "/home/rady/caravel/files4vcs/pdk","sky130A",
34+
# "/home/rady/caravel/swift/caravel_user_project/")
35+
36+
# WriteDesignInfo("/home/Marwan/caravel/swift/caravel-dynamic-sims/cocotb/",paths,Emailto=["mostafa.rady@efabless.com"])

0 commit comments

Comments
 (0)