examples for .meas

This commit is contained in:
h_vogt 2009-08-30 11:02:48 +00:00
parent 1a9a809111
commit 82052e0700
5 changed files with 315 additions and 0 deletions

View File

@ -0,0 +1,15 @@
* func_cap.sp
.func icap_calc(A,B,C,D) '2*A*sqrt(B*C*D)'
.param cap_val = 'max(icap_calc(1,2,3,4))'
VDD 1 0 DC 1
C1 1 0 'cap_val'
.measure tran capacitance param='cap_val'
.measure tran capac2 param='max(icap_calc(1,2,3,4))'
.tran 1ps 100ps
.end

View File

@ -0,0 +1,103 @@
Inverter example circuit
* This netlist demonstrates the following:
* global nodes (vdd, gnd)
* autostop (.tran defines simulation end as 4ns but simulation stops at
* 142.5ps when .measure statements are evaluated)
* scale (all device units are in microns)
* model binning (look in device.values file for which bin chosen)
*
* m.x1.mn:
* model = nch.2
*
* m.x1.mp:
* model = pch.2
*
* parameters
* parameterized subckt
* vsrc with repeat
* .measure statements for delay and an example ternary operator
* device listing and parameter listing
* You can run the example circuit with this command:
*
* ngspice inverter3.sp
* global nodes
.global vdd gnd
* autostop -- stop simulation early if .measure statements done
* scale -- define scale factor for mosfet device parameters (l,w,area,perimeter)
.option autostop
.option scale = 1e-6
* model binning
.model nch.1 nmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
.model nch.2 nmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=10u wmax=100u )
.model pch.1 pmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
.model pch.2 pmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=10u wmax=100u )
* parameters
.param vp = 1.0v
.param lmin = 0.10
.param wmin = 0.12
.param plmin = 'lmin'
.param nlmin = 'lmin'
.param wpmin = 'wmin'
.param wnmin = 'wmin'
.param drise = 400ps
.param dfall = 100ps
.param trise = 100ps
.param tfall = 100ps
.param period = 1ns
.param skew_meas = 'vp/2'
* parameterized subckt
.subckt inv in out pw='wpmin' pl='plmin' nw='wnmin' nl='nlmin'
mp out in vdd vdd pch w='pw' l='pl'
mn out in gnd gnd nch w='nw' l='nl'
.ends
v0 vdd gnd 'vp'
* vsrc with repeat
v1 in gnd pwl
+ 0ns 'vp'
+ 'dfall-0.8*tfall' 'vp'
+ 'dfall-0.4*tfall' '0.9*vp'
+ 'dfall+0.4*tfall' '0.1*vp'
+ 'dfall+0.8*tfall' 0v
+ 'drise-0.8*trise' 0v
+ 'drise-0.4*trise' '0.1*vp'
+ 'drise+0.4*trise' '0.9*vp'
+ 'drise+0.8*trise' 'vp'
+ 'period+dfall-0.8*tfall' 'vp'
+ r='dfall-0.8*tfall'
x1 in out inv pw=60 nw=20
c1 out gnd 220fF
.tran 1ps 4ns
.meas tran inv_delay trig v(in) val='vp/2' fall=1 targ v(out) val='vp/2' rise=1
.meas tran inv_delay2 trig v(in) val='vp/2' td=1n fall=1 targ v(out) val='vp/2' rise=1
.meas tran test_data1 trig AT = 1n targ v(out) val='vp/2' rise=3
.meas tran out_slew trig v(out) val='0.2*vp' rise=2 targ v(out) val='0.8*vp' rise=2
.meas tran delay_chk param='(inv_delay < 100ps) ? 1 : 0'
.meas tran skew when v(out)=0.6
.meas tran skew2 when v(out)=skew_meas
.meas tran skew3 when v(out)=skew_meas fall=2
.meas tran skew4 when v(out)=skew_meas fall=LAST
.meas tran skew5 FIND v(out) AT=2n
*.measure tran v0_min min i(v0) from='dfall' to='dfall+period'
*.measure tran v0_avg avg i(v0) from='dfall' to='dfall+period'
*.measure tran v0_integ integ i(v0) from='dfall' to='dfall+period'
*.measure tran v0_rms rms i(v0) from='dfall' to='dfall+period'
.control
run
rusage all
plot v(in) v(out)
.endc
.end

View File

