A plugin for multiple instance and bus naming for KiCad's Eeschema.
Use this script in Eeschema's BOM plugin interface to generate Pcbnew netlists with multiple instance and bus naming. Components, pins, and nets with "plural" names, as described below, will be replicated and reconnected appropriately. Hierarchical sheets are not supported yet.
Copy expand_netlist.py and expand_bom.py into the plugins folder of your KiCad installation. These scripts will work with the unmodified kicad_netlist_reader.py located there. You can also copy in the tweaked version of that file from this repository, which has a few minor improvements. The default location of the plugins folder on Windows is C:\Program Files\KiCad\bin\scripting\plugins.
To use the scripts in Eeschema, add them as BOM plugins. The BOM plugin interface is preferable to the netlist export interface because it displays the documentation and reports error messages.
Components references, pin names, and net names (labels) are expanded using the following operators:
A,B,C -> A, B, C
- Whitespace is not removed, so be careful:
A, B->A,B
Both first:last and first:last:step are valid syntax.
firstandlastmust be non-negative integers or uppercase letters.stepmust be a positive integer.firstandlastwill both be included in the range unless thestepdoesn't align.lastmay be less thanstart, in which case the range will count down. A negativestepneed not be specified.- Valid letters are in
ABCDEFGHJKLMNPRTUVWY.IOQSXZare excluded, which is typical of BGA grid lettering. After 'Y' comes 'AA'.
Examples:
1:3->1,2,33:1->3,2,10:10:5->0,5,10A:D->A,B,C,DA:D:2->A,C(This is an example ofsteppreventinglastfrom being included.)
A,B|1:3 -> A1, A2, A3, B1, B2, B3
A[1,2,3]B -> A1B, A2B, A3B
- To keep the brackets, double them:
A[[1]]B->A[1]B
If multiple replications occur in the same name it behaves similarly to the vertical bar:
A[1,2].B[3,4]->A1.B3,A1.B4,A2.B3,A2.B4
A[1:5]`1 -> A1, A2, ...
- This is to keep KiCad's annotation checker happy on netlist export. That is, Eeschema will not recognize
A[1:5]as a valid reference, which would prevent you from running this script, but it will acceptA[1:5]`1.
When expanding nets, there are two valid cases for how they are connected:
- If the net name or any of the nodes the net connects to are singular,
then all of the nodes are shorted together.
- E.g. Component
U[0:7]pinVCC(U[0:7].VCC) is connected to+3V3by an unlabeled wire. Each ofU0.VCCthroughU7.VCCwill be shorted to+3V3.
- E.g. Component
- If the net name and each node it connects to expand to name lists with the same
cardinality, then a net is created connecting each corresponding node.
- E.g. Component
U1.OUT[0:7]is connected toD[15:8].Aby an unlabeled wire. 8 nets are created connectingU1.OUT0toD15.A,U1.OUT1toD14.A, ...
- E.g. Component
Any other situations are treated as an error.
- BoM generation.
- Deterministic tstamps so that renaming components doesn't destroy the PCB.
- Images of example schematics.
- Add syntax checking to the parser.
- Add error messages.
- Support hierarchical schematics.
- Convert to C.
- https://bugs.launchpad.net/kicad/+bug/1797038