From e1bc444380094a4f865b3a0e9f1d7c13b767e4cb Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 12 Apr 2026 11:38:07 +0200 Subject: [PATCH] Update van der Pol oscillator Add oscillators with .control section --- examples/pss/19-nand-ro-IHP_ctrl.cir | 68 +++++++++++++++++++ examples/pss/colpitt_osc_pss_ctrl.cir | 41 +++++++++++ .../pss/compl_cross_quad_osc_pss_ctrl.cir | 44 ++++++++++++ examples/pss/hartley_osc_pss_ctrl.cir | 31 +++++++++ examples/pss/ring_osc_pss_ctrl.cir | 41 +++++++++++ examples/pss/vackar_osc_pss_ctrl.cir | 33 +++++++++ examples/pss/vdp_osc_pss.cir | 32 +++++---- examples/pss/vdp_osc_pss_ctrl.cir | 37 ++++++++++ 8 files changed, 315 insertions(+), 12 deletions(-) create mode 100644 examples/pss/19-nand-ro-IHP_ctrl.cir create mode 100644 examples/pss/colpitt_osc_pss_ctrl.cir create mode 100644 examples/pss/compl_cross_quad_osc_pss_ctrl.cir create mode 100644 examples/pss/hartley_osc_pss_ctrl.cir create mode 100644 examples/pss/ring_osc_pss_ctrl.cir create mode 100644 examples/pss/vackar_osc_pss_ctrl.cir create mode 100644 examples/pss/vdp_osc_pss_ctrl.cir diff --git a/examples/pss/19-nand-ro-IHP_ctrl.cir b/examples/pss/19-nand-ro-IHP_ctrl.cir new file mode 100644 index 000000000..d34d6e8f3 --- /dev/null +++ b/examples/pss/19-nand-ro-IHP_ctrl.cir @@ -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 diff --git a/examples/pss/colpitt_osc_pss_ctrl.cir b/examples/pss/colpitt_osc_pss_ctrl.cir new file mode 100644 index 000000000..74ea012df --- /dev/null +++ b/examples/pss/colpitt_osc_pss_ctrl.cir @@ -0,0 +1,41 @@ +Colpitt's Oscillator Circuit +* Colpitt is an harmonic oscillator (LC based) which use +* a capacitive partition of resonator to feed the single +* active device. +* Predicted frequency is about 3.30435e+06 Hz. + +* Models: +.model qnl npn(level=1 bf=80 rb=100 ccs=2pf tf=0.3ns tr=6ns cje=3pf cjc=2pf va=50) + +r1 1 0 1 +q1 2 1 3 qnl +vcc 4 0 5 +rl 4 2 750 +c1 2 3 500p +c2 4 3 4500p +l1 4 2 5uH +re 3 6 4.65k +vee 6 0 dc -10 pwl 0 0 1e-9 -10 + +.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 + + + + diff --git a/examples/pss/compl_cross_quad_osc_pss_ctrl.cir b/examples/pss/compl_cross_quad_osc_pss_ctrl.cir new file mode 100644 index 000000000..2c169508b --- /dev/null +++ b/examples/pss/compl_cross_quad_osc_pss_ctrl.cir @@ -0,0 +1,44 @@ +Complimentary Cross Quad CMOS Oscillator +* Predicted frequency is 5.61224e+08 Hz. +* +* PLOT i1 + +* Supply +vdd vdd gnd 1.2 pwl 0 1.2 1e-9 1.2 +rdd vdd vdd_ana 70m +rgnd gnd gnd_ana 70m + +* Cross quad +mpsx v_plus v_minus vdd_ana vdd_ana pch w=10u l=0.1u +mnsx v_plus v_minus gnd_ana gnd_ana nch w=10u l=0.1u +mpdx v_minus v_plus vdd_ana vdd_ana pch w=10u l=0.1u +mndx v_minus v_plus gnd_ana gnd_ana nch w=10u l=0.1u + +* Lumped elements model of real inductor +ls v_plus i1 19.462n ic=0.06 +rs i1 v_minus 7.789 +cs v_plus v_minus 443f +coxs v_plus is 2.178p +coxd v_minus id 2.178p +rsis is gnd_ana 308 +rsid id gnd_ana 308 +csis is gnd_ana 51f +csid id gnd_ana 51f + +* Parallel capacitor to determine leading resonance +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 ) + +.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 + diff --git a/examples/pss/hartley_osc_pss_ctrl.cir b/examples/pss/hartley_osc_pss_ctrl.cir new file mode 100644 index 000000000..6594a93d5 --- /dev/null +++ b/examples/pss/hartley_osc_pss_ctrl.cir @@ -0,0 +1,31 @@ +Hartley's Oscillator Circuit +* Hartley is an harmonic oscillator (LC based) which use +* an inductive partition of resonator to feed the single +* active device. Output is taken on node 2. +* Prediceted frequency is about 121.176 Hz. +* +* PLOT V(3) + +* Models: +.model qnl npn(level=1 bf=80 rb=100 ccs=2pf tf=0.3ns tr=6ns cje=3pf cjc=2pf va=50) + +vcc 1 0 5 pwl 0 0 1e-5 5 +r1 1 2 0.2k +q1 2 3 0 qnl +c1 3 4 633n +l1 3 0 1.5 +l2 0 4 500m +r2 4 2 100 + +.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 + diff --git a/examples/pss/ring_osc_pss_ctrl.cir b/examples/pss/ring_osc_pss_ctrl.cir new file mode 100644 index 000000000..04270ec96 --- /dev/null +++ b/examples/pss/ring_osc_pss_ctrl.cir @@ -0,0 +1,41 @@ +Ring CMOS Oscillator +* Oscillation is taken on node "bout". +* Predicted frequency is 3.8e+09 Hz. +* +* PLOT bout + +* Supply +vdd vdd gnd 1.2 pwl 0 1.2 1e-9 1.2 +rdd vdd vdd_ana 70m +rgnd gnd gnd_ana 70m + +* Inverter +mp1 inv1 inv3 vdd_ana vdd_ana pch w=10u l=0.18u +mn1 inv1 inv3 gnd_ana gnd_ana nch w=10u l=0.18u +mp2 inv2 inv1 vdd_ana vdd_ana pch w=10u l=0.18u +mn2 inv2 inv1 gnd_ana gnd_ana nch w=10u l=0.18u +mp3 inv3 inv2 vdd_ana vdd_ana pch w=10u l=0.18u +mn3 inv3 inv2 gnd_ana gnd_ana nch w=10u l=0.18u + +* Buffer out +mp4 bout inv3 vdd_ana vdd_ana pch w=10u l=0.18u +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 ) + +.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 + diff --git a/examples/pss/vackar_osc_pss_ctrl.cir b/examples/pss/vackar_osc_pss_ctrl.cir new file mode 100644 index 000000000..27f1c8eab --- /dev/null +++ b/examples/pss/vackar_osc_pss_ctrl.cir @@ -0,0 +1,33 @@ +Vackar's Oscillator Circuit +* Vackar is a derivation of Colpitt's oscillator (LC based). +* Oscillation is taken on node 4. +* Predicted frequency is 1.91803e+06Hz. + +* Models: +.model qnl npn(level=1 bf=80 rb=100 ccs=2pf tf=0.3ns tr=6ns cje=3pf cjc=2pf va=50) + +vcc 1 0 5 pwl 0 10 1e-9 5 +lrfc 1 2 100u +cdec 2 0 7n +q1 3 2 0 qnl +rb 3 0 4700 +c1 3 4 100p +c2 3 0 600p +c0 4 0 1n +l1 4 1 6.2u + +.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 + diff --git a/examples/pss/vdp_osc_pss.cir b/examples/pss/vdp_osc_pss.cir index f4e66815c..d5f399f71 100644 --- a/examples/pss/vdp_osc_pss.cir +++ b/examples/pss/vdp_osc_pss.cir @@ -1,17 +1,25 @@ 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 +* Third harmonic is as 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 +RLa gib gib1 1m +La gib1 0 1.2e-6 +Ra gib 0 158.113 +Ca gib 0 1e-9 ic=-1 + +Vnew 0 gr 1 +Rnew gr gib 5k + +*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 10e-9 20e-6 uic +.pss 0.5e6 100e-6 1 50 10 50 5e-3 uic + +.end -*.tran 1e-9 150e-6 uic -.pss 0.8e6 130e-6 1 50 10 50 5e-3 uic diff --git a/examples/pss/vdp_osc_pss_ctrl.cir b/examples/pss/vdp_osc_pss_ctrl.cir new file mode 100644 index 000000000..011d0943c --- /dev/null +++ b/examples/pss/vdp_osc_pss_ctrl.cir @@ -0,0 +1,37 @@ +Van Der Pol Oscillator +* Prediceted frequency is about 4.54167e+06 Hz. + +* Third harmonic is as high as the first one +Ba gib 0 I=-1e-2*v(gib,0)+1e-2*v(gib,0)^3 +* Q is about 10 +RLa gib gib1 1m +La gib1 0 1.2e-6 +Ra gib 0 158.113 +Ca gib 0 1e-9 ic=-1 + +Vnew 0 gr 1 +Rnew gr gib 5k + +*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 + +.control +tran 10e-9 20e-6 uic +rusage time +plot gib xlimit 0 5u +meas tran ptdiff TRIG v(gib) val=0 RISE=25 TARG v(gib) val=0 RISE=50 +let freq = 25.0/ptdiff +echo frequency is $&freq +reset +pss 0.5e6 100e-6 1 50 10 50 5e-3 uic +rusage time +plot gib +setplot pss1 +plot gib +.endc + +.end +