https://open-source-silicon.dev logo
#analog-design
Title
# analog-design
s

Stefan Schippers

05/06/2022, 8:59 AM
@User one minute to parse the megabytes of sky130 models is quite normal (of course it's system dependent). Ensure you have the following
.spiceinit
file in the directory where ngspice is running, the second line speeds up model loading.
set ngbehavior=hsa
set ng_nomodcheck
1
a

Aleksandar Pajkanovic

05/06/2022, 9:01 AM
Hi @User, it's an honor. Thank you for your work. Ok, so I was thinking something like that... Let me check my
.spiceinit
...
Yes, you were right, there was no
set ng_nomodcheck
line, however, no change in behavior at all when added. I went ahead and actually measured the time for
.op
simulation of a few transistor circuit, and it's 107 seconds either way, with and without
ng_nomodcheck
set. == Is there maybe a way to somehow focus the engine to loading just a subset of models (I do use only two kinds of devices)?
s

Stefan Schippers

05/06/2022, 9:23 AM
When you run ngspice do you see this message in the simulator output? This ensures ngspice is reading the .spiceinit file. On my system ngspice start simulting after 30 seconds. My system is a 12 years old laptop, no SSD.
Compatibility modes selected: hs a
If you can send your netlist i can test the same testcase here. Also what version of ngspice are you using?
schippes@mazinga:~/.xschem/simulations$ ngspice -v
******
** ngspice-36+ : Circuit level simulation program
a

Aleksandar Pajkanovic

05/06/2022, 9:29 AM
yes, I see that line:
Copy code
Compatibility modes selected: hs a


Circuit: **.subckt miel21_tb_opamp_op

Scale set to 1e-06
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

 Reference value :  0.00000e+00
No. of Data Rows : 1
ngspice is version 34, and it's all running within an Ubuntu 18.04 virtual machine (VirtualBox) where 16 GB of RAM and 2 cores have been dedicated
s

Stefan Schippers

05/06/2022, 9:31 AM
May be you should try to update ngspice from the sources https://git.code.sf.net/p/ngspice/ngspice
a

Aleksandar Pajkanovic

05/06/2022, 9:32 AM
Here's the full netlist
right... updating...
s

Stefan Schippers

05/06/2022, 9:38 AM
on my system it takes 30 seconds, and 99% of the time is just parsing the huge pdk.
30 seconds is a big improvement. Older ngspiec versions took 3/5 minutes do do the task. Ngspice developers have done lot of quirks to speed up the model parsing.
a

Aleksandar Pajkanovic

05/06/2022, 9:39 AM
Right, I notice the same thing - the simulation is a snap, but the loading is taking all the time. Ok, thanks, so it's definitely something wrong with my setup, thanks.
s

Stefan Schippers

05/06/2022, 9:41 AM
yes one minute is bit too much, either there is a I/O bottleneck in the virtal machine or the ngspice version is too old. The load improvement is quite recent so let's hope things get better with updated ngspice.
a

Aleksandar Pajkanovic

05/06/2022, 9:56 AM
ok, here we go:
Copy code
******
** ngspice-36+ : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Copyright 2001-2020, The ngspice team.
** Please get your ngspice manual from <http://ngspice.sourceforge.net/docs.html>
** Please file your bug-reports at <http://ngspice.sourceforge.net/bugrep.html>
** Creation Date: Fri May  6 09:49:12 UTC 2022
******
All right! 22 seconds! Thanks @User!
👍 1
I'll be re-running my other simulations as well, to make sure results remain the same, but in general, this is a 5x improvement.
oh yeah, one more thing, not that important, but it's a bit annoying... at some point, ngspice stopped accepting arrow up for previous command... do you happen to know why the hell?
and is there a way to bring that back - it's really helpful ...
s

Stefan Schippers

05/06/2022, 10:03 AM
I also believe the ng_nomodcheck is now the default in ngspice. Even if i remove the .spiceinit file i don't see differences. However keep at least the compatibility option set ngbehavior=hsa.
👍 1
you need to configure and compile ngspice with readline support: ../configure --prefix=/home/schippes --with-x --enable-xspice --disable-debug --enable-cider -
-with-readline=yes
--enable-openmp --no-create --no-recursion
--with-x
also enables graphical plotting
a

Aleksandar Pajkanovic

05/06/2022, 10:05 AM
ah, ok, so that's the thing I dropped out a few versions back and I just kept using the same line to compile, so the mistake propagated... Thank you
s

Stefan Schippers

05/06/2022, 10:08 AM
do not add --no-create --no-recursion, these are saved in my config.log for reasons i ignore, but they should not be given at config time.
a

Aleksandar Pajkanovic

05/06/2022, 10:08 AM
Ok.
h

Harald Pretl

05/06/2022, 10:56 AM
@User @User I made a script to put all the models into a single file, only keep a single corner, and strip all the comments from it. In my experience, this also brings quite a bit of speed. In case you are interested: https://github.com/hpretl/iic-osic
👍 1
Tool is
iic-spice-model-red.py
My ngspice starting time is 5sec or so.
👍 1
t

Tim Edwards

05/06/2022, 12:41 PM
@User: Hello once again, and thanks for posting! To all of you over there in the European time zones: It's nice to find the complicated questions all cleared up before I've even had breakfast. To everyone: Aleksandar is a great guy and talented designer who has been active with efabless since the early days, and has always been very supportive of us, even when suffering through all of our start-up pains.
🌄 1
s

Stefan Schippers

05/06/2022, 1:03 PM
@User (@User) you are right, loading a single corner further speeds up start up time considerably. If instead of doing:
.lib /home/schippes/share/pdk/sky130A/libs.tech/ngspice/sky130.lib.spice tt
I take only the 'tt' portion of the .lib file: .
param mc_mm_switch=0
.param mc_pr_switch=0
* MOSFET
.include /home/schippes/share/pdk/sky130A/libs.tech/ngspice/corners/tt.spice
* Resistor/Capacitor
.include /home/schippes/share/pdk/sky130A/libs.tech/ngspice/r+c/res_typical__cap_typical.spice
.include /home/schippes/share/pdk/sky130A/libs.tech/ngspice/r+c/res_typical__cap_typical__lin.spice
* Special cells
.include /home/schippes/share/pdk/sky130A/libs.tech/ngspice/corners/tt/specialized_cells.spice
with this single change ngspice parsing goes from 30 seconds down to 6.5 seconds on my system. The real question is why ngspice (apparently) insists on parsing unused corners (@User also dealt with this issue a lot).
a

Aleksandar Pajkanovic

05/10/2022, 9:34 AM
Thanks @User for jumping in and bringing the script to our attention. Thank you for the contribution, as well, these kinds of things are what take us forward on a daily basis - your work is much appreciated. I will take over the script and try it out in our environment - I am stuck on openlane now 🙂
Dear @User, it has been a delight following your work all these years, and daring to even think that I played the smallest of parts in this technology revolution you guys are leading is a great honor for me. Thank you for such an introduction, I hope to live to the promise and raise our collaboration to higher levels.