pascalkuthe / OpenVAF

An innovative Verilog-A compiler
https://openvaf.semimod.de/
GNU General Public License v3.0
123 stars 20 forks source link

BSIM-CMG v107 fails to simulate correctly #96

Closed topolarity closed 10 months ago

topolarity commented 10 months ago

BSIM-CMG v107 (http://bsim.berkeley.edu/BSIMCMG/BSIMCMG107.0.0_20130712.tar.gz) successfully compiles with OpenVAF, but it fails to simulate properly:

$ openvaf bsimcmg107/code/bsimcmg.va  -o ./bsimcmg.osdi
$ ngspice ./inverter_cmg_ngspice.cir
...
Initial Transient Solution
--------------------------

Node                                   Voltage
----                                   -------
q                                  1.66259e-06
d                                          0.5
vss                                          0
vdd                                          1
vd#branch                          -2.8533e-13
vvss#branch                        2.47656e-10
vvdd#branch                       -2.47383e-10

No. of Data Rows : 401
                                ** test circuit
                                Transient Analysis  Thu Nov 16 19:36:13  2023
--------------------------------------------------------------------------------
Index   time            v(q)
--------------------------------------------------------------------------------
0       0.000000e+00    1.662588e-06
1       1.000000e-09    1.877221e-06
2       2.000000e-09    1.908811e-06
...
394     3.940000e-07    1.658756e-06
395     3.950000e-07    1.689037e-06
396     3.960000e-07    1.719760e-06
397     3.970000e-07    1.750852e-06
398     3.980000e-07    1.782233e-06
399     3.990000e-07    1.813816e-06
400     4.000000e-07    1.845512e-06
ngspice-41 done

The output averages about 1.7 μV , which is several orders of magnitude off from what, e.g., Xyce simulates for BSIM-CMG v107.

The same circuit simulated with BSIMCMG v110 (http://bsim.berkeley.edu/BSIMCMG/BSIMCMG110.0.0_20160101.tar.gz) appears to work (and also matches Xyce very closely):

$ openvaf bsimcmg110/code/bsimcmg.va -o ./bsimcmg.osdi
$ ngspice ./inverter_cmg_ngspice.cir
...
Initial Transient Solution
--------------------------

Node                                   Voltage
----                                   -------
q                                      0.22989
d                                          0.5
vss                                          0
vdd                                          1
vd#branch                          4.27349e-13
vvss#branch                        1.79449e-05
vvdd#branch                       -1.79449e-05

No. of Data Rows : 401
                                ** test circuit
                                Transient Analysis  Thu Nov 16 20:01:34  2023
--------------------------------------------------------------------------------
Index   time            v(q)
--------------------------------------------------------------------------------
0       0.000000e+00    2.298897e-01
1       1.000000e-09    2.258882e-01
2       2.000000e-09    2.220603e-01
3       3.000000e-09    2.184140e-01
4       4.000000e-09    2.149506e-01
5       5.000000e-09    2.116702e-01
6       6.000000e-09    2.085718e-01
...
391     3.910000e-07    2.721864e-01
392     3.920000e-07    2.671648e-01
393     3.930000e-07    2.621614e-01
394     3.940000e-07    2.572085e-01
395     3.950000e-07    2.523351e-01
396     3.960000e-07    2.475660e-01
397     3.970000e-07    2.429221e-01
398     3.980000e-07    2.384204e-01
399     3.990000e-07    2.340745e-01
400     4.000000e-07    2.298944e-01
ngspice-41 done

netlist: inverter_cmg_ngspice.cir.txt

pascalkuthe commented 10 months ago

which OpenVAF version did you use?

topolarity commented 10 months ago

I compiled from the OpenVAF-v23.5.0 tag, although the problem appears to show on a more recent master build as well

pascalkuthe commented 10 months ago

There were quite significant changes on master. Does the problem still reproduce with the latest master build?

These kind of issues can be very hard to debug. If a simulation converges its very unusual for results to just be wrong. Usually compiler bugs lead to convergence issues instead.

The most likely explanation would be some backwards incompatible changes in BSIM paramter names. How did you test with xyce exactly? Sometimes they patch the official Verilog-A files

topolarity commented 10 months ago

Does the problem still reproduce with the latest master build?

Yes, it does

How did you test with xyce exactly?

Using this netlist: inverter_cmg_xyce.cir.txt

If you change level = 107 to level = 110 it will warn about a few missing parameters, but it matches the OpenVAF-compiled/ngspice-simulated BSIM-CMG v110 very closely. The ASAP7 PDK that these .model cards are taken from is based on BSIM-CMG v107, so hopefully it's not a parameter issue.

dwarning commented 10 months ago

The problem is not caused by openVAF. The TO didn't show the whole ngspice printout: `** ngspice-41+ : Circuit level simulation program Compiled with Sparse Direct Linear Solver The U. C. Berkeley CAD Group Copyright 1985-1994, Regents of the University of California. Copyright 2001-2023, The ngspice team. Please get your ngspice manual from https://ngspice.sourceforge.io/docs.html Please file your bug-reports at http://ngspice.sourceforge.net/bugrep.html Creation Date: Sat Nov 11 19:40:01 UTC 2023


Note: No compatibility mode selected!

Circuit: ** test circuit

Warning: Model issue on line 4 : .model asap7_nmos_lvt bsimcmg type=1 bulkmod=1 igcmod=1 igbmod=0 gidlmod ... unrecognized parameter (type) - ignored

Warning: Model issue on line 58 : .model asap7_pmos_lvt bsimcmg type=0 bulkmod=1 igcmod=1 igbmod=0 gidlmod ... unrecognized parameter (type) - ignored

Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

Warning: Interpolated raw file data!

Initial Transient Solution

Node Voltage


q 1.66259e-06 d 0.5 vss 0 vdd 1 vd#branch -2.8533e-13 vvss#branch 2.47656e-10 vvdd#branch -2.47383e-10

Reference value : 2.88060e-07 No. of Data Rows : 401 ` The very old vacode of the 107 model is using devtype as model parameter for channel type selection. Using that the simulation will show the expected larger amplitude. BTW - it is questionable to user a parameter set for a original 105 version to a version 110 and expect same results in mV range.

pascalkuthe commented 10 months ago

Thanks Dietmar! In that case, I will close this issue

topolarity commented 10 months ago

Ah-ha. Thank you for the help!

Sorry for the noise here.