Skip to content

New zener functions to improve mcu modelisation - #1013

Open
DamienEspitallier wants to merge 3 commits into
diodeinc:mainfrom
DRBRev0:pin-capability-model
Open

DamienEspitallier wants to merge 3 commits into
diodeinc:mainfrom
DRBRev0:pin-capability-model

Conversation

@DamienEspitallier

@DamienEspitallier DamienEspitallier commented Aug 4, 2026

Copy link
Copy Markdown

When trying to make zener model for a STM32 a did not find a good way to ensure the user use the right port for a given peripheral.

So, I have extended zener language for supporting this natively. The idea is to add a solver to automatically select the best pins for a selected peripheral (specified with zener stdlib interface). You do not select manually, you request an interface (uart, i2c). You are still free to force the use of a specific pin.

It also add basic first support for swapiness declaration.

The idea is to let zener choose best ports to ensure all peripheral constraints are met and this also allow zener to throw an error if the mcu you choose do not have enough peripheral for you need.

I tried to make it as generic as possible, and added an example for a non mcu part like a quad comparator. This even allow the quad comparator module to automatically wire unused inputs to prevent oscillation.

Disclaimer: I used claude, especially for the pinmux constraint solver


Open in Devin Review

Note

High Risk
Large new elaboration solver (~3.5k LOC) on the critical eval/io/module path, plus a breaking interface() keyword change that can fail existing designs at elaboration time.

Overview
Adds a pinmux elaboration layer so multi-function parts declare peripheral capabilities and interface requests, then pin_solve picks a joint instance × pin assignment (with pin/instance exclusivity across repeated solves in a module). Results land in module properties pin_assignment and swap_classes; pin_map turns a solve into Component(pins=…), tying unclaimed pads to open nets.

Designers constrain placement with at(value, pins, soft=) on module connections (recorded through io() / config() and enforced at the root for contended or unused hard constraints). pin_request supports optional slots (if_connected), dict-of-roles (bind=), locks, and where= predicates; peripheral / pool / pin describe what each block can provide.

interface() gains implies (nominal capability matching over a DAG) and attrs (typed peripheral metadata); attrs and implies are now reserved—connection fields with those names must be renamed. Stdlib interfaces pick up attr vocabularies and new AdcIn / GpioPin types.

Smaller wiring: builtin.pinmux, module-context claim/tie-off state, clearer errors when at() is used on component pins, and a test that DiffPair impedance still reaches net properties through nested interfaces.

Reviewed by Cursor Bugbot for commit b3e8695. Bugbot is set up for automated code reviews on this repo. Configure here.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

ghost 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.

Devin Review found 2 new potential issues.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment thread crates/pcb-zen-core/src/lang/pinmux.rs Outdated
Comment thread crates/pcb-zen-core/src/lang/pinmux.rs Outdated
cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

ghost 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.

Devin Review found 1 new potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment thread crates/pcb-zen-core/src/lang/pinmux.rs Outdated

ghost 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.

Devin Review found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

Comment thread crates/pcb-zen-core/src/lang/pinmux.rs

ghost 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.

Devin Review found 1 new potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment thread crates/pcb-zen-core/src/lang/pinmux.rs

ghost 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.

Devin Review found 1 new potential issue.

View 10 additional findings in Devin Review.

Open in Devin Review

Comment thread crates/pcb-zen-core/src/lang/pinmux.rs
Comment thread crates/pcb-zen-core/src/lang/pinmux.rs
Comment thread crates/pcb-zen-core/src/lang/pinmux.rs
Comment thread crates/pcb-zen-core/src/lang/eval.rs
Comment thread CHANGELOG.md

ghost 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b3e8695. Configure here.

),
"pinmux.at_without_net",
starlark::errors::EvalSeverity::Error,
));

ghost Aug 8, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wrong file for at() net error

Medium Severity

The pinmux.at_without_net diagnostic uses eval.source_path() and omits the PinAt span, so it lands on the child module’s io()/config() file instead of the caller’s at() site. PinAt already carries site and span for this, and other pinmux diagnostics use them.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b3e8695. Configure here.

This branch has not been deployed

No deployments
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