Skip to content

feat(hdl-schematic-editor): add HDL schematic editor demo for Yosys JSON - #82

Open
Geliogabalus wants to merge 4 commits into
clientIO:mainfrom
Geliogabalus:hdl-schematic-editor
Open

Geliogabalus wants to merge 4 commits into
clientIO:mainfrom
Geliogabalus:hdl-schematic-editor

Conversation

@Geliogabalus

Copy link
Copy Markdown
Contributor

Summary

New TypeScript demo: a schematic editor for Yosys JSON netlists (write_json output). The netlist is shown as a schematic laid out with ELK (@joint/layout-elk), and the Yosys JSON in the left sidebar stays in sync as you edit.

screenshot

How it's built

The demo uses the workflow-builder architecture. src/system/ is copied from workflow-builder with three small changes: the default port ids are A/Y, the ELK options are tuned for schematics (junction points are collected and wire labels are left out of the layout), and there is one new attribute.

  • src/yosys/ converts between Yosys JSON and the diagram data.
    • Import looks at which bits each port reads. A port that reads a whole output becomes a single wire. A port that reads part of a bus gets a split, one built from several sources gets a join, and constant bits become constant nodes.
    • Export gives every output port new net bit numbers and writes them back into each cell's connections.
    • Loading a file and saving it again keeps the same connections, and a second round produces identical output.
  • src/registry/ describes each supported Yosys cell type in one definition: ports, parameters, shape and parameter mapping. To support another cell type, you add one definition.
    • First set: $not $and $or $xor $xnor $_NAND_ $_NOR_ $add $sub $mul $eq $ne $lt $gt $mux $dff $dffe $adff.
    • Unknown cells and submodule instances show up as generic blocks and are exported unchanged.
  • Interactions are the same ones workflow-builder uses:
    • port menus (add, drive or disconnect)
    • the + button on wires to insert a cell
    • the ⋮ node menu (change cell type, delete)
    • the cell picker dialog, drag to connect (an input can only have one driver)
    • an inspector bound to the data, undo/redo, file drop and the minimap
  • Styling follows the KiCad default schematic colour theme: wires green, buses blue with a width marker, junction dots. Wires connecting ports of different widths are drawn red and dashed.

Note on dependencies

@joint/layout-elk 4.4.0 has not been published yet. Like the demos on elk-layout-demos-refactor, package.json points to the local tarballs: file:../../.packages/joint-layout-elk.tgz plus an override that pins @joint/core to .packages/joint-core.tgz. Once the package is released, both should switch to registry versions.

Testing

  • tsc --noEmit, eslint, and the webpack build all pass.

  • I ran the example netlist through the converters, saved it and loaded it again; the connections came back the same.

  • I tested the interactions in a headless browser with Playwright:

    • adding cells from a port
    • inserting a cell on a wire
    • drag-to-connect, and a second driver on the same input being rejected
    • a width change, undo, delete, changing a polarity, and New

    No console errors came up.

  • The example counter.json is written by hand in write_json format. It's worth also checking the demo with a netlist that Yosys actually generated.

🤖 Generated with Claude Code

Geliogabalus and others added 4 commits October 6, 2026 14:27
Schematic editor for Yosys JSON netlists built on the workflow-builder
architecture (data-driven system/ engine with ELK auto-layout via
@joint/layout-elk).

- Import/export between Yosys JSON and the diagram data, with bus
  split/join and constant inference from bit vectors
- Cell registry describing the supported Yosys cells (gates, arithmetic,
  comparison, mux, registers); unknown cells shown as generic blocks
- Workflow-builder interactions: port and wire menus, cell picker,
  drag-to-connect, inspector bound to the data, undo/redo
- Live Yosys JSON sidebar highlighting the selected element
- KiCad default schematic color theme, bus widths and junction dots

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rework the editor from a fixed ELK layout to free placement:

- Stencil with all the shapes (drag and drop); nodes can be moved freely,
  their positions are stored in the diagram data (undoable)
- Wires routed with libavoid (@joint/router-avoid), aligned to the grid;
  junction points where the wires of a net split, one bus width label
  per net
- "Auto layout" toolbar button (ELK), ordered by the diagram data so it
  matches the layout of a loaded netlist
- Pins of all shapes aligned to the paper grid
- Collapsible Yosys JSON panel below the inspector (collapsed by default)
- Constant hitbox of the wires (hover/selection drawn by a separate path)
- Hover tools kept while moving the pointer to them (e.g. the menu button)
- Minimal JointJS+ theme (design tokens, Lucide icons) replacing the
  local copy of the light theme

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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