mirror of
https://github.com/The-OpenROAD-Project/OpenLane.git
synced 2026-05-29 00:23:55 +08:00
Allow Including sky130A in the OpenLane Docker Image (#846)
+ Add a dependency system for tools, so some tools can be built first in local installs or have other repos and commits included in docker image builds + Add fully working `open_pdks` image that does NOT use Conda + Add options to list containerized tools in `dependencies/tool.py`, with a `--no-pdks` flag to exclude open_pdks + Add libraries/sky130_fd_pr/latest to the full PDK build (was missing) ~ Isolated PDK building stuff into `./dependencies/pdk.mk` ~ Final merge no longer uses a tarball, just uses a good 'ol copy --- Caveat is this will not be enabled by default or used by the CI for now. The reason is the PDK adds another 3 gigabytes to the final image and takes positively forever to build. To use an internally built PDK, you need to export two variables: export EXTERNAL_PDK_INSTALLATION=0 export NO_PDKS=0 Then you'd `make openlane` as normal. To finally enable this, we'd need to rewrite make_timing to not take forever (probably in Rust/Swift/Go/whatever) and Open_PDKs would need to be updated so it gzips the liberty files. We'd also need to ensure that all tools can load .lib.gz files. Co-authored-by: Olof Kindgren <olof.kindgren@gmail.com>
This commit is contained in:
133
Makefile
133
Makefile
@@ -1,4 +1,4 @@
|
||||
# Copyright 2020-2021 Efabless Corporation
|
||||
# Copyright 2020-2022 Efabless Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -15,10 +15,9 @@ PYTHON_BIN ?= python3
|
||||
|
||||
OPENLANE_DIR ?= $(shell pwd)
|
||||
|
||||
PDK_ROOT ?= $(shell pwd)/pdks
|
||||
|
||||
DOCKER_OPTIONS = $(shell $(PYTHON_BIN) ./env.py docker-config)
|
||||
|
||||
# Allow Configuring Memory Limits
|
||||
ifneq (,$(DOCKER_SWAP)) # Set to -1 for unlimited
|
||||
DOCKER_OPTIONS += --memory-swap=$(DOCKER_SWAP)
|
||||
endif
|
||||
@@ -27,7 +26,8 @@ DOCKER_OPTIONS += --memory=$(DOCKER_MEMORY)
|
||||
# To verify: cat /sys/fs/cgroup/memory/memory.limit_in_bytes inside the container
|
||||
endif
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
# Allow using GUIs
|
||||
UNAME_S = $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
DOCKER_OPTIONS += -e DISPLAY=$(DISPLAY) -v /tmp/.X11-unix:/tmp/.X11-unix -v $(HOME)/.Xauthority:/.Xauthority --network host
|
||||
endif
|
||||
@@ -39,18 +39,6 @@ ifneq (,$(ROUTING_CORES))
|
||||
DOCKER_OPTIONS += -e ROUTING_CORES=$(ROUTING_CORES)
|
||||
endif
|
||||
|
||||
STD_CELL_LIBRARY ?= sky130_fd_sc_hd
|
||||
SPECIAL_VOLTAGE_LIBRARY ?= sky130_fd_sc_hvl
|
||||
IO_LIBRARY ?= sky130_fd_io
|
||||
INSTALL_SRAM ?= disabled
|
||||
|
||||
OPEN_PDK_ARGS ?= ""
|
||||
ifeq ($(INSTALL_SRAM), enabled)
|
||||
OPEN_PDK_ARGS += --enable-sram-sky130
|
||||
else ifneq ($(INSTALL_SRAM), disabled)
|
||||
OPEN_PDK_ARGS += --enable-sram-sky130=$(INSTALL_SRAM)
|
||||
endif
|
||||
|
||||
ifeq ($(OPENLANE_IMAGE_NAME),)
|
||||
OPENLANE_TAG ?= $(shell $(PYTHON_BIN) ./dependencies/get_tag.py)
|
||||
ifneq ($(OPENLANE_TAG),)
|
||||
@@ -69,115 +57,29 @@ PRINT_REM_DESIGNS_TIME ?= 0
|
||||
SKYWATER_COMMIT ?= $(shell $(PYTHON_BIN) ./dependencies/tool.py sky130 -f commit)
|
||||
OPEN_PDKS_COMMIT ?= $(shell $(PYTHON_BIN) ./dependencies/tool.py open_pdks -f commit)
|
||||
|
||||
# designs is mounted over install so env.tcl is not found inside the Docker
|
||||
# container.
|
||||
PDK_OPTS =
|
||||
EXTERNAL_PDK_INSTALLATION ?= 1
|
||||
ifeq ($(EXTERNAL_PDK_INSTALLATION), 1)
|
||||
export PDK_ROOT ?= ./pdks
|
||||
export PDK_ROOT := $(shell python3 -c "import os; print(os.path.realpath('$(PDK_ROOT)'), end='')")
|
||||
PDK_OPTS = -v $(PDK_ROOT):$(PDK_ROOT) -e PDK_ROOT=$(PDK_ROOT)
|
||||
endif
|
||||
|
||||
# ./designs is mounted over ./install so env.tcl is not found inside the Docker
|
||||
# container if the user had previously installed it.
|
||||
ENV_START = docker run --rm\
|
||||
-v $(OPENLANE_DIR):/openlane\
|
||||
-v $(OPENLANE_DIR)/designs:/openlane/install\
|
||||
-v $(PDK_ROOT):$(PDK_ROOT)\
|
||||
-e PDK_ROOT=$(PDK_ROOT)\
|
||||
$(PDK_OPTS)\
|
||||
$(DOCKER_OPTIONS)
|
||||
|
||||
ENV_COMMAND = $(ENV_START) $(OPENLANE_IMAGE_NAME)
|
||||
|
||||
ifndef PDK_ROOT
|
||||
$(error PDK_ROOT is undefined, please export it before running make)
|
||||
endif
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
.PHONY: all
|
||||
all: openlane pdk
|
||||
all: openlane
|
||||
|
||||
.PHONY: pdk
|
||||
pdk: skywater-pdk skywater-library open_pdks build-pdk gen-sources
|
||||
|
||||
.PHONY: native-pdk
|
||||
native-pdk: skywater-pdk skywater-library open_pdks native-build-pdk gen-sources
|
||||
|
||||
.PHONY: full-pdk
|
||||
full-pdk: skywater-pdk all-skywater-libraries open_pdks build-pdk gen-sources
|
||||
|
||||
.PHONY: native-full-pdk
|
||||
native-full-pdk: skywater-pdk all-skywater-libraries open_pdks native-build-pdk gen-sources
|
||||
|
||||
$(PDK_ROOT)/:
|
||||
mkdir -p $(PDK_ROOT)
|
||||
|
||||
$(PDK_ROOT)/skywater-pdk:
|
||||
git clone $(shell $(PYTHON_BIN) ./dependencies/tool.py sky130 -f repo) $(PDK_ROOT)/skywater-pdk
|
||||
|
||||
.PHONY: skywater-pdk
|
||||
skywater-pdk: $(PDK_ROOT)/ $(PDK_ROOT)/skywater-pdk
|
||||
cd $(PDK_ROOT)/skywater-pdk && \
|
||||
git checkout main && git submodule init && git pull --no-recurse-submodules && \
|
||||
git checkout -qf $(SKYWATER_COMMIT)
|
||||
|
||||
.PHONY: skywater-library
|
||||
skywater-library: $(PDK_ROOT)/skywater-pdk
|
||||
cd $(PDK_ROOT)/skywater-pdk && \
|
||||
git submodule update --init libraries/$(STD_CELL_LIBRARY)/latest && \
|
||||
git submodule update --init libraries/$(IO_LIBRARY)/latest && \
|
||||
git submodule update --init libraries/$(SPECIAL_VOLTAGE_LIBRARY)/latest && \
|
||||
git submodule update --init libraries/sky130_fd_pr/latest && \
|
||||
$(MAKE) -j$(NPROC) timing
|
||||
|
||||
.PHONY: all-skywater-libraries
|
||||
all-skywater-libraries: skywater-pdk
|
||||
cd $(PDK_ROOT)/skywater-pdk && \
|
||||
git submodule update --init libraries/sky130_fd_sc_hd/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_hs/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_hdll/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_ms/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_ls/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_hvl/latest && \
|
||||
git submodule update --init libraries/sky130_fd_io/latest && \
|
||||
$(MAKE) -j$(NPROC) timing
|
||||
|
||||
### OPEN_PDKS
|
||||
$(PDK_ROOT)/open_pdks:
|
||||
git clone $(shell $(PYTHON_BIN) ./dependencies/tool.py open_pdks -f repo) $(PDK_ROOT)/open_pdks
|
||||
|
||||
.PHONY: open_pdks
|
||||
open_pdks: $(PDK_ROOT)/ $(PDK_ROOT)/open_pdks
|
||||
cd $(PDK_ROOT)/open_pdks && \
|
||||
git checkout master && \
|
||||
git pull && \
|
||||
git checkout -qf $(OPEN_PDKS_COMMIT)
|
||||
|
||||
.PHONY: build-pdk
|
||||
native-build-pdk: ENV_COMMAND=env
|
||||
native-build-pdk: build-pdk
|
||||
build-pdk: $(PDK_ROOT)/open_pdks $(PDK_ROOT)/skywater-pdk
|
||||
[ -d $(PDK_ROOT)/sky130A ] && rm -rf $(PDK_ROOT)/sky130A || true
|
||||
$(ENV_COMMAND) sh -c "\
|
||||
cd $(PDK_ROOT)/open_pdks && \
|
||||
./configure --enable-sky130-pdk=$(PDK_ROOT)/skywater-pdk/libraries $(OPEN_PDK_ARGS)\
|
||||
"
|
||||
cd $(PDK_ROOT)/open_pdks/sky130 && \
|
||||
$(MAKE) veryclean && \
|
||||
$(MAKE) prerequisites
|
||||
$(ENV_COMMAND) sh -c "\
|
||||
cd $(PDK_ROOT)/open_pdks/sky130 && \
|
||||
make && \
|
||||
make SHARED_PDKS_PATH=$(PDK_ROOT) install && \
|
||||
make clean \
|
||||
"
|
||||
|
||||
gen-sources: $(PDK_ROOT)/sky130A
|
||||
touch $(PDK_ROOT)/sky130A/SOURCES
|
||||
OPENLANE_COMMIT=$(git rev-parse HEAD)
|
||||
printf "openlane " > $(PDK_ROOT)/sky130A/SOURCES
|
||||
cd $(OPENLANE_DIR) && git rev-parse HEAD >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
printf "magic " >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
python3 ./dependencies/tool.py -f commit magic >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
printf "\n" >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
printf "skywater-pdk " >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
cd $(PDK_ROOT)/skywater-pdk && git rev-parse HEAD >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
printf "open_pdks " >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
cd $(PDK_ROOT)/open_pdks && git rev-parse HEAD >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
|
||||
### OPENLANE
|
||||
.PHONY: openlane
|
||||
openlane:
|
||||
$(MAKE) -C docker openlane
|
||||
@@ -218,6 +120,9 @@ test:
|
||||
echo "Basic test passed" || \
|
||||
echo "Basic test failed"
|
||||
|
||||
# PDK build commands
|
||||
include ./dependencies/pdk.mk
|
||||
|
||||
.PHONY: clean_all clean_runs clean_results
|
||||
clean_all: clean_runs clean_results
|
||||
|
||||
|
||||
64
dependencies/installer.py
vendored
64
dependencies/installer.py
vendored
@@ -124,8 +124,6 @@ class Installer(object):
|
||||
exit(-1)
|
||||
|
||||
tools = Tool.from_metadata_yaml(open("./dependencies/tool_metadata.yml").read())
|
||||
if self.input_options("RISK_ACKNOWLEDGED", "I affirm that I have read docs/source/local_installs.md and agree to the outlined risks.", ["n", "y"]) != "y":
|
||||
return
|
||||
|
||||
print(textwrap.dedent(f"""\
|
||||
OpenLane Local Installer ALPHA
|
||||
@@ -274,6 +272,7 @@ class Installer(object):
|
||||
|
||||
run_env = os.environ.copy()
|
||||
run_env["PREFIX"] = install_dir
|
||||
run_env["PATH"] = f"{install_dir}/bin:{os.getenv('PATH')}"
|
||||
|
||||
path_elements = ["$OL_INSTALL_DIR/venv/bin", "$OL_INSTALL_DIR/bin"]
|
||||
|
||||
@@ -336,11 +335,22 @@ class Installer(object):
|
||||
sh("mkdir", "-p", folder)
|
||||
|
||||
skip_tools = re.compile(os.getenv("SKIP_TOOLS") or "Unmatchable")
|
||||
for tool in tools.values():
|
||||
if not tool.in_install:
|
||||
continue
|
||||
if skip_tools.match(tool.name) is not None:
|
||||
tool_queue = list(tools.values()).copy()
|
||||
pop = lambda: tool_queue.pop(0) if len(tool_queue) else None
|
||||
installed = set()
|
||||
tool = pop()
|
||||
while tool is not None:
|
||||
if not (tool.in_install and (skip_tools.match(tool.name) is None)):
|
||||
tool = pop()
|
||||
continue
|
||||
|
||||
if len(tool.dependencies):
|
||||
dependencies = set(tool.dependencies)
|
||||
if not dependencies.issubset(installed):
|
||||
tool_queue.append(tool)
|
||||
tool = pop()
|
||||
continue
|
||||
|
||||
installed_version = ""
|
||||
version_path = f"versions/{tool.name}"
|
||||
try:
|
||||
@@ -349,28 +359,30 @@ class Installer(object):
|
||||
pass
|
||||
if installed_version == tool.version_string and os.getenv("FORCE_REINSTALL") != "1":
|
||||
print(f"{tool.version_string} already installed, skipping...")
|
||||
continue
|
||||
|
||||
print(f"Installing {tool.name}...")
|
||||
|
||||
with chdir("repos"):
|
||||
if not exists(tool.name):
|
||||
sh("git", "clone", tool.repo, tool.name)
|
||||
else:
|
||||
print(f"Installing {tool.name}...")
|
||||
|
||||
with chdir(tool.name):
|
||||
sh("git", "fetch")
|
||||
sh("git", "submodule", "update", "--init")
|
||||
sh("git", "checkout", tool.commit)
|
||||
subprocess.run([
|
||||
"bash", "-c", f"""\
|
||||
set -e
|
||||
source {install_dir}/venv/bin/activate
|
||||
{tool.build_script}
|
||||
"""
|
||||
], env=run_env, check=True)
|
||||
with chdir("repos"):
|
||||
if not exists(tool.name):
|
||||
sh("git", "clone", tool.repo, tool.name)
|
||||
|
||||
with chdir(tool.name):
|
||||
sh("git", "fetch")
|
||||
sh("git", "submodule", "update", "--init")
|
||||
sh("git", "checkout", tool.commit)
|
||||
subprocess.run([
|
||||
"bash", "-c", f"""\
|
||||
set -e
|
||||
source {install_dir}/venv/bin/activate
|
||||
{tool.build_script}
|
||||
"""
|
||||
], env=run_env, check=True)
|
||||
|
||||
with open(version_path, "w") as f:
|
||||
f.write(tool.version_string)
|
||||
with open(version_path, "w") as f:
|
||||
f.write(tool.version_string)
|
||||
|
||||
installed.add(tool.name)
|
||||
tool = pop()
|
||||
|
||||
path_elements.reverse()
|
||||
with open("env.tcl", "w") as f:
|
||||
|
||||
115
dependencies/pdk.mk
vendored
Normal file
115
dependencies/pdk.mk
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
# Copyright 2020-2022 Efabless Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# This file is intended to be included by the top-level Makefile. Please don't use it directly. :)
|
||||
|
||||
STD_CELL_LIBRARY ?= sky130_fd_sc_hd
|
||||
SPECIAL_VOLTAGE_LIBRARY ?= sky130_fd_sc_hvl
|
||||
IO_LIBRARY ?= sky130_fd_io
|
||||
INSTALL_SRAM ?= disabled
|
||||
|
||||
OPEN_PDK_ARGS ?= ""
|
||||
ifeq ($(INSTALL_SRAM), enabled)
|
||||
OPEN_PDK_ARGS += --enable-sram-sky130
|
||||
else ifneq ($(INSTALL_SRAM), disabled)
|
||||
OPEN_PDK_ARGS += --enable-sram-sky130=$(INSTALL_SRAM)
|
||||
endif
|
||||
|
||||
.PHONY: pdk
|
||||
pdk: skywater-pdk skywater-library open_pdks build-pdk gen-sources
|
||||
|
||||
.PHONY: native-pdk
|
||||
native-pdk: skywater-pdk skywater-library open_pdks native-build-pdk gen-sources
|
||||
|
||||
.PHONY: full-pdk
|
||||
full-pdk: skywater-pdk all-skywater-libraries open_pdks build-pdk gen-sources
|
||||
|
||||
.PHONY: native-full-pdk
|
||||
native-full-pdk: skywater-pdk all-skywater-libraries open_pdks native-build-pdk gen-sources
|
||||
|
||||
$(PDK_ROOT):
|
||||
mkdir -p $(PDK_ROOT)
|
||||
|
||||
$(PDK_ROOT)/skywater-pdk: $(PDK_ROOT)
|
||||
git clone $(shell $(PYTHON_BIN) ./dependencies/tool.py sky130 -f repo) $(PDK_ROOT)/skywater-pdk
|
||||
|
||||
.PHONY: skywater-pdk
|
||||
skywater-pdk: $(PDK_ROOT)/skywater-pdk
|
||||
cd $(PDK_ROOT)/skywater-pdk && \
|
||||
git checkout main && git submodule init && git pull --no-recurse-submodules && \
|
||||
git checkout -qf $(SKYWATER_COMMIT)
|
||||
|
||||
.PHONY: skywater-library
|
||||
skywater-library: $(PDK_ROOT)/skywater-pdk
|
||||
cd $(PDK_ROOT)/skywater-pdk && \
|
||||
git submodule update --init libraries/$(STD_CELL_LIBRARY)/latest && \
|
||||
git submodule update --init libraries/$(IO_LIBRARY)/latest && \
|
||||
git submodule update --init libraries/$(SPECIAL_VOLTAGE_LIBRARY)/latest && \
|
||||
git submodule update --init libraries/sky130_fd_pr/latest && \
|
||||
$(MAKE) -j$(NPROC) timing
|
||||
|
||||
.PHONY: all-skywater-libraries
|
||||
all-skywater-libraries: skywater-pdk
|
||||
cd $(PDK_ROOT)/skywater-pdk && \
|
||||
git submodule update --init libraries/sky130_fd_sc_hd/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_hs/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_hdll/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_ms/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_ls/latest && \
|
||||
git submodule update --init libraries/sky130_fd_sc_hvl/latest && \
|
||||
git submodule update --init libraries/sky130_fd_io/latest && \
|
||||
git submodule update --init libraries/sky130_fd_pr/latest && \
|
||||
$(MAKE) -j$(NPROC) timing
|
||||
|
||||
### OPEN_PDKS
|
||||
$(PDK_ROOT)/open_pdks:
|
||||
git clone $(shell $(PYTHON_BIN) ./dependencies/tool.py open_pdks -f repo) $(PDK_ROOT)/open_pdks
|
||||
|
||||
.PHONY: open_pdks
|
||||
open_pdks: $(PDK_ROOT)/ $(PDK_ROOT)/open_pdks
|
||||
cd $(PDK_ROOT)/open_pdks && \
|
||||
git checkout master && \
|
||||
git pull && \
|
||||
git checkout -qf $(OPEN_PDKS_COMMIT)
|
||||
|
||||
.PHONY: build-pdk
|
||||
native-build-pdk: ENV_COMMAND=env
|
||||
native-build-pdk: build-pdk
|
||||
build-pdk: $(PDK_ROOT)/open_pdks $(PDK_ROOT)/skywater-pdk
|
||||
[ -d $(PDK_ROOT)/sky130A ] && rm -rf $(PDK_ROOT)/sky130A || true
|
||||
$(ENV_COMMAND) sh -c "\
|
||||
cd $(PDK_ROOT)/open_pdks && \
|
||||
./configure --enable-sky130-pdk=$(PDK_ROOT)/skywater-pdk/libraries $(OPEN_PDK_ARGS)\
|
||||
"
|
||||
cd $(PDK_ROOT)/open_pdks/sky130 && \
|
||||
$(MAKE) veryclean && \
|
||||
$(MAKE) prerequisites
|
||||
$(ENV_COMMAND) sh -c "\
|
||||
cd $(PDK_ROOT)/open_pdks/sky130 && \
|
||||
make && \
|
||||
make SHARED_PDKS_PATH=$(PDK_ROOT) install && \
|
||||
make clean \
|
||||
"
|
||||
|
||||
gen-sources: $(PDK_ROOT)/sky130A
|
||||
touch $(PDK_ROOT)/sky130A/SOURCES
|
||||
OPENLANE_COMMIT=$(git rev-parse HEAD)
|
||||
printf "openlane " > $(PDK_ROOT)/sky130A/SOURCES
|
||||
cd $(OPENLANE_DIR) && git rev-parse HEAD >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
printf "magic " >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
python3 ./dependencies/tool.py -f commit magic >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
printf "\n" >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
printf "skywater-pdk " >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
cd $(PDK_ROOT)/skywater-pdk && git rev-parse HEAD >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
printf "open_pdks " >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
cd $(PDK_ROOT)/open_pdks && git rev-parse HEAD >> $(PDK_ROOT)/sky130A/SOURCES
|
||||
85
dependencies/tool.py
vendored
85
dependencies/tool.py
vendored
@@ -1,4 +1,5 @@
|
||||
# Copyright 2021 Efabless Corporation
|
||||
#!/usr/bin/env python3
|
||||
# Copyright 2021-2022 Efabless Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -11,18 +12,27 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
from typing import Dict, List
|
||||
|
||||
class Tool(object):
|
||||
def __init__(self, name, repo, commit, build_script="make && make install", in_install=True, in_container=True):
|
||||
by_name: Dict[str, 'Tool']
|
||||
|
||||
def __init__(self, name, repo, commit, build_script="make && make install", default_branch=None, in_install=True, in_container=True, dependencies=[], pdk=False):
|
||||
self.name = name
|
||||
self.repo = repo
|
||||
self.commit = commit
|
||||
self.build_script = build_script
|
||||
self.default_branch = default_branch
|
||||
self.in_install = in_install
|
||||
self.in_container = in_container
|
||||
self.dependencies = dependencies
|
||||
self.pdk = pdk
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Tool {self.name} (using {self.repo_pretty or 'None'}@{self.commit or 'None'})>"
|
||||
|
||||
@property
|
||||
def repo_pretty(self):
|
||||
@@ -36,8 +46,17 @@ class Tool(object):
|
||||
def version_string(self) -> str:
|
||||
return f"{self.repo or 'None'}:{self.commit or 'None'}"
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Tool {self.name} (using {self.repo_pretty or 'None'}@{self.commit or 'None'})>"
|
||||
def get_docker_tag(self, for_os: str) -> str:
|
||||
return f"{self.name}-{self.commit}-{for_os}"
|
||||
|
||||
@property
|
||||
def docker_args(self) -> List[str]:
|
||||
return [
|
||||
"--build-arg",
|
||||
f"{self.name.upper()}_REPO={self.repo}",
|
||||
"--build-arg",
|
||||
f"{self.name.upper()}_COMMIT={self.commit}"
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def from_metadata_yaml(metadata_yaml: str) -> Dict[str, 'Tool']:
|
||||
@@ -48,35 +67,75 @@ class Tool(object):
|
||||
name=tool['name'],
|
||||
repo=tool['repo'],
|
||||
commit=tool['commit'],
|
||||
build_script=tool['build'],
|
||||
build_script=tool.get('build') or "",
|
||||
default_branch=tool.get('default_branch') or None,
|
||||
in_container=tool['in_container'] if tool.get('in_container') is not None else True,
|
||||
in_install=tool['in_install'] if tool.get('in_install') is not None else True
|
||||
in_install=tool['in_install'] if tool.get('in_install') is not None else True,
|
||||
dependencies= tool.get('dependencies') or [],
|
||||
pdk=tool.get('pdk') or False
|
||||
)
|
||||
return final_dict
|
||||
|
||||
Tool.by_name = Tool.from_metadata_yaml(open(os.path.join(os.path.dirname(__file__), "tool_metadata.yml")).read())
|
||||
|
||||
def main():
|
||||
import os
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description="Get Tool Info")
|
||||
parser.add_argument("--docker-tag-for-os", default=None)
|
||||
parser.add_argument("--containerized", action="store_true")
|
||||
parser.add_argument("--docker-args", action="store_true")
|
||||
parser.add_argument("--no-pdks", action="store_true")
|
||||
parser.add_argument("--docker-tag-for-os", default=None)
|
||||
parser.add_argument("--field", "-f")
|
||||
parser.add_argument("tool")
|
||||
tools = Tool.from_metadata_yaml(open(os.path.join(os.path.dirname(__file__), "tool_metadata.yml")).read())
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.no_pdks:
|
||||
pdk_keys = []
|
||||
for key, value in Tool.by_name.items():
|
||||
if value.pdk:
|
||||
pdk_keys.append(key)
|
||||
|
||||
for key in pdk_keys:
|
||||
del Tool.by_name[key]
|
||||
|
||||
if args.containerized:
|
||||
for tool in Tool.by_name.values():
|
||||
if tool.in_container:
|
||||
print(tool.name, end=" ")
|
||||
exit(0)
|
||||
|
||||
tool = tools[args.tool]
|
||||
try:
|
||||
tool = Tool.by_name[args.tool]
|
||||
except:
|
||||
print(f"Unknown tool {args.tool}.", file=sys.stderr)
|
||||
exit(os.EX_DATAERR)
|
||||
|
||||
if args.docker_tag_for_os:
|
||||
print(f"{tool.name}-{tool.commit}-{args.docker_tag_for_os}")
|
||||
print(tool.get_docker_tag(for_os=args.docker_tag_for_os))
|
||||
elif args.docker_args:
|
||||
print(f"--build-arg {tool.name.upper()}_REPO={tool.repo} --build-arg {tool.name.upper()}_COMMIT={tool.commit}", end="")
|
||||
arg_list = tool.docker_args
|
||||
|
||||
# 1. Dependents
|
||||
dependents = []
|
||||
for dependent in Tool.by_name.values():
|
||||
if tool.name in dependent.dependencies:
|
||||
dependents.append(dependent)
|
||||
for dependent in dependents:
|
||||
arg_list += dependent.docker_args
|
||||
|
||||
# 2. Dependencies
|
||||
for dependency_name in tool.dependencies:
|
||||
dependency = Tool.by_name[dependency_name]
|
||||
arg_list += dependency.docker_args
|
||||
|
||||
print(" ".join(arg_list), end="")
|
||||
elif args.field:
|
||||
field = tool.__dict__[args.field]
|
||||
print(field, end="")
|
||||
else:
|
||||
print("Either --field or --docker-args is required.")
|
||||
parser.print_help(file=sys.stderr)
|
||||
exit(os.EX_USAGE)
|
||||
|
||||
|
||||
|
||||
5
dependencies/tool_metadata.yml
vendored
5
dependencies/tool_metadata.yml
vendored
@@ -91,7 +91,10 @@
|
||||
commit: 476f7428f7f686de51a5164c702629a9b9f2da46
|
||||
build: ''
|
||||
in_install: false
|
||||
in_container: false
|
||||
pdk: true
|
||||
dependencies:
|
||||
- sky130
|
||||
- magic
|
||||
- name: sky130
|
||||
repo: https://github.com/google/skywater-pdk
|
||||
commit: c094b6e83a4f9298e47f696ec5a7fd53535ec5eb
|
||||
|
||||
@@ -10,7 +10,13 @@ DOCKER_BUILD_OPTS ?= --rm
|
||||
DOCKER_BUILD_INVOCATION ?= docker build # docker buildx build --platform linux/amd64 --load
|
||||
BUILD_COMMAND = $(DOCKER_BUILD_INVOCATION) $(DOCKER_BUILD_OPTS)
|
||||
|
||||
TOOLS = cugr drcu yosys magic openroad_app padring netgen vlogtoverilog cvc git
|
||||
NO_PDKS_ARGS =
|
||||
NO_PDKS ?= 1
|
||||
ifeq ($(NO_PDKS), 1)
|
||||
NO_PDKS_ARGS = --no-pdks
|
||||
endif
|
||||
|
||||
TOOLS = $(shell python3 ../dependencies/tool.py --containerized $(NO_PDKS_ARGS) .)
|
||||
|
||||
TOOL_BUILD_TARGETS = $(foreach tool,$(TOOLS),build-$(tool))
|
||||
TOOL_EXPORT_TARGETS = $(foreach tool,$(TOOLS),tar/$(tool).tar.gz)
|
||||
@@ -59,22 +65,28 @@ $(TOOL_EXPORT_TARGETS): tar/%.tar.gz : FORCE
|
||||
${ROOT} docker cp $$id:/build.tar.gz tar/$*.tar.gz ; \
|
||||
${ROOT} docker rm -v $$id
|
||||
|
||||
tar/openroad_tools.tar.gz: $(TOOL_EXPORT_TARGETS)
|
||||
for tarFile in $(foreach tool,$(TOOLS),tar/$(tool).tar.gz); do \
|
||||
tar -xzf $$tarFile ; \
|
||||
./tar/build: $(TOOL_EXPORT_TARGETS)
|
||||
rm -rf ./tar/build
|
||||
cd tar && \
|
||||
for tarFile in $(foreach tool,$(TOOLS),$(tool).tar.gz); do \
|
||||
tar -xzf $$tarFile ; \
|
||||
chmod -R +x ./build/bin ; \
|
||||
find ./build/ -name "*.tcl" -exec chmod +x {} \; ;\
|
||||
done
|
||||
chmod -R +x ./build/bin
|
||||
find ./build/ -name "*.tcl" -exec chmod +x {} \;
|
||||
cd tar && tar -czf openroad_tools.tar.gz ../build
|
||||
|
||||
tar/openlane.tar.gz: FORCE
|
||||
cd tar && tar --exclude='../../.git' --exclude='../../docker' --exclude="../../designs" --exclude="../../pdks" --exclude="../../logs/*" -czf openlane.tar.gz ../../
|
||||
OPENLANE_SKELETON=configuration dependencies designs regression_results scripts AUTHORS.md env.py flow.tcl LICENSE run_designs.py
|
||||
./tar/openlane: FORCE
|
||||
rm -rf ./tar/openlane
|
||||
mkdir -p ./tar/openlane
|
||||
for file in $(OPENLANE_SKELETON); do \
|
||||
cp -r ../$$file ./tar/openlane/$$file ; \
|
||||
done
|
||||
|
||||
FORCE:
|
||||
|
||||
.PHONY: merge openlane
|
||||
openlane: merge
|
||||
merge: run_base_image tar/openroad_tools.tar.gz tar/openlane.tar.gz ../dependencies/tool_metadata.yml
|
||||
merge: run_base_image ./tar/build ./tar/openlane ../dependencies/tool_metadata.yml
|
||||
cat ../dependencies/tool_metadata.yml > ./tar/tool_metadata.yml
|
||||
printf "$(shell git rev-parse --short=7 HEAD)" > ./tar/git_version
|
||||
mkdir -p logs/tar
|
||||
@@ -86,12 +98,8 @@ merge: run_base_image tar/openroad_tools.tar.gz tar/openlane.tar.gz ../dependenc
|
||||
|
||||
.PHONY: clean_merge
|
||||
clean_merge:
|
||||
ifneq (,$(wildcard ./tar/openroad_tools.tar.gz))
|
||||
ifneq (,$(wildcard ./tar/openlane.tar.gz))
|
||||
rm ./tar/openlane.tar.gz
|
||||
rm ./tar/openroad_tools.tar.gz
|
||||
endif
|
||||
endif
|
||||
rm -rf ./tar/openlane
|
||||
rm -rf ./tar/build
|
||||
|
||||
clean_export:
|
||||
rm -rf export/*.tar.gz
|
||||
|
||||
@@ -26,16 +26,8 @@ make # or make openlane # or make merge
|
||||
```
|
||||
|
||||
## Updating a Tool Binary
|
||||
You can update a tool binary as follows:
|
||||
You can build a tool runnable using the following command: `make build-<tool_name>`.
|
||||
|
||||
```
|
||||
make build-<tool_name>
|
||||
```
|
||||
To list the available tools, `python3 ../dependencies/tool.py --containerized`.
|
||||
|
||||
The following are the available tools:
|
||||
|
||||
```bash
|
||||
cugr drcu yosys magic openroad_app padring netgen vlogtoverilog cvc git
|
||||
```
|
||||
|
||||
Be sure to make openlane after.
|
||||
Be sure to `make openlane` after building any tool.
|
||||
102
docker/open_pdks/Dockerfile
Normal file
102
docker/open_pdks/Dockerfile
Normal file
@@ -0,0 +1,102 @@
|
||||
# Copyright 2022 Efabless Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# WIP, probably will never make it to the image because it's taking forever to build
|
||||
|
||||
FROM openlane-build-base AS builder
|
||||
|
||||
ARG SKY130_REPO
|
||||
ARG SKY130_COMMIT
|
||||
|
||||
ENV PDK_ROOT /build/pdk
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
ENV LC_CTYPE en_US.UTF-8
|
||||
|
||||
WORKDIR ${PDK_ROOT}
|
||||
RUN git clone ${SKY130_REPO}
|
||||
WORKDIR ${PDK_ROOT}/skywater-pdk
|
||||
RUN git checkout main &&\
|
||||
git submodule init &&\
|
||||
git pull --no-recurse-submodules &&\
|
||||
git checkout -qf ${SKY130_COMMIT}
|
||||
RUN git submodule update --init libraries/sky130_fd_sc_hd/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_hs/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_hdll/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_ms/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_ls/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_hvl/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_io/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_pr/latest
|
||||
RUN python3 -m pip install -e scripts/python-skywater-pdk
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hd/latest
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hd/latest all
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hd/latest all --ccsnoise
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hdll/latest
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hdll/latest all
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hdll/latest all --ccsnoise
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hs/latest
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hs/latest all
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hs/latest all --ccsnoise
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hvl/latest
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hvl/latest all
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_hvl/latest all --ccsnoise
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_ls/latest
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_ls/latest all
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_ls/latest all --ccsnoise
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_ms/latest all --leakage
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_ms/latest
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_ms/latest all
|
||||
RUN python3 -m skywater_pdk.liberty libraries/sky130_fd_sc_ms/latest all --ccsnoise
|
||||
|
||||
ARG MAGIC_REPO
|
||||
ARG MAGIC_COMMIT
|
||||
|
||||
WORKDIR /magic
|
||||
RUN curl -L ${MAGIC_REPO}/tarball/${MAGIC_COMMIT} | tar -xzC . --strip-components=1 && \
|
||||
./configure --prefix=/usr && \
|
||||
make -j$(nproc) && \
|
||||
make install
|
||||
|
||||
ARG OPEN_PDKS_REPO
|
||||
ARG OPEN_PDKS_COMMIT
|
||||
|
||||
WORKDIR ${PDK_ROOT}
|
||||
RUN git clone ${OPEN_PDKS_REPO}
|
||||
WORKDIR ${PDK_ROOT}/open_pdks
|
||||
RUN git checkout master &&\
|
||||
git checkout -qf ${OPEN_PDKS_COMMIT}
|
||||
RUN ./configure --enable-sky130-pdk=${PDK_ROOT}/skywater-pdk/libraries --enable-sram-sky130
|
||||
WORKDIR ${PDK_ROOT}/open_pdks/sky130
|
||||
RUN make alpha-repo xschem-repo sram-repo 2>&1 | tee /build/pdk_prereq.log
|
||||
RUN make 2>&1 | tee /build/pdk.log
|
||||
RUN make SHARED_PDKS_PATH=${PDK_ROOT} install
|
||||
|
||||
RUN printf "skywater-pdk ${SKY130_COMMIT}" > ${PDK_ROOT}/sky130A/SOURCES
|
||||
RUN printf "magic ${MAGIC_COMMIT}" >> ${PDK_ROOT}/sky130A/SOURCES
|
||||
RUN printf "open_pdks ${OPEN_PDKS_COMMIT}" >> ${PDK_ROOT}/sky130A/SOURCES
|
||||
|
||||
RUN rm -rf ${PDK_ROOT}/skywater-pdk
|
||||
RUN rm -rf ${PDK_ROOT}/open_pdks
|
||||
|
||||
|
||||
RUN tar -c /build | gzip -1 > /build.tar.gz
|
||||
|
||||
# ---
|
||||
# pdk can't really be runnable, might as well shed a few layers
|
||||
FROM centos:centos7 as runnable
|
||||
|
||||
COPY --from=builder /build.tar.gz /build.tar.gz
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ ENV MANPATH=$OPENROAD/share/man:$MANPATH
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
ENV LC_CTYPE en_US.UTF-8
|
||||
ENV PDK_ROOT /build/pdk
|
||||
|
||||
# Tools
|
||||
ARG CACHE_INVALIDATOR=1
|
||||
@@ -39,9 +40,9 @@ ADD ./tool_metadata.yml /tool_metadata.yml
|
||||
## Copy Version
|
||||
ADD ./git_version /git_version
|
||||
|
||||
## Tarballs
|
||||
ADD ./openroad_tools.tar.gz /
|
||||
ADD ./openlane.tar.gz $OPENLANE_ROOT
|
||||
## Artifacts
|
||||
COPY ./build /build
|
||||
COPY ./openlane /openlane
|
||||
|
||||
## Tclsh RC
|
||||
COPY ./.tclshrc /.tclshrc
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
# Copyright 2020-2021 Efabless Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# WIP, probably will never make it to the image because it's taking forever to build
|
||||
|
||||
FROM openlane-build-base AS builder
|
||||
|
||||
ARG SKY130_REPO
|
||||
ARG SKY130_COMMIT
|
||||
|
||||
ENV PDK_ROOT /build/pdk
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
ENV LC_CTYPE en_US.UTF-8
|
||||
|
||||
WORKDIR ${PDK_ROOT}
|
||||
RUN git clone ${SKY130_REPO}
|
||||
WORKDIR ${PDK_ROOT}/skywater-pdk
|
||||
RUN git checkout main &&\
|
||||
git submodule init &&\
|
||||
git pull --no-recurse-submodules &&\
|
||||
git checkout -qf ${SKY130_COMMIT}
|
||||
RUN git submodule update --init libraries/sky130_fd_sc_hd/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_hs/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_hdll/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_ms/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_ls/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_sc_hvl/latest &&\
|
||||
git submodule update --init libraries/sky130_fd_io/latest
|
||||
RUN make -j$(nproc) timing > /build/pdk_timing.log 2>&1
|
||||
|
||||
ARG MAGIC_REPO
|
||||
ARG MAGIC_COMMIT
|
||||
|
||||
WORKDIR /magic
|
||||
RUN curl -L ${MAGIC_REPO}/tarball/${MAGIC_COMMIT} | tar -xzC . --strip-components=1 && \
|
||||
./configure --prefix=/usr && \
|
||||
make -j$(nproc) && \
|
||||
make install
|
||||
|
||||
ARG OPEN_PDKS_REPO
|
||||
ARG OPEN_PDKS_COMMIT
|
||||
|
||||
WORKDIR ${PDK_ROOT}
|
||||
RUN git clone ${OPEN_PDKS_REPO}
|
||||
WORKDIR ${PDK_ROOT}/open_pdks
|
||||
RUN git checkout master &&\
|
||||
git checkout -qf ${OPEN_PDKS_COMMIT}
|
||||
RUN ./configure --enable-sky130-pdk=${PDK_ROOT}/skywater-pdk/libraries --enable-sram-sky130
|
||||
WORKDIR ${PDK_ROOT}/open_pdks/sky130
|
||||
RUN make alpha-repo xschem-repo sram-repo > /build/pdk_prereq.log 2>&1
|
||||
RUN make > ./build/pdk.log 2>&1
|
||||
RUN make SHARED_PDKS_PATH=${PDK_ROOT} install
|
||||
|
||||
|
||||
|
||||
# ---
|
||||
FROM openlane-run-base AS runnable
|
||||
|
||||
COPY --from=builder /build/pdk/pdk.log /build/pdk/pdk.log
|
||||
COPY --from=builder /build/pdk/sky130A /build/pdk/sky130A
|
||||
|
||||
|
||||
4
docker/tar/.gitignore
vendored
4
docker/tar/.gitignore
vendored
@@ -1,4 +1,6 @@
|
||||
/*.tar.gz
|
||||
/*.yml
|
||||
/*.txt
|
||||
/git_version
|
||||
/git_version
|
||||
/build
|
||||
/openlane
|
||||
Reference in New Issue
Block a user