boardwright 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. boardwright-0.1.0/.gitignore +19 -0
  2. boardwright-0.1.0/CHANGELOG.md +41 -0
  3. boardwright-0.1.0/LICENSE +201 -0
  4. boardwright-0.1.0/PKG-INFO +163 -0
  5. boardwright-0.1.0/README.md +133 -0
  6. boardwright-0.1.0/docs/devlog/README.md +44 -0
  7. boardwright-0.1.0/examples/existing/README.md +32 -0
  8. boardwright-0.1.0/examples/libs/customlib/README.md +6 -0
  9. boardwright-0.1.0/pyproject.toml +61 -0
  10. boardwright-0.1.0/src/boardwright/__init__.py +1 -0
  11. boardwright-0.1.0/src/boardwright/__main__.py +5 -0
  12. boardwright-0.1.0/src/boardwright/board.py +64 -0
  13. boardwright-0.1.0/src/boardwright/build.py +425 -0
  14. boardwright-0.1.0/src/boardwright/check.py +60 -0
  15. boardwright-0.1.0/src/boardwright/circuit.py +208 -0
  16. boardwright-0.1.0/src/boardwright/cli.py +99 -0
  17. boardwright-0.1.0/src/boardwright/copper.py +211 -0
  18. boardwright-0.1.0/src/boardwright/edits.py +110 -0
  19. boardwright-0.1.0/src/boardwright/env.py +90 -0
  20. boardwright-0.1.0/src/boardwright/existing.py +377 -0
  21. boardwright-0.1.0/src/boardwright/live.py +257 -0
  22. boardwright-0.1.0/src/boardwright/model.py +258 -0
  23. boardwright-0.1.0/src/boardwright/pins.py +48 -0
  24. boardwright-0.1.0/src/boardwright/placement.py +91 -0
  25. boardwright-0.1.0/src/boardwright/preview.py +135 -0
  26. boardwright-0.1.0/src/boardwright/project.py +186 -0
  27. boardwright-0.1.0/src/boardwright/review.py +252 -0
  28. boardwright-0.1.0/src/boardwright/route.py +343 -0
  29. boardwright-0.1.0/src/boardwright/sch.py +381 -0
  30. boardwright-0.1.0/src/boardwright/selection.py +67 -0
  31. boardwright-0.1.0/src/boardwright/si.py +110 -0
  32. boardwright-0.1.0/src/boardwright/verify.py +42 -0
  33. boardwright-0.1.0/tests/conftest.py +56 -0
  34. boardwright-0.1.0/tests/test_board_model.py +59 -0
  35. boardwright-0.1.0/tests/test_edit_route.py +63 -0
  36. boardwright-0.1.0/tests/test_pipeline.py +47 -0
  37. boardwright-0.1.0/tests/test_sch_cli.py +71 -0
  38. boardwright-0.1.0/tests/test_si.py +22 -0
