Local label delimiters in spice netlists

Hi there,
after some time elapsed, I am still/again busy using KiCAD as schematic entry tool for ngspice.
When using hierarchy sheets everything works fine within eeschema.
The spice netlister converts the hierarchy back into a flat-scheet.
The local labels are prefixed with the name of the subsheet and separated by a / character.
E.g. the label “op_out” in the subsheet “Amplifier” is represented by “/Amplifier/op_out”.

This is, where ngspice get stuck, when it tries to access such a label: it just doesn’t recognize it properly.
When I replace the /-character by an underline _-character, ngspice simulation works fine.
Replacing it with :-character fails either.

So my question is:

  • how/where can I change the delimiter-character / into something, that goes along with ngspice?
  • What is your recommendation for a better choice of a delimiting character?

Thanks a lot for your response
sepp2gl

Your message is not precise enough. What does “access” mean? Best would be if you could give an example.

What ngspice vesrion are you using?

Recent ngspice does handle such file or directory names and simulates them, or plots them within Eeschema.

However there are some limitations concerning write, print, plot, let commands in a control section.

Hi Holger,
thanks for responding.
My issue is not about file and directory handling, but handling of hierarchical net-labels.
Access in this respect means, that a statement in a control-section,
e.g. "let op_out = /Amplifier/op_out
will fail. In some cases, the ngspice even crashes.
I am using ngspice version 3.2.
I am not using the ngspice-integration within KiCad, instead I operate ngspice using skripts due to higher flexibility.

So this should not be discussed here, but in the ngspice discussion forums.

@Holger:
sorry, I disagree in this respect.
The KiCad netlister generates “/subsheet/local-label” for spice-netlists.
In some cases I was more successful with “_subsheet_local-label” expressions with ngspice.

My question is about, where to handle these delimiters within the Kicad netlister configuration.
Another question to the experts:
Is the utilisation of “/” as delimiter common sense between Kidac ans nagspice?

Can you post a ZIP of an example project which has hierarchical sheets and labels to help convey the problem better? I believe I understand your issue, but I don’t know how to address it. Maybe an example will help others, who are able to address it, understand it better.

Hi Ste,
pls. find an example project attached…Amplifier-Benchmark.tar.gz (8.2 KB)

All,
the example project, that I attached for Ste also contains a strange flew when spice-netlisting of dependent sources F and H; the controls source of F/H is not exported into the netlist. So there is one parameter missing in the spice-netlist. As a consequence ngspice crashes (without error message).

Again:
Is the utilisation of “/”-character as delimiter common sense between Kicad and ngspice?

See also the discussion at https://gitlab.com/kicad/code/kicad/-/issues/159

See also https://sourceforge.net/p/ngspice/bugs/526/ for a remedy inside of ngspice.

There is a fix in branch pre-master: No more crash, but error message and stop.

@Holger:
thx for the link to https://gitlab.com/kicad/code/kicad/-/issues/159.
As that thread is already closed, here is my proposal:
I understand the analogy of /subsheet/label with /directory/file.
(I hate me to say that, but) couldn’t you use backslash “\” instead?
It wouldn’t interfere with the division-operator.

I am not a KiCad developer, so the wrong address here.

You may need to open an issue at the KiCad bug tracker to reach the KiCad developers.

Did you test the compatibility of \ in ngspice?

…apparingly “\” seem to work properly.
But: to my surprise “/” does also work now, after last corrections.
I will monitor this issue further on.

OK…I got the root-cause now.
It is neither “/” nor “\”; both work.
It is, what Holger indicated in the very beginning:
the netlist-handling of dependent sources F and H.
After I fixed it manually in the .cir-file, it of cause returned whenever I created another spice-netlist.
It almost drove me crazy.
The solution within KiCad looks like this:

I have to apply both “control source” and “gain” in the value-field separated by a blanc-char.
I am using dependent sources from pyopus, as there where no respective symbols in the KiCad-libs (at least I didn’t find them). Obviously the netlister doesn’t operate properly on pyopus-controlled sources (or I am using them improperly…).

Perhaps it is just me, but I find the use of “/” and “” in node names to be very problematic. These are well known as directory delimiters, and to use them in a netlist where they could be node names or file names depending on context just seems to be begging for confusion.

John