Skip to content

Structured SVG export, export decorations, fanout bands, role grouping - #49

Merged
xtofalex merged 1 commit into
mainfrom
svg-structure-fanout-bands
Nov 14, 2026
Merged

xtofalex merged 1 commit into
mainfrom
svg-structure-fanout-bands

Conversation

@xtofalex

Copy link
Copy Markdown
Contributor

Summary

Role grouping — group_by: "role" gathers a wide net's sinks by the naja role of the receiving pin (clock, reset, set, enable, scan, address, else data). Both providers send a sparse "role" on term and occurrence entries (termRoleName() in LocalSNLProvider.cpp, term_role() in protocol.py); shared cases in tests/data/role_protocol_cases.json.

Structured SVG — every drawn object is a <g> with data-* attributes, so scripts can find things without reading geometry:

  • <g class="net"> (wires, junction dots, bus marks, label): data-net, data-driver (u1/u2:Q, or a port name), data-driver-id-path, data-label
  • <g class="instance">: data-path, data-id-path, data-model
  • <g class="port">: data-name, data-direction; <g class="summary">: data-group, data-count; <g class="module">
  • data-path-json / data-driver-json when a name is empty or holds / or :

The groups come from SchematicPainter::BeginGroup()/EndGroup() (no-ops on screen and in PNG). The drawing itself is unchanged: tests/SvgExportTest.cpp compares an undecorated export, group tags stripped, with tests/data/export_golden.svg.

Export decorations — view options title, caption, legend, hide_ui_glyphs, also export_svg()/export_png()/export_svgs() keywords and --title, --caption, --legend, --hide-ui-glyphs on every CLI. Exports only, never the canvas; the PNG draws the same page as the SVG.

Fanout layout

  • A sink grid with several drivers gets one band of rows per driver, level with it, all bands starting in the same column: no staircase, and no net's wires cross another net's sinks.
  • Sinks are in natural name order (lut_111 before lut_1037); this also decides which max_sinks sinks are drawn.
  • The near-black convergence outline is never drawn on a styled box; new view option convergence_outline (--no-convergence-outline, View > Outline Trace Convergence) turns it off.
  • --help and the README say max_sinks defaults to 32 when not given, and 0 disables it.

Version — __version__ goes from 0.2.1 to 0.3.0 (najaeda PR keplertech/naja#534 depends on this release).

Behavior changes

  • Natural order changes which sinks are summarized: in wide_fanout.v the six LUTs now come first, so the summary is FDRE ×38 instead of FDRE ×32 + LUT1 ×6 (test updated). The golden SVG was regenerated for the same reason.
  • A single driver's sink grid now has rows aligned across its columns.
  • Many drivers with small fanouts stack into one tall column instead of wrapping, so their wires don't cross each other's sinks.

Testing

  • ctest: 316/316 on macOS. New: SvgExportTest.cpp (groups, decorations, hide_ui_glyphs, PNG page size, golden); MultiDriverFanout tests in FanoutTest.cpp (no crossings with 3 drivers at 20 and 40 sinks each; bands level with their drivers; natural order; convergence outline). The crossing test fails with the old single-group grid.
  • pytest: 251 passed with NAJA_SCHEMATIC_REQUIRE_RENDER=1 (najaeda 0.7.35); test_notebook.py not run. Python tests parse the renderer's SVG with ElementTree and check the groups against the design's ids.
  • reuse lint passes.
  • The golden file is font-measured and was generated on macOS only, so Linux CI may show a rounding difference (NAJA_SCHEMATIC_UPDATE_GOLDEN=1 rewrites it).

Role grouping: group_by "role" gathers a wide net's sinks by the naja
role of the receiving pin (clock, reset, set, enable, scan, address,
data), sent as a sparse "role" on term and occurrence entries by both
providers (shared cases in tests/data/role_protocol_cases.json).

SVG structure: every net, instance box, top-level port flag, fanout
summary and module frame is a <g> with data-* attributes (data-net,
data-driver, data-path, data-id-path, data-model, ...; JSON paths when a
name holds "/" or ":" or is anonymous). The drawing is unchanged:
tests/SvgExportTest.cpp compares it to a golden file.

Export decorations (view options, export_svg()/export_png() keywords,
CLI flags): title and caption bands, a legend of traces and labeled
nets, and hide_ui_glyphs (no open-pin stubs or "more pins" dots). The
PNG export draws the same page.

Fanout layout: a sink grid with several drivers gives each driver a band
of rows level with it, all bands starting in the same column, so no
net's wires cross another net's sinks. Sinks are in natural name order
(lut_111 before lut_1037), which also picks the first max_sinks drawn.
The convergence outline is never drawn on a styled box, and the new
view option convergence_outline (--no-convergence-outline) turns it
off. --help and the README say max_sinks defaults to 32 and 0 disables
it.
@xtofalex
xtofalex merged commit 4de5eda into main Nov 14, 2026
27 checks passed
@xtofalex
xtofalex deleted the svg-structure-fanout-bands branch November 14, 2026 13:04
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