feat: PORT-to-INTERCONNECT conversion (+ case-insensitive enum CLI options) - #9
Merged
Merged
Conversation
EntryType and ConflictStrategy member values are lower case, so passing the natural upper-case SDF spelling (e.g. `query --entry-type IOPATH`) raised `ValueError: 'IOPATH' is not a valid EntryType` as an uncaught traceback. Add a CaseInsensitiveStrEnum base that resolves values case-insensitively via `_missing_`, and surface genuinely invalid values as a clean `typer.BadParameter` instead of a traceback.
Back-ends such as Microchip Libero express routing delay with the SDF `(PORT <pin> ...)` construct, which names only the load pin and leaves the driver implicit. Tools that consume only `(INTERCONNECT <src> <dst> ...)`, which names both endpoints, cannot use those delays. `port_to_interconnect` rewrites each PORT delay into the equivalent INTERCONNECT by recovering the driver from the gate-level netlist (parsed with Yosys, reusing the connectivity path already used for INTERCONNECT annotation). Drivers are read from connectivity, never guessed: the SDF's own IOPATH outputs and the top-level port directions identify drivers, and a cell the SDF does not time is resolved by elimination on its single-driver net. Any sink that does not resolve to exactly one driver raises DriverResolutionError; nothing is dropped or defaulted. Exposed as `sdf-toolkit port-to-interconnect FILE.sdf NETLIST.v`.
KelvinChung2000
force-pushed
the
feat/port-to-interconnect
branch
from
June 23, 2026 22:52
23a5d78 to
19ce1e6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related changes, one per commit:
fix(cli)— enum-valued CLI options now accept any case.feat(transform)— newport-to-interconnecttransform + CLI command.fix(cli): case-insensitive enum option valuesEntryType/ConflictStrategymember values are lower case, so the naturalupper-case SDF spelling crashed with a raw traceback:
A
CaseInsensitiveStrEnumbase resolves values case-insensitively via_missing_, so--entry-type IOPATH(and--strategy KEEP-FIRST) work.Genuinely invalid values now surface as a clean
typer.BadParameterinstead ofa traceback.
feat(transform): PORT → INTERCONNECTBack-ends such as Microchip Libero express routing delay with
(PORT <pin> ...),which names only the load pin and leaves the driver implicit. Tools that consume
only
(INTERCONNECT <src> <dst> ...)(both endpoints named) cannot use thosedelays.
port_to_interconnectrewrites each PORT into the equivalentINTERCONNECT by recovering the driver from the gate-level netlist.
Drivers are read from connectivity, never guessed. Yosys parses the netlist
into bit-level nets (reusing the path already used for INTERCONNECT annotation);
the SDF's own IOPATH outputs and the top-level port directions identify drivers;
a cell the SDF does not time is resolved by elimination on its single-driver net
(the one endpoint that is not a known sink). Any sink that does not resolve to
exactly one driver raises
DriverResolutionErrorwith the full list — nothing isdropped or defaulted.
Testing
tests/test_interconnect.py: hand-built-netlist unit tests (no Yosys) coveringtop-input drivers, IOPATH-identified cell-output drivers, elimination for an
untimed buffer, PORT removal, top-cell placement, delay carry-over, input
immutability, and the raising paths (missing/unknown top module, instance not
in netlist, ambiguous driver). Plus Yosys-gated integration + CLI tests over a
new
tests/data/port_netlist.{v,sdf}fixture (+ golden).tests/test_typer_cli.py: upper-case--entry-typeworks; invalid value is aclean error, not a traceback.
346 passed); new/changed files passruff checkandruff format.Notes
rufffindings inanalysis/*and the top-level__init__.pyare left untouched (out of scope for this PR).