Hi all, I'm trying to simulate a ring oscillator i...
# analog-design
m
Hi all, I'm trying to simulate a ring oscillator in xschem (actually ngspice). In the ngspice console, I get:
Copy code
Checking parameters for BSIM 4.5 model x3.xm1:sky130_fd_pr__nfet_01v8__model.25
Fatal: Pclm = -0.0968433 is not positive.
Fatal: Drout = -0.261499 is negative.
Warning: Cdscd = -0.00649389 is negative.
Warning: Eta0 = -0.0934787 is negative.
Fatal error: detected during BSIM4v5.5.0 parameter checking for 
    model x3.xm1:sky130_fd_pr__nfet_01v8__model.25 of device instance m.x3.xm1.msky130_fd_pr__nfet_01v8
I've tried 1 inverter and 3 inverters. I'm attaching PNG exports from xschem. Any advice appreciated.
a
try checking for pdk versions. Is it up to date?
s
Please send the complete .spice netlist so I can run a test.
In some cases users were running an ancient version of ngspice. DO not use an ngspice installed with apt from the linux repositories, get ngspice from sourceforge repository as explained here.
m
pdks are up to date for sure. ngspice was a distro provided version but not too far behind. have updated ngspice to latest git from sourceforge, but same/similar behavior as before. here is the generated netlist:
Copy code
** sch_path: /home/user/work/inverter/xschem/inverter_multi_tb.sch
**.subckt inverter_multi_tb val
*.opin val
x1 val net2 inverter
x2 net1 val inverter
x3 net2 net1 inverter
V1 VDD GND 1.8
.save i(v1)
**** begin user architecture code

.lib /usr/local/share/pdk/sky130A/libs.tech/ngspice/sky130.lib.spice tt



.ic V(val) 1
.control
save all
tran 1n 1u
plot V(val)
.endc

**** end user architecture code
**.ends

* expanding   symbol:  inverter.sym # of pins=2
** sym_path: /home/user/work/inverter/xschem/inverter.sym
** sch_path: /home/user/work/inverter/xschem/inverter.sch
.subckt inverter out inp
*.ipin inp
*.opin out
XM1 out inp GND GND sky130_fd_pr__nfet_01v8 L=0.18 W=4.5 nf=3 ad='int((nf+1)/2) * W/nf * 0.29' as='int((nf+2)/2) * W/nf * 0.29'
+ pd='2*int((nf+1)/2) * (W/nf + 0.29)' ps='2*int((nf+2)/2) * (W/nf + 0.29)' nrd='0.29 / W' nrs='0.29 / W'
+ sa=0 sb=0 sd=0 mult=1 m=1
XM2 out inp VDD VDD sky130_fd_pr__pfet_01v8 L=0.18 W=3 nf=3 ad='int((nf+1)/2) * W/nf * 0.29' as='int((nf+2)/2) * W/nf * 0.29'
+ pd='2*int((nf+1)/2) * (W/nf + 0.29)' ps='2*int((nf+2)/2) * (W/nf + 0.29)' nrd='0.29 / W' nrs='0.29 / W'
+ sa=0 sb=0 sd=0 mult=1 m=1
.ends

.GLOBAL GND
.GLOBAL VDD
.end
s
I copied your netlist, changed only the path for the
sky130.lib.spice
file which is different on my system and simulation did run with no errors. If you build and install ngspice from sources remember to remove the packaged ngspice installation (
sudo apt purge ngspice
) my open_pdks install is super new, updated yesterday, as well as ngspice.
m
I get similar results at my end too when I invoke similarly
ngspice -i ~/.xschem/simulations/inverter_multi_tb.spice
. it still does not work when I press the
simulate
button in
xschem
though. the command line for
ngspice
seems the same up to
-a
option which just seem to trigger an irrelevant compatibility option. however the working directory varies between these - when I invoke ngspice manually from the schematic directory I get the good behavior but when I invoke it manually from
.xschem/simulations
I get the bad behavior similar to the button. update: if I soft-link the spice init file in the
simulations
directory it seems to work from the button too, though I wasn't expecting that to be necessary. resolved, thanks.
s
Good!. Yes whatever the directory you use for ngspice simulations you must provide or soft-link a .spiceinit file:
Copy code
set ngbehavior=hsa
set ng_nomodcheck 
# set filetype=ascii
set num_threads=4