<@U05CYP3A11T> Also consider that in ngspice, insi...
# xschem
s
@Calvin Yan Also consider that in ngspice, inside a
.control / .endc
block you can use environment variables. Example:
.control
...
...
write $FILENAME
.endc
if environment variable
FILENAME
is defined before starting ngspice:
export FILENAME=circuit.raw
the above write command will write into
circuit.raw
(@Tim Edwards did you know this?). Unfortunately environment variables expansion does NOT work outside a .control block, so for example we can not use
$PDK_ROOT
in a
.lib
statement (sigh).
πŸ‘ 2
h
Unfortunately complaining does not help.
But what will help is a short request to the feature request tracker at https://sourceforge.net/p/ngspice/feature-requests/. If it is accompnied with a short spec, that might be helpful. Adding reading env variables is not a major issue, but when, where is probably important.
Another request: there are complaints about ngspice, e.g. from Daryl Miles. When I am reading this, I do not understand a single word. If these issues are serious, please translate them into ngspice speech. Otherwise I cannot react.
s
@holger vogt Adding env variables recognition anywhere in a netlist is probably not an easy task to do without nasty side effects. In many netlist specifications $ is a inline comment character (so anything following $ in a line will be ignored. So I don't know if this is an easy task to do. It would be nice to allow in a netlist the following:
.lib $PDK_ROOT/$PDK/libs.tech/combined tt
This will make the netlist portable (no absolute pathnames) But I know the $ has another meaning (as an in-line comment character), so I recognize it is not trivial.
t
No, I did not know that environment variables will be substituted inside a control block. Interesting. Not sure I would make use of it; I try to avoid environment variables except where they actually describe the environment, which is how they are intended to be used.
$PDK_ROOT
is a true environment variable, because it describes where the PDK is in the user's environment and makes files portable.
$FILENAME
, by contrast, is specific to the simulation. It's basically being used as an end-run around the fact that ngspice's interpreter doesn't accept arguments passed from the command line. But I noticed from the ngspice documentation that variables can be created and passed directly to the program from the command line with the
-D
argument. It's a bit oblique (and hard to find in the documentation), but seems reasonable.
h
There is a commit on ngspice git branch pre-master-43 which says: Search path for .lib and .include has been enhanced to read complete or partial paths from an environmental variable. The env variable name has to start with '$' as the first character after the .inc or .lib token. It is read until it hits a directory separator '/' or '\\', or if none is found, until the end of the line. In this case the filename has to be included in the env variable. If the env variable is read successfully, a ngspice variable with the same name (without leading '$') and contents is defined for use in a .control section.
πŸ‘ 1
There is an update available at ngspice git branch pre-master-43. ngspice now supports .lib $ENV1/filename tt .lib $ENV1\$ENV2\dirs\filename tt .lib $ENV1 .lib $ENV1/$ENV2
πŸ‘ 1
πŸ’ͺ 1
Similar with .include (no tt).
s
@Holger Vogt Thank you! this makes netlists portable across systems (given proper environment setup). I have verified pre-master-43 and it works, including the ngspice variables creation.
πŸ‘ 1