Update to examples

tran, fft added, pss made to converge (if possible).
vdp_osc removed as it does not oscillate
80 transistor 19 stage NAND gate RO, IHP PDK added (80 transistors)
as stress test.
This commit is contained in:
Holger Vogt 2025-12-15 17:02:10 +01:00
parent 1c23511554
commit cc1f6c57a1
7 changed files with 142 additions and 29 deletions

View File

@ -0,0 +1,68 @@
NAND-2 Ring Oscillator IHP Open PDK
.lib "$PDK_ROOT/$PDK/libs.tech/ngspice/models/cornerMOSlv.lib" mos_tt
.subckt nand2 a b vdd vss z
xm01 vdd a z vdd sg13_lv_pmos l=0.15u w=0.96u as=0.20405p ad=0.20405p ps=2.07u pd=2.07u
xm02 vss a sig3 vss sg13_lv_nmos l=0.15u w=0.82u as=0.1749p ad=0.1749p ps=1.85u pd=1.85u
xm03 z b vdd vdd sg13_lv_pmos l=0.15u w=0.96u as=0.20405p ad=0.20405p ps=2.07u pd=2.07u
xm04 sig3 b z vss sg13_lv_nmos l=0.15u w=0.82u as=0.1749p ad=0.1749p ps=1.85u pd=1.85u
c4 a vss 0.549f
c5 b vss 0.578f
c1 z vss 0.609f
.ends
XNAND1 1 1 vd vs 2 nand2
XNAND2 2 2 vd vs 3 nand2
XNAND3 3 3 vd vs 4 nand2
XNAND4 4 4 vd vs 5 nand2
XNAND5 5 5 vd vs 6 nand2
XNAND6 6 6 vd vs 7 nand2
XNAND7 7 7 vd vs 8 nand2
XNAND8 8 8 vd vs 9 nand2
XNAND9 9 9 vd vs 10 nand2
XNAND10 10 10 vd vs 11 nand2
XNAND11 11 11 vd vs 12 nand2
XNAND12 12 12 vd vs 13 nand2
XNAND13 13 13 vd vs 14 nand2
XNAND14 14 14 vd vs 15 nand2
XNAND15 15 15 vd vs 16 nand2
XNAND16 16 16 vd vs 17 nand2
XNAND17 17 17 vd vs 18 nand2
XNAND18 18 18 vd vs 19 nand2
XNAND19 19 19 vd vs 1 nand2
XNAND20 1 1 vd 0 out nand2
Vdd vd 0 1.5
Vss vs 0 0
.option noinit
.tran 10p 80n uic
.control
pre_osdi ../lib/ngspice/psp103_nqs.osdi
set temp=0
option klu
run
rusage
set xbrushwidth=3
*plot i(Vss) ylimit 0 500u xlimit 50n 60n
plot out
plot out xlimit 50n 60n
meas tran tdiff TRIG V(out) val=0.7 rise=5 TARG v(out) val=0.7 rise=15
let freq=10/tdiff
print freq
linearize out
fft out
plot mag(out) xlimit 300Meg 2300Meg
meas sp fmax MAX_AT out from=1e8 to=1e9
echo
reset
pss 500e6 10n out 256 10 5 5e-3 uic
plot out xlimit 300Meg 2300Meg
inventory
.endc
.end

View File

@ -17,6 +17,25 @@ l1 4 2 5uH
re 3 6 4.65k
vee 6 0 dc -10 pwl 0 0 1e-9 -10
*.tran 30n 12u
.pss 3.1e6 500e-6 3 256 10 50 5e-3
.control
** transient sim
tran 3n 120u 20u
plot V(2) v(3)
** fft of tran sim
linearize v(3)
fft v(3)
let dbv3 = db(v(3))
plot dbv3 xlimit 1Meg 5Meg
** measure the frequency of oscillation
meas sp fosc MAX_AT dbv3 from=1Meg to=5Meg
** periodic steady state sim
pss 1e6 50e-6 3 256 10 50 5e-3
set xbrushwidth=3
plot v(3) ylimit 0 0.3
.endc
.end

View File

@ -31,5 +31,14 @@ cp v_plus v_minus 3.4p
.model nch nmos ( version=4.7 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
.model pch pmos ( version=4.7 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
*.tran 0.05n 1u uic
.pss 500e6 1u 1 1024 10 10 5e-3 uic
.control
tran 0.05n 1u uic
plot i1
reset
pss 400e6 2u 1 1024 10 10 5e-3 uic
set xbrushwidth=3
plot i1
.endc
.end

View File

@ -17,5 +17,15 @@ l1 3 0 1.5
l2 0 4 500m
r2 4 2 100
*.tran 300n 50m
.pss 50 200e-3 2 1024 11 10 5e-3 uic
.control
set xbrushwidth=3
tran 10u 1
plot v(2)
linearize v(2)
fft v(2)
plot mag(V(2)) xlimit 0 500 ylimit 0 1.5
reset
pss 50 200e-3 2 1024 11 10 5e-3
plot v(2) xlimit 0 500 ylimit 0 1.5
.endc

View File

@ -24,6 +24,18 @@ mn4 bout inv3 gnd_ana gnd_ana nch w=10u l=0.18u
.model nch nmos ( version=4.7 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
.model pch pmos ( version=4.7 level=54 lmin=0.1u lmax=20u wmin=0.1u wmax=10u )
*.tran 0.005n 100n
*.plot tran v(4)
.pss 624e6 500n 1 1024 10 5 5e-3 uic
.control
tran 0.005n 100n uic
plot v(bout)
linearize bout
fft bout
set xbrushwidth=3
plot mag(bout) xlimit 0 35G
reset
pss 2G 10n bout 1024 10 5 5e-3 uic
plot bout xlimit 0 35G
.endc
.end

View File

@ -16,6 +16,18 @@ c2 3 0 600p
c0 4 0 1n
l1 4 1 6.2u
*.tran 30n 12u
*.plot tran v(4)
.pss 1e6 10e-6 4 1024 10 50 5e-3 uic
.control
tran 10n 20u
plot v(4)
linearize v(4)
fft v(4)
set xbrushwidth=3
plot mag(v(4)) xlimit 0 10Meg
let maxfft=mag(v(4))
meas sp fosc MAX_AT maxfft from=1Meg to=10Meg
reset
pss 1.8e6 10e-6 4 1024 10 50 5e-3 uic
plot v(4) xlimit 0 10Meg
.endc
.end

View File

@ -1,17 +0,0 @@
Van Der Pol Oscillator
* Prediceted frequency is about 4.54167e+06 Hz.
* Third harmonic is high as the first one
Ba gib 0 I=-1e-2*v(gib,0)+1e-2*v(gib,0)^3
* Q is about 10
La gib 0 1.2e-6
Ra gib 0 158.113
Ca gib 0 1e-9 ic=0.5
*La gib 0 1e-9
*Ra gib 0 474.6
*Ca gib 0 1e-9 ic=0.5
* Ghost node... Test for my PSS!
Rb bad 0 1k
*.tran 1e-9 150e-6 uic
.pss 0.8e6 130e-6 1 50 10 50 5e-3 uic