<@U01819B63HP>, to your knowledge, is there any wa...
# xschem
c
@Stefan Schippers, to your knowledge, is there any way to use
source
,
include
, or
.lib
from within a ngspice control structure without having to terminate and restart ngspice entirely?
s
@Christoph Maier to my knowledge, No. I have numerous times tried to setup a testbench that does multi-corner simulations, unsuccessfully. You can restart ngspice, modify the .lib / .include and append simulation data to the previous raw file (with
set appendwrite
)
c
@Stefan Schippers, for what it's worth, I'm starting to pester the ngspice core developers how to do control loops in ngspice: https://sourceforge.net/p/ngspice/discussion/133842/thread/9ea3c00af1/ forgetting to say "thank you" and almost getting locked out from the discussion forum by its gatekeepers, and lagging behind in my chipalooza design because of that. If ngspice doesn't work, and the device models for a process need to get edited, anyhow, do you think it might be feasible to modify device models such that they can be invoked with a non-standard calling mechanism other than
.lib <model> <corner>
that allows process corner analysis from within a ngspice control structure?
s
@Christoph Maier it is probably possible to modify core model parameters to switch from
tt
to
ss
or
ff
, using
alter
/
altermod
/
alterparam
, but I never tried that, expecially with sky130 models that are a black hole of recursively called files. Usually I keep the corner switching as the outermost loop and I simply restart ngspice on the new corner. Not a solution to your problem, though.
c
@Stefan Schippers, what scripts do you use to restart ngspice? My problem is how to keep python script kiddies off my lawn, who will corrupt the tool chain with dependency and version hell that nobody can keep track of.
s
something like this: change .lib and write statements and run ngspice.
Copy code
for c in  ss tt ff; do
   # replace last 2 chars in .lib lines with $c
   sed -i "/^\.lib /s/..\$/$c/" test_nmos.spice
   # modify raw file name in write statements (test_nmos_$c.raw) 
   sed -i "s/^write test_nmos.*/write test_nmos_$c.raw/" test_nmos.spice
   ngspice -i test_nmos.spice
done
๐Ÿ’ก 1
c
bash? tcl??
l
This should be a feature in xschem itself: the possibility of generating several spice files with different corner headers and simulating each of them in distinct ngspice processes.
l
I made a script to run a given netlist on given corners (in parallel) and save a dummy 'corner' variable so you can switch between them in xschem. You can copy the multicorner launcher.sym into your schematic and it should work without edits. (Although you need to edit the launcher.sym to add/remove corners.) Seems like workable solution to me. Files attached to next message.
๐Ÿ’ช 2
s
@Christoph Maier the above is bash script
๐Ÿ™ 1
l
multicorner.py,multicorner_copypasta.sch,multicorner_example.sch
the 'corner' vector is made with
let corner = v(dd) * 0 + $corner
in the script. So you either need a node named
dd
or can edit script to your convention
My problem is how to keep python script kiddies off my lawn
rip. there's no dependencies though
I tried doing in tcl for a good while but it was too hard for me lol
s
@Luis Henrique Rodovalho It is possible to run multiple simulations in parallel with different parameter settings / process corners / whatever: this example:
Copy code
xschem load poweramp.sch
set id_list {}

xschem netlist
set id [simulate]
# some delay to allow ngspice to start and read the netlist before changing it
delay 1000
lappend id_list $id

# change VPP, output file name and input signal amplitude
set commands [xschem getprop instance NGSPICE value]
regsub {\.param VPP=50} $commands {.param VPP=30} commands
regsub -all {poweramp\.raw} $commands {poweramp1.raw} commands
xschem setprop instance NGSPICE value $commands
xschem setprop instance V3 value {dc 0 sin 0 0.5 {frequ} 1m}

xschem netlist
set id [simulate]
# some delay to allow ngspice to start and read the netlist before changing it
delay 1000
lappend id_list $id

# change again VPP and output file name
regsub {\.param VPP=30} $commands {.param VPP=25} commands
regsub -all {poweramp1\.raw} $commands {poweramp2.raw} commands
xschem setprop instance NGSPICE value $commands

xschem netlist
set id [simulate]
# some delay to allow ngspice to start and read the netlist before changing it
delay 1000
lappend id_list $id


# poll loop
while {1} {
  delay 1000
  set busy 0
  foreach id $id_list {
    set var "execute(cmd,$id)"
    if {[info exists $var]} { set busy 1}
  }
  if {!$busy} { break }
}
puts Done
does exactly that. See video.
๐Ÿ’ก 1
๐Ÿ™Œ 1