How can I make my own vector in ngspice? I want to...
# ieee-sscs-dc-23
m
How can I make my own vector in ngspice? I want to alter the width, run dc then plot gm vs width (in one plot)?
h
**.subckt test_nmos XM1 D G S B nfet_03v3 L=0.28u W=20u nf=20 ad='int((nf+1)/2) * W/nf * 0.18u' as='int((nf+2)/2) * W/nf * 0.18u' + pd='2*int((nf+1)/2) * (W/nf + 0.18u)' ps='2*int((nf+2)/2) * (W/nf + 0.18u)' nrd='0.18u / W' nrs='0.18u / W' + sa=0 sb=0 sd=0 m=1 ****nmos subcircuit description .include /home/sonic/.volare/gf180mcuC/libs.tech/ngspice/design.ngspice .lib /home/sonic/.volare/gf180mcuC/libs.tech/ngspice/sm141064.ngspice typical vg g 0 0 vd d 0 dc 0.9 vs s 0 0 vb b 0 0 .control set w_start = 20u set sweep_num = 10 set w_delta = 1u let gm = vector($sweep_num) let sweep_w = vector($sweep_num) let ft = vector($sweep_num) let w_loop = $w_start let cnt = 0 while cnt < $sweep_num echo $&cnt alter @m.xm1.m0[w] = $&w_loop let sweep_w[$&cnt] = $&w_loop op let gm[$&cnt] = @m.xm1.m0[gm] let ft[$&cnt]=@m.xm1.m0[gm]/@m.xm1.m0[cgg] let w_loop = w_loop + $w_delta let cnt = cnt + 1 end plot gm vs sweep_w plot ft vs sweep_w .endc .end
This code within gf180mcuC prints these two plots
Variables defined by set command cannot use expr (+ - / * ). So I recommand you use set only for static variables. And those defined by 'let' are vectors. They are referenced by '$&' not '$' outside of expr commands.