diff options
| author | Friedrich Beckmann <friedrich.beckmann@tha.de> | 2026-11-08 18:14:54 +0100 |
|---|---|---|
| committer | Friedrich Beckmann <friedrich.beckmann@tha.de> | 2026-11-08 18:14:54 +0100 |
| commit | 5129a5a5448012a53cb9ddae1349c2a2c8571339 (patch) | |
| tree | 41d60bbce7fe0de57cdd92b232682831759de1a8 /kicad/lib/tools/kicad_sym_grid.py | |
| parent | 9e4911662b81bad61183cca74b8c1905f84e60e4 (diff) | |
Schematic (kicad/), one sheet per function as on ULX3S:
- power: TLV62569 bucks for +1V1 / +3V3, AP2112K LDO for +2V5
- usb: USB-C with PTC and TVS, CH347F for JTAG and UART
- fpga_power, fpga_config, fpga_banks_01/23/67: ECP5 LFE5U-25F caBGA256
(pin compatible with the 45F), quad SPI flash, 50 MHz CLOCK_50,
ball assignment as in PINPLAN.md
- ethernet: RTL8211F gigabit PHY, HR911130A RJ45, shield via 1M || 1nF 2kV
- sdram: 32 MB W9825G6KH-6
- hdmi: TMDS from the FPGA (LVCMOS33D), AC coupled, ESD protected
- user_io: SW, KEY (debounced), LEDR, LEDG, HEX0-HEX3 with DE1 names
- gpio: two DE1 compatible 2x20 headers (THDB-ADA on GPIO_0),
Pmod A/B, ESD arrays
- testpoints: bring-up pads, M3 mounting holes
All parts have LCSC numbers, MPN and manufacturer for JLCPCB assembly;
footprints are cross-checked against the EasyEDA data.
Libraries: ECP5 symbols generated from the Lattice pinout CSVs (kipart),
CH347F, RTL8211F, SM410561N symbols, HR911130A symbol and footprint from
KiCad library merge requests, generator scripts in lib/tools/.
Datasheets of all parts except resistors and capacitors in datasheets/
(manufacturer copyright, not covered by the project licenses).
Diffstat (limited to 'kicad/lib/tools/kicad_sym_grid.py')
| -rwxr-xr-x | kicad/lib/tools/kicad_sym_grid.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/kicad/lib/tools/kicad_sym_grid.py b/kicad/lib/tools/kicad_sym_grid.py new file mode 100755 index 0000000..de52a8e --- /dev/null +++ b/kicad/lib/tools/kicad_sym_grid.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-or-later +"""Snap kipart symbol pins onto the 2.54 mm grid. + +kipart centres each pin column, which puts columns with an even pin count +(and box edges) on a 1.27 mm half grid; it also writes float noise such as +3.55e-15. Pins are moved by half a grid step along their column, and pins +whose end point is off grid are lengthened so the symbol body stays put. + + kicad_sym_grid.py IN.kicad_sym > OUT.kicad_sym +""" +import re +import sys + + +def on_grid(v): + return abs(v / 2.54 - round(v / 2.54)) < 0.004 + + +def fix(m): + kind, x, y, a = m.group(1), float(m.group(2)), float(m.group(3)), m.group(4) + length = float(m.group(5)) + vertical = a in ("90", "270") + if vertical and not on_grid(x): + x += 1.27 + if not vertical and not on_grid(y): + y += 1.27 + if vertical and not on_grid(y): + y += 1.27 if y > 0 else -1.27 + length += 1.27 + if not vertical and not on_grid(x): + x += 1.27 if x > 0 else -1.27 + length += 1.27 + + def f(v): + v = round(v, 4) + return "0" if v == 0 else f"{v:g}" + return f"(pin {kind} (at {f(x)} {f(y)} {a}) (length {f(length)})" + + +text = open(sys.argv[1]).read() +text = re.sub(r"\(pin ([\w ]+?)\s*\(at ([-\d.e+]+) ([-\d.e+]+) (\d+)\)\s*\(length ([\d.]+)\)", + fix, text) +sys.stdout.write(text) |
