Skip to content

feat: PORT-to-INTERCONNECT conversion (+ case-insensitive enum CLI options) - #9

Merged
KelvinChung2000 merged 2 commits into
masterfrom
feat/port-to-interconnect
Jul 7, 2026
Merged

feat: PORT-to-INTERCONNECT conversion (+ case-insensitive enum CLI options)#9
KelvinChung2000 merged 2 commits into
masterfrom
feat/port-to-interconnect

Conversation

@KelvinChung2000

Copy link
Copy Markdown
Collaborator

Summary

Two related changes, one per commit:

  1. fix(cli) — enum-valued CLI options now accept any case.
  2. feat(transform) — new port-to-interconnect transform + CLI command.

fix(cli): case-insensitive enum option values

EntryType / ConflictStrategy member values are lower case, so the natural
upper-case SDF spelling crashed with a raw traceback:

$ sdf-toolkit query design.sdf --entry-type IOPATH
ValueError: 'IOPATH' is not a valid EntryType

A CaseInsensitiveStrEnum base resolves values case-insensitively via
_missing_, so --entry-type IOPATH (and --strategy KEEP-FIRST) work.
Genuinely invalid values now surface as a clean typer.BadParameter instead of
a traceback.

feat(transform): PORT → INTERCONNECT

Back-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 those
delays. port_to_interconnect rewrites each PORT into the equivalent
INTERCONNECT by recovering the driver from the gate-level netlist.

sdf-toolkit port-to-interconnect design.sdf netlist.v -o design_interconnect.sdf

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 DriverResolutionError with the full list — nothing is
dropped or defaulted.

Testing

  • tests/test_interconnect.py: hand-built-netlist unit tests (no Yosys) covering
    top-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-type works; invalid value is a
    clean error, not a traceback.
  • Full suite green (346 passed); new/changed files pass ruff check and
    ruff format.

Notes

  • Pre-existing ruff findings in analysis/* and the top-level __init__.py
    are left untouched (out of scope for this PR).

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
KelvinChung2000 force-pushed the feat/port-to-interconnect branch from 23a5d78 to 19ce1e6 Compare June 23, 2026 22:52
@KelvinChung2000
KelvinChung2000 merged commit 405f101 into master Jul 7, 2026
10 checks passed
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