Don't use / in netlists for ngspice, use _ instead

Bug #1821502 reported by Holger Vogt
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Medium
Jon Evans

Bug Description

When I generate a ngspice netlist from a circuit, e.g. demo laser_driver, eeschema adds / to certain node names, e.g. to in and out of the laser driver's netlist (see below).

Please don't do that, better use for example _ , if any.

ngspice, if run in external mode (see http://ngspice.sourceforge.net/ngspice-eeschema.html#external for example), has difficulties in using /in or /out in plot, write and other control language commands, because the internal parser treats / as 'divide', and of course then an error occurs. The user has to manually add "" around these nodes, which is not ok in all circumstances.

.title KiCad schematic
.include "C:\Program Files\KiCad\share\kicad\demos\simulation\laser_driver\ad8009.lib"
.include "C:\Program Files\KiCad\share\kicad\demos\simulation\laser_driver\fzt1049a.lib"
.include "C:\Program Files\KiCad\share\kicad\demos\simulation\laser_driver\laser.lib"
V1 /in GND pulse(0 3 100n 1n 1n 20n 100n )
XU1 Net-_R2-Pad1_ Net-_C1-Pad1_ VDD VSS Net-_Q1-Pad2_ ad8009
V2 VDD GND DC 10
V3 GND VSS DC 10
C2 /out Net-_C1-Pad2_ 1p
R5 /out Net-_C1-Pad2_ 2.5
R1 Net-_C1-Pad1_ GND 220
R3 Net-_C1-Pad2_ Net-_C1-Pad1_ 220
C1 Net-_C1-Pad1_ Net-_C1-Pad2_ 1p
D1 /out GND laser
R4 /out Net-_R2-Pad1_ 220
R2 Net-_R2-Pad1_ /in 160
Q1 VDD Net-_Q1-Pad2_ Net-_C1-Pad2_ fzt1049a
.save @v1[i]
.save @v2[i]
.save @v3[i]
.save @c2[i]
.save @r5[i]
.save @r1[i]
.save @r3[i]
.save @c1[i]
.save @d1[id]
.save @r4[i]
.save @r2[i]
.save @q1[ib]
.save @q1[ic]
.save @q1[ie]
.save V(/in)
.save V(/out)
.save V(GND)
.save V(Net-_C1-Pad1_)
.save V(Net-_C1-Pad2_)
.save V(Net-_Q1-Pad2_)
.save V(Net-_R2-Pad1_)
.save V(VDD)
.save V(VSS)
.tran 10p 150n
.end

Application: eeschema
Version: (5.1.0)-1, release build
Libraries:
    wxWidgets 3.0.4
    libcurl/7.61.1 OpenSSL/1.1.1 (WinSSL) zlib/1.2.11 brotli/1.0.6 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) nghttp2/1.34.0
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8)
    Boost: 1.68.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.61.1
    Compiler: GCC 8.2.0 with C++ ABI 1013

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=OFF
    KICAD_SCRIPTING_WXPYTHON=ON
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

Holger Vogt (h+vogt)
tags: added: eeschema ngspice
Jon Evans (craftyjon)
Changed in kicad:
assignee: nobody → Jon Evans (craftyjon)
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@Jon, FYI don't forget to check for duplicate nets when replacing '/' with some other character. This fix should probably be cherry-picked to 5.1 as well. Thanks.

Changed in kicad:
status: New → Triaged
importance: Undecided → Medium
Jon Evans (craftyjon)
Changed in kicad:
milestone: none → 6.0.0-rc1
milestone: 6.0.0-rc1 → 5.1.1
Revision history for this message
Holger Vogt (h+vogt) wrote :

There has been a user question as to why at all prepend any character.

The met names on the circuit diagram and the spice results then differ, and one has to select the proper node for plotting.

Jon Evans (craftyjon)
Changed in kicad:
assignee: Jon Evans (craftyjon) → nobody
Jon Evans (craftyjon)
Changed in kicad:
assignee: nobody → Jon Evans (craftyjon)
Jon Evans (craftyjon)
Changed in kicad:
status: Triaged → In Progress
Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision eadf6d93bcf8eafb5d1d4383522fae4229c5f9d1
https://git.launchpad.net/kicad/patch/?id=eadf6d93bcf8eafb5d1d4383522fae4229c5f9d1

Changed in kicad:
status: In Progress → Fix Committed
Revision history for this message
Holger Vogt (h+vogt) wrote :

I am not that happy with this fix.

Wouldn't it be possible to just not adding a / to the net names supplied by the user, if transferred into the spice netlist?

In the circuit simulation example file laser_driver.sch we have extra net names in and out. It would be nice if these user defined names would appear in the spice netlist without any change, still being in and out .

Is there a good reason to prepend a / to these net names?

Revision history for this message
Jon Evans (craftyjon) wrote :

Local labels get the sheet path prepended in order to distinguish them from global labels.
The nets "/in" and "in" are different: the first is local, the second is global.

If we were to change the behavior to remove the sheet path from local labels, we would first have to check to make sure it didn't conflict with any globals, and if it did, we'd have to keep the path. Even if there weren't any conflicts, it would be confusing to remove the sheet path from the SPICE netlist because in the KiCad netlist, the sheet path must remain.

In KiCad 6.0, you will be able to view the full net name easily for a connection (that is, you'll be able to see that a net with local label "in" gets named "/in" on the root sheet). This should help. We could also add a feature to more easily cross-probe between the simulator and the schematic.

Revision history for this message
jean-pierre charras (jp-charras) wrote :

@Holger

You can see label exactly like filenames.
Labels are living in sheets, like files in folders.

Because Kicad supports hierarchies, and especially complex hierarchies (having sub-schematics instantiated more than once) labels, like files, have a full name (similar to a full file name)

The label "mylabel" inside the root sheet has the full name /mylabel, like the file "myfile" in the root directory is actually /myfile.
The label "mylabel" inside the sheet "sample_sheet" has the full name /sample_sheet/mylabel, like the file "myfile" in "/sample_sheet" folder is actually /sample_sheet/myfile.

This is mandatory to avoid collision between label names.

However global labels are not attached to a specific sheet, therefore have no path.

the global label "GND" for instance has no path, therefore any label called "GND" in any sheet is connected to any other "GND", regardless the sheet where it is living.

Changed in kicad:
status: Fix Committed → Fix Released
Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision eadf6d93bcf8eafb5d1d4383522fae4229c5f9d1
https://git.launchpad.net/kicad/patch/?id=eadf6d93bcf8eafb5d1d4383522fae4229c5f9d1

Changed in kicad:
status: Fix Released → Fix Committed
Changed in kicad:
status: Fix Committed → Fix Released
Revision history for this message
Janne Huttunen (jmhuttun) wrote :

Hi,

I am new here. I see that there are some fixes released already almost a year ago, but at least 5.1.6 still seems to add '/' to node names in the netlist.

This is quite a problem for me as the coupled transmission line (CPL) fails to parse model name when node names starts with '/'.

Revision history for this message
Janne Huttunen (jmhuttun) wrote :

So is this fixed in some version, for example, in the nightly build?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.