Skip to content

Export compiled PB designs as native KiCad schematics - #557

Open
Suke0811 wants to merge 19 commits into
BerkeleyHCI:masterfrom
Suke0811:codex/kicad-schematic-export
Open

Suke0811 wants to merge 19 commits into
BerkeleyHCI:masterfrom
Suke0811:codex/kicad-schematic-export

Conversation

@Suke0811

@Suke0811 Suke0811 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Add opt-in schematic export from compiled PB designs. The exporter maps symbols, places and routes functional circuits, and writes hierarchical KiCad schematics with machine-readable layout and routing evidence.

The final review fixes mirrored arc geometry and arc clearance bounds, consolidates wire serialization and page-fit rules, and covers native test artifact lifetimes.

Local verification on the PR head: 721 PB tests passed with KiCad 9 and 10 enabled. Repository-wide Black and strict mypy passed.

Contributor License Agreement

  • I agree to dual-license this contribution under both BSD 3-clause and Apache License, Version 2.0.

Verification of the five audit fixes

PB 7a3b262 rejects cross-net endpoint contacts, T-junctions and collinear overlaps before publishing a schematic. The writer and router use consistent pin escapes and coordinate rounding. With the reported two-part fixture at 35.56 mm separation, the unsafe placement is rejected with the nets, pins and coordinate. The 50.8 mm control and a true wire crossing preserve the expected connectivity in KiCad 9.0.3 and 10.0.7. Native checks also cover fractional placement coordinates.

Explicit diode mappings take precedence over footprint defaults and registry inference. The plain diode, Zener and Schottky fixtures compiled with export enabled and disabled, retained pad polarity, and resolved the expected KiCad symbols. An automatically named Overview content sheet keeps its region title and receives a distinct sheet title alongside reserved or explicitly assigned names.

Local verification on this head passed all 727 PB tests with native KiCad enabled. Black checked 564 files and strict mypy checked 553. Independent reviewers checked the electrical regressions, category symbol mappings and cross-group title collision.

Suke0811 and others added 18 commits November 2, 2026 19:39
Add functional circuit placement, bounded orientation passes, serialized scene guards, verified capacitor mappings, and compact LED-driver layouts. Include native KiCad 9/10 regression coverage, corpus and performance reports, and matched renders.
@Suke0811
Suke0811 requested a review from ducky64 November 12, 2026 20:23
@ducky64

ducky64 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

This is badly needed capability, but is also a ton of code which I'm not sure is in a shape conducive to efficient human review. And while it's pretty amazing that it can generate a semi-coherent schematic, the quality of results could use more work, which I suspect would benefit from rapid iteration outside the core repo.

What do you think, instead, of having this as a plugin that lives in your own package that you would publish on pip (eg, edg-schematic-visualization)? I would add into edg core some capability to detect installed plugins, and run them on compilation? Details tbd since I need to give it more thought, but I think the structure would be:

  • It would take the CompiledBlock data structure as its input, after all transforms (eg, refdesing) have run. This would not be able to modify the design, but it would be able to generate additional compiled artifacts, here probably .kicad_sch or .pdf files.
    • CompiledBlock exposes the full superclasses list, so you would be able to match on those. CompiledBlock has access to all solved values.
  • It would follow the backend structure like NetlistBackend, except it would take a CompiledBlock (the IR structure currently used in existing backends would be considered an internal implementation detail that may one day go away).
  • There may be some opt-in mechanism beyond just having the plugin package installed. This may be a pyproject.toml config line listing the plugins to run. Configs (if any) to your particular plugin would also be defined in pyproject.toml.

If that sounds reasonable, the plugin infrastructure would be my next priority after the in-progress strict-params change.

I also see changes here to add a per-Block symbol infrastructure. I need to think on that a bit more, as well as what is the right API. I'm leaning towards footprints having an optional schematic symbol field and pinmap, and kicad-schematic-import capable blocks filling the optional schematic symbol field by default. Not sure about pinmaps, especially deduplicating pinmaps between symbol and footprint. But in the meantime, you should be able to maintain a registry of blocks -> kicad symbols.

@Suke0811

Copy link
Copy Markdown
Collaborator Author

Thanks, Ducky! One thought on the plugin work: would it make sense for reusable PB circuit blocks to optionally point to a reference PCB layout? For example, a buck converter could provide relative placement and local routing for a verified footprint combination, and the plugin could check that the compiled block matches before applying it. The board designer would still choose where the converter goes and route its connections to the rest of the board.

I saw that Sublayout already supports restoring prerouted blocks, and SvgPcbTemplateBlock lets blocks generate layout for SVG-PCB. Is linking a PB block directly to a compatible layout something you already had in mind? The schematic exporter and layout plugin could use the same block paths to identify components, with separate templates for schematic presentation and physical layout.

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.

2 participants