PRODUCTION_WORTHY_SPICE_RESOURCES
Spice can set up to do automatic testing, and further process the test
results to a text file. That means it is possible to predict the spec
limits for a design while in the simulation stage.
The real power comes in testing a design to "corners" to verify that
a design will work under all conditions of temperature, processing,
and application conditions, etc.
The real corners to apply are three different temperatures, over min
and max limits for processing things like pnp and npn beta, base sheet
rho resistance.. etc, and maybe two different supply voltages.
Automatic testing make this stuff easy. Spice appears to store everything
in array format. Knowing how to read and write to these dataarrays appears
to be just a matter of knowing the format.
The following examples have been set up to copy and pasted into a text
file which can be run on Ngspice. Copying text between the following two
lines can be pasted into a text file that Ngpsice can source.
StartLine: NPN_ADJUSTMENTS_to_Area_Temp_and_Beta_and_R
EndLine: *source /Users/don_sauer/Downloads/stabie/SI_Lib/Tests.cir
================NPN_ADJUSTMENTS_to_Area_Temp_and_Beta_and_R================
NPN_ADJUSTMENTS_to_Area_Temp_and_Beta_and_R
*=====================================================================
* Spice stores data as arrays which can be accessed and modified within a run.
* Trandient, AC, and DC output waveforms are really arrays.
* This example shows how to read and modify models and individual components.
* Models parameters are stored as an array accessed by the showmod statment.
* Each transistor has its own operating point array accessed by the show statment.
* This simulation is applying negative feedback to the VOFF point throught BOFF.
*=====================================================================
* ^ VC
* /_\
* |
* __/\ /\ /\_|__/\ /\ /\__
* | \/ \/ \/ \/ |
* | R1 R2 |
* _|VC1 VC2 |_
* _____|'QN1 QN2`|__
* |VOFF |`->1X 1X<-'| |
* _|_ |VE1 | |
* /BOF\ |____________________________| |
* \___/ _|_ VE1 |
* | / _ \1I |
* _|_ \/ \/ |
* /// /\_/\ ___/\ /\ /\_|
* \___/ _|_ \/ \/
* _|_ /// R3
* ///
.OPTIONS GMIN=1e-15 METHOD=gear ABSTOL=1e-15 temp=27
*====== ====== ====== ====== ====== ====== ======
VCC VC 0 DC 10
BOFF VOFF 0 V= (V(VC1)-V(VC2))*100k
QN1 VC1 VOFF VE1 NPN1 1.00
QN2 VC2 VB2 VE1 NPN1 1.00
I1 VE1 0 100u
R1 VC1 VC 1000
R2 VC2 VC 1000
R3 VB2 0 1m
.control
*====================Initial_Offset=================================
* In spice the offset typically come close to zero
*====================================================
op
echo "With a Perfect Match Everywhere the input Offset is $&voff"
*with a perfect match everywhere the input offset is -4.65661E-10
*====================Change_R3=================================
* Adding resistance to R3 can show the effects of beta
*====================================================
alter R3 Resistance = 10k
op
echo "With the Resistance R3 at 10k input Offset is $&voff"
*with the resistance r3 at 10k input offset is -0.00473442
*=====================Half_NPN_Beta================================
* Now a change in npn beta can be observed
*====================================================
altermod npn1 bf = 50
op
echo "With half the beta at QN1 the input Offset is $&voff"
*with half the beta at qn1 the input offset is -0.00937981
*=====================Back_to_Normal================================
* Now set back to normal
*====================================================
alter R3 Resistance = 1m
op
echo "With the Resistance R3 back to 1m input Offset is $&voff"
*with the resistance r3 back to 1m input offset is -8.14907E-10
*======================Add_4%_Offset===============================
* A 4% change in area should creat about 1 mV offfset
*====================================================
alter qn1 Area = 1.04
op
echo "With the area of QN1 at +104% the input Offset is $&voff"
*with the area of qn1 at +104% the input offset is -0.00101452
*=====================Back_to_Normal================================
* Now set back to normal
*====================================================
alter qn1 Area = 1.00
op
echo "With the area of QN1 back to 1 the input Offset is $&voff"
*with the area of qn1 back to 1 the input offset is -8.14907E-10
*=====================Change_One_NPN_Temperature================
* The temperature of a single transistorcan be adjusted
*====================================================
alter qn1 TEMP = 37
alter qn1 Area = 1.0
op
echo "with just QN1 at 37C the input Offset is $&voff"
*with just qn1 at temperature 37c the input offset is -0.0164536
*=====================Measure_Saturation_Voltage===============
* It is possible to smeasure the sat voltage of a single transistor
* The base and collector current is also available
*====================================================
alter qn1 TEMP = 37
let vc1sat = @qn1[vbc] - @qn1[vbe]
echo "Can measure VCE of qn1 a $&vc1sat"
print @qn1[ic]
print @qn1[ib]
*can measure vceof qn1 at -10.646
*@qn1[ic] =4.906234e-05
*@qn1[ib] = 9.379640e-07
*====================Extract_Operation_Values====================
* The following transistor data is available
*====================================================
echo "Can read model parameters"
print @npn1[is]
print @npn1[bf]
print @npn1[nf]
print @npn1[vaf]
print @npn1[ikf]
print @npn1[ise]
print @npn1[ne]
print @npn1[re]
*can read model parameters
*@npn1[is] = 1.000000e-16
*@npn1[bf] = 5.000000e+01
*@npn1[nf] = 1.000000e+00
*@npn1[vaf] = 2.160000e+02
*@npn1[ikf] = 0.000000e+00
*@npn1[ise] = 0.000000e+00
*@npn1[ne] = 1.500000e+00
*@npn1[re] = 0.000000e+00
*====================List_Operation_Values_Available==============
* show shows all the operation data points of a transistor
*====================================================
showqn1
* BJT: Bipolar Junction Transistor
* device qn1
* model npn1
* ic 4.90623e-05
* ib 9.37964e-07
* ie -5.00003e-05
* vbe 0.678618
* vbc -9.96739
* gm 0.00183554
* gpi 3.50957e-05
* gmu 1e-15
* gx 0
* go 2.17121e-07
* cpi 0
* cmu 0
* cbx 0
* csub 0
*=====================List_Model_Parameters==============
* showmode shows all the model parameters
*====================================================
showmod
* BJT models (Bipolar Junction Transistor)
* model npn1
* type npn
* tnom 27
* is 1e-16
* bf 50
* nf 1
* vaf 216
* ikf 0
* ise 0
* ne 1.5
* br 1
* nr 1
* var 0
* ikr 0
* isc 0
* nc 2
* rb 0
* irb 0
* rbm 0
* re 0
* rc 0
* cje 0
* vje 0.75
.endc
.model NPN1 NPN( BF=100 VAF=216 )
.end
* ngspice
*source /Users/don_sauer/Downloads/stabie/SI_Lib/Tests.cir
===================NMOS_ADJUSTMENTS_to_L_W=================================
NMOS_ADJUSTMENTS_to_L_W_
*=====================================================================
* Spice stores data as arrays which can be accessed and modified within a run
* Trandient, AC, and DC output waveforms are really arrays
* This example shows how to read and modify models and individual components
* Models parameters are stored as an array accessed by the showmod statment
* Each transistor has its own operating point array accessed by the show statment
* This simulation is applying negative feedback to the VOFF point throught BOFF
*=====================================================================
* ^ VDD
* /_\
* |
* __/\ /\ /\_|__/\ /\ /\__
* | \/ \/ \/ \/ |
* _| VD1 R1 R2 |_
* || VD2 ||
* _____||___ ___||__
* |VOF ||-> <-|| |
* _|_ |VS1 1| |
* /BOF\ |____________________________| _|_
* \___/ _|_ VS1 ///
* | / _ \1I
* _|_ \/ \/
* /// /\_/\
* \___/
* _|_
* ///
.OPTIONS GMIN=1e-15 METHOD=gear ABSTOL=1e-15 temp=27
*====== ====== ====== ====== ====== ====== ======
VDD VD 0 DC 10
BOFF VOFF 0 V= (V(VD1)-V(VD2))*100k
MN1 VD1 VOFF VS1 0 nmosc w=.5u l=.5u Pd = 4u Ps = 4u
MN2 VD2 0 VS1 0 nmosc w=.5u l=.5u Pd = 4u Ps = 4u
I1 VS1 0 1000u
R1 VD1 VD 1000
R2 VD2 VD 1000
.control
*=================View_Thresshold_Voltage==================
* It is possible to view a model parameter like vth
*====================================
op
echo "With a Perfect Match Everywhere the input Offset is $&voff"
let vthh = @mn1[vth]
echo "The Vth is $&vthh"
*the vth is 0.479105
*================Change_Thresshold_Voltage===================
* It is possible to change and view the altered a model parameter like vth0
*====================================
altermod nmosc vth0 = .9
op
let vth0 = @mn1[vth]
echo "The Vth has been increased to $&vth0"
*the vth has been increased to 0.659992
*=================Change_Length==================
* It is possible to change just the length of one transistor
*====================================
alter mn1 l = .51u
op
echo "With MN1 at l=.51u the input Offset is $&voff"
*with mn1 at l=.51u the input offset is 0.0231356
*=================Change_Width==================
* For mos both length and width are adjustable
*====================================
op
alter mn1 l = .5u
alter mn1 w =.51u
echo "With MN1 at l=.5u and w= .51 the input Offset is $&voff"
*with mn1 at l=.5u and w= .51 the input offset is 0.0231356
*==================List_All_Operation_Points_Available=========
* The show can show everything stored for a given transistor
*====================================
echo "============show MN1=================="
showMN1
*===========show mn1==================
*BSIM3: Berkeley Short Channel IGFET Model Version-3
* device mn1 acnqsmod 0 gbs 1e-15 cbg -8.698e-17
* model nmosc gmbs -7.16609e-05 qb -4.43787e-15 cbd 2.8519e-21
* l 5e-07 gm 0.00235592 cqb 0 cbs 5.13708e-17
* w 5.1e-07 gds 0.000259864 qg 8.95953e-17 capbd 4.08689e-16
* m 1 vdsat 0.172983 cqg 0 capbs 1.58214e-15
* ad 0 vth 0.666037 qd 5.68068e-15
* as 0 id 0.000500018 cqd 0
* pd 4e-06 vbs 0.92713 cgg 4.03022e-16
* ps 4e-06 vgs 0.950266 cgd 5.29523e-21
* nrd 1 vds 10.2465 cgs -3.63449e-16
* nrs 1 ibd -9.31942e-15 cdg -1.26417e-16
* off 0 ibs 9.2713e-16 cdd -3.23205e-21
* nqsmod 0 gbd 1e-15 cds 1.24832e-16
*
*===================List_All_Model_Parameters_Available================
* The showmod can show everything stored for a given model
*====================================
echo "============showmod=================="
showmod
*===========showmod==================
* model nmos c delta 0.01655 cgdl 0 lpdiblc1 0 wub1 0 pk3b 0
* capmod 3 rsh 70 ckappa 0.6 lpdiblc2 0 wuc 0 pw0 0
* mobmod 1 rdsw 375 cf7.16238e-11 lpdiblcb 0 wuc1 0 pnlx 0
* noimod 1 prwg-4.441e-17 clc 1e-07 lpscbe1 0 wu0 0 pdvt0 0
* acnqsmod 0 prwb 0 cle 0.6 lpscbe2 0 wute 0 pdvt1 0
* paramchk 0 prt 0 dwc 1.5e-07 lpvag 0 wvoff 0 pdvt2 0
* binunit 1 eta0 4.441e-16 dlc 5e-08 lwr 0 welm 0 pdvt0w 0
* version 3.3.0 etab -0.2 alpha0 1.61e-05 ldwg 0 wdelta 0 pdvt1w 0
* tox 1.6e-08 pclm 0.19 alpha1 0 ldwb 0 wrdsw 0 pdvt2w 0
* toxm 1.6e-08 pdiblc1 0.00886 beta0 36.68 lb0 0 wprwg 0 pdrout 0
* cdsc -0.00024 pdiblc2 0.00029 ijth 0.1 lb1 0 wprwb 0 pdsub 0
* cdscb -0.0002219 pdiblcb 0.4 lcdsc 0 lcgsl 0 wprt 0 pvth0 0
* cdscd -0.1506 pscbe1 3.79e+08 lcdscb 0 lcgdl 0 weta0 0 pvtho 0
* cit -0.0005 pscbe2 9.4e-05 lcdscd 0 lckappa 0 wetab 0 pua 0
* nfactor 1.8 pvag 0.4484 lcit 0 lcf 0 wpclm 0 pua1 0
* xj 2.5e-07 js 5.858e-08 nfactor 0 lclc 0 wpdiblc1 0 pub 0
* vsat 86000 jsw 0 lxj 0 lcle 0 wpdiblc2 0 pub1 0
* at 33000 pb 0.5614 lvsat 0 lalpha0 0 wpdiblcb 0 puc 0
* a0 1 nj 1 lat 0 lalpha1 0 wpscbe1 0 puc1 0
* ags 0 xti 3 la0 0 lbeta0 0 wpscbe2 0 pu0 0
* a1 0 mj 0.3551 lags 0 lvfbcv 0 wpvag 0 pute 0
* a2 1 pbsw 0.8 la1 0 lvfb 0 wwr 0 pvoff 0
* keta -0.047 mjsw 0.3873 la2 0 lacde 0 wdwg 0 pelm 0
* nsub 6e+16 pbswg 0.8 lketa 0 lmoin 0 wdwb 0 pdelta 0
* nch 5e+16 mjswg 0.3873 lnsub 0 lnoff 0 wb0 0 prdsw 0
* ngate 0 cj 0.0002424 lnch 0 lvoffcv 0 wb1 0 pprwg 0
* gamma1 0 vfbcv -1 lngate 0 wcdsc 0 wcgsl 0 pprwb 0
* gamma2 0 vfb 0 lgamma1 0 wcdscb 0 wcgdl 0 pprt 0
* vbx 0 cjsw 2.73e-10 lgamma2 0 wcdscd 0 wckappa 0 peta0 0
* vbm -3 cjswg 2.73e-10 lvbx 0 wcit 0 wcf 0 petab 0
* xt 1.55e-07 tpb 0 lvbm 0 wnfactor 0 wclc 0 ppclm 0
* k1 1.04 tcj 0 lxt 0 wxj 0 wcle 0 ppdiblc1 0
* kt1 -0.11 tpbsw 0 lk1 0 wvsat 0 walpha0 0 ppdiblc2 0
* kt1l 0 tcjsw 0 lkt1 0 wat 0 walpha1 0 ppdiblcb 0
* kt2 0.022 tpbswg 0 lkt1l 0 wa0 0 wbeta0 0 ppscbe1 0
* k2 -0.1209 tcjswg 0 lkt2 0 wags 0 wvfbcv 0 ppscbe2 0
* k3 2.53 acde 1 lk2 0 wa1 0 wvfb 0 ppvag 0
* k3b -5 moin 15 lk3 0 wa2 0 wacde 0 pwr 0
* w0 0.00026 noff 1 lk3b 0 wketa 0 wmoin 0 pdwg 0
* nlx 1.2e-07 voffcv 0 lw0 0 wnsub 0 wnoff 0 pdwb 0
* dvt0 2.2 lintnoi 0 lnlx 0 wnch 0 wvoffcv 0 pb0 0
* dvt1 0.53 lint 1.2e-07 ldvt0 0 wngate 0 pcdsc 0 pb1 0
* dvt2 -0.1521 ll 0 ldvt1 0 wgamma1 0 pcdscb 0 pcgsl 0
* dvt0w 0 llc 0 ldvt2 0 wgamma2 0 pcdscd 0 pcgdl 0
* dvt1w 5.3e+06 lln 1 ldvt0w 0 wvbx 0 pcit 0 pckappa 0
* dvt2w -0.1 lw 0 ldvt1w 0 wvbm 0 pnfactor 0 pcf 0
* drout 0.76 lwc 0 ldvt2w 0 wxt 0 pxj 0 pclc 0
* dsub 0.7 lwn 1 ldrout 0 wk1 0 pvsat 0 pcle 0
* vth0 0.9 lwl 0 ldsub 0 wkt1 0 pat 0 palpha0 0
* vtho 0.9 lwlc 0 lvth0 0 wkt1l 0 pa0 0 palpha1 0
* ua 8.964e-10 lmin 0 lvtho 0 wkt2 0 pags 0 pbeta0 0
* ua1 4.31e-09 lmax 1 lua 0 wk2 0 pa1 0 pvfbcv 0
* ub 1.472e-18 wr 0.7586 lua1 0 wk3 0 pa2 0 pvfb 0
* ub1 -7.61e-18 wint 1.6e-07 lub 0 wk3b 0 pketa 0 pacde 0
* uc -4.441e-17 dwg 0 lub1 0 ww0 0 pnsub 0 pmoin 0
* uc1 -5.6e-11 dwb 0 luc 0 wnlx 0 pnch 0 pnoff 0
* u0 678 wl 0 luc1 0 wdvt0 0 pngate 0 pvoffcv 0
* ute -1.5 wlc 0 lu0 0 wdvt1 0 pgamma1 0 noia 1e+20
* voff -0.07862 wln 1 lute 0 wdvt2 0 pgamma2 0 noib 50000
* tnom 300.15 ww-9.525e-14 lvoff 0 wdvt0w 0 pvbx 0 noic -1.4e-12
* cgso 9e-13 wwc-9.525e-14 lelm 0 wdvt1w 0 pvbm 0 em 4.1e+07
* cgdo 9e-13 wwn 1 ldelta 0 wdvt2w 0 pxt 0 ef 1
* cgbo 7e-10 wwl 0 lrdsw 0 wdrout 0 pk1 0 af 1
* xpart 0 wwlc 0 lprwg 0 wdsub 0 pkt1 0 kf 0
* elm 5 wmin 0 lprwb 0 wvth0 0 pkt1l 0
* wmax 1 lprt 0 wvtho 0 pkt2 0
* b0 0 leta0 0 wua 0 pk2 0
* b1 0 letab -0 wua1 0 pk3 0
* cgsl 0 lpclm 0 wub 0
*
.endc
.model NMOSC NMOS
+ Level= 49 Tnom=27.0 version=3.24
+ mobmod=2 capmod=3 noimod=2
**-----------------Process-----------------------------------------------
+ tox=160e-10 toxm=160e-10
+ ngate=8.000e+19 xj=0.25e-06 nch=0.5e+17
*------------------V_threshold-------------------------------------------
+ vth0=0.72 lvth0=0.025 nlx=0.12e-06 kt1=-0.9821
+ dvt0=2.2 dvt1=0.53 dvt2=-1.521E-01
*------------------NarrowChannel-----------------------------------------
+ w0=2.6e-04 wint=0.16e-06 ww=-9.525E-14 wwn=1.0
+ dvt0w=0 dvt1w=5.3e6 dvt2w=-1.E-01
+ k3=2.53 k3b=-5 dwg=0 dwb=0
*------------------Bulk--------------------------------------------------
+ k1=1.04 k2=-1.209E-01 kt2=-0.2916
+ cdsc=-2.4E-4 cdscd=-1.506E-04 cdscb=-2.219E-04
*------------------Mobility----------------------------------------------
+ u0=678 ua=8.964e-10 ub=1.472e-18 uc=-4.441E-17
+ ute=-1.176 ua1=5.705e-09 ub1=-1.147E-17 uc1=-1.302E-01
+ vsat=86000 at=20380 elm=2
*------------------Resistance--------------------------------------------
+ rsh=70 rdsw=375 prt=-3.287E+02
+ wr=0.7586 prwb=0 prwg=-4.441E-17
*------------------VAF---------------------------------------------------
+ lint=.12e-06 pclm=.19 pscbe1=3.79e+08 pscbe2=9.4e-05
+ delta=0.01655 pdiblc1=0.39 pdiblc2=0.0086 drout=0.56
*------------------Subthresshold-----------------------------------------
+ nfactor=1.8 cit=-5.0E-04 voff=-7.862E-02
+ eta0=4.441e-16 etab=-2.E-01 dsub=0.7
*------------------HotElectrons-----------------------------------------
+ alpha0=1.61e-05 alpha1=8.276E-05 beta0=36.68
*------------------Capacitance-------------------------------------------
+ cjswg=2.73e-10 mjswg=0.2 pbswg=8.800e-01
+ cj=0.0002424 mj=0.3551 pb=0.5614
+ cjsw=2.73e-10 mjsw=0.3873 pbsw=0.8
+ cgso=9e-13 cgdo=9e-13 cgbo=7e-10
+ dlc=5e-08 dwc=1.5e-07 xpart=0
*------------------BulkDiode--------------------------------------------
+ js=5.858e-08 jsw=1.25E-10 xti=2.000e+00 nj=1.08
*------------------BulkChargeEffect--------------------------------------
+ a0=0.7 a1=1 a2=1 ags=0.05583
+ b0=6.305e-08 b1=6.579e-08 keta=-1.531E-02
*------------------Noise????-------------------------------------------------
+ af=1 kf=0 ef=1 em=4.1E+07
+ noia=1E+20 noib=50000 noic=-1.4E-12
*------------------dLdW?????------------------------------------------
+ wl=0 wln=1 wwl=0
+ ll=0 lln=1 lw=0 lwn=1
+ lwl=0 llc=2E-13 lwc=0 lwlc=0
+ wlc=0 wwc=0 wwlc=0
*------------------Bsim???------------------------------------
+ wk3=0 lk3=0 pk3=1.257
+ lk3b=0 wk3b=0 pk3b=0
+ pa0=0.0489 la0=-1.052 lags=0.01093
+ wags=0 pags=0.1573 lketa=0
+ wdwg=0 ldwb=0 wdwb=0
*------------------HspiceBSIM4??-------------------------------------------
+ hdif=2.7E-07 ldif=0 lu0=0 ldwg=0
+ uc1=-1.098E-11 acm=13 wu0=1
+ wua=3.641E-11 lua=9.782E-10 pua=-4.46E-10 lub=-7.249E-19
+ wub=1.056E-20 pub=8.812E-19 pu0=1
+ wuc=1.177E-11 luc=-2.164E-10 puc=1.231E-10
*------------------Flagged!!-------------------------------------------
* nqsmod lmlt=1.000e+00 wmlt=1.000e+00
* tlev=0.000e+00 tlevc=0.000e+00
*------------------------------------------------------------------------
.end
===================RMS_Tests=================================
RMS_Tests
*===============Create_Sine_Square_And_Two_Noise_Signals===========================
* The goal is to sanity check whether everything concerning noise is done right
* A VT is a ramp voltage to represent time. Vtime rises 1 volt over 1 second.
* A sine wave is created using the time voltage and a equatiom
* The unity function can convert the sine wave to a square
* The noise signals Vn and Vn2 are called out having 1Vrm at a 0.5msec sample rate
*=====================================================================
VT Vtime 0 PWL(0 0 1 1 )
Bsin Vsin 0 V =sin(6.283185307179586232*2*v(Vtime) )
Bsq Vsq 0 V =2*u(V(Vsin)) -1
Vn Vn 0 TRNOISE( 1 .5m 0 0) $ 1Vrms, 0.5m period, 1/fslope=0, 1/fmag=0
Vn2 Vn2 0 TRNOISE( 1 .5m 0 0) $ 1Vrms, 0.5m period, 1/fslope=0, 1/fmag=0
.control
*================Simulate_at_5X_Noise_Sample_Rate======================================
* The transient simulation can be run at 0.1msec which is five times faster than the noise
* Ploting the sinewave and square wave show they are both a +/- 1volt peak
*=====================================================================
tran .1m 1
plot Vsin Vsq
*======================1Vrms_Noise_Should Eyeball_At_6Vppk=====================
* A 1Vrms noise should proceed about a 6vppk signal (6 sigma)
*=====================================================================
plot Vsq Vn
*=================Can_add_Signals_After_The_Simulation================================
* The two noise signals can be added as such
*=====================================================================
let Vn3 = Vn + Vn2
*=================Noise_Sample_Rate_5X_lower_than_Transient_==================
* The noise voltage Vn and Vn2 are all sampled at 500usecwhile run at 100usec
*=====================================================================
plot Vn Vn2 Vn3 xlimit 0 10m ylimit -3 3
*=============Test_Noise_Using_Array_Math==================================
* All voltages are stored as arrays over time
* Math can be applied to measure the rms
*=====================================================================
echo "=========Using_Array_Math==============================="
let RmsValsin = sqrt(mean(vsin*vsin))
let RmsValsq = sqrt(mean(vsq*vsq))
let RmsValn = sqrt(mean(vn*vn))
let RmsValn2 = sqrt(mean(vn2*vn2))
let RmsValn3 = sqrt(mean(vn3*vn3))
let Nerr1 = (1-1/RmsValn)*100
let Nerr2 = (1-1/RmsValn2)*100
let Nerr3 = (1-1.414/RmsValn3)*100
echo "RMS level sin $&RmsValsin expect 0.707"
echo "RMS level sq $&RmsValsq expect 1.000"
echo "RMS level nois $&RmsValn expect 1.000 error%= $&Nerr1"
echo "RMS level nois2 $&RmsValn2 expect 1.000 error%= $&Nerr2"
echo "RMS level nois3 $&RmsValn3 expect 1.404 error%= $&Nerr3"
*=========using_array_math===============================
*rms level sin0.706997 expect 0.707
*rms level sq 0.999969 expect 1.000
*rms level nois0.850095 expect 1.000 error%= -17.6339
*rms level nois20.852311 expect 1.000 error%= -17.328
*rms level nois31.20208 expect 1.404 error%= -17.6294
*==============Test_Noise_Using_Measure_Feature====================
* Ngspice has a further measure function which may have more errors
*=====================================================================
echo "=========Using_Measure==============================="
meas tran vsin_rms RMS vsin from=0m to=1
meas tran vsq_rms RMS vsq from=0m to=1
meas tran vn_rms RMS vn from=0m to=1
meas tran vn2_rms RMS vn2 from=0m to=1
meas tran vn3_rms RMS vn3 from=0m to=1
*=========using_measure===============================
*vsin_rms = 7.07107e-01 from= 0.00000e+00 to= 1.00000e+00
*vsq_rms = 1.00000e+00 from= 0.00000e+00 to= 1.00000e+00
*vn_rms = 7.94459e-01 from= 0.00000e+00 to= 1.00000e+00
*vn2_rms = 7.99658e-01 from= 0.00000e+00 to= 1.00000e+00
*vn3_rms = 1.12647e+00 from= 0.00000e+00 to= 1.00000e+00
*=============Extract_Noise_Spectrum========================================
* When doing a FFT the total sample time is 1sec
* This sets the FFT resolution at 1Hz
* This transient is being run at 100sec
* That a transient sample nyquist 5KHz (100usec)
* Which is five times higher that the noise nyquist of 1kHz(500usec sample rate)
*=====================================================================
echo "=========Sanity_Check the spectrum==============================="
let FFT_BandWidth_Hz = 5k
let FFT_resolution_Hz= 1
echo "FFT_BandWidth_Hz= $&FFT_BandWidth_Hz"
echo "FFT_resolution_Hz= $&FFT_resolution_Hz"
set specwindow= "rectangular"
spec $&FFT_resolution_Hz$&FFT_BandWidth_Hz$&FFT_resolution_Hzv(vn)
*=========sanity_check the spectrum===============================
*fft_bandwidth_hz= 5000
*fft_resolution_hz= 1
*==============Estimate_Noise_Spectrum=======================================================
* The expected noise level should be a 1/ sqrt(1000) (1Vrms spread out over 1000 points)
* The expected noise bandwidth should be its nysquist at 1KHz (500usec sample rate)
* The noise FFT and its expected value can be ploted
* Notice that frequency is an array
*=====================================================================
let Vexpect = 1/ (sqrt(1000)*(1+sqrt(frequency/1000)*sqrt(frequency/1000)*sqrt(frequency/1000)))
plot Vexpect mag(vn) loglog
.endc
.end
* ngspice
* source /Users/don_sauer/Downloads/stabie/SI_Lib/Tests4.cir
=========================
Monte Carlo methods (or Monte Carlo experiments) are a broad class of computational algorithms that rely on repeated random sampling to obtain numerical results; typically one runs simulations many times over in order to obtain the distribution of an unknown probabilistic entity.
==============SANITY_CHECK_WITH_EYEBALLING========================================
SIMULATE_AND_EYEBALL_DISTRIBUTIONs
* Design distribution for things like Input offset, input bias current, supply current, etc..
* can be found by knowing all the process distributions like match, beta, resistance.., etc
* And then finding the sensitivity each process parameter has on a given design.
* It should be possible to eyeball the sensitivites one at a time.
* Process distributions times sensitivity finds a list of standard deviation.
* Multible standard deviations sum together like noise voltage.
*
* ^
* /_\
* __________________________________________________|VCC
* | qp2 qp1 | | | |
* -> <- qp3 -> qp4 -> |
* `|____|'__________ `|_______________ `| |
* _ '| | |`_ vp1b _ '| _ '| |
* | | | | | |
* |vn2b |____| | | |
* |_____ | | BANDGAP | |
* | | | | | |
* |_ | _| | 60mV/6k = 10u | |
* qn2 `|__|__|'qn1 | | |
* VCC <-'| |`-> | | |
* | | 10X | | VAF=100V |
* ^ |_____/\r1__| | 26m/10u = 26k | Rout=10Meg |
* /_\ _|_ 6K \/ vn1e | | OpenLoop |
* | \ / | 26K&3p =2Meg | 100/26mV |
* _|_ V VEE | | 72dB |
* /VCC\ _____| | |
* \___/ ___ 33n | 5u/150 | |
* |______|INP|_________/|\_______________ | |
* | | |___| ____|__________ | | vp4c |
* | _|_ | vp3c | | |_______ |
* | /// ___ <- -> | | _| | _|
* | |INN|_|'qp5 qp6`|_| |_|'qn8 |_|'qn9 10X
* | |___| |`_ _ '| 3p |`-> |`-> ___
* _|_ | |vp5c |_______||__ |vqp7e |_____|OUT|
* /VEE\ | | ^ vp6c | ||c1| <- | |___|
* \___/ | | /_\VCC | VCC ^ |_|'qp7 <- |
* _|_ | | _| | /_\ | |`_ _|'qp8 |
* \ / | |__|'qn4 | _| |____|_| |`_ 10X |
* V | | |`-> |__|'qn6 | vn7c | |
* VEE | |_ | vn4e _| |`-> _| | |
* | qn3 `|__|_______|'qn5 |__|'qn7 | |
* | <-'| | |`-> | |`-> | |
* | | |/\r4___ | | |___________| |
* | | 60K \/ _|_ | |/\r5_| 150*1Meg |
* | | VEE \ / | 60K \/ | __/\R6__|
* | vn3e| V | _|_ _|_ \/ |
* | |__/\r2____/\r3__| vn5e \ / /VL \ 10K |
* | 20K \/ |20K \/ V VEE \___/ |
* | _|_ _|_ |
* | \ /VEE /// |
* | V OP AMP |
* |______________________________________________________|
*
*==============================NETLIST=============================================
.OPTIONS GMIN=1e-15 METHOD=gear ABSTOL=1e-15 TEMP=27 srcsteps = 1 gminsteps = 1
*======== ====== ====== ====== ====== ====== ======
*V_DC_NUM NODE_P NODE_N DC VALUE
*======== ====== ====== ====== ====== ====== ======
VCC VCC 0 DC 5
VEE 0 VEE DC 5
BVT vt 0 V= (V(vn1e)-V(VEE))*1k
BVOFF voff 0 V= V(OUT)*1MEG
*======== ====== ====== ====== ====== ====== ====== ====== ======
*Q_NUMB NCOL NBASE NEMIT NSUB MODEL AREA
*======== ====== ====== ====== ====== ====== ====== ====== ======
qn1 vp1b vn2b vn1e npnv 10
qn2 vn2b vn2b VEE npnv 1
qp1 vp1b vp1b VCC pnpl 1
qp2 vn2b vp1b VCC pnpl 1
qp3 vp3c vp1b VCC pnpl 1
qp4 vp4c vp1b VCC pnpl 1
qp5 vp5c OUT vp3c pnpl 1
qp6 vp6c 0 vp3c pnpl 1
qn3 vp5c vn4e vn3e npnv 1
qn4 VCC vp5c vn4e npnv 1
qn5 vp6c vn4e vn5e npnv 1
qn6 VCC vp6c vn6e npnv 1
qn7 vn7c vn6e VEE npnv 1
qn8 vp4c vp4c vqp7e npnv 1
qn9 VCC vp4c OUT npnv 10
qp7 vn7c vn7c vqp7e pnpl 1
qp8 VEE vn7c OUT pnpl 10
*======== ====== ====== ====== ====== ====== ====== ====== ======
*R_NUMB NODE1 NODE2 RVALUE MODEL L=VAL W=VAL
*======== ====== ====== ====== ====== ====== ====== ====== ======
r1 vn1e VEE 6k
r2 vn3e VEE 20k
r3 vn5e VEE 20k
r4 vn4e VEE 60k
r5 vn6e VEE 60k
r6 OUT 0 10k
C1 vp6c vn7c 6p
.control
*================Eye_Ball_the_Bandgap=======================================
* The first thing to start up is the bias circuitry.
* The simplified bandgap at the upper left is a positive feedback loop
* that runs out of gain when vt goes to 60mV
*=========================================================================
op
echo "===========Eye_Ball_the_Bandgap=========================="
echo "Expect 60mV for a 10x to one ratio for qn1 to qn2"
echo "the bandgap voltage is measured at $&vt mV"
*================eye_ball_the_bandgap==========================
*expect 60mv for a 10x to one ratio for qn1 to qn2
*the bandgap voltage is measured at 60.8043 mv
*=================Eye_Ball_Supply_Current=============================
* The whole circuit is going to be biased off currents scaled to r1 current
* The 60mV across r1 is well defined and will track absolute temperature.
* Resistors vary about +/-20% and increase with temperature
* Depending on process, the TC of voltage and resistance tend to cancel out
* Just about all bias currents should be around 10uA and can be printed out
* Summing the total supply current should all make sense
* Expect supply current of vary with resistivity but not as much over temp
*=========================================================================
echo "==========Eye_Ball_Supply_Current==========================="
echo "With r1 at 6K, expect qp1,qp2,qp3,qp4 all to have about 10uA"
echo "It is possible to print out all transistor currrents"
print @qp1[ic]
print @qp2[ic]
print @qp3[ic]
print @qp4[ic]
print @qn9[ic]
print @qn4[ic]
print @qn6[ic]
let icc = -(vcc#branch)*1e6
echo "total supply current is therefore $&icc uA"
*==========eye_ball_supply_current===========================
*with r1 at 6k, expect qp1,qp2,qp3,qp4 all to have about 10ua
*it is possible to print out all transistor currrents
*@qp1[ic] = 9.811158e-06
*@qp2[ic] = 1.024062e-05
*@qp3[ic] = 9.992716e-06
*@qp4[ic] = 9.995452e-06
*@qn9[ic] = 9.522401e-05
*@qn4[ic] = 1.110209e-05
*@qn6[ic] = 9.768441e-06
*total supply current is therefore 156.394 ua
*=================NPN_Offset_On_Supply_Current=============================
* Assume at a +/-1mV offset deviation on qn2
* That should add about a +/-1.66% change in supply current
*=========================================================================
alter qn2 Area = 1.04
op
let icc = -(vcc#branch)*1e6
echo "total supply current at 1mV qn2 is now $&icc uA"
*total supply current at 1mv qn2 is now 154.086 ua
*=================PNP_Offset_On_Supply_Current=============================
* Assume at a +/-1mV offset deviation on qp2
* That should add about the same change in supply current
*=========================================================================
alter qp2 Area = 1.04
alter qn2 Area = 1.00
op
let icc = -(vcc#branch)*1e6
echo "total supply current at 1mV qn2 is now $&icc uA"
*total supply current at 1mv qp2 is now 159.084 ua
*=================PNP_Beta_On_Supply_Current=============================
* Assume pnp beta varies +/- 50%
* This not so easy to eyeball
*=========================================================================
alter qp2 Area = 1.00
altermod pnpl bf = 75
op
let icc = -(vcc#branch)*1e6
echo "total supply current at 50% PNP Beta is now $&icc uA"
*total supply current at 50% pnp beta is now 151.704 ua
*=================NPN_Beta_On_Supply_Current=============================
* Assume npn beta varies +/- 50%
* It used to be common for beta in production to vary three to on
*=========================================================================
altermod pnpl bf = 150
altermod npnv bf = 75
op
let icc = -(vcc#branch)*1e6
echo "total supply current at 50% NPN Beta is now $&icc uA"
*total supply current at 50% npn beta is now 148.781 ua
*=================Resistivity_On_Supply_Current=============================
* A process will typically have +/-20% change in resistivity
* That should cause about a +/-20% change in supply current
*=========================================================================
alter r1 Resistance = 7.2k
altermod npnv bf = 150
op
let icc = -(vcc#branch)*1e6
echo "total supply current at 7.2k is now $&icc uA"
*total supply current at 7.2k is now 133.356 ua
*================EyeBall_Tail_Current=========================================================
* The total emitter current to the input diff stage is called the tail current
* The current match between qp5 and qp6 should be very good at both being 5uA
* Expect the tail current to track resistivity.
*=========================================================================
alter r1 Resistance = 6k
op
echo "===========Eye_Ball_the_Tail_Current=========================="
echo "qp5 and qp6 should have about 5uA"
let vr2 = (vn3e - VEE)*1K
let ir2 = vr2/20
echo "the voltage and current in r2 is measured at $&vr2 mV and $&ir2 uA"
let vr3 = (vn5e - VEE)*1K
let ir3 = vr3/20
echo "the voltage and current in r3 is measured at $&vr3 mV and $&ir3 uA"
*================eye_ball_the_tail_current==========================
*qp5 and qp6 should have about 5ua
*the voltage and current in r2 is measured at 98.6148 mv and 4.93074 ua
*the voltage and current in r3 is measured at 98.6063 mv and 4.93031 ua
*================Eye_Ball_bias_Current=========================================================
* The input bias current should be 1/2 tail current divided by pnp beta BF=150
* Expect the input bias current to be a function of resistivity and pnp beta
*=========================================================================
echo "==========Eye_Ball_bias_Current==========================="
echo "It is possible to print out the input bias currrents"
print @qp5[ib]
print @qp6[ib]
*it is possible to print out the input bias currrents
*@qp5[ib] = 3.216196e-08
*@qp6[ib] = 3.209099e-08
*=================Beta_On_Input_Bias_Current=============================
* Say the process has a +/-50% variation in PNP beta
* A +/-20% change in supply current should have a +/-20% change in bias current
* A +/-50% change in beta should have a +/-50% change in bias current
*=========================================================================
altermod pnpl bf = 75
op
echo "==========Beta_On_Input_Bias_Current==========================="
echo "Would expect a 50% reduction in beta to have same effect on bias current"
print @qp5[ib]
print @qp6[ib]
*==========beta_on_input_bias_current===========================
*would expect a 50% reduction in beta to have same effect on bias current
*@qp5[ib] = 6.162000e-08
*@qp6[ib] = 6.148991e-08
*=================Eye_Ball_Input_Match_Qp6===========================================
* Adding 4% error to Qn6 should add 1mV offset
*=========================================================================
altermod pnpl bf = 150
alter qp6 Area = 1.04
op
let voffset = out*1meg
echo "==========Eye_Ball_Input_Match_Qp6==========================="
echo "Mismatch qp6 by 4% and the offset is measured at $&voffset uV"
*==========eye_ball_input_match_qn3===========================
*mismatch qn3 by 4% and the offset is measured at -272.751 uv
*=================Eye_Ball_Input_Match_Qn3===========================================
* Adding 4% error to Qn3 should add less than 1mVoffset
* It is common to add degeneration resistors r2 and r3
*=========================================================================
alter qp6 Area = 1.00
alter qn3 Area = 1.04
op
let voffset = out*1meg
echo "==========Eye_Ball_Input_Match_Qn3==========================="
echo "Mismatch qn3 by 4% and the offset is measured at $&voffset uV"
echo "The degeneration of r2 and r3 reduces the 4% mismatch in qn3 by 4 "
*==========eye_ball_input_match_qn3===========================
*mismatch qn3 by 4% and the offset is measured at -272.751 uv
*the degeneration of r2 and r3 reduces the 4% mismatch in qn3 by 4
*=================Eye_Ball_Effects_Of_Removing_Degeneration============================
* Without degeneration Adding 4% error to Qn3 should add 1mV offset
*=========================================================================
alter r2 Resistance = 1m
alter r3 Resistance = 1m
op
echo "==========Eye_Ball_Effects_of_R2_and_R3======================="
let voffset = out*1meg
echo "Without R2 and R3 degeneration, the offset is $&voffset uV"
*==========eye_ball_effects_of_r2_and_r3=======================
*without r2 and r3 degeneration, the offset is -999.341 uv
*=================Full_Sensitivity_Simulation============================
* Spice can run full sensitivity simulations to all processing distributions
* in an automatic fashion like running corner lots.
* For instance a design can be run over corners of +/- 50% beta and +/-20% resistivity.
* The resulting data can be arranged as a table such as is shown below.
* Eyeballing everything in a design is recommented to sanity check the simulations.
* Computers are not very good at recognizing when things don't make sence.
* Resist+/-20% BetaNPN+/-50% BetaPNP+/-50% MatchNPN+/-1mV MatchPNP+/-1mV
*Supply_Current +/-17% +/-5% +/-3% +/-1.5% +/-1.7%
*Input_bias_current +/-17% +/-5% +/-50% +/-1.5% +/-1.7%
*Input_Offset_Qp5Qp6 .. .. .. .. +/-1mV
*Input_Offset_Qn3Qn5 .. .. .. +/-0.25mV ..
*Input_Offset_Qp1Qp3 .. .. .. .. ..
* Notice the table is varying everything by processing distribution in terms of onestandard deviation.
* This means the table is showing the distibution of the design to each processing distribution.
* The total distribution can be found by RMS summing the effects of all processing variations
* By RMS summing the supply current items in the table, a +/- 18% standard deviation is how much
* supply current should vary in production.
.endc
*=======================MODELS=========================================================
.model RMODEL R (RSH=1000 TC1= 0.00138 TC2=0.0000000078 )
.model npnv npn (
+IS=1E-15 NF=1.0 BF=150 VAF=200 IKF=6e-03
+CJE=1.7E-13 CJC=1.8E-13 CJS=2.9E-12 TF=1.6E-9
+XTB=2 EG=1.11 XTI=10 TNOM=25
.model pnpl pnp (
+IS=7.91E-17 NF=1.01 BF=150 VAF=200 IKF=0.002
+CJE=1.7E-13 CJC=1.8E-13 CJS=2.9E-12 TF=1.6E-9
+XTB=2 EG=1.11 XTI=7 TNOM=25 )
.end
* ngspice
* source /Users/don_sauer/Downloads/stabie/SI_Lib/Tests5.cir
==============AUTOMATED_TESTING===============================================
Auto_Corner_Checker
*=====================================================================
* www.idea2ic.com all dsauersanjose@aol.com 1-7-15-16-18-25
* The following simulation shows how to automatically test a circuit design
* over temperatures, supply voltages, beta levels and resistivity levels.
* For each condition the design is tested for input voltage offset,
* input bias current offset, Input bias current, supply current,
* common mode rejection ratio, power supply rejection ratio, open loop gain,
* output current, gain_bandwidth, and phase margin.
* The all test conditions and results are printed to "OpAmpCorners.txt"
* Test results are compared to specifications such that a failure is
* flagged in the output file
*=====================================================================
*
* ^
* /_\
* _____________________| ____/\RL___
* | | _|_ _|_ 10K\/ |
* -> <- /VCC\ /VL \ |
* q13`|____|'q12 \___/ \___/ |
* _ '| | |`_ | | |
* | | | | R1 60u/1u @ 1k/sq _|_ |
* |vbq15 |____| _|_ R2 60u/1u @ 1k/sq /// |
* |_____ |vbq12 /// R3 60u/1u @ 1k/sq |
* | | |________ R4 6u/1u @ 1k/sq |
* |_ | _| | |
* q15 `|__|__|'q16 |______________________ |
* <-'| |`-> 10X | | ^ |
* | | | | /_\ |
* |_____/\r4__| ___/|\____________________/|\_____|VCC |
* | 6K \/ | | | | | |
* |_ veq16 -> | -> | | |
* /// q0`|_| q11`|_| | |
* _ '| _ '| | |
* ___ | | | |
* _____________|INP|_________/|\_______________ | | |
* | |___| ____|__________ | | vbq9 | |
* | | vcq0 | | |_______ | |
* | ___ <- -> | | _| | _| |
* | ____ |INN|_|'q1 q2`|_| |_|'q7 |_|'q9 10X |
* | _|_ | |___| |`_ _ '| |`-> |`-> _|_
* | /VAC\ | | | |_______||__ |veq7 |_____|OUT|
* | \___/ | | | | ||c1| <- | |___|
* | _|_ | | | | ^ |_|'q8 <- |
* | /VIN\ | | |vcq1 vcq2 | /_\ | |`_ _|'q10 |
* | \___/ | | |_____ | _| |____|_| |`_ 10X |
* |___| | | | | |__|'q5 | | |
* _|_ | | |_ | _| |`-> _| vbq10 | |
* /VCM\ | | q3 `|__|_______|'q4 |__|'q6 | |
* \___/ | | <-'| |`-> vbq6| |`-> | |
* | | | | | | |___________| |
* | | | |__/\r1____/\r2__| |/\r3_| |
* _|_ | | 60K \/ |60K \/ 60K \/ | |
* /// | | veq3 |_ veq4 _|_ |
* | | /// /// |
* | | |
* |_/\r5_|_____________/\r6_____________________________________|
* 10K\/ 10K \/
*
*==============================NETLIST=============================================
.OPTIONS GMIN=1n METHOD=gear ABSTOL=1n TEMP=27 srcsteps = 1 gminsteps = 1
*======== ====== ====== ====== ====== ====== ======
*V_DC_NUM NODE_P NODE_N DC VALUE
*======== ====== ====== ====== ====== ====== ======
VCC VCC 0 DC 5
VCM INP 0 DC 1.5
VIN VIN INP DC 1u
VAC VAC VIN AC 1m DC 0
VL VL 0 DC 1
*======== ====== ====== ====== ====== ====== ====== ====== ======
*Q_NUMB NCOL NBASE NEMIT NSUB MODEL AREA
*======== ====== ====== ====== ====== ====== ====== ====== ======
q13 vbq15 vbq12 Vcc pnpl 1
q12 vbq12 vbq12 Vcc pnpl 1
q15 vbq15 vbq15 0 npnv 1
q16 vbq12 vbq15 veq16 npnv 10
q0 vcq0 vbq12 Vcc pnpl 1
q11 vbq9 vbq12 Vcc pnpl 3
q1 vcq1 INN vcq0 pnpl 1
q2 vcq2 INP vcq0 pnpl 1
q3 vcq1 vcq1 veq3 npnv 1
q4 vcq2 vcq1 veq4 npnv 1
q5 Vcc vcq2 vbq6 npnv 1
q6 vbq10 vbq6 0 npnv 3
q7 vbq9 vbq9 veq7 npnv 1
q9 Vcc vbq9 OUT npnv 10
q8 vbq10 vbq10 veq7 pnpl 1
q10 0 vbq10 OUT pnpl 10
*======== ====== ====== ====== ====== ====== ====== ====== ======
*R_NUMB NODE1 NODE2 RVALUE MODEL L=VAL W=VAL
*======== ====== ====== ====== ====== ====== ====== ====== ======
r1 veq3 0 RMODEL L=60u W=1u
r2 veq4 0 RMODEL L=60u W=1u
r3 vbq6 0 RMODEL L=60u W=1u
r4 veq16 0 RMODEL L=6u W=1u
c1 vcq1 vbq10 5p
r5 VAC INN 10k
r6 OUT INN 10k
rl OUT VL 10k
*=======================SIMULATION=====================================================
* 2 SupplyVoltages X 3 Temperatures X 4 beta X 2 ResOhmperSq = 48 test set ups
* The output results will be printed to a text file called OpAmpCorners.txt
* The user needs to provide the correct full path to this file
*======================================================================================
.control
op
set outfile= "/Users/don_sauer/Downloads/stabie/SI_Lib/OpAmpCorners.txt"
echo "OpAmpCorners.txt" > $outfile
*=======================PROCESSING_LOOP==================================================
* The first loop simulates running corners in processing.
* For Bipolar this meant over limits of beta and sheet rho
* This example only shows how to do four combinations
* The following is the spice format for changing/viewing process parameters
*==============================================================================================
foreach processval 1 2 3 4
echo " " >> $outfile
echo " " >> $outfile
echo "=============================SET_PROCESSING=====================================" >> $outfile
if ( $processval = 2 )
altermod @rmodel[rsh] = 1200
end ***<-- if $processval
if ( $processval = 3 )
altermod @rmodel[rsh] = 1000
altermod @pnpl[bf] = 70
end ***<-- if $processval
if ( $processval = 4 )
altermod @pnpl[bf] = 150
altermod @npnv[bf] = 70
end ***<-- if $processval
let npnbf = @npnv[bf]
let npnvaf = @npnv[vaf]
let pnpbf = @pnpl[bf]
let pnpvaf = @pnpl[vaf]
let resq = @rmodel[rsh]
echo "npnbf=$&npnbf npnvaf=$&npnvaf pnpbf=$&pnpbf pnpvaf=$&pnpvaf Ressq=$&resq" >> $outfile
*=======================TEMPERATURE_LOOP================================================
* Within each processing setting, three temperatures will be run
* The following is the spice format for changing temperature parameters
*==============================================================================================
foreach tempval -45 27 127
set temp = $tempval
set tnom = $tempval
*=======================SUPPLY_LOOP=======================================================
* Within each temperature setting, two different supply voltages will be run
* The following is the spice format for setting up the DC tests
* Notice that only two points are being run of vcm and vcc
* All nodes are stored as arrays using vcm as v-sweep
* Note the index arranges the data of the array
* print inn vcc
* Index v-sweep inn vcc
* --------------------------------------------------------------------------------
* 0 1.500000e+001.500071e+001.000000e+01
* 1 1.501000e+001.501071e+001.000000e+01
* 2 1.500000e+001.500071e+001.000100e+01
* 3 1.501000e+001.501071e+001.000100e+01
*==============================================================================================
foreach vsval 1 2
*
if ( $vsval = 1 )
*DC SOURC1 VSTART VSTOP VSTEP SOURC2 START2 STOP2 STEP2
*======== ====== ====== ====== ====== ====== ====== ====== ======
dc vcm 1.5 1.501 .001 vcc 5 5.001 .001
end ***<-- if $vsval
if ( $vsval = 2 )
dc vcm 1.500 1.501 .001 vcc 10.000 10.001 .001
end ***<-- if $vsval
*=======================USE_DC_SIMULATION_ARRAY========================================
* From the arrays and it's indexes, it is possible to calculate the most DC specs.
* All test conditions are printed out with the test results.
*==============================================================================================
let TT = @q1[temp]
let Vs = VCC[0]
let Vcmm = INP[0]
let Vout = OUT[0]
let Is = -vcc#branch[0]
let Iin = (@q1[ib] + @q2[ib])/2
let Ioff = abs(@q2[ib]-@q1[ib])
let vos = INP[0]-INN[0]
let avos = abs(INP[0]-INN[0])
let Cmrr = -db(abs(INP[0]-INN[0]-INP[1]+INN[1]))-60
let Psrr = -db(abs(INP[0]-INN[0]-INP[2]+INN[2]))-60
let Iout = (OUT[0]-VL[0])/10000
echo "=============================SUPPLY = $&Vs V TEMP = $&TT C==========================" >> $outfile
echo "Temp_C= $&TT Vcc=$&Vs Vcm=$&Vcmm Vout=$&Vout Iout=$&Iout Is=$&Is" >> $outfile
echo "vos = $&vos Iin =$&Iin Ioff=$&Ioff Cmrr_dB=$&Cmrr Psrr_dB=$&Psrr " >> $outfile
*=======================TEST_TO_SPEC_LIMITS================================================
* The DC specs can be compared to spec limits and printed out if a failure
* The specs should fail Iin at some conditons
* A flag can be printed in the output file for each failure
*==============================================================================================
if ( avos >1m or Iin >35n or Ioff > 1u or cmrr < 90 or psrr < 90 )
echo "spec failure #########################################################" >> $outfile
end ***<-- if avos >1m etc....
*=======================TEST_OUTPUT_CURRENT==================================================================
* Now output gain and current limit are measure.
* Should fail Ioutn unders some conditions
* A flag can be printed in the output file for each failure
*==============================================================================================
*DC SOURC1 VSTART VSTOP VSTEP SOURC2 START2 STOP2 STEP2
*======== ====== ====== ====== ====== ====== ====== ====== ======
dc vin 1u 1001u .001 vl -29 31 30
let Avol = -db(abs(INP[2]-INN[2]-INP[3]+INN[3]))-60
let Ioutn = (OUT[0]-VL[0])/10000
let Ioutp = (OUT[4]-VL[4])/10000
echo "Avol_dB=$&Avol Ioutn = $&Ioutn Ioutp = $&Ioutp" >> $outfile
if ( Avol < 80 or Ioutn < 2.7m or Ioutp > -2.7m )
echo "spec failure #########################################################" >> $outfile
end ***<-- if Avol < 80u etc....
*=======================TEST_AC_GAIN====================================================
* Now AC gain is measure.
*=========================================================================================
*AC DECADE NUMDEC FSTART FSTOP
*======== ====== ====== ====== ====== ====== ====== ====== ======
ac dec 2 .1Meg 10Meg
let GBW = mag(out[0]/inn[0])/10
let Pmarg = phase(inn[2]) -phase(out[2])
echo "GBW_MHz = $&GBW Pmarg_deg = $&Pmarg " >> $outfile
*=====================OPAMPCORNERS.TXT_EXAMPLE_PRINTOUT================================
*=====================set_processing===================================
*npnbf=150 npnvaf=150 pnpbf=150 pnpvaf=150 ressq=1000
*=====================supply= 5 v temp= -45 c==========================
*temp_c= -45 vcc=5 vcm=1.5 vout=1.49981 iout=4.99812E-05 is=0.000286117
*vos = -1.91086E-05 iin =2.56224E-08 ioff=2.65053E-10 cmrr_db=121.933 psrr_db=99.1558
*avol_db=116.366 ioutn = 0.00304997 ioutp = -0.00295002
*gbw_mhz = 5.89234 pmarg_deg = 0.428523
*=====================supply= 10 v temp= 27 c==========================
*temp_c= 27 vcc=10 vcm=1.5 vout=1.49966 i out=4.99664E-05 is=0.000393734
*vos = 4.18336E-06 iin =3.58328E-08 ioff=3.01005E-10 cmrr_db=120.056 psrr_db=98.7389
*spec failure #########################################################
*avol_db=115.392 ioutn = 0.00304997 ioutp = -0.00295002
*gbw_mhz = 5.855 pmarg_deg = 0.42852
end **** <--foreach vsval
end **** <--foreach tempval
end **** <--foreach processval
echo "done"
.endc
*=====================MODELS=========================================================
.model RMODEL R (RSH=1000 TC1= 0.00138 TC2=0.0000000078 )
.model npnv npn (
+IS=1E-15 NF=1.0 BF=150 VAF=150 IKF=8e-03
+CJE=1.7E-13 CJC=1.8E-13 CJS=2.9E-12 TF=1.6E-9
+XTB=2 EG=1.11 XTI=10
.model pnpl pnp (
+IS=7.91E-17 NF=1.01 BF=150 VAF=150 IKF=0.003
+CJE=1.7E-13 CJC=1.8E-13 CJS=2.9E-12 TF=1.6E-9
+XTB=2 EG=1.11 XTI=7 )
.end
* ngspice
* source /Users/don_sauer/Downloads/stabie/SI_Lib/Tests3.cir
*===============OPAMPCORNERS.TXT_PRINTOUT================================
The printout below should be in the file called OPAMPCORNERS.TXT.
Spice has certain formats in how it stores data, access data, run loops,
does conditional testing, and prints results to a file. This simulation
show a working example of how all that gets done.
opampcorners.txt
=============================set_processing=====================================
npnbf=150 npnvaf=150 pnpbf=150 pnpvaf=150 ressq=1000
=============================supply = 5 v temp = -45 c==========================
temp_c= -45 vcc=5 vcm=1.5 vout=1.49981 iout=4.99812E-05 is=0.000286117
vos = -1.91086E-05 iin =2.56224E-08 ioff=2.65053E-10 cmrr_db=121.933 psrr_db=99.1558
avol_db=116.366 ioutn = 0.00304997 ioutp = -0.00295002
gbw_mhz = 5.89234 pmarg_deg = 0.428523
=============================supply = 10 v temp = -45 c==========================
temp_c= -45 vcc=10 vcm=1.5 vout=1.49969 iout=4.99691E-05 is=0.000307737
vos = 3.24429E-05 iin =2.73783E-08 ioff=1.82482E-10 cmrr_db=125.031 psrr_db=100.316
avol_db=116.366 ioutn = 0.00304997 ioutp = -0.00295002
gbw_mhz = 5.89234 pmarg_deg = 0.428523
=============================supply = 5 v temp = 27 c==========================
temp_c= 27 vcc=5 vcm=1.5 vout=1.49981 iout=4.9981E-05 is=0.000366111
vos = -5.74532E-05 iin =3.35973E-08 ioff=3.97586E-10 cmrr_db=117.787 psrr_db=97.6284
avol_db=115.392 ioutn = 0.00304997 ioutp = -0.00295002
gbw_mhz = 5.855 pmarg_deg = 0.42852
=============================supply = 10 v temp = 27 c==========================
temp_c= 27 vcc=10 vcm=1.5 vout=1.49966 iout=4.99664E-05 is=0.000393734
vos = 4.18336E-06 iin =3.58328E-08 ioff=3.01005E-10 cmrr_db=120.056 psrr_db=98.7389
spec failure #########################################################
avol_db=115.392 ioutn = 0.00304997 ioutp = -0.00295002
gbw_mhz = 5.855 pmarg_deg = 0.42852
=============================supply = 5 v temp = 127 c==========================
temp_c= 127 vcc=5 vcm=1.5 vout=1.49984 iout=4.99842E-05 is=0.00047619
vos = -0.000128353 iin =4.46307E-08 ioff=6.06243E-10 cmrr_db=114.099 psrr_db=95.7598
spec failure #########################################################
avol_db=114.067 ioutn = 0.00304998 ioutp = -0.00295001
gbw_mhz = 5.81042 pmarg_deg = 0.428867
=============================supply = 10 v temp = 127 c==========================
temp_c= 127 vcc=10 vcm=1.5 vout=1.49966 iout=4.9966E-05 is=0.00051208
vos = -5.17092E-05 iin =4.75349E-08 ioff=4.90226E-10 cmrr_db=115.893 psrr_db=96.8206
spec failure #########################################################
avol_db=114.067 ioutn = 0.00304998 ioutp = -0.00295001
gbw_mhz = 5.81042 pmarg_deg = 0.428867
=============================set_processing=====================================
npnbf=150 npnvaf=150 pnpbf=150 pnpvaf=150 ressq=1200
=============================supply = 5 v temp = -45 c==========================
temp_c= -45 vcc=5 vcm=1.5 vout=1.49984 iout=4.99838E-05 is=0.000243103
vos = -1.19606E-05 iin =2.15779E-08 ioff=2.49678E-10 cmrr_db=122.507 psrr_db=98.3412
avol_db=114.515 ioutn = 0.00289163 ioutp = -0.00295001
gbw_mhz = 4.91731 pmarg_deg = 0.350936
=============================supply = 10 v temp = -45 c==========================
temp_c= -45 vcc=10 vcm=1.5 vout=1.49971 iout=4.9971E-05 is=0.000261506
vos = 4.45632E-05 iin =2.30833E-08 ioff=1.71522E-10 cmrr_db=128.129 psrr_db=99.5322
avol_db=114.515 ioutn = 0.00289163 ioutp = -0.00295001
gbw_mhz = 4.91731 pmarg_deg = 0.350936
=============================supply = 5 v temp = 27 c==========================
temp_c= 27 vcc=5 vcm=1.5 vout=1.49985 iout=4.99847E-05 is=0.000309621
vos = -4.96562E-05 iin =2.82845E-08 ioff=3.72648E-10 cmrr_db=118.539 psrr_db=96.9298
avol_db=113.887 ioutn = 0.00304998 ioutp = -0.00295001
gbw_mhz = 4.88404 pmarg_deg = 0.35109
=============================supply = 10 v temp = 27 c==========================
temp_c= 27 vcc=10 vcm=1.5 vout=1.49969 iout=4.99694E-05 is=0.000333037
vos = 1.7056E-05 iin =3.01898E-08 ioff=2.82054E-10 cmrr_db=120.355 psrr_db=98.0631
avol_db=113.887 ioutn = 0.00304998 ioutp = -0.00295001
gbw_mhz = 4.88404 pmarg_deg = 0.35109
=============================supply = 5 v temp = 127 c==========================
temp_c= 127 vcc=5 vcm=1.5 vout=1.4999 iout=4.99895E-05 is=0.000401228
vos = -0.000119467 iin =3.75633E-08 ioff=5.64293E-10 cmrr_db=114.742 psrr_db=95.1841
spec failure #########################################################
avol_db=112.804 ioutn = 0.00304998 ioutp = -0.00295001
gbw_mhz = 4.84501 pmarg_deg = 0.352157
=============================supply = 10 v temp = 127 c==========================
temp_c= 127 vcc=10 vcm=1.5 vout=1.49971 iout=4.99706E-05 is=0.000431542
vos = -3.76543E-05 iin =4.00256E-08 ioff=4.5644E-10 cmrr_db=116.371 psrr_db=96.2627
spec failure #########################################################
avol_db=112.804 ioutn = 0.00304998 ioutp = -0.00295001
gbw_mhz = 4.84501 pmarg_deg = 0.352157
=============================set_processing=====================================
npnbf=150 npnvaf=150 pnpbf=70 pnpvaf=150 ressq=1000
=============================supply = 5 v temp = -45 c==========================
temp_c= -45 vcc=5 vcm=1.5 vout=1.49961 iout=4.99611E-05 is=0.000271259
vos = -3.97727E-05 iin =4.99487E-08 ioff=3.55247E-10 cmrr_db=125.035 psrr_db=98.5681
spec failure #########################################################
avol_db=112.367 ioutn = 0.00304995 ioutp = -0.00295003
gbw_mhz = 5.49691 pmarg_deg = 0.42387
=============================supply = 10 v temp = -45 c==========================
temp_c= -45 vcc=10 vcm=1.5 vout=1.49946 iout=4.99464E-05 is=0.000291781
vos = 1.53278E-05 iin =5.34882E-08 ioff=2.01831E-10 cmrr_db=132.759 psrr_db=99.7476
spec failure #########################################################
avol_db=112.367 ioutn = 0.00304995 ioutp = -0.00295003
gbw_mhz = 5.49691 pmarg_deg = 0.42387
=============================supply = 5 v temp = 27 c==========================
temp_c= 27 vcc=5 vcm=1.5 vout=1.49955 iout=4.99551E-05 is=0.000346615
vos = -8.69491E-05 iin =6.54606E-08 ioff=5.60888E-10 cmrr_db=120.025 psrr_db=97.0542
spec failure #########################################################
avol_db=111.609 ioutn = 0.00304995 ioutp = -0.00295004
gbw_mhz = 5.46143 pmarg_deg = 0.423857
=============================supply = 10 v temp = 27 c==========================
temp_c= 27 vcc=10 vcm=1.5 vout=1.49937 iout=4.99374E-05 is=0.000372825
vos = -2.11744E-05 iin =6.99635E-08 ioff=3.84157E-10 cmrr_db=123.185 psrr_db=98.1846
spec failure #########################################################
avol_db=111.609 ioutn = 0.00304995 ioutp = -0.00295004
gbw_mhz = 5.46143 pmarg_deg = 0.423857
=============================supply = 5 v temp = 127 c==========================
temp_c= 127 vcc=5 vcm=1.5 vout=1.49951 iout=4.99507E-05 is=0.000450324
vos = -0.000171254 iin =8.69072E-08 ioff=8.9457E-10 cmrr_db=115.78 psrr_db=95.2059
spec failure #########################################################
avol_db=110.52 ioutn = 0.00304994 ioutp = -0.00295004
gbw_mhz = 5.41911 pmarg_deg = 0.424174
=============================supply = 10 v temp = 127 c==========================
temp_c= 127 vcc=10 vcm=1.5 vout=1.49928 iout=4.99284E-05 is=0.000484366
vos = -8.96642E-05 iin =9.27525E-08 ioff=6.85703E-10 cmrr_db=118.166 psrr_db=96.2887
spec failure #########################################################
avol_db=110.52 ioutn = 0.00304994 ioutp = -0.00295004
gbw_mhz = 5.41911 pmarg_deg = 0.424174
=============================set_processing=====================================
npnbf=70 npnvaf=150 pnpbf=150 pnpvaf=150 ressq=1000
=============================supply = 5 v temp = -45 c==========================
temp_c= -45 vcc=5 vcm=1.5 vout=1.49987 iout=4.99867E-05 is=0.000266144
vos = -4.44888E-05 iin =2.52837E-08 ioff=2.99096E-10 cmrr_db=126.452 psrr_db=95.2086
avol_db=104.455 ioutn = 0.00217808 ioutp = -0.00295
spec failure #########################################################
gbw_mhz = 5.862 pmarg_deg = 0.410199
=============================supply = 10 v temp = -45 c==========================
temp_c= -45 vcc=10 vcm=1.5 vout=1.49969 iout=4.99686E-05 is=0.000286581
vos = 3.65743E-05 iin =2.70352E-08 ioff=1.81356E-10 cmrr_db=129.899 psrr_db=96.4008
avol_db=104.455 ioutn = 0.00217808 ioutp = -0.00295
spec failure #########################################################
gbw_mhz = 5.862 pmarg_deg = 0.410199
=============================supply = 5 v temp = 27 c==========================
temp_c= 27 vcc=5 vcm=1.5 vout=1.4999 iout=4.999E-05 is=0.000340491
vos = -0.000100148 iin =3.31506E-08 ioff=4.52979E-10 cmrr_db=116.426 psrr_db=93.3611
avol_db=103.935 ioutn = 0.00246962 ioutp = -0.00295
spec failure #########################################################
gbw_mhz = 5.82506 pmarg_deg = 0.410112
=============================supply = 10 v temp = 27 c==========================
temp_c= 27 vcc=10 vcm=1.5 vout=1.49968 iout=4.99676E-05 is=0.000366597
vos = 3.56692E-07 iin =3.538E-08 ioff=3.10955E-10 cmrr_db=118.3 psrr_db=94.5132
spec failure #########################################################
avol_db=103.935 ioutn = 0.00246962 ioutp = -0.00295
spec failure #########################################################
gbw_mhz = 5.82506 pmarg_deg = 0.410112
=============================supply = 5 v temp = 127 c==========================
temp_c= 127 vcc=5 vcm=1.5 vout=1.49999 iout=4.99991E-05 is=0.000442809
vos = -0.000199449 iin =4.40332E-08 ioff=6.96038E-10 cmrr_db=110.577 psrr_db=91.2156
spec failure #########################################################
avol_db=103.166 ioutn = 0.00283162 ioutp = -0.00294999
gbw_mhz = 5.78136 pmarg_deg = 0.410213
=============================supply = 10 v temp = 127 c==========================
temp_c= 127 vcc=10 vcm=1.5 vout=1.4997 iout=4.99703E-05 is=0.000476721
vos = -7.05245E-05 iin =4.69288E-08 ioff=5.20167E-10 cmrr_db=112.086 psrr_db=92.332
spec failure #########################################################
avol_db=103.166 ioutn = 0.00283162 ioutp = -0.00294999
gbw_mhz = 5.78136 pmarg_deg = 0.410213
1-21-15-15-28-11
dsauersanjose@aol.com
Don Sauer http://www.idea2ic.com/