Basics: Project 135k
Project name: How to generate a netlist and how to add an external plugin a netlist in KiCad v5.
Tags: KiCad, KiCad v5, Importing netlist, CAD tools, ajour plugin, BOM plugin, CADSTAR-RINF plugin, PADS-PCB plugin
We will learn about netlists, how to generate a netlist and how to add an external plugin for a netlist in KiCad v5.
What is a Netlist?
“A netlist is a description of the connectivity of an electronic circuit. It consists of a list of the electronic components in a circuit and a list of the nodes they are connected to. A network (net) is a collection of two or more interconnected components. The structure, complexity and representation of netlists can vary a lot, but the fundamental purpose of every netlist is to convey connectivity information. Netlists usually provide nothing more than instances, nodes, and perhaps some attributes of the components involved.
Most netlists either contain or refer to descriptions of the parts or devices used. Each time a part is used in a netlist, this is called an “instance”. These descriptions will usually list the connections that are made to that kind of device, and some basic properties of that device. These connection points are called “terminals” or “pins”, among several other names. An “instance” could be anything from a transistor, to a resistor, a capacitor, or an integrated circuit chip. Instances have “terminals”. Networks (nets) are the “wires” that connect things together in the circuit. There may or may not be any special attributes associated with the nets in a design, depending on the particular language the netlist is written in, and that language’s features. Instance based netlists usually provide a list of the instances used in a design. Along with each instance, either an ordered list of net names is provided, or a list of pairs provided, of an instance port name, along with the net name to which that port is connected.
In this kind of description, the list of nets can be gathered from the connection lists, and there is no place to associate particular attributes with the nets themselves. SPICE is an example of instance-based netlists.
Net-based netlists usually describe all the instances and their attributes, then describe each net, and say which port they are connected on each instance. This allows for attributes to be associated with nets. EDIF is probably the most famous of the net-based netlists.” – from WikiPedia
Let’s describe it in simple way. A netlist is a file which describes electrical connections between symbols. These connections are referred to as nets. In the netlist file you can find the list of the symbols and the list of connections (nets) between symbols. Many different netlist formats exist. Sometimes the symbols list and the list of nets are two separate files. This netlist is fundamental in the use of schematic capture software, because the netlist is the link with other electronic CAD software such as:
- PCB layout software.
- Schematic and electrical signal simulators.
- CPLD (and other programmable IC’s) compilers.
- Eeschema supports several netlist formats.
- PCBNEW format (KiCad PCB design software, printed circuits).
- ORCAD PCB2 format (OrCAD PCB design software, printed circuits).
- CADSTAR format (CADSTAR PCB design software, printed circuits).
- SPICE format, for various simulators (the Spice format is also used by other simulators)
Please note that many software tools that use netlists do not accept spaces in the component names, pins, nets or other information. Avoid using spaces in labels, or names and value fields of components or their pins to ensure maximum compatibility. In the same way, special characters other than letters and numbers can cause problems. Note that this limitation is not related to Schematic Layout Editor (Eeschema) tool, but to the netlist formats that can then become untranslatable to software that uses netlist files.
Step by Step instruction
1.Generating the netlists
- We assume that you have the KiCad v5 already installed. Double-click on the KiCad shortcut to start the program.
2. You will see KiCad project manager window opened. Click on Schematic Layout Editor (Eeschema) button.
3. Go to Tools -> Generate Netlist File… or click on Generate netlist icon. The Netlist window pops up.
4. You can select the desired format by using corresponding tab. Netlist formats available:
- PCBNEW format with .net extension (KiCad PCB design software).
- ORCAD PCB2 format with .net extension (OrCAD PCB design software). This format has only one section which is the footprint list. Each footprint includes its list of pads with reference to a net.
- CADSTAR format with .frp extension (CADSTAR PCB design software). The Cadstar format is comprised of two sections: the footprint list and the Nets list: grouping pads references by nets.
- SPICE format with .clr extension, for various simulators (the Spice format is also used by other simulators). In SPICE format you can generate netlists with either net names which makes the SPICE file more human readable or net numbers which are used by older SPICE.
5. Default format option is available on all tabs, select the format which you use. Click on Generate Netlist button Select the folder and give file a name and click on Save button. The netlist generation can take up to several minutes for large schematics.
6. Go to the folder where you saved your netfile. It is a simple text file with .net extension which you can inspect with any text editor (for example, Notepad, Notepad++, Sublime, Atom and so on) and you will notice that it contains all the information that the PCB Layout Editor (PCBnew) tool will need in order to know which components are supposed to be included and what are the connections between those components, information about nets and so on.
In this file, notice first that each (Net) is listed with a (code) and a (name). After this, each pin for each component is listed that is connected to the named net.
2. Adding and using the netlist plugins
You can add netlist converters in the form of plugins for other netlist formats. These converters are automatically launched by the Schematic Layout Editor (Eeschema) tool. A converter is a text file (xsl format) but one can use other languages like Python. When using the xsl format, a tool (xsltproc.exe or xsltproc) read the intermediate file created by Schematic Layout Editor (Eeschema) tool, and the converter file to create the output file. In this case, the converter file (a sheet style) is very small and very easy to write.
1. Click on Add Plugin… button in the Netlist window.
2. The Plugin properties window will pops up. Click on Browse plugins button. Navigate to C:\Program Files\KiCad\bin\scripting\plugins and select the plugin which you want to add. You can also download and add to this folder netlist_form_pads-pcb.xsl file. Click on Open button.
3. Give plugin a name and click on OK button. You can see the tab corresponding to your added plugin now and you can also remove it but clicking on Remove Plugin… button.
4. When the netlist is generated the Schematic Layout Editor (Eeschema) tool creates an intermediate file *.tmp, for example, testproject.tmp. Schematic Layout Editor (Eeschema) tool runs the plug-in, which reads testproject.tmp file and creates testproject.xml file. The netlist files can be converted from an Intermediate netlist file created by Schematic Layout Editor (Eeschema) tool. This file uses XML syntax and is called the intermediate netlist. The intermediate netlist includes a large amount of data about your board and because of this, it can be used with post-processing to create different reports. Depending on the output (BOM or netlist), different subsets of the complete Intermediate Netlist file will be used in the post-processing. By applying a post-processing filter to the Intermediate netlist file you can generate foreign netlist files. Because this conversion is a text to text transformation, this post-processing filter can be written using Python, XSLT, or any other tool capable of taking XML as input. XSLT itself is an XML language very suitable for XML transformations. There is a free program called xsltproc which can be used to read the Intermediate XML netlist input file, apply a style-sheet to transform the input, and save the results in an output file. Use of xsltproc requires a style-sheet file using XSLT conventions. The full conversion process is handled by Schematic Layout Editor (Eeschema) tool, after it is configured once to run xsltproc in a specific way.
The Netlist command xsltproc -o “%O” “C:\Program Files\KiCad\bin\scripting\plugins\netlist_form_pads-pcb.xsl” “%I” described in the table below:
|xsltproc||xsltproc is a command line tool for applying XSLT stylesheets to XML documents, command line XSLT processor. Used to read and convert xsl file.|
|-o “%O”||%O will define the output file.|
|“C:\Program Files\KiCad\bin\scripting\plugins\netlist_form_pads-pcb.asc.xsl”||File name converter, a sheet style which in xsl format.|
|“%I”||Will be replaced by the intermediate file created by Eeschema (*.tmp).|
Assuming we are using the program xsltproc.exe to apply the sheet style to the intermediate file, xsltproc.exe is executed with the following command: xsltproc.exe -o <output filename> < style-sheet filename> <input XML file to convert>
- In KiCad under Windows the command line is the following: C:/Program Files/kicad/bin/xsltproc.exe -o “%O” C:/Program Files/kicad/bin/plugins/netlist_form_pads-pcb.xsl “%I”
- Under Linux the command becomes as follows: xsltproc -o “%O” /usr/local/kicad/bin/plugins/netlist_form_pads-pcb.xsl “%I”
Where netlist_form_pads-pcb.xsl is the style-sheet that you are applying. Do not forget the double quotes around the file names, this allows them to have spaces after the substitution by Eeschema.
The command line format accepts parameters for filenames:
The supported formatting parameters are.
- %B ⇒ base filename and path of selected output file, minus path and extension.
- %I ⇒ complete filename and path of the temporary input file (the intermediate net file).
- %O ⇒ complete filename and path of the user chosen output file.
%I will be replaced by the actual intermediate file name.
%O will be replaced by the actual output file name.
Command line format: example for xsltproc
The command line format for xsltproc is the following: <path of xsltproc> xsltproc <xsltproc parameters>
- under Windows: C:/Program Files/kicad/bin/xsltproc.exe -o “%O” C:/Program Files/kicad/bin/plugins/netlist_form_pads-pcb.xsl “%I”
- under Linux: xsltproc -o “%O” /usr/local/kicad/bin/plugins/netlist_form_pads-pcb.xsl “%I”
The above examples assume xsltproc is installed on your PC under Windows and all files located in kicad/bin.
5. Click on Generate Netlist button. Select folder, give file a name and click on Save button. It will be saved in .xml format.
6. Because the intermediate netlist file contains all information about used components, a Bill of Materials (BOM) can be extracted from it. In the list of plugins you can find the plugin bom2csv.xsl to create a customized Bill Of Materials (BOM) file. It will be also created in .xml format.
7. As you can see it’s very easy to add an external plugin. You can practice and add CADSTAR-RINF plugin now.
We have learnt about netlists, how to generate a netlist and how to add an external plugin for a netlist in KiCad v5.
Thank you for reading and supporting us.
- See attachments on the beginning of this project description.