@ -0,0 +1,103 @@
Inverter example circuit
* This netlist demonstrates the following:
* global nodes (vdd, gnd)
* autostop (.tran defines simulation end as 4ns but simulation stops at
* 142.5ps when .measure statements are evaluated)
* scale (all device units are in microns)
* model binning (look in device.values file for which bin chosen)
*
* m.x1.mn:
* model = nch.2
*
* m.x1.mp:
* model = pch.2
*
* parameters
* parameterized subckt
* vsrc with repeat
* .measure statements for delay and an example ternary operator
* device listing and parameter listing
* You can run the example circuit with this command:
*
* ngspice inverter3.sp
* global nodes
.global vdd gnd
* autostop -- stop simulation early if .measure statements done
* scale -- define scale factor for mosfet device parameters (l,w,area,perimeter)
*.option autostop
.option scale = 1e-6
* model binning
.model nch.1 nmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
.model nch.2 nmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=10u wmax=100u )
.model pch.1 pmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
.model pch.2 pmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=10u wmax=100u )
* parameters
.param vp = 1.0v
.param lmin = 0.10
.param wmin = 0.12
.param plmin = 'lmin'
.param nlmin = 'lmin'
.param wpmin = 'wmin'
.param wnmin = 'wmin'
.param drise = 400ps
.param dfall = 100ps
.param trise = 100ps
.param tfall = 100ps
.param period = 1ns
.param skew_meas = 'vp/2'
* parameterized subckt
.subckt inv in out pw='wpmin' pl='plmin' nw='wnmin' nl='nlmin'
mp out in vdd vdd pch w='pw' l='pl'
mn out in gnd gnd nch w='nw' l='nl'
.ends
v0 vdd gnd 'vp'
* vsrc with repeat
v1 in gnd pwl
+ 0ns 'vp'
+ 'dfall-0.8*tfall' 'vp'
+ 'dfall-0.4*tfall' '0.9*vp'
+ 'dfall+0.4*tfall' '0.1*vp'
+ 'dfall+0.8*tfall' 0v
+ 'drise-0.8*trise' 0v
+ 'drise-0.4*trise' '0.1*vp'
+ 'drise+0.4*trise' '0.9*vp'
+ 'drise+0.8*trise' 'vp'
+ 'period+dfall-0.8*tfall' 'vp'
+ r='dfall-0.8*tfall'
x1 in out inv pw=60 nw=20
c1 out gnd 220fF
.tran 1ps 4ns
.meas tran inv_delay trig v(in) val='vp/2' fall=1 targ v(out) val='vp/2' rise=1
.meas tran inv_delay2 trig v(in) val='vp/2' td=1n fall=1 targ v(out) val='vp/2' rise=1
.meas tran test_data1 trig AT = 1n targ v(out) val='vp/2' rise=3
.meas tran out_slew trig v(out) val='0.2*vp' rise=2 targ v(out) val='0.8*vp' rise=2
.meas tran delay_chk param='(inv_delay < 100ps) ? 1 : 0'
.meas tran skew when v(out)=0.6
.meas tran skew2 when v(out)=skew_meas
.meas tran skew3 when v(out)=skew_meas fall=2
.meas tran skew4 when v(out)=skew_meas fall=LAST
.meas tran skew5 FIND v(out) AT=2n
.meas tran v0_min min i(v0) from='dfall' to='dfall+period'
.meas tran v0_avg avg i(v0) from='dfall' to='dfall+period'
.meas tran v0_integ integ i(v0) from='dfall' to='dfall+period'
.meas tran v0_rms rms i(v0) from='dfall' to='dfall+period'
.control
run
rusage all
plot v(in) v(out)
.endc
.end

View File

@ -0,0 +1,48 @@
***** Single NMOS Transistor .measure (Id-Vd) ***
m1 d g s b nch L=0.6u W=10.0u
vgs g 0 3.5
vds d 0 3.5
vs s 0 dc 0
vb b 0 dc 0
.dc vds 0 3.5 0.05 vgs 0.5 3.5 0.5
.print dc v(1) i(vs)
* model binning
.model nch.1 nmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
.model nch.2 nmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=10u wmax=100u )
.model pch.1 pmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
.model pch.2 pmos ( version=4.4 level=54 lmin=0.1u lmax=20u wmin=10u wmax=100u )
.meas dc is_at FIND i(vs) AT=1
.meas dc is_max max i(vs) from=0 to=3.5
.meas dc vds_at when i(vs)=0.01
* the following fails (probably does not recognize m or u):
.meas dc vds_at2 when i(vs)=10000u
.meas dc vd_diff1 trig i(vs) val=0.005 rise=1 targ i(vs) val=0.01 rise=1
.meas dc vd_diff2 trig i(vs) val=0.005 rise=1 targ i(vs) val=0.01 rise=2
*.meas ac fixed_diff trig AT = 10k targ v(out) val=0.1 rise=1
*.meas ac vout_avg avg v(out) from=10k to=1MEG
*.meas ac vout_integ integ v(out) from=20k to=500k
*.meas ac freq_at2 when v(out)=0.1 fall=LAST
*.meas ac bw_chk param='(vout_diff < 100k) ? 1 : 0'
*.meas ac bw_chk2 param='(vout_diff > 500k) ? 1 : 0'
*.meas ac vout_rms rms v(out) from=10 to=1G
.control
run
*rusage all
plot i(vs)
.endc
.end

View File

@ -0,0 +1,46 @@
RC band pass example circuit
* This netlist demonstrates the following:
* global nodes (vdd, gnd)
* .measure statements for delay and an example ternary operator
* You can run the example circuit with this command:
*
* ngspice rc-meas-ac.sp
* global nodes
.global vdd gnd
* autostop -- stop simulation early if .measure statements done
*.option autostop
vin in gnd dc 0 ac 1
R1 in mid1 1k
c1 mid1 gnd 1n
C2 mid1 out 500p
R2 out gnd 1k
.ac DEC 10 1k 10MEG
.meas ac vout_at FIND v(out) AT=1MEG
.meas ac vout_max max v(out) from=1k to=10MEG
.meas ac freq_at when v(out)=0.1
.meas ac vout_diff trig v(out) val=0.1 rise=1 targ v(out) val=0.1 fall=1
.meas ac fixed_diff trig AT = 10k targ v(out) val=0.1 rise=1
.meas ac vout_avg avg v(out) from=10k to=1MEG
.meas ac vout_integ integ v(out) from=20k to=500k
.meas ac freq_at2 when v(out)=0.1 fall=LAST
.meas ac bw_chk param='(vout_diff < 100k) ? 1 : 0'
.meas ac bw_chk2 param='(vout_diff > 500k) ? 1 : 0'
.meas ac vout_rms rms v(out) from=10 to=1G
.control
run
*rusage all
plot v(out)
.endc
.end