### Running an Example with Dockerized OpenLane
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/migrants/index.md
This example demonstrates how to clone the OpenLane repository, set up the PDK, mount the environment, and run a design using the Dockerized OpenLane installation. It shows the command-line interface for starting the OpenLane environment from any location.
```bash
git clone https://github.com/The-OpenROAD-Project/OpenLane
make pdk
make mount
./flow.tcl -design spm
```
```bash
pip3 install --upgrade openlane
openlane --dockerized --run-example spm
```
--------------------------------
### Example Setup Timing Report
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/usage/timing_closure/index.md
This snippet shows an example of a worst negative slack report for setup timing, indicating the maximum deviation from the required timing constraints.
```text
===========================================================================
Worst Negative Slack (Setup)
============================================================================
nom_tt_025C_1v80: 0.0
```
--------------------------------
### Run SPM Example with OpenLane2
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/nix_installation/_running_example.md
Create a directory for your designs, navigate into it, and run the 'spm' example using OpenLane2. This is a basic test to ensure the installation is working correctly.
```bash
mkdir my_designs
cd my_designs/
openlane --run-example spm
```
--------------------------------
### Setup Nix Package Manager
Source: https://github.com/chipfoundry/openlane2/blob/main/notebook.ipynb
Installs the Nix package manager and enables the experimental 'flakes' feature. This is the primary method for installing OpenLane 2. If not in Colab, ensure Nix is installed and flakes are enabled manually.
```python
# @title Setup Nix {display-mode: "form"}
# @markdown
# @markdown
# @markdown Nix is a package manager with an emphasis on reproducible builds,
# @markdown and it is the primary method for installing OpenLane 2.
# @markdown
# @markdown This step installs the Nix package manager and enables the
# @markdown experimental "flakes" feature.
# @markdown
# @markdown If you're not in a Colab, this just sets the environment variables.
# @markdown You will need to install Nix and enable flakes on your own following
# @markdown [this guide](https://openlane2.readthedocs.io/en/stable/getting_started/common/nix_installation/index.html).
import os
import sys
import shutil
os.environ["LOCALE_ARCHIVE"] = "/usr/lib/locale/locale-archive"
if "google.colab" in sys.modules:
if shutil.which("nix-env") is None:
!curl -L https://nixos.org/nix/install | bash -s -- --daemon --yes
!echo "extra-experimental-features = nix-command flakes" >> /etc/nix/nix.conf
!killall nix-daemon
else:
if shutil.which("nix-env") is None:
raise RuntimeError("Nix is not installed!")
os.environ["PATH"] = f"/nix/var/nix/profiles/default/bin/:{os.getenv('PATH')}"
```
--------------------------------
### Run OpenLane Example
Source: https://github.com/chipfoundry/openlane2/blob/main/Readme.md
An example command to run OpenLane with a specific PDK root and configuration file.
```sh
python3 -m openlane --pdk-root $HOME/.volare ./designs/spm/config.json
```
--------------------------------
### Install PDK with OpenLane 1
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/migrants/index.md
Use 'make pdk' to install PDKs in OpenLane 1. OpenLane 2 automates this using Volare.
```bash
make pdk
```
--------------------------------
### Minimal YAML Configuration Example
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/reference/configuration.md
A basic YAML configuration file demonstrating essential design parameters and PDK-specific settings, equivalent to the JSON example.
```yaml
DESIGN_NAME: spm
VERILOG_FILES: dir::src/*.v
CLOCK_PORT: clk
CLOCK_PERIOD: 100
pdk::sky130A:
MAX_FANOUT_CONSTRAINT: 6
FP_CORE_UTIL: 40
PL_TARGET_DENSITY_PCT: expr::($FP_CORE_UTIL + 10.0)
scl::sky130_fd_sc_hd:
CLOCK_PERIOD: 15.0
```
--------------------------------
### Install Dependencies with Homebrew
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/docker_installation/installation_macos.md
Installs necessary packages like make, Python, and Docker using Homebrew. Ensure Homebrew is installed first.
```shell
brew install make python python-tk
brew install --cask docker
```
--------------------------------
### Install curl on Ubuntu
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/nix_installation/installation_linux.md
Ensures `curl` is installed, which is a prerequisite for downloading and running the Nix installation script.
```bash
sudo apt-get install -y curl
```
--------------------------------
### Pin Placement Configuration Example
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/reference/pin_placement_cfg.md
Example .cfg file demonstrating section definitions, pin regular expressions, virtual pins, and annotations for the SPM design.
```cfg
#N
@min_distance=0.1
x.*
#S
$1
rst
#E
clk
#W
p
y
```
--------------------------------
### Install Ubuntu on WSL
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/docker_installation/installation_win.md
Use this command in Windows PowerShell to install the Ubuntu distribution for WSL.
```powershell
wsl --install -d Ubuntu
```
--------------------------------
### Minimal JSON Configuration Example
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/reference/configuration.md
A basic JSON configuration file demonstrating essential design parameters and PDK-specific settings.
```json
{
"DESIGN_NAME": "spm",
"VERILOG_FILES": "dir::src/*.v",
"CLOCK_PORT": "clk",
"CLOCK_PERIOD": 100,
"pdk::sky130A": {
"MAX_FANOUT_CONSTRAINT": 6,
"FP_CORE_UTIL": 40,
"PL_TARGET_DENSITY_PCT": "expr::($FP_CORE_UTIL + 10.0)",
"scl::sky130_fd_sc_hd": {
"CLOCK_PERIOD": 15.0
}
}
}
```
--------------------------------
### Example Timing Path Analysis
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/usage/timing_closure/index.md
This report snippet details a specific timing path, including start and end points, path type, delays, arrival times, required times, and the final slack calculation.
```text
Startpoint: x[9] (input port clocked by clk)
Endpoint: _618_ (rising edge-triggered flip-flop clocked by clk)
Path Group: clk
Path Type: min
Delay Time Description
---------------------------------------------------------
0.00 0.00 clock clk (rise edge)
0.00 0.00 clock network delay (ideal)
0.20 0.20 v input external delay
0.01 0.21 v x[9] (in)
0.08 0.28 ^ _537_/Y (sky130_fd_sc_hd__nand2_1)
0.06 0.34 v _541_/Y (sky130_fd_sc_hd__o21ai_1)
0.00 0.34 v _618_/D (sky130_fd_sc_hd__dfrtp_1)
0.34 data arrival time
0.00 0.00 clock clk (rise edge)
0.00 0.00 clock network delay (ideal)
0.00 0.00 clock reconvergence pessimism
0.00 ^ _618_/CLK (sky130_fd_sc_hd__dfrtp_1)
-0.05 -0.05 library hold time
-0.05 data required time
---------------------------------------------------------
-0.05 data required time
-0.34 data arrival time
---------------------------------------------------------
0.39 slack (MET)
```
--------------------------------
### Run Example Design with OpenLane 1
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/migrants/index.md
In OpenLane 1, example designs were run using './flow.tcl -design spm'. OpenLane 2 uses 'openlane --run-example spm' and copies designs to the current directory.
```bash
./flow.tcl -design spm
```
```bash
openlane --run-example spm
```
--------------------------------
### Instantiate and Run a Flow with Flow.__init__() and Flow.start()
Source: https://context7.com/chipfoundry/openlane2/llms.txt
Initialize a `Flow` object with a configuration and execute its steps using the `start()` method. The `Flow` constructor resolves configuration, and `start()` returns the final `State` after all steps are completed.
```python
from openlane.flows import Flow
Classic = Flow.factory.get("Classic")
```
--------------------------------
### Install Docker Engine on Ubuntu
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/docker_installation/installation_ubuntu.md
Follow these steps to install Docker Engine, CLI, containerd, and Docker Compose plugin. It is recommended to refer to the official Docker documentation for the most up-to-date instructions.
```bash
# Remove old installations
sudo apt-get remove docker docker-engine docker.io containerd runc
# Installation of requirements
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
# Add the keyrings of docker
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Add the package repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update the package repository
sudo apt-get update
# Install Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Check for installation
sudo docker run hello-world
```
--------------------------------
### Verify Docker Installation
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/docker_installation/installation_linux.md
Run this command to confirm that Docker has been installed correctly. It pulls and runs a minimal 'hello-world' container.
```bash
sudo docker run hello-world
```
--------------------------------
### Install Nix with OpenLane Configuration
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/nix_installation/installation_win.md
This command installs Nix using the Determinate Systems installer script. It configures Nix to use the OpenLane cachix binary cache for faster builds. Ensure you close and reopen your Ubuntu terminal after installation.
```bash
$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm --extra-conf "
extra-substituters = https://openlane.cachix.org
extra-trusted-public-keys = openlane.cachix.org-1:qqdwh+QMNGmZAuyeQJTH9ErW57OWSvdtuwfBKdS254E=
"
```
--------------------------------
### Flow.__init__() and Flow.start()
Source: https://context7.com/chipfoundry/openlane2/llms.txt
The Flow constructor accepts a config path/dict and resolves configuration; start() executes all steps and returns the final State.
```APIDOC
## Flow.__init__() and Flow.start() — Instantiate and Run a Flow
### Description
The `Flow` constructor accepts a config path/dict and resolves configuration; `start()` executes all steps and returns the final `State`.
### Method Signature
```python
Flow(config_path_or_dict, flow_name)
Flow.start()
```
### Parameters
- **config_path_or_dict**: Path to a configuration file or a dictionary containing configuration variables.
- **flow_name**: The name of the flow to instantiate (e.g., "Classic").
### Request Example
```python
from openlane.flows import Flow
Classic = Flow.factory.get("Classic")
# Instantiate the flow with a configuration file
flow = Classic("~/my_designs/pm32/config.json")
# Execute the flow
final_state = flow.start()
# Instantiate the flow with a configuration dictionary
config_dict = {
"DESIGN_NAME": "inverter",
"VERILOG_FILES": ["/path/to/inv.v"],
"CLOCK_PERIOD": 10,
"CLOCK_PORT": "clk",
}
flow2 = Classic(config_dict)
final_state2 = flow2.start()
```
### Response Example
```json
{
"state": {
"design_name": "pm32",
"metrics": {
"timing_slew_violation": 0,
"timing_setup_violation": 0
},
"views": {
"verilog": "/path/to/run/results/final.v",
"def": "/path/to/run/results/final.def"
}
}
}
```
```
--------------------------------
### Instantiate and Start Custom Flow Using API
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/usage/writing_custom_flows.md
Instantiate and start a custom flow defined via the API. The `start` method returns the final state and a list of step objects. Avoid calling the `run` method directly, as it is intended for internal use by the `Flow` class.
```python
flow = MyFlow(
{
"PDK": "sky130A",
"DESIGN_NAME": "spm",
"VERILOG_FILES": ["./src/spm.v"],
"CLOCK_PORT": "clk",
"CLOCK_PERIOD": 10,
},
design_dir=".",
)
flow.start()
```
--------------------------------
### Docker Hello-World Output
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/docker_installation/installation_linux.md
The expected output after a successful Docker installation when running the 'hello-world' container.
```text
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64)
3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
```
--------------------------------
### Install Nix on macOS
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/nix_installation/installation_macos.md
Run this command in Terminal.app to install Nix with specific configurations for OpenLane. Ensure you close all terminals after completion.
```bash
$ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm --extra-conf "
extra-substituters = https://openlane.cachix.org
extra-trusted-public-keys = openlane.cachix.org-1:qqdwh+QMNGmZAuyeQJTH9ErW57OWSvdtuwfBKdS254E="
```
--------------------------------
### Install Ubuntu Development Packages
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/_ubuntu_packages.md
Update package lists, upgrade existing packages, and install essential development tools including build tools, Python, pip, venv, curl, make, and git.
```bash
sudo apt-get update
sudo apt-get upgrade
sudo apt install -y build-essential python3 python3-venv python3-pip python3-tk curl make git
```
--------------------------------
### OpenLane 1 Macro Configuration Example
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/migrants/variables.md
Illustrates how macro information was defined across multiple variables in OpenLane 1.
```json
{
"VERILOG_FILES_BLACKBOX": ["dir::macros/spm/nl/spm.nl.v"],
"EXTRA_GDS_FILES": ["dir::macros/gds/spm.gds"],
"EXTRA_LEFS": ["dir::macros/lef/spm.lef"],
"EXTRA_SPEFS": "spm dir::macros/spm/spef/nom_/spm.nom.spef dir::macros/spm/spef/nom_/spm.nom.spef dir::macros/spm/spef/nom_/spm.max.spef",
"MACRO_PLACEMENT_CFG": "dir::macro_placement.cfg"
}
```
--------------------------------
### WSL Verbose Output - Ubuntu Running
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/docker_installation/installation_win.md
Example output indicating that Ubuntu and Docker services are running correctly within WSL.
```powershell
PS C:\Users\user> wsl --list --verbose
NAME STATE VERSION
* Ubuntu Running 2
docker-desktop Running 2
docker-desktop-data Running 2
```
--------------------------------
### Instantiate and Run Classic Flow
Source: https://context7.com/chipfoundry/openlane2/llms.txt
Instantiate the Classic flow with a configuration file, PDK, and PDK root. The start method runs the flow and returns the final state, providing paths to GDSII, netlists, and design metrics.
```python
flow = Classic(
config="~/my_designs/pm32/config.json",
pdk="sky130A",
pdk_root="~/.volare",
)
final_state = flow.start(
tag="my_run_01", # optional: name the run directory
overwrite=False, # set True to delete and re-run an existing tag
)
print(final_state["gds"])
print(final_state["nl"])
print(final_state.metrics.get("design__instance__area"))
```
--------------------------------
### Run Docker Hello World
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/docker_installation/_common.md
Execute the 'hello-world' Docker image to confirm Docker is functioning. This command should run without requiring root privileges after initial setup.
```shell
# After reboot
docker run hello-world
```
--------------------------------
### CVC Timing Violation Message Example
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/usage/timing_closure/index.md
This is an example of a timing violation message that CVC might display during simulation, indicating a potential issue with setup or hold times.
```text
WARN** now 2050218 ps [566] timing violation in
x.y.sky130_fd_sc_hd__dfxtp_1_0_ (diff. 11 ps)
setup(of setuphold)((posedge D):2050207 ps, (posedge CLK):2050218 ps, 76 ps);
```
--------------------------------
### Install curl on Ubuntu
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/nix_installation/installation_win.md
Before installing Nix, ensure curl is installed on your Ubuntu WSL distribution. This command uses apt-get to install curl.
```bash
$ sudo apt-get install -y curl
```
--------------------------------
### Verify OpenLane Installation
Source: https://github.com/chipfoundry/openlane2/blob/main/notebook.ipynb
Prints the installed version of the OpenLane library to verify the installation.
```python
import openlane
print(openlane.__version__)
```
--------------------------------
### Classic Flow Instantiation and Execution
Source: https://context7.com/chipfoundry/openlane2/llms.txt
Demonstrates how to instantiate the Classic flow with a configuration file and run it. It also shows how to access the final state, including GDSII path, netlist, and design metrics.
```APIDOC
## Classic Flow
### Description
Instantiate and run the Classic flow.
### Method
`Classic(config, pdk, pdk_root)`
### Parameters
- **config** (string) - Path to the configuration JSON file.
- **pdk** (string) - The PDK to use (e.g., "sky130A").
- **pdk_root** (string) - The root directory for the PDK.
### Method
`start(tag, overwrite)`
### Parameters
- **tag** (string, optional) - Name for the run directory.
- **overwrite** (boolean, optional) - Set to `True` to delete and re-run an existing tag. Defaults to `False`.
### Response
- **final_state** (dict) - A dictionary containing the final state of the flow.
- **gds** (string) - Path to the final GDSII file.
- **nl** (string) - Path to the gate-level netlist.
- **metrics** (dict) - Dictionary of design metrics.
### Request Example
```python
from openlane.flows import Classic
flow = Classic(
config="~/my_designs/pm32/config.json",
pdk="sky130A",
pdk_root="~/.volare",
)
final_state = flow.start(
tag="my_run_01",
overwrite=False,
)
print(final_state["gds"])
print(final_state["nl"])
print(final_state.metrics.get("design__instance__area"))
```
```
--------------------------------
### Install OpenLane using PIP
Source: https://github.com/chipfoundry/openlane2/blob/main/docs/source/getting_started/common/docker_installation/_common.md
Install the OpenLane package using pip. This command downloads and installs the latest version of OpenLane.
```shell
python3 -m pip install openlane
```
--------------------------------
### Get and Display Step Help
Source: https://github.com/chipfoundry/openlane2/blob/main/notebook.ipynb
Retrieve a specific implementation step, such as Yosys Synthesis, from the step factory and display its available configuration options and help information.
```python
from openlane.steps import Step
Synthesis = Step.factory.get("Yosys.Synthesis")
Synthesis.display_help()
```
--------------------------------
### Download and Install OpenLane
Source: https://github.com/chipfoundry/openlane2/blob/main/notebook.ipynb
Downloads and installs OpenLane, its tool dependencies using Nix, and OpenLane itself using PIP. Ensure `python3-tk` is installed on your OS if needed.
```python
# @title Get OpenLane {display-mode: "form"}
# @markdown Click the ▷ button to download and install OpenLane.
# @markdown
# @markdown This will install OpenLane's tool dependencies using Nix,
# @markdown and OpenLane itself using PIP.
# @markdown
# @markdown Note that `python3-tk` may need to be installed using your OS's
# @markdown package manager.
import os
import subprocess
import IPython
openlane_version = "version-2.1" # @param {key:"OpenLane Version", type:"string"}
if openlane_version == "latest":
openlane_version = "main"
pdk_root = "~/.volare" # @param {key:"PDK Root", type:"string"}
pdk_root = os.path.expanduser(pdk_root)
pdk = "sky130" # @param {key:"PDK (without the variant)", type:"string"}
openlane_ipynb_path = os.path.join(os.getcwd(), "openlane_ipynb")
display(IPython.display.HTML("
tkinter library for Python, which is required to load PDK configuration values. Make sure python3-tk or equivalent is installed on your system.'
)
)
raise e from None
display(IPython.display.HTML("