[5.0rc2] Spice netlist


I use ngspice with kicad 4.0.7 for a long time without trouble. I have built a 5.0rc2 on Debian/Testing as official 4.0.7 now segfaults on Debian. Kicad runs as expected but I have some trouble with ngspice.

I used -PSPICE and +PSPICE symbols to add spice directives. With 5.0rc2, these directives don’t work anymore. How can I add spice directives directly in eeshema ?

Second problem. First letters of all symbols are duplicated. For example:

XXT3 /C1 /G3 /C3 JJECC83
VV2 /G3 Net-R1-Pad2 VSOURCE
RR1 /G3 Net-R1-Pad2 47k
XXT1 /A1 /G1 /C1 JJE88CC
RR3 /C3 Net-R1-Pad2 1k
RR6 /C3 /C4 47k
RR4 Net-R1-Pad2 /C4 1k
XXT4 /C2 Net-R1-Pad2 /C4 JJECC83
XXT2 /A2 /G2 /C2 JJE88CC
RR9 Net-C1-Pad2 /G2 1k
RR8 Net-C2-Pad2 /G1 1k
RR5 /A2 /HT2 200k
RR2 /HT2 /A1 200k

Why all first letters are duplicated ? And how avoid this duplication ?



I have modified my libraries (new Spice fields) and I have fixed duplicated letters and .include. But the last point has to be fixed : how can I add Spice directives (.tran for example) ?

And a simple text block (without +PSPICE) seems to be enough to indicate Spice primitives.

Are you talking about the exported spice file?

Yes of course.

Only trouble I have now is duplication of first letters. Example:

.title KiCad schematic
.include "/home/bertrand/cvs/electronique/lib/tubes.lib"
VV12 /VIN 0 SIN(0 7m 1k 0 0 0)
RR1 /VIN 0 47k
RR3 /C3 0 1k
RR6 /C3 /C4 47k
RR4 0 /C4 1k
RR9 Net-_C1-Pad2_ /G2 1k
RR8 Net-_C2-Pad2_ /G1 1k
RR5 /A2 /HT2 200k
RR2 /HT2 /A1 200k
RR10 /G6 /A2 300
RR7 Net-_R7-Pad1_ /A1 300
RR21 /C6 0 33k
RR20 0 /C5 33k
RR16 Net-_C2-Pad2_ /C5 500k
RR17 0 Net-_C2-Pad2_ 900k
RR18 Net-_C1-Pad2_ 0 900k
RR19 /C6 Net-_C1-Pad2_ 500k
RR11 Net-_C1-Pad1_ Net-_C3-Pad1_ 10k
RR13 Net-_C4-Pad2_ Net-_C2-Pad1_ 10k
RR14 /C5 Net-_C3-Pad1_ 3.3k
RR15 /C6 Net-_C4-Pad2_ 3.3k
RR12 Net-_C2-Pad1_ Net-_C1-Pad1_ 100k
CC4 0 Net-_C4-Pad2_ 100n

I have to write later:
.save i(vv9) @rr2[i]
instead of
.save i(v9) @r2[i]

Please note that schematic title is not exported also.

Best regards,


I’ve only played with this a little. If, big IF, I remember correctly the nightlies put that ‘/’ in for local lables and I think that was a problem. It works OK for the simulator in the program but causes problems if you try and use ngspice from the command line. I don’t remember if the ‘export’ function had the same problem.

Hmm… That looks like a bug.

I thought it might have been KiCad trying to assign a model prefix, as in C… R… etc, but if I misname C1 as xC1, it emits xxC1, so it seems to be simply duplicating a character, not doing anything like mapping.

Which exact version did you try ?

Maybe with the internal spice, external netlist generate has been less-tested, and had a regression ?

Addit: I did find this thread - not exactly this issue, but may expose another useful workaround pathway.

Looks like they quite recently added internal-spice netlist visibility, so that might give a more-tested spice netlist ?

I have built an up to date rc2 from git.

Best regards,


Did you find the newly added internal-spice netlist visibility, and does it show the same effect ?
If it does, you could raise the issue in that bugtracker link above ?

I have tried to check internal spice netlist but field is always empty.

Won’t fix :frowning:

This ‘feature’ comes with a lot of side effects…

Not sure I agree.

I tried xC12, and it gives xxC12, which rather blows a hole in the clever-prefix argument.
That was my first guess, so I tried to see if Prefix was assigned.

As for conventions, well, I’ve not seen any OTHER spice programs trying to be clever in the background like this, they all expect R,C, prefixes, and users who want to model in spice, do have to expect to follow some spice rules.
They have to manage models

If they ARE going to add a prefix, then all user fields, should have the same rule applied invisibly, so you can write “K1 L1 L2 0.98” as that is spice portable.
What they have chosen to do, is NOT spice portable.

Addit: Here is one of many examples out there, of a Spice Schematic, and the Spice netlist.


and another SCH/Netlist example

It is common to move netlists between spice programs.

I tested some more, and this prefix does work, provided you have defined the Spice model info.
I tested a circuit that did correctly fix one prefix, and then I edited another. (C1 -> N1)

.title KiCad schematic
.include "ad8009.lib"
.include "fzt1049a.lib"
.include "laser.lib"
VV1 /in GND pulse(0 3 100n 1n 1n 20n 100n )
XU1 Net-_R2-Pad1_ Net-_N1-Pad1_ VDD VSS Net-_Q1-Pad2_ ad8009
CC2 /out Net-_C2-Pad2_ 1p
RR5 /out Net-_C2-Pad2_ 2.5
RR1 Net-_N1-Pad1_ GND 220
RR3 Net-_C2-Pad2_ Net-_N1-Pad1_ 220
CN1 Net-_N1-Pad1_ Net-_C2-Pad2_ 1p
DD1 /out GND laser
RR4 /out Net-_R2-Pad1_ 220
RR2 Net-_R2-Pad1_ /in 160
QQ1 VDD Net-_Q1-Pad2_ Net-_C2-Pad2_ fzt1049a
.tran 10p 150n

In that list, only U1 and N1 need a prefix fixup, so I’ve suggested that on the bug list, (tho that may be closed?)

The suggested fix I gave of only adding a prefix fixup when needed, would have the netlist in #1, report normally.
In code terms this is trivial - if the added prefix letter does not change existing letter, skip the addition.

Just noticed seems there is good news, a small nudge, and they fixed this back in April 27th :slight_smile:

Maciej Suminski (orsonmmz) wrote on 2018-04-27: #10
I have pushed a fix for the bug, as it turned out to be a simple and low risk change in exchange for much greater benefit.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.