which isn't very portable. Is there a way of using...
# analog-design
m
which isn't very portable. Is there a way of using environment variables like PDK_ROOT in a spice file?
m
I guess you can use environment variables to handle it. .include “$YOUR_PATH/…”
t
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
Sorry my bad. Thanks for correcting me.
s
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
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
@Tim Edwards I see ngspice can get a value from a shell variable, like in:
Copy code
ngspice 42 -> set mypath  = `echo $HOME`
ngspice 43 -> echo $mypath
/home/schippes
However i don't know if it is then possible to use this var in a .lib or .include statement. I don't think it is allowed.