@@ -0,0 +1,19 @@
1
+ __pycache__/
2
+ .venv/
3
+ dist/
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ .libmerge/
7
+ *.solve.kicad_pcb
8
+ *.kicad_prl
9
+ *.lck
10
+ .history/
11
+ *-backups/
12
+ fp-info-cache
13
+ **/out/
14
+ **/boardwright_out/
15
+ *.dsn
16
+ *.ses
17
+ *.rules
18
+ preview.svg
19
+ *_preview.png
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
+ [Semantic Versioning](https://semver.org/) (before 1.0, a minor version may change
6
+ the command line).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-11-14
11
+
12
+ First public release.
13
+
14
+ ### Added
15
+
16
+ - `boardwright place | gen | check | verify | pads` for boards described in a
17
+ `board.py`: schematic generation, placement (fixed or by pad intent with
18
+ `pad_at`), hand copper (`TRACKS`, `VIAS`, `ZONES`, `KEEPOUTS`, `TEXT`),
19
+ Freerouting with a bottom-layer cost and plane layers closed to it, a
20
+ pad-to-pad completion pass, pours, and a KiCad gate (ERC, DRC at every
21
+ severity with schematic parity, netlist, gerbers, drill, BOM, placement,
22
+ PDF, plots).
23
+ - An engineering review beyond DRC (`REVIEW`): pad distances, net and path
24
+ lengths, pair matching with vias counted, reference-plane runs, ground vias
25
+ beside signal vias, pour coverage and continuity, current capacity per
26
+ IPC-2221.
27
+ - `boardwright existing` for boards the tool did not make: inspection and
28
+ preview of any size of board, review, DRC compared with a baseline, in-place
29
+ edits (move, rip-up, routes by intent, hand copper), and re-routing of named
30
+ nets that leaves every other net byte-identical.
31
+ - `boardwright sch` for schematics: list parts, set fields, remove parts, add
32
+ a part by copying one with the same symbol, across hierarchical sheets;
33
+ `ercdiff` for ERC reports.
34
+ - `boardwright live` for the board open in KiCad 10 through its IPC API
35
+ (optional `[live]` extra), and `boardwright edits` / `selection` for plain
36
+ edit lists and KiCad's selection text.
37
+ - `boardwright impedance` (IPC-2141 closed form) and `doctor`.
38
+ - Seven example boards and specs for KiCad's own demo projects.
39
+
40
+ [Unreleased]: https://github.com/heibench/boardwright/compare/v0.1.0...HEAD
41
+ [0.1.0]: https://github.com/heibench/boardwright/releases/tag/v0.1.0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.5
2
+ Name: boardwright
3
+ Version: 0.1.0
4
+ Summary: Generate and edit KiCad boards and schematics from a short Python description, checked by KiCad itself.
5
+ Project-URL: Homepage, https://github.com/heibench/boardwright
6
+ Project-URL: Issues, https://github.com/heibench/boardwright/issues
7
+ Project-URL: Changelog, https://github.com/heibench/boardwright/blob/main/CHANGELOG.md
8
+ Author: heibench
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: autorouter,eda,electronics,kicad,pcb,schematic
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Manufacturing
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
22
+ Requires-Python: >=3.12
23
+ Requires-Dist: kicad-netspec==0.9.0
24
+ Requires-Dist: kicad-tools==0.29.0
25
+ Requires-Dist: numpy>=1.24
26
+ Requires-Dist: shapely>=2.0
27
+ Provides-Extra: live
28
+ Requires-Dist: kicad-python==0.8.0; extra == 'live'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # boardwright
32
+
33
+ **Generate and edit KiCad boards and schematics from a short Python description,
34
+ checked by KiCad itself.**
35
+
36
+ > **Status: alpha.** It makes real, routed, DRC-clean KiCad 10 projects and edits
37
+ > existing ones in place. None of the example boards has been fabricated. The
38
+ > command line is the stable surface; the Python modules will move.
39
+
40
+ ```sh
41
+ pip install boardwright # add [live] to edit the board open in KiCad
42
+ boardwright doctor # what this machine has for each step
43
+ ```
44
+
45
+ Needs KiCad 10 (its libraries and `kicad-cli`) and [Freerouting](https://github.com/freerouting/freerouting)
46
+ for autorouting. `boardwright doctor` finds them in the usual install places, Flatpak
47
+ included, and names the setting to use when it cannot.
48
+
49
+ ![RP2040 board generated by boardwright](https://raw.githubusercontent.com/heibench/boardwright/main/docs/img/rp2040_min.png)
50
+
51
+ ## What it does
52
+
53
+ A board is a directory with a `board.py`: the circuit, where the parts go, and what
54
+ matters about the layout.
55
+
56
+ ```python
57
+ from boardwright.circuit import Circuit
58
+
59
+ NAME, W, H = "ldo_breakout", 30, 20
60
+ CIRCUIT = c = Circuit("LDO breakout")
61
+ c.add("J1", "Connector_Generic:Conn_01x02", "VIN", "Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical", {1: "VIN", 2: "GND"})
62
+ c.add("U1", "Regulator_Linear:AMS1117-3.3", "AMS1117-3.3", "Package_TO_SOT_SMD:SOT-223-3_TabPin2", {1: "GND", 2: "+3V3", 3: "VIN"})
63
+ c.add("C1", "Device:C", "10u", "Capacitor_SMD:C_0805_2012Metric", {1: "VIN", 2: "GND"})
64
+ # ...
65
+ PLACE = {"J1": (3, 8.7, 0), "C1": (8.5, 10, 90), "U1": (15, 10, 270)}
66
+ REVIEW = {"near": [("C1.1", "U1.3", 6.0)]} # input capacitor within 6 mm of the input pin
67
+ ```
68
+
69
+ ```sh
70
+ boardwright place examples/boards/ldo_breakout # placement + ratsnest preview, ~5 s, no KiCad
71
+ boardwright gen examples/boards/ldo_breakout # schematic, board, routing, pours
72
+ boardwright check examples/boards/ldo_breakout # KiCad: ERC, DRC + parity, netlist, gerbers, plots
73
+ boardwright verify examples/boards/ldo_breakout # PASS / NOT DONE
74
+ ```
75
+
76
+ `verify` passes only when KiCad reports **zero** ERC and DRC findings at every
77
+ severity, schematic parity included, KiCad's netlist equals the declared circuit,
78
+ the fab files exist, and the engineering review is clean.
79
+
80
+ The review exists because a zero DRC is not a good board. An autorouter will run a
81
+ signal through a power polygon and leave the halves joined by a thin trace, and KiCad
82
+ accepts it. `REVIEW` checks what a reviewer would: decoupler-to-pin distance,
83
+ routed path lengths and pair matching (vias counted), how far a signal runs with no
84
+ ground on the adjacent layer, ground vias beside signal vias, pour coverage and
85
+ whether each pour is still one piece, and current capacity per IPC-2221.
86
+
87
+ **Boards that already exist** are edited in place and nothing is regenerated:
88
+
89
+ ```sh
90
+ boardwright existing MYPROJ info # layers, nets, pours, preview; any size of board
91
+ boardwright existing MYPROJ review # the same review, against a spec beside the board
92
+ boardwright existing MYPROJ apply # MOVE, RIPUP, ROUTES, TRACKS, VIAS, ZONES from the spec
93
+ boardwright existing MYPROJ reroute /SDA # re-route named nets; every other net stays byte-identical
94
+ boardwright existing MYPROJ verify # review + no DRC finding that is not in the baseline
95
+ boardwright sch MYPROJ set R12 Value=4k7 # one block of the schematic replaced, the rest untouched
96
+ boardwright live apply edit.py # the same edits to the board open in KiCad, one undo step
97
+ ```
98
+
99
+ ## How it decides
100
+
101
+ - **KiCad is the judge.** Nothing is "done" on the tool's own arithmetic. Every
102
+ generated board goes through `kicad-cli`, and edits to existing designs are compared
103
+ against a baseline that KiCad produced. Connectivity before and after an edit is
104
+ checked with [netspec](https://github.com/heibench/netspec), which this project uses
105
+ to find KiCad.
106
+ - **Placement and hand copper are yours; the rest is routed.** Power loops, USB pairs and
107
+ anything sensitive are drawn in `board.py` (`TRACKS`, `VIAS`, `ZONES`). Parts can be
108
+ placed by intent: `pad_at(1, ("U1", 24), dy=-1.7)` puts a capacitor's pad 1.7 mm from
109
+ pin 24. Freerouting does the remaining small signals, and a pad-to-pad router finishes
110
+ what it leaves open.
111
+ - **Edits are plain data.** An edit to an existing board is an ordered list of
112
+ operations in the board's own coordinates, checked against the board before it runs,
113
+ so the same file can be applied to the file on disk or to KiCad's open board.
114
+
115
+ ## Examples
116
+
117
+ `examples/boards/` has seven boards made with it; all but the library fixture follow a vendor
118
+ reference design:
119
+
120
+ | Board | Layers | What it exercises |
121
+ |---|---|---|
122
+ | `ldo_breakout` | 2 | the loop itself |
123
+ | `rp2040_min` | 2 | 0.4 mm QFN, USB-C, crystal, QSPI flash |
124
+ | `tps54202_buck` | 2 | a switching regulator's current loops, hand-routed power |
125
+ | `stm32f103_min` | 2 | 0.5 mm LQFP-48, bottom-side decoupling, USB pair |
126
+ | `esp32c3_min` | 2 | RF module with antenna keep-out, USB on the bottom layer |
127
+ | `stm32f103_4l` | 4 | inner ground planes, return-path and via review |
128
+ | `customlib_test` | 2 | parts from a library outside KiCad's stock set |
129
+
130
+ `examples/existing/` has specs for demo projects that ship with KiCad, for trying the
131
+ existing-board and schematic commands. [`docs/devlog/`](docs/devlog/) records what each
132
+ board broke in the tool and what was changed.
133
+
134
+ ## Documentation
135
+
136
+ - [`docs/guide.md`](docs/guide.md): the full workflow, every `board.py` option, existing
137
+ boards and schematics, the live KiCad client, and what the tool does badly.
138
+ - [`docs/devlog/gaps.md`](docs/devlog/gaps.md): known limits.
139
+
140
+ ## Known limits
141
+
142
+ - Freerouting is not repeatable on dense boards; the pad-to-pad router does not push
143
+ other tracks aside, tune lengths or route pairs as pairs.
144
+ - Schematic editing changes fields, removes parts, and adds a part by copying one with
145
+ the same symbol. It cannot add a symbol the sheet does not already use, and a
146
+ schematic change is pushed to the board in KiCad.
147
+ - Generated schematics are one flat sheet.
148
+ - Impedance figures are closed-form (IPC-2141, about +-10 %); confirm with your fab.
149
+ - KiCad 10 only. The live client uses KiCad's IPC API, which is what KiCad 11 builds on.
150
+
151
+ ## Development
152
+
153
+ ```sh
154
+ just setup # uv sync --all-extras
155
+ just check # ruff
156
+ just test # pytest; the full KiCad pipeline test skips where KiCad is absent
157
+ ```
158
+
159
+ ## License
160
+
161
+ Apache-2.0. The example boards are generated from KiCad's libraries, whose licence
162
+ (CC-BY-SA 4.0 with an exception for designs that use them) places no restriction on
163
+ the boards.
@@ -0,0 +1,133 @@
1
+ # boardwright
2
+
3
+ **Generate and edit KiCad boards and schematics from a short Python description,
4
+ checked by KiCad itself.**
5
+
6
+ > **Status: alpha.** It makes real, routed, DRC-clean KiCad 10 projects and edits
7
+ > existing ones in place. None of the example boards has been fabricated. The
8
+ > command line is the stable surface; the Python modules will move.
9
+
10
+ ```sh
11
+ pip install boardwright # add [live] to edit the board open in KiCad
12
+ boardwright doctor # what this machine has for each step
13
+ ```
14
+
15
+ Needs KiCad 10 (its libraries and `kicad-cli`) and [Freerouting](https://github.com/freerouting/freerouting)
16
+ for autorouting. `boardwright doctor` finds them in the usual install places, Flatpak
17
+ included, and names the setting to use when it cannot.
18
+
19
+ ![RP2040 board generated by boardwright](https://raw.githubusercontent.com/heibench/boardwright/main/docs/img/rp2040_min.png)
20
+
21
+ ## What it does
22
+
23
+ A board is a directory with a `board.py`: the circuit, where the parts go, and what
24
+ matters about the layout.
25
+
26
+ ```python
27
+ from boardwright.circuit import Circuit
28
+
29
+ NAME, W, H = "ldo_breakout", 30, 20
30
+ CIRCUIT = c = Circuit("LDO breakout")
31
+ c.add("J1", "Connector_Generic:Conn_01x02", "VIN", "Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_Vertical", {1: "VIN", 2: "GND"})
32
+ c.add("U1", "Regulator_Linear:AMS1117-3.3", "AMS1117-3.3", "Package_TO_SOT_SMD:SOT-223-3_TabPin2", {1: "GND", 2: "+3V3", 3: "VIN"})
33
+ c.add("C1", "Device:C", "10u", "Capacitor_SMD:C_0805_2012Metric", {1: "VIN", 2: "GND"})
34
+ # ...
35
+ PLACE = {"J1": (3, 8.7, 0), "C1": (8.5, 10, 90), "U1": (15, 10, 270)}
36
+ REVIEW = {"near": [("C1.1", "U1.3", 6.0)]} # input capacitor within 6 mm of the input pin
37
+ ```
38
+
39
+ ```sh
40
+ boardwright place examples/boards/ldo_breakout # placement + ratsnest preview, ~5 s, no KiCad
41
+ boardwright gen examples/boards/ldo_breakout # schematic, board, routing, pours
42
+ boardwright check examples/boards/ldo_breakout # KiCad: ERC, DRC + parity, netlist, gerbers, plots
43
+ boardwright verify examples/boards/ldo_breakout # PASS / NOT DONE
44
+ ```
45
+
46
+ `verify` passes only when KiCad reports **zero** ERC and DRC findings at every
47
+ severity, schematic parity included, KiCad's netlist equals the declared circuit,
48
+ the fab files exist, and the engineering review is clean.
49
+
50
+ The review exists because a zero DRC is not a good board. An autorouter will run a
51
+ signal through a power polygon and leave the halves joined by a thin trace, and KiCad
52
+ accepts it. `REVIEW` checks what a reviewer would: decoupler-to-pin distance,
53
+ routed path lengths and pair matching (vias counted), how far a signal runs with no
54
+ ground on the adjacent layer, ground vias beside signal vias, pour coverage and
55
+ whether each pour is still one piece, and current capacity per IPC-2221.
56
+
57
+ **Boards that already exist** are edited in place and nothing is regenerated:
58
+
59
+ ```sh
60
+ boardwright existing MYPROJ info # layers, nets, pours, preview; any size of board
61
+ boardwright existing MYPROJ review # the same review, against a spec beside the board
62
+ boardwright existing MYPROJ apply # MOVE, RIPUP, ROUTES, TRACKS, VIAS, ZONES from the spec
63
+ boardwright existing MYPROJ reroute /SDA # re-route named nets; every other net stays byte-identical
64
+ boardwright existing MYPROJ verify # review + no DRC finding that is not in the baseline
65
+ boardwright sch MYPROJ set R12 Value=4k7 # one block of the schematic replaced, the rest untouched
66
+ boardwright live apply edit.py # the same edits to the board open in KiCad, one undo step
67
+ ```
68
+
69
+ ## How it decides
70
+
71
+ - **KiCad is the judge.** Nothing is "done" on the tool's own arithmetic. Every
72
+ generated board goes through `kicad-cli`, and edits to existing designs are compared
73
+ against a baseline that KiCad produced. Connectivity before and after an edit is
74
+ checked with [netspec](https://github.com/heibench/netspec), which this project uses
75
+ to find KiCad.
76
+ - **Placement and hand copper are yours; the rest is routed.** Power loops, USB pairs and
77
+ anything sensitive are drawn in `board.py` (`TRACKS`, `VIAS`, `ZONES`). Parts can be
78
+ placed by intent: `pad_at(1, ("U1", 24), dy=-1.7)` puts a capacitor's pad 1.7 mm from
79
+ pin 24. Freerouting does the remaining small signals, and a pad-to-pad router finishes
80
+ what it leaves open.
81
+ - **Edits are plain data.** An edit to an existing board is an ordered list of
82
+ operations in the board's own coordinates, checked against the board before it runs,
83
+ so the same file can be applied to the file on disk or to KiCad's open board.
84
+
85
+ ## Examples
86
+
87
+ `examples/boards/` has seven boards made with it; all but the library fixture follow a vendor
88
+ reference design:
89
+
90
+ | Board | Layers | What it exercises |
91
+ |---|---|---|
92
+ | `ldo_breakout` | 2 | the loop itself |
93
+ | `rp2040_min` | 2 | 0.4 mm QFN, USB-C, crystal, QSPI flash |
94
+ | `tps54202_buck` | 2 | a switching regulator's current loops, hand-routed power |
95
+ | `stm32f103_min` | 2 | 0.5 mm LQFP-48, bottom-side decoupling, USB pair |
96
+ | `esp32c3_min` | 2 | RF module with antenna keep-out, USB on the bottom layer |
97
+ | `stm32f103_4l` | 4 | inner ground planes, return-path and via review |
98
+ | `customlib_test` | 2 | parts from a library outside KiCad's stock set |
99
+
100
+ `examples/existing/` has specs for demo projects that ship with KiCad, for trying the
101
+ existing-board and schematic commands. [`docs/devlog/`](docs/devlog/) records what each
102
+ board broke in the tool and what was changed.
103
+
104
+ ## Documentation
105
+
106
+ - [`docs/guide.md`](docs/guide.md): the full workflow, every `board.py` option, existing
107
+ boards and schematics, the live KiCad client, and what the tool does badly.
108
+ - [`docs/devlog/gaps.md`](docs/devlog/gaps.md): known limits.
109
+
110
+ ## Known limits
111
+
112
+ - Freerouting is not repeatable on dense boards; the pad-to-pad router does not push
113
+ other tracks aside, tune lengths or route pairs as pairs.
114
+ - Schematic editing changes fields, removes parts, and adds a part by copying one with
115
+ the same symbol. It cannot add a symbol the sheet does not already use, and a
116
+ schematic change is pushed to the board in KiCad.
117
+ - Generated schematics are one flat sheet.
118
+ - Impedance figures are closed-form (IPC-2141, about +-10 %); confirm with your fab.
119
+ - KiCad 10 only. The live client uses KiCad's IPC API, which is what KiCad 11 builds on.
120
+
121
+ ## Development
122
+
123
+ ```sh
124
+ just setup # uv sync --all-extras
125
+ just check # ruff
126
+ just test # pytest; the full KiCad pipeline test skips where KiCad is absent
127
+ ```
128
+
129
+ ## License
130
+
131
+ Apache-2.0. The example boards are generated from KiCad's libraries, whose licence
132
+ (CC-BY-SA 4.0 with an exception for designs that use them) places no restriction on
133
+ the boards.
@@ -0,0 +1,44 @@
1
+ # Development log
2
+
3
+ How the tool was built: each example board and each piece of existing-board
4
+ work, what broke, and what changed in the tool because of it. The entries were
5
+ written as the work happened, before the project was named boardwright, so
6
+ they use the paths and commands of the time (`boards/` is now
7
+ `examples/boards/`, `dogfood/existing/` is `examples/existing/`,
8
+ `boardwright build DIR STEP` is `boardwright STEP DIR`,
9
+ `scripts/check.sh` is `boardwright check`, and netlist comparisons are now
10
+ `netspec diff`).
11
+
12
+ Every board built with this repo gets a numbered entry here. The point is to
13
+ find where the process breaks on real reference designs and fix the tool, not
14
+ the board. One file per board:
15
+
16
+ - **Reference** -- the vendor document the circuit and layout rules come from,
17
+ and which values were read from it versus chosen here.
18
+ - **Stresses** -- why this board was picked.
19
+ - **What broke** -- in order, with the symptom as KiCad or the plot showed it.
20
+ - **Tool changes** -- what changed in `boardwright/` because of it.
21
+ - **Left open** -- what a real engineer would still fix or check.
22
+
23
+ `gaps.md` is the running backlog of tool gaps, most painful first.
24
+
25
+ | # | Board | Reference | Stresses | Gate |
26
+ |---|-------|-----------|----------|------|
27
+ | 01 | `ldo_breakout` | AMS1117 datasheet typical application | the loop itself | PASS |
28
+ | 02 | `rp2040_min` | Raspberry Pi "Hardware design with RP2040" minimal design | 0.4 mm QFN, USB, crystal, QSPI | PASS (second pass) |
29
+ | 03 | `tps54202_buck` | TI TPS54202 datasheet (SLVSD26C) Fig. 7-1 and layout 7.4 | power polygons, hand routing, current loops | PASS |
30
+ | 04 | `stm32f103_min` | ST AN2586 and STM32F103x8 datasheet | 0.5 mm LQFP-48, bottom decoupling, crystal, USB pair | PASS |
31
+ | 05 | `esp32c3_min` | Espressif ESP32-C3 hardware design guidelines | RF module, antenna keep-out, USB pair on the bottom | PASS |
32
+ | 06 | `stm32f103_4l` | as 04, on signal / GND / GND / signal | four layers, inner planes, return path, placement by intent | PASS |
33
+ | 07 | `existing/stickhub` | a KiCad demo project nobody here drew | an existing board: read, review, edit in place, selective re-route | PASS vs baseline |
34
+ | 08 | `customlib_test` | none (fixture) | parts from a library outside KiCad's stock set | PASS |
35
+ | 09 | `existing/schtest` | the StickHub demo's schematic | an existing schematic: change a value, add two parts | netlist diff is exactly the edit |
36
+ | 10 | `existing/hier` and two read-only demos | KiCad's hierarchical, 6-layer and 9-layer demos | shared sub-sheets, routing with vias and inner layers, per-net rules | see entry |
37
+
38
+ "Gate PASS" means: ERC 0, DRC 0 at every severity with schematic parity,
39
+ KiCad's netlist equals the declared circuit, the `REVIEW` checks pass, fab
40
+ files exported. It does not mean built or powered.
41
+
42
+ All five were regenerated and gated with the tool as it stands at the last
43
+ entry. Bottom GND pour coverage (share of board area): 01 92%, 02 78% in
44
+ five pieces, 03 94%, 04 77%, 05 68%.
@@ -0,0 +1,32 @@
1
+ # Existing-board examples
2
+
3
+ Specs for working on boards boardwright did not make. The boards themselves
4
+ are demo projects that ship with KiCad, under their own licences, so they are
5
+ not copied here: copy each demo folder from your KiCad install next to the
6
+ spec.
7
+
8
+ KiCad keeps its demos in `share/kicad/demos/`:
9
+
10
+ | System | Folder |
11
+ |---|---|
12
+ | Linux package | `/usr/share/kicad/demos/` |
13
+ | Linux Flatpak | `/var/lib/flatpak/app/org.kicad.KiCad/current/active/files/share/kicad/demos/` |
14
+ | macOS | `/Applications/KiCad/KiCad.app/Contents/SharedSupport/demos/` |
15
+ | Windows | `C:\Program Files\KiCad\<version>\share\kicad\demos\` |
16
+
17
+ | Here | KiCad demo | What the spec does |
18
+ |---|---|---|
19
+ | `stickhub/` | `stickhub` | `boardwright.py`: a `REVIEW` for the USB hub (pair matching, decoupling); `live_demo.py`: a harmless first edit (one ground via and track) for `boardwright live apply` |
20
+ | `stickhub_schematic/` | `stickhub` | `add_demo.py`: add two parts to the existing schematic with `boardwright sch DIR add` |
21
+ | `complex_hierarchy/` | `complex_hierarchy` | `add_demo.py`: add a part on the root sheet of a hierarchical schematic |
22
+
23
+ For example:
24
+
25
+ ```sh
26
+ cp -r /usr/share/kicad/demos/stickhub/* examples/existing/stickhub/
27
+ boardwright existing examples/existing/stickhub info
28
+ boardwright existing examples/existing/stickhub review
29
+ ```
30
+
31
+ Then follow "First contact with a board you did not make" in
32
+ [`docs/guide.md`](../../docs/guide.md).
@@ -0,0 +1,6 @@
1
+ # Test library for `LIBS`
2
+
3
+ A stand-in for a private part library: one symbol (`Custom:MYLDO-3.3`) and one
4
+ footprint (`Custom:MY_SOT-23-5`), copied from KiCad's stock AP2112K-3.3 and
5
+ SOT-23-5 and renamed, so nothing here exists under that name in the stock
6
+ libraries. `boards/customlib_test` builds against it.