How to Parse the Kicad Netlist

Hello,
for those of you who need to import the kicad netlist into another tool (for example boundary scan, ICT; FPT) please find a proposal here: http://www.blunk-electronic.de/pdf/how_to_parse_the_kicad_netlist.pdf
Your feedback is appreciated !

For those needing to parse an eeschema netlist in C89, we have working code in pcb-rnd, the very actively developed fork of gEDA PCB, that allows an eeschema netlist to be imported into the PCB layout tool. pcb-rnd doesn’t care what tool you use for schematic design!!

See:

http://igor2.repo.hu/cgi-bin/minisvn.cgi?cmd=cat&repo=pcb-rnd&path=trunk/src_plugins/io_kicad/read_net.c

We also export to kicad legacy and kicad s-expression formats, for those who are keen to play with existing gEDA PCB designs in kicad.

Regards,

Erich.

1 Like

Personally, I would implement a generic S-expression parser, and then use that to read KiCad files. I haven’t seen many people writing in Ada, interesting choice.

KiCad can also produce a netlist in XML format, which might be easier to read.

Is there a Windows build?

The project architecture emphasizes portability, such that the code is not tied to a particular HID, whether it be headless, gtk2, gtk3, lesstiff or some other HID.

There is no windows build currently due to a lack of testers, but a headless cross compiled exe or native build would be possible at present, for those simply using it as a CLI utility.

We would revisit the windows port if we had >= 4 dedicated testers.

Cheers,

Erich.

I’m interested in trying it out. How to clone or download the complete set of the source code?

Do you know where to find the syntax specifications for the KiCad Netlist? Having the specification handy would be very helpful to review your design documents.

Joe,
the standard netlist exported by KiCad is self explaining. At least I myself am able to read it without greater difficulties. Just let me know where I can help you.
Mario

1 Like

I don’t think the netlist file is documented anywhere, but the s-expression syntax is mostly documented. I can never remember where that document is though, on launchpad somewhere I think.

Ok, I found it file formats. That doc is old and not maintained though, but at least gives some background.

I think the general policy of KiCad is not to work to design specs. Definitive behaviour is defined by the source code.

For the s-expression netlist, the best place to look is probably the parser in pcbnew : https://github.com/KiCad/kicad-source-mirror/blob/master/pcbnew/kicad_netlist_reader.cpp

There is an open invitation to anyone wanting better docs, to go ahead and write them :slight_smile: I have found it difficult to write a precise, formal description of the file formats because there is a lot of “quirkiness” in the implementation.

For example, you might think that a worksheet file with no entries would create a blank worksheet, but in fact KiCad uses the default worksheet instead. To get a blank sheet, I had to create a dummy entry with a line of zero length.

2 Likes

Oh yes, been there done that. I documented it somewhere on this forum only though, mea culpa :wink:

There are three main ways to install it

  1. there is a debian package which lags svn head

  2. just download a release tarball

http://www.repo.hu/projects/pcb-rnd/releases/

  1. best of all, use subversion to checkout svn head

svn://repo.hu/pcb-rnd/trunk

cd trunk

./configure
make
cd src
./pcb-rnd &

you don’t necessarily need to make install if you are doing a quick build and test.

./configure will let you know if you are missing any dependencies.

If you have any issues, compliments or code contributions :wink: feel free to drop into

http://www.repo.hu/projects/pcb-rnd/irc.html

where someone should be able to help.

FWIW we have just about finished the protel autotrax/easytrax importer (complete with netlist support), which now gives anyone with kicad a pathway to achieve:

legacy protel autotrax/easytrax layout -> pcb-rnd -> Kicad legacy/kicad s-expression layout

pcb-rnd can be run headless too, so converting formats by using it as a CLI tool is possible, with the right CLI incantations.

Cheers,

Erich.