From aa5009fbe42dc61469eb9dc8d9432db01250c1ee Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 14 Jul 2017 19:07:03 +0200 Subject: [PATCH] implement "case" --- .../devices/adms/admst/ngspiceMODULE.hxx.xml | 38 +++++++- .../admst/ngspiceMODULEguesstopology.c.xml | 30 ++++++ .../devices/adms/admst/ngspiceVersion.xml | 31 +++++- .../devices/adms/bsim6/admsva/bsim6.va | 96 ++++++++++--------- 4 files changed, 148 insertions(+), 47 deletions(-) diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULE.hxx.xml b/src/spicelib/devices/adms/admst/ngspiceMODULE.hxx.xml index 17b3a7d62..41b936538 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMODULE.hxx.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMODULE.hxx.xml @@ -2633,6 +2633,37 @@ inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2738,8 +2769,13 @@ inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0. + + + + + - + diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULEguesstopology.c.xml b/src/spicelib/devices/adms/admst/ngspiceMODULEguesstopology.c.xml index b1542bb07..aec807554 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMODULEguesstopology.c.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMODULEguesstopology.c.xml @@ -138,6 +138,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/spicelib/devices/adms/admst/ngspiceVersion.xml b/src/spicelib/devices/adms/admst/ngspiceVersion.xml index 0558cbc36..49f9c5ee4 100644 --- a/src/spicelib/devices/adms/admst/ngspiceVersion.xml +++ b/src/spicelib/devices/adms/admst/ngspiceVersion.xml @@ -1599,8 +1599,35 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/spicelib/devices/adms/bsim6/admsva/bsim6.va b/src/spicelib/devices/adms/bsim6/admsva/bsim6.va index 754c121eb..eb65f3a7d 100755 --- a/src/spicelib/devices/adms/bsim6/admsva/bsim6.va +++ b/src/spicelib/devices/adms/bsim6/admsva/bsim6.va @@ -165,14 +165,14 @@ `define BSIM6RdsEndIso(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEnd, rgeo, TYPE, Rend) \ if (TYPE == 1) begin \ - if(rgeo == 1 || rgeo == 2 || rgeo == 5) \ - begin \ + case(rgeo) \ + 1, 2, 5: begin \ if (nuEnd == 0.0) \ Rend = 0.0; \ else \ Rend = Rsh * DMCG / (Weffcj * nuEnd); \ end \ - else if(rgeo == 3 || rgeo == 4 || rgeo == 6) begin \ + 3, 4, 6: begin \ if ((DMCG + DMCI) == 0.0) \ `STROBE("(DMCG + DMCI) can not be equal to zero"); \ if (nuEnd == 0.0) \ @@ -180,21 +180,22 @@ else \ Rend = Rsh * Weffcj / (3.0 * nuEnd * (DMCG + DMCI)); \ end \ - else begin \ + default: begin \ `STROBE2("Warning: (instance BSIM6) Specified RGEO = %d not matched (BSIM6RdsEndIso), \ Rend is set to zero.", rgeo); \ Rend = 0.0; \ end \ + endcase \ end \ else begin \ - if(rgeo == 1 || rgeo == 3 || rgeo == 7) \ - begin \ + case(rgeo) \ + 1, 3, 7: begin \ if (nuEnd == 0.0) \ Rend = 0.0; \ else \ Rend = Rsh * DMCG / (Weffcj * nuEnd); \ end \ - else if(rgeo == 2 || rgeo == 4 || rgeo == 8) begin \ + 2, 4, 8: begin \ if ((DMCG + DMCI) == 0.0) \ `STROBE("(DMCG + DMCI) can not be equal to zero"); \ if (nuEnd == 0.0) \ @@ -202,25 +203,26 @@ else \ Rend = Rsh * Weffcj / (3.0 * nuEnd * (DMCG + DMCI)); \ end \ - else begin \ + default: begin \ `STROBE2("Warning: (instance BSIM6) Specified RGEO=%d not matched (BSIM6RdsEndIso \ type 2), Rend is set to zero.", rgeo); \ Rend = 0.0; \ end \ + endcase \ end `define BSIM6RdsEndSha(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEnd, rgeo, TYPE, Rend) \ begin \ if (TYPE == 1) begin \ - if(rgeo == 1 || rgeo == 2 || rgeo == 5) \ - begin \ + case(rgeo) \ + 1, 2, 5: begin \ if (nuEnd == 0.0) \ Rend = 0.0; \ else \ Rend = Rsh * DMCG / (Weffcj * nuEnd); \ end \ - else if (rgeo == 3 || rgeo == 4 || rgeo == 6) begin \ + 3, 4, 6: begin \ if (DMCG == 0.0) \ `STROBE("DMCG can not be equal to zero"); \ if (nuEnd == 0.0) \ @@ -228,21 +230,22 @@ else \ Rend = Rsh * Weffcj / (6.0 * nuEnd * DMCG); \ end \ - else begin \ + default: begin \ `STROBE2("Warning: (instance BSIM6) Specified RGEO = %d not matched (BSIM6RdsEndSha), \ Rend is set to zero.", rgeo); \ Rend = 0.0; \ end \ + endcase \ end \ else begin \ - if(rgeo == 1 || rgeo == 3 || rgeo == 7) \ - begin \ + case(rgeo) \ + 1, 3, 7: begin \ if (nuEnd == 0.0) \ Rend = 0.0; \ else \ Rend = Rsh * DMCG / (Weffcj * nuEnd); \ end \ - else if (rgeo == 2 || rgeo == 4 || rgeo == 8) begin \ + 2, 4, 8: begin \ if (DMCG == 0.0) \ `STROBE("DMCG can not be equal to zero"); \ if (nuEnd == 0.0) \ @@ -250,11 +253,12 @@ else \ Rend = Rsh * Weffcj / (6.0 * nuEnd * DMCG); \ end \ - else begin \ + default: begin \ `STROBE2("Warning: (instance BSIM6) Specified RGEO=%d not matched (BSIM6RdsEndSha \ type 2), Rend is set to zero.", rgeo); \ Rend = 0.0; \ end \ + endcase \ end \ end @@ -275,8 +279,8 @@ Rint = Rsh * DMCG / ( Weffcj * nuIntD); \ end \ end \ - if (geo == 0) \ - begin \ + case(geo) \ + 0: begin \ if (TYPE == 1) \ `BSIM6RdsEndIso(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndS, \ rgeo, 1, Rend) \ @@ -284,7 +288,7 @@ `BSIM6RdsEndIso(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndD, \ rgeo, 0, Rend) \ end \ - else if (geo == 1) begin \ + 1: begin \ if (TYPE == 1) \ `BSIM6RdsEndIso(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndS, \ rgeo, 1, Rend) \ @@ -292,7 +296,7 @@ `BSIM6RdsEndSha(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndD, \ rgeo, 0, Rend) \ end \ - else if (geo == 2) begin \ + 2: begin \ if (TYPE == 1) \ `BSIM6RdsEndSha(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndS, \ rgeo, 1, Rend) \ @@ -300,7 +304,7 @@ `BSIM6RdsEndIso(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndD, \ rgeo, 0, Rend) \ end \ - else if (geo == 3) begin \ + 3: begin \ if (TYPE == 1) \ `BSIM6RdsEndSha(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndS, \ rgeo, 1, Rend) \ @@ -308,14 +312,14 @@ `BSIM6RdsEndSha(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndD, \ rgeo, 0, Rend) \ end \ - else if (geo == 4) begin \ + 4: begin \ if (TYPE == 1) \ `BSIM6RdsEndIso(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndS, \ rgeo, 1, Rend) \ else \ Rend = Rsh * DMDG / Weffcj; \ end \ - else if (geo == 5) begin \ + 5: begin \ if (TYPE == 1) \ `BSIM6RdsEndSha(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndS, \ rgeo, 1, Rend) \ @@ -326,14 +330,14 @@ Rend = Rsh * DMDG / (Weffcj * nuEndD); \ end\ end \ - else if (geo == 6) begin \ + 6: begin \ if (TYPE == 1) \ Rend = Rsh * DMDG / Weffcj; \ else \ `BSIM6RdsEndIso(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndD, \ rgeo, 0, Rend) \ end \ - else if (geo == 7) begin \ + 7:begin \ if (TYPE == 1) begin \ if (nuEndS==0) \ Rend = 0; \ @@ -343,10 +347,10 @@ `BSIM6RdsEndSha(Weffcj, Rsh, DMCG, DMCI, DMDG, nuEndD, \ rgeo, 0, Rend) \ end \ - else if (geo == 8) begin \ + 8: begin \ Rend = Rsh * DMDG / Weffcj; \ end \ - else if (geo == 9) begin /* all wide contacts assumed for geo = 9 and 10 */\ + 9: begin /* all wide contacts assumed for geo = 9 and 10 */\ if (TYPE == 1) begin \ Rend = 0.5 * Rsh * DMCG / Weffcj; \ if (nf == 2.0) \ @@ -359,7 +363,7 @@ Rint = Rsh * DMCG / (Weffcj * nf); \ end \ end \ - else if (geo == 10) begin \ + 10: begin \ if (TYPE == 1) begin \ Rend = 0.0; \ Rint = Rsh * DMCG / (Weffcj * nf); \ @@ -372,11 +376,12 @@ Rint = Rsh * DMCG / (Weffcj * (nf - 2.0)); \ end \ end \ - else begin \ + default: begin \ `STROBE2("Warning: (instance BSIM6) Specified RGEO=%d not matched (BSIM6RdseffGeo \ ), Rint is set to zero.", rgeo); \ Rint = 0.0; \ end \ + endcase \ if (Rint <= 0.0) \ Rtot = Rend; \ else if (Rend <= 0.0) \ @@ -407,74 +412,74 @@ ADsha = DMCG * Weffcj;\ ASmer = DMDG * Weffcj; \ ADmer = DMDG * Weffcj; \ - if(geo == 0) \ - begin \ + case(geo) \ + 0: begin \ Ps = nuEndS * PSiso + nuIntS * PSsha;\ Pd = nuEndD * PDiso + nuIntD * PDsha;\ As = nuEndS * ASiso + nuIntS * ASsha;\ Ad = nuEndD * ADiso + nuIntD * ADsha;\ end \ - else if(geo == 1) begin \ + 1: begin \ Ps = nuEndS * PSiso + nuIntS * PSsha;\ Pd = (nuEndD + nuIntD) * PDsha;\ As = nuEndS * ASiso + nuIntS * ASsha;\ Ad = (nuEndD + nuIntD) * ADsha;\ end \ - else if(geo == 2) begin \ + 2: begin \ Ps = (nuEndS + nuIntS) * PSsha;\ Pd = nuEndD * PDiso + nuIntD * PDsha;\ As = (nuEndS + nuIntS) * ASsha;\ Ad = nuEndD * ADiso + nuIntD * ADsha;\ end \ - else if(geo == 3) begin \ + 3: begin \ Ps = (nuEndS + nuIntS) * PSsha;\ Pd = (nuEndD + nuIntD) * PDsha;\ As = (nuEndS + nuIntS) * ASsha;\ Ad = (nuEndD + nuIntD) * ADsha;\ end \ - else if(geo == 4) begin \ + 4: begin \ Ps = nuEndS * PSiso + nuIntS * PSsha;\ Pd = nuEndD * PDmer + nuIntD * PDsha;\ As = nuEndS * ASiso + nuIntS * ASsha;\ Ad = nuEndD * ADmer + nuIntD * ADsha;\ end \ - else if(geo == 5) begin \ + 5: begin \ Ps = (nuEndS + nuIntS) * PSsha;\ Pd = nuEndD * PDmer + nuIntD * PDsha;\ As = (nuEndS + nuIntS) * ASsha;\ Ad = nuEndD * ADmer + nuIntD * ADsha;\ end \ - else if(geo == 6) begin \ + 6: begin \ Ps = nuEndS * PSmer + nuIntS * PSsha;\ Pd = nuEndD * PDiso + nuIntD * PDsha;\ As = nuEndS * ASmer + nuIntS * ASsha;\ Ad = nuEndD * ADiso + nuIntD * ADsha;\ end \ - else if(geo == 7) begin \ + 7: begin \ Ps = nuEndS * PSmer + nuIntS * PSsha;\ Pd = (nuEndD + nuIntD) * PDsha;\ As = nuEndS * ASmer + nuIntS * ASsha;\ Ad = (nuEndD + nuIntD) * ADsha;\ end \ - else if(geo == 8) begin \ + 8: begin \ Ps = nuEndS * PSmer + nuIntS * PSsha;\ Pd = nuEndD * PDmer + nuIntD * PDsha;\ As = nuEndS * ASmer + nuIntS * ASsha;\ Ad = nuEndD * ADmer + nuIntD * ADsha;\ end \ - else if(geo == 9) begin \ + 9: begin \ Ps = PSiso + (nf - 1.0) * PSsha;\ Pd = nf * PDsha;\ As = ASiso + (nf - 1.0) * ASsha;\ Ad = nf * ADsha;\ end \ - else if(geo == 10) begin \ + 10: begin \ Ps = nf * PSsha;\ Pd = PDiso + (nf - 1.0) * PDsha;\ As = nf * ASsha;\ Ad = ADiso + (nf - 1.0) * ADsha;\ end \ - else begin \ + default: begin \ `STROBE2("Warning: (instance BSIM6) Specified GEO=%d not matched (BSIM6RdseffGeo \ ), PS,PD,AS,AD set to zero.", geo); \ Ps = 0;\ @@ -482,6 +487,7 @@ As = 0;\ Ad = 0;\ end \ + endcase \ end \ //****************************************************** @@ -3956,7 +3962,8 @@ DevTemp = $temperature + DTEMP; thetanoisq = T4 * T4; cm_igid=0; //Initialization - if(TNOIMOD == 0) begin + case(TNOIMOD) + 0: begin `endif QSi = - NF * Weff * Leff * Cox *Vt * Qs; QDi = - NF * Weff * Leff * Cox *Vt * Qd; @@ -3967,7 +3974,7 @@ DevTemp = $temperature + DTEMP; I(`IntrinsicDrain, `IntrinsicSource) <+ white_noise(sidn, "id"); `ifdef __TNOISW__ end - else if(TNOIMOD == 1) begin + 1: begin Vtn = 2.0 * nq * nVt; T0 = ueff * Dptwg * Moc * Cox * Vtn; T1 = 0.5 * (qs + qdeff); @@ -4006,6 +4013,7 @@ DevTemp = $temperature + DTEMP; I(`IntrinsicGate,`IntrinsicSource) <+ ddt(0.5 * ((1.0 + sigvds) * mig * Cox * Weff * NF * Leff * V(NC))); I(`IntrinsicGate,`IntrinsicDrain) <+ ddt(0.5 * ((1.0 - sigvds) * mig * Cox * Weff * NF * Leff * V(NC))); end + endcase I(N2) <+ V(N2); I(NR) <+ V(NR);