Skip to content

Commit

Permalink
🏠 Update import structure for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daquintero committed Sep 17, 2024
1 parent 34e00c7 commit d3071a7
Show file tree
Hide file tree
Showing 316 changed files with 4,153 additions and 3,153 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
uv venv --python=python${{ matrix.python-version }} venv
source venv/bin/activate
uv pip install -e .[dev]
uv pip install -r requirements_notebooks.txt
#----------------------------------------------
# add matrix specifics and run test suite
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/test_notebooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "piel-test-notebooks"

on:
workflow_dispatch:
push:
branches: [ develop ]
pull_request:
branches:
- develop

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
submodules: 'recursive'
- name: Test pre-commit hooks
run: |
python -m pip install --upgrade pip
pip install pre-commit
pre-commit run # this should be really more aggressive
build:
name: test ${{ matrix.python-version }} - ${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
strategy:
matrix:
python-version: ['3.10', '3.11']
platform: [ubuntu-latest]
defaults:
run:
shell: bash
env: # Set environment variables for the whole job
PIP_ONLY_BINARY: gdstk
MPLBACKEND: agg
steps:
- uses: actions/checkout@v4

- name: Set up uv
# Install a specific uv version using the installer
run: curl -LsSf https://astral.sh/uv/0.3.0/install.sh | sh

#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
uv --version
uv venv --python=python${{ matrix.python-version }} venv
source venv/bin/activate
uv pip install -e .[dev]
uv pip install -r requirements_notebooks.txt
#----------------------------------------------
# add matrix specifics and run test suite
#----------------------------------------------
- name: Run tests
run: |
source venv/bin/activate
uv run python docs/examples/run_all_notebooks.py
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 11 additions & 14 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
Examples
**************************

.. include:: examples/docs/tools.rst
.. include:: examples/docs/integrations.rst
.. include:: examples/docs/flows.rst
.. include:: examples/docs/experimental.rst


.. toctree::
:maxdepth: 3
:caption: List:
:hidden:

examples/00_setup
examples/01_run_openlane_flow
examples/02_digital_design_simulation/02_digital_design_simulation
examples/02a_large_scale_digital_layout/02a_large_scale_digital_layout
examples/03_sax_basics
examples/03a_sax_cocotb_cosimulation
examples/03b_optical_function_verification
examples/04_spice_cosimulation/04_spice_cosimulation
examples/04a_analogue_circuit_layout_simulation/04a_analogue_circuit_layout_simulation
examples/05_quantum_integration_basics
examples/06_component_codesign_basics
examples/06a_analytical_mzm_model
examples/08_basic_interconnection_modelling/08_basic_interconnection_modelling
examples/08a_pcb_interposer_characterisation/08a_pcb_interposer_characterisation
examples/docs/tools
examples/docs/integrations
examples/docs/flows
examples/docs/experimental
18 changes: 15 additions & 3 deletions docs/examples/00_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,18 @@
# You can interact with standard `OpenLane` [environment variables](https://openlane.readthedocs.io/en/latest/reference/configuration.html) through:

import os
import pathlib

os.environ["OPENLANE_ROOT"]
try:
os.environ["OPENLANE_ROOT"]
except KeyError as e:
print(
f"Make sure you have an OPENLANE_ROOT environment variable for Openlane V1: {e}"
)
design_directory = pathlib.Path(__file__).parent.absolute()
print(f"Setting OPENLANE_ROOT to the piel examples: {design_directory}")
os.environ["OPENLANE_ROOT"] = str(design_directory)
exit

# This gives us the source directory of the OpenLane v1 installation under `foss/tools/`, but not the version directory, nor the directory of the standard `./flow.tcl` design inclusion and execution.

Expand All @@ -120,5 +130,7 @@
openlane_root_directory

# We can find out all the default designs in Openlane designs accordingly

list((openlane_root_directory / "designs").iterdir())
try:
list((openlane_root_directory / "designs").iterdir())
except Exception as e:
print("Make sure you are using an Openlane V1 root directory.")
27 changes: 20 additions & 7 deletions docs/examples/01_run_openlane_flow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# # Run OpenLane Flow

# <div style="padding: 10px; border-radius: 5px;">
# <strong>⚠️ Warning:</strong> This example requires uses packages which are locally available when cloning and installing the `stable` verision of the github source code. See example setup as follows:
# </div>

# + active=""
# !git clone https://github.com/daquintero/piel.git
# !cd piel/
# !pip install -e .[tools]
# !pip install -r requirements_notebooks.txt
# -

import piel

# Assume we are starting from the iic-osic-home design directory, all our design files are there in the format as described in the piel `sections/project_structure` documentation. You have followed the previous environment docs/examples/00_setup_environment to run the projects in this example:
Expand Down Expand Up @@ -48,15 +59,15 @@

piel.return_path(amaranth_driven_flow)

openlane_2_run_amaranth_flow = piel.run_openlane_flow(

openlane_2_run_amaranth_flow = piel.tools.openlane.run_openlane_flow(
design_directory=amaranth_driven_flow,
only_generate_flow_setup=True,
)
# TODO fix warnings

# This should generate a `openlane 2` driven layout in the `amaranth_driven_flow` directory if you change the `only_generate_configuration` flag to `True`. Let's list the available runs in this project:

all_amaranth_driven_design_runs = piel.find_all_design_runs(
all_amaranth_driven_design_runs = piel.tools.openlane.find_all_design_runs(
design_directory=amaranth_driven_flow,
)
all_amaranth_driven_design_runs
Expand All @@ -66,21 +77,23 @@
# 'v1': [PosixPath('/home/daquintero/piel/docs/examples/designs/amaranth_driven_flow/amaranth_driven_flow/runs/RUN_2023.08.22_00.06.09')]}
# ```

latest_amaranth_driven_openlane_runs = piel.find_latest_design_run(
latest_amaranth_driven_openlane_runs = piel.tools.openlane.find_latest_design_run(
design_directory=amaranth_driven_flow,
)
latest_amaranth_driven_openlane_runs

# We can check what is the path to our generated `gds` file accordingly:

piel.get_gds_path_from_design_run(
piel.tools.openlane.get_gds_path_from_design_run(
design_directory=amaranth_driven_flow,
)

# It is quite easy to visualise it on the jupyter lab using the `gdsfactory` integration widget:

amaranth_driven_flow_component = piel.create_gdsfactory_component_from_openlane(
design_directory=amaranth_driven_flow,
amaranth_driven_flow_component = (
piel.integration.create_gdsfactory_component_from_openlane(
design_directory=amaranth_driven_flow,
)
)
amaranth_driven_flow_component

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
output_ports=["phase_map_out"],
**detector_phase_truth_table,
)
am_module = piel.amaranth.construct_amaranth_module_from_truth_table(
am_module = piel.tools.amaranth.construct_amaranth_module_from_truth_table(
truth_table, logic_implementation_type="sequential"
)
am_module
Expand Down Expand Up @@ -214,11 +214,11 @@

# Check that there exist cocotb python test files already in our design directory:

piel.check_cocotb_testbench_exists(simple_design)
piel.tools.cocotb.check_cocotb_testbench_exists(simple_design)

# Create a cocotb Makefile

piel.configure_cocotb_simulation(
piel.tools.cocotb.configure_cocotb_simulation(
design_directory=simple_design,
simulator="icarus",
top_level_language="verilog",
Expand All @@ -243,7 +243,7 @@
# Now we can create the simulation output files from the `makefile`. Note this will only work in our configured Linux environment.

# Run cocotb simulation
piel.run_cocotb_simulation(design_directory)
piel.tools.cocotb.run_cocotb_simulation(design_directory)

# ```bash
# Standard Output (stdout):
Expand Down Expand Up @@ -307,8 +307,8 @@
#
# We first list the files for our design directory, which is out `simple_design` local package if you have followed the correct installation instructions, and we can input our module import rather than an actual path unless you desire to customise.

cocotb_simulation_output_files = piel.get_simulation_output_files_from_design(
simple_design
cocotb_simulation_output_files = (
piel.tools.cocotb.get_simulation_output_files_from_design(simple_design)
)
cocotb_simulation_output_files

Expand All @@ -318,7 +318,7 @@

# We can read the simulation output files accordingly:

example_simple_simulation_data = piel.read_simulation_data(
example_simple_simulation_data = piel.tools.cocotb.read_simulation_data(
cocotb_simulation_output_files[0]
)
example_simple_simulation_data
Expand Down Expand Up @@ -350,38 +350,41 @@
# ## Sequential Implementation

# +
from openlane.flows import SequentialFlow
from openlane.steps import Yosys, OpenROAD, Magic, Netgen


class MyFlow(SequentialFlow):
Steps = [
Yosys.Synthesis,
OpenROAD.Floorplan,
OpenROAD.TapEndcapInsertion,
OpenROAD.GeneratePDN,
OpenROAD.IOPlacement,
OpenROAD.GlobalPlacement,
OpenROAD.DetailedPlacement,
OpenROAD.GlobalRouting,
OpenROAD.DetailedRouting,
OpenROAD.FillInsertion,
Magic.StreamOut,
Magic.DRC,
Magic.SpiceExtraction,
Netgen.LVS,
]


flow = MyFlow(
{
"PDK": "sky130A",
"DESIGN_NAME": "spm",
"VERILOG_FILES": ["./src/spm.v"],
"CLOCK_PORT": "clk",
"CLOCK_PERIOD": 10,
},
design_dir=".",
)
flow.start()
try:
from openlane.flows import SequentialFlow
from openlane.steps import Yosys, OpenROAD, Magic, Netgen

class MyFlow(SequentialFlow):
Steps = [
Yosys.Synthesis,
OpenROAD.Floorplan,
OpenROAD.TapEndcapInsertion,
OpenROAD.GeneratePDN,
OpenROAD.IOPlacement,
OpenROAD.GlobalPlacement,
OpenROAD.DetailedPlacement,
OpenROAD.GlobalRouting,
OpenROAD.DetailedRouting,
OpenROAD.FillInsertion,
Magic.StreamOut,
Magic.DRC,
Magic.SpiceExtraction,
Netgen.LVS,
]

flow = MyFlow(
{
"PDK": "sky130A",
"DESIGN_NAME": "spm",
"VERILOG_FILES": ["./src/spm.v"],
"CLOCK_PORT": "clk",
"CLOCK_PERIOD": 10,
},
design_dir=".",
)
flow.start()
except ModuleNotFoundError as e:
print(
f"Make sure you are running this from an environment with Openlane nix installed {e}"
)
# -
Loading

0 comments on commit d3071a7

Please sign in to comment.