Skip to content

Commit

Permalink
Migrate Build System to Match OpenLane 2 (The-OpenROAD-Project#2115)
Browse files Browse the repository at this point in the history
+ Repository is now a Nix flake
~ Change all invocations of `openroad -python` to use `run_odbpy_script` for consistency
~ Change build system from ad-hoc to Nix, still producing a Docker image as a final result
~ Update KLayout scripts to use `klayout-pymod` or properly parse commandline arguments
~ `open_pdks` -> `bdc9412` to match OpenLane 2
- Remove local installer; `nix run .` will run OpenLane natively
  • Loading branch information
donn authored May 8, 2024
1 parent 337ffbf commit 14b94a6
Show file tree
Hide file tree
Showing 65 changed files with 844 additions and 2,629 deletions.
41 changes: 17 additions & 24 deletions .github/actions/docker_build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,33 @@ runs:
using: "composite"
steps:
- uses: actions/checkout@v2
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
- uses: docker/setup-buildx-action@v2
- uses: ./.github/actions/set_env_variables

- name: Check If Going To Push An Image To Docker
shell: bash
run: |
export PUSHING=$(ruby -e 'if ("${{ github.event_name }}" != "pull_request" && "${{ inputs.dockerhub_user }}" != ""); print(1) else print(0) end')
echo "PUSHING=$PUSHING" >> $GITHUB_ENV
- name: Login to DockerHub
if: ${{ env.PUSHING == '1' }}
uses: docker/login-action@v1
with:
username: ${{ inputs.dockerhub_user }}
password: ${{ inputs.dockerhub_password }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- uses: DeterminateSystems/nix-installer-action@main
with:
extra-conf: |
extra-substituters = https://openlane.cachix.org
extra-trusted-public-keys = openlane.cachix.org-1:qqdwh+QMNGmZAuyeQJTH9ErW57OWSvdtuwfBKdS254E=
- name: Docker Build
shell: bash
run: |
export BUILD_IF_CANT_PULL=1
export BUILD_COMMAND="docker build"
if [ "$PUSHING" = "1" ]; then
export BUILD_IF_CANT_PULL_THEN_PUSH=1
export BUILD_COMMAND="docker buildx build --load --cache-from=type=gha --cache-to=type=gha,scope=${{ github.workflow }}}"
fi
export BUILD_ARCH=${{ inputs.arch }}
cd docker/ && make merge
make -C docker
- name: Export Docker Image
shell: bash
run: docker save -o /tmp/image-${{ inputs.arch }}.tar ${{ env.OPENLANE_IMAGE_NAME }}-${{ inputs.arch }}
run: |
docker save -o /tmp/image-${{ inputs.arch }}.tar efabless/openlane:current-${{ inputs.arch }}
- name: Upload Docker Image
uses: actions/upload-artifact@v2
Expand Down
4 changes: 0 additions & 4 deletions .github/actions/set_env_variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ runs:
- name: Export Branch Name
shell: bash
run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Export Temp Image Name
shell: bash
run: echo "OPENLANE_IMAGE_NAME=openlane:intermediate" >> $GITHUB_ENV
5 changes: 0 additions & 5 deletions .github/scripts/gh.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ def export_env_alt(key, value):
print('Environment variables required: "PDK_ROOT"')
exit(os.EX_CONFIG)

if os.getenv("OPENLANE_IMAGE_NAME") is None:
print('Environment variables required: "OPENLANE_IMAGE_NAME"')
exit(os.EX_CONFIG)

origin = os.getenv("REPO_URL")
repo = Repo("Openlane", origin)

Expand All @@ -136,7 +132,6 @@ def export_env_alt(key, value):
"run_id": os.getenv("GITHUB_RUN_ID"),
"origin": origin,
"branch": os.getenv("BRANCH_NAME"),
"image": os.getenv("OPENLANE_IMAGE_NAME"),
"root": os.getenv("GITHUB_WORKSPACE"),
"pdk_root": os.getenv("PDK_ROOT"),
"pdk": os.getenv("PDK"),
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
f"PDK_ROOT={gh.pdk_root}",
"-e",
f"PDK={gh.pdk}",
gh.image,
"efabless/openlane:current-amd64",
"bash",
"-c",
shlex.join(
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/openlane_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ jobs:
run: python3 -m pip install pyyaml

- name: Run Issue Regression Test
run: cd ${GITHUB_WORKSPACE}/ && make run_issue_regression ISSUE_REGRESSION_DESIGN=${{ matrix.test }}
run: |
OPENLANE_IMAGE_NAME=efabless/openlane:current\
make run_issue_regression ISSUE_REGRESSION_DESIGN=${{ matrix.test }}
- name: Upload Logs
if: ${{ always() }}
Expand Down Expand Up @@ -231,7 +233,7 @@ jobs:

- name: Run Test
run: |
OPENLANE_IMAGE_NAME=$OPENLANE_IMAGE_NAME-amd64\
OPENLANE_IMAGE_NAME=efabless/openlane:current-amd64\
python3 ${GITHUB_WORKSPACE}/.github/scripts/run_tests.py ${{ matrix.design.name }}
- name: Escape Design Name
Expand Down Expand Up @@ -267,6 +269,16 @@ jobs:
with:
fetch-depth: 0

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true

- name: Set up environment variables
uses: ./.github/actions/set_env_variables

Expand Down Expand Up @@ -355,7 +367,7 @@ jobs:
run: |
for tag in $TAG_LIST; do
for arch in amd64 arm64v8; do
docker image tag ${{ env.OPENLANE_IMAGE_NAME }}-$arch ${{ vars.DOCKER_IMAGE }}:$tag-$arch
docker image tag efabless/openlane:current-$arch ${{ vars.DOCKER_IMAGE }}:$tag-$arch
docker push ${{ vars.DOCKER_IMAGE }}:$tag-$arch
done
docker manifest create ${{ vars.DOCKER_IMAGE }}:$tag\
Expand Down
82 changes: 0 additions & 82 deletions .github/workflows/tool_updater.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ FASTEST_TEST_SET_TAG ?= FASTEST_TEST_SET
EXTENDED_TEST_SET_TAG ?= EXTENDED_TEST_SET
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)

export PDK_ROOT ?= $(HOME)/.volare
Expand Down Expand Up @@ -114,8 +113,9 @@ ENV_COMMAND = $(ENV_START) $(OPENLANE_IMAGE_NAME)-$(DOCKER_ARCH)
all: get-openlane pdk

.PHONY: openlane
openlane: venv/created
@PYTHON_BIN=$(PWD)/venv/bin/$(PYTHON_BIN) $(MAKE) -C docker openlane
openlane:
@$(MAKE) -C docker openlane
docker tag efabless/openlane:current-$(DOCKER_ARCH) $(OPENLANE_IMAGE_NAME)-$(DOCKER_ARCH)

.PHONY: openlane-and-push-tools
openlane-and-push-tools: venv/created
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<h1 align="center">OpenLane</h1>
<p align="center">
<a href="https://colab.research.google.com/github/chipsalliance/silicon-notebooks/blob/main/digital-inverter-openlane.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open in Colab"></a>
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License: Apache 2.0"/></a>
<img src="https://github.com/efabless/volare/actions/workflows/ci.yml/badge.svg?branch=main" alt="GitHub Actions Status Badge" />
<a href="https://openlane.readthedocs.io/"><img src="https://readthedocs.org/projects/openlane/badge/?version=latest" alt="Documentation Build Status Badge"/></a>
<a href="https://invite.skywater.tools"><img src="https://img.shields.io/badge/Community-Open%20Source%20Silicon%20Slack-ff69b4?logo=slack" alt="Invite to the Open Source Silicon Slack"/></a>
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/python%20code%20style-black-000000.svg" alt="Python Code Style: black"/></a>
<a href="https://open-source-silicon.dev"><img src="https://img.shields.io/badge/Community-Open%20Source%20Silicon%20Slack-ff69b4?logo=slack" alt="Invite to the Open Source Silicon Slack"/></a>
<a href="https://nixos.org/"><img src="https://img.shields.io/static/v1?logo=nixos&logoColor=white&label=&message=Built%20with%20Nix&color=41439a" alt="Built with Nix"/></a>
</p>

OpenLane is an automated RTL to GDSII flow based on several components including OpenROAD, Yosys, Magic, Netgen, CVC, SPEF-Extractor, KLayout and a number of custom scripts for design exploration and optimization. The flow performs all ASIC implementation steps from RTL all the way down to GDSII.
Expand Down
117 changes: 117 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Copyright 2024 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.
{
lib,
libparse,
stdenv,
python3,
makeWrapper,
ncurses,
coreutils-full,
gnugrep,
gnused,
gnutar,
gzip,
git,
bash,
klayout-pymod,
yosys,
opensta,
openroad,
klayout,
netgen,
magic,
verilog,
verilator,
tclFull,
}:
let
pyenv = (python3.withPackages (ps: with ps; [
libparse
click
pyyaml
XlsxWriter
klayout-pymod
]));
pyenv-sitepackages = "${pyenv}/${pyenv.sitePackages}";
in
stdenv.mkDerivation rec {
name = "openlane1";

src = [
./flow.tcl
./scripts
./configuration
./dependencies
];

unpackPhase = ''
echo $src
for file in $src; do
BASENAME=$(python3 -c "import os; print('$file'.split('-', maxsplit=1)[1], end='$EMPTY')")
cp -r $file $PWD/$BASENAME
done
ls -lah
'';

passthru = {
pyenv = pyenv;
};

includedTools = [
yosys
opensta
openroad
klayout
netgen
magic
verilog
verilator
tclFull
];

propagatedBuildInputs = includedTools ++ [
pyenv
ncurses
coreutils-full
gnugrep
gnused
bash
gnutar
gzip
git
];

nativeBuildInputs = [makeWrapper];

installPhase = ''
mkdir -p $out/bin
cp -r * $out/bin
wrapProgram $out/bin/flow.tcl\
--set PATH ${lib.makeBinPath (propagatedBuildInputs)}\
--set PYTHONPATH ${pyenv-sitepackages}
'';

doCheck = true;

computed_PATH = lib.makeBinPath (propagatedBuildInputs);

meta = with lib; {
description = "RTL-to-GDSII flow for application-specific integrated circuits (ASIC)s";
homepage = "https://efabless.com/openlane";
mainProgram = "flow.tcl";
license = licenses.asl20;
platforms = platforms.linux ++ platforms.darwin;
};
}
Loading

0 comments on commit 14b94a6

Please sign in to comment.