Skip to content

feat(cspdk): add logical electrical pins for SPICE export - #334

Draft
das-dias wants to merge 4 commits into
gdsfactory:mainfrom
das-dias:dev/add-logical-pins-cspdk
Draft

feat(cspdk): add logical electrical pins for SPICE export#334
das-dias wants to merge 4 commits into
gdsfactory:mainfrom
das-dias:dev/add-logical-pins-cspdk

Conversation

@das-dias

@das-dias das-dias commented Aug 20, 2026

Copy link
Copy Markdown

Closes doplaydo/pdks#45

Summary

  • Bump gdsfactory to ~=9.48.0
  • Delete _common.py wrapper
  • Remove duplicate add_electrical_pins calls from cells wrapping upstream gf.c.* components that already register pins in 9.48 (wire_corner, wire_corner45, wire_corner45_straight, taper_metal, pad, compass)
  • Keep add_electrical_pins on cells using gf.c.straight/bend_circular/bend_s (which don't register pins internally)
  • Add EXPECTED_PIN_NAMES + 120 parametrized tests across all 6 variants (si220_oband, si220_cband, si340, sin200, sin300, si500)
  • Regenerate GDS/settings reference files for gdsfactory 9.48

Test plan

  • All 120 electrical pin tests pass
  • Full test suite passes (flaky ring_double/coupler_straight excluded)
  • Reference files regenerated for gdsfactory 9.48

Summary by Sourcery

Enable reliable logical electrical pin export for SPICE across the supported PDK cells.

New Features:

  • Add logical DC electrical pins to metal waveguide cells across all supported PDK variants for SPICE export.

Enhancements:

  • Update the project to gdsfactory 9.48 and align electrical-pin registration with upstream component behavior.

Build:

  • Add a development option for installing gdsfactory from its main branch.

Tests:

  • Add parametrized coverage validating electrical pin registration, types, and names across six PDK variants.

Chores:

  • Regenerate reference settings and dependency lock data for the updated gdsfactory version.

das-dias added 3 commits July 28, 2026 21:23
Add add_electric_pins() to all PCells with electrical ports.
Logical-only mode. Closes doplaydo/pdks#45
…egistration

- Bump gdsfactory 9.45→9.48.0
- Delete _common.py wrapper
- Remove add_electrical_pins calls from cells wrapping upstream gf.c.*
  components that already register pins (wire_corner, wire_corner45,
  wire_corner45_straight, taper_metal, pad, compass)
- Keep add_electrical_pins for cells wrapping gf.c.straight, gf.c.bend_circular,
  gf.c.bend_s which don't register pins upstream
- Rewrite test_electrical_pins.py with EXPECTED_PIN_NAMES for all 6 variants
- Regenerate GDS/settings/model reference files for gdsfactory 9.48
@sourcery-ai

sourcery-ai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds logical electrical pin registration for specific metal routing cells, upgrades gdsfactory to 9.48, introduces a parametrized test suite to verify electrical pins for six PDK variants, and refreshes reference settings/GDS fixtures to match the new upstream behavior.

Sequence diagram for electrical pin registration in metal waveguide cells

sequenceDiagram
    participant Caller
    participant straight_metal
    participant bend_metal
    participant bend_s_metal
    participant gf_c as gf.c
    participant add_electrical_pins

    Caller->>straight_metal: straight_metal(length, cross_section, width)
    straight_metal->>gf_c: straight(length, cross_section, width, npoints)
    gf_c-->>straight_metal: Component c
    straight_metal->>add_electrical_pins: add_electrical_pins(c)
    add_electrical_pins-->>straight_metal: c with electrical pins
    straight_metal-->>Caller: Component c

    Caller->>bend_metal: bend_metal(angle, cross_section, width)
    bend_metal->>gf_c: bend_circular(radius, angle, width, cross_section, npoints, layer)
    gf_c-->>bend_metal: Component c
    bend_metal->>add_electrical_pins: add_electrical_pins(c)
    add_electrical_pins-->>bend_metal: c with electrical pins
    bend_metal-->>Caller: Component c

    Caller->>bend_s_metal: bend_s_metal(size, cross_section, width, allow_min_radius_violation)
    bend_s_metal->>gf_c: bend_s(size, cross_section, npoints, allow_min_radius_violation, width)
    gf_c-->>bend_s_metal: Component c
    bend_s_metal->>add_electrical_pins: add_electrical_pins(c)
    add_electrical_pins-->>bend_s_metal: c with electrical pins
    bend_s_metal-->>Caller: Component c
Loading

File-Level Changes

Change Details Files
Ensure metal-routing cells that use base straight/bend components register logical electrical pins for SPICE export.
  • Import add_electrical_pins from gdsfactory.add_pins into si220 cband/oband waveguide cells modules.
  • Wrap gf.c.straight/bend_circular/bend_s calls in straight_metal/bend_metal/bend_s_metal to assign the created component to a variable.
  • Invoke add_electrical_pins on the constructed metal-routing components before returning them.
cspdk/si220/cband/cells/waveguides.py
cspdk/si220/oband/cells/waveguides.py
Add a comprehensive test suite that validates DC logical electrical pins and pin names across six PDK variants.
  • Define EXPECTED_PIN_NAMES dictionaries per PDK variant capturing expected pin sets per cell.
  • Create parametrized pytest cases that activate each PDK, instantiate cells, and assert pins exist, are type 'DC', and include the expected names.
  • Generate parametrized lists (pytest.param) for each variant to give readable test IDs per cell name.
tests/test_electrical_pins.py
Upgrade dependency and tooling to gdsfactory 9.48 and support testing against gdsfactory main.
  • Bump gdsfactory dependency constraint from ~=9.45.0 to ~=9.48.0 in pyproject.toml.
  • Add a gf-main optional dependency group pointing to gdsfactory.git@main in pyproject.toml.
  • Add a gf-main Makefile target that installs gdsfactory from main via uv pip.
pyproject.toml
Makefile
Update reference settings YAML fixtures to align with new geometries and widths from gdsfactory 9.48.
  • Adjust optical port widths (e.g., from 0.4 to 0.45 or 0.8) and coordinates across si220_oband fixtures to match regenerated layouts.
  • Update si500 fixtures to reflect new xs_rc cross-section width and coupler/MZI geometries.
  • Refresh additional YAML reference files that capture bend, straight, coupler, grating, and spiral characteristics under the new version.
tests/test_si220_oband/test_settings_add_fiber_array_.yml
tests/test_si220_oband/test_settings_bend_euler_.yml
tests/test_si220_oband/test_settings_bend_s_.yml
tests/test_si220_oband/test_settings_coupler_.yml
tests/test_si220_oband/test_settings_coupler_rib_.yml
tests/test_si220_oband/test_settings_coupler_ring_.yml
tests/test_si220_oband/test_settings_crossing_.yml
tests/test_si220_oband/test_settings_crossing_rib_.yml
tests/test_si220_oband/test_settings_grating_coupler_elliptical_.yml
tests/test_si220_oband/test_settings_grating_coupler_rectangular_rib_.yml
tests/test_si220_oband/test_settings_mzi_.yml
tests/test_si220_oband/test_settings_ring_single_.yml
tests/test_si220_oband/test_settings_spiral_.yml
tests/test_si220_oband/test_settings_spiral_racetrack_.yml
tests/test_si220_oband/test_settings_straight_.yml
tests/test_si220_oband/test_settings_straight_heater_meander_.yml
tests/test_si220_oband/test_settings_straight_heater_metal_.yml
tests/test_si220_oband/test_settings_straight_rib_.yml
tests/test_si220_oband/test_settings_straight_strip_.yml
tests/test_si500/test_settings_bend_euler_.yml
tests/test_si500/test_settings_bend_euler_rc_.yml
tests/test_si500/test_settings_coupler_.yml
tests/test_si500/test_settings_coupler_rc_.yml
tests/test_si500/test_settings_coupler_straight_.yml
tests/test_si500/test_settings_grating_coupler_elliptical_.yml
tests/test_si500/test_settings_grating_coupler_elliptical_rc_.yml
tests/test_si500/test_settings_mzi_.yml
tests/test_si500/test_settings_mzi_rc_.yml
tests/test_si500/test_settings_straight_.yml
tests/test_si500/test_settings_straight_rc_.yml
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The electrical pin tests in tests/test_electrical_pins.py repeat the same three patterns for each PDK; consider parametrizing over (PDK, EXPECTED_PIN_NAMES) to remove the duplicated test blocks and keep them in sync more easily.
  • In the waveguide cells where you wrap gf.c.straight/bend_circular/bend_s, a small helper (e.g. straight_with_pins, bend_with_pins) could reduce repetition of c = ...; add_electrical_pins(c); return c and make it harder to forget pin registration in future cells.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The electrical pin tests in `tests/test_electrical_pins.py` repeat the same three patterns for each PDK; consider parametrizing over `(PDK, EXPECTED_PIN_NAMES)` to remove the duplicated test blocks and keep them in sync more easily.
- In the waveguide cells where you wrap `gf.c.straight`/`bend_circular`/`bend_s`, a small helper (e.g. `straight_with_pins`, `bend_with_pins`) could reduce repetition of `c = ...; add_electrical_pins(c); return c` and make it harder to forget pin registration in future cells.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@das-dias
das-dias marked this pull request as draft August 21, 2026 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant