An oddity about `ngspice`: If I type the following...
# analog-design
y
An oddity about `ngspice`: If I type the following code into the
ngspice
interactive session
Copy code
compose Ws values 1u   2u
compose Ls values 0.1u 0.2u

foreach WW $&Ws
  foreach LL $&Ls
    echo W/L = $WW / $LL
  end
end
The printing of W/L works as expected. But if it is put into the
.control
...
.endc
block in a file and use
ngspice
to load it from commandline, it complains that Error: WW: no such variable. Error: LL: no such variable. I am puzzled by this behavior. Any suggestions?
s
Looks like ngspice does weird things. If there's an
echo
it appears that whole thing is evaluated in a shell script? If I change the
echo ...
to
print $WW / $LL
I get meaningful results
v
I believe that
echo
is a nutmeg command (nutmeg is the name of the interactive interpreter). IIRC, nutmeg is essentially a modified csh, so that's what's running commands specific to the interpreter. The
print
command, however, is an internal SPICE command, so it works like you'd expect in batch mode. I'm afraid the ngpsice manual doesn't do a good job pointing out what commands are specific to nutmeg. The interactive interpreter section has asterisks to indicate "only available in ngspice, not in ngnutmeg," which I think indicates the given command only makes sense inside a
.control
block, not on the nutmeg command line. There's no marker to indicate what makes sense on the command line, but not in a
.control
block, however.
y
Thanks for the explanations. But it is still very puzzling to me. See the following code:
Copy code
.control
let a = 1
set b = 1
echo $&a, $b
.endc
which run as expected in batch mode. echo clearly has access to both vector and variable. The only trouble seems to be with the
foreach
generated variable, which somehow is not accessible by
echo
.