which isn't very portable. Is there a way of using environment variables like PDK_ROOT in a spice file?
m
manili
07/13/2022, 4:33 PM
I guess you can use environment variables to handle it.
.include “$YOUR_PATH/…”
t
Tim Edwards
07/13/2022, 5:26 PM
I don't think ngspice handles environment variables in the netlist.
The only way I've found to do it is to pre-process a script (containing variable names) and then pass it to ngspice.
👍 2
m
manili
07/13/2022, 6:29 PM
Sorry my bad. Thanks for correcting me.
s
Stefan Schippers
07/13/2022, 10:45 PM
I also struggled in the past to do this
Didn't find a way to use env var in netlists.
For xschem generated netlists the idea is to make schematic portable (by defining library locations in xschemrc and using env vars like PDK_ROOT to handle spice models). Variables are expanded in the spice netlist and as a result it is not portable. However recreating the netlist from the schematic (which is portable) on a different system fixes all the file locations.
t
Tim Edwards
07/14/2022, 1:19 PM
Yes, I should have mentioned that xschem has a nice solution which does all the variable substitutions within xschem. I think that unless the ngspice developers are willing to extend the ngspice syntax to include a way to embed and expand variables in the netlist, then a SPICE netlist has to be treated as a temporary format; the primary source has to be either an xschem schematic or a netlist with variables, passed through a preprocessor (like preproc.py in open_pdks).
s
Stefan Schippers
07/17/2022, 10:06 PM
@Tim Edwards I see ngspice can get a value from a shell variable, like in:
Linen is a search-engine friendly community platform. We offer integrations with existing Slack/Discord communities and make those conversations Google-searchable.