⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 b4ld.c

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 C
📖 第 1 页 / 共 5 页
字号:
                         *(ckt->CKTstate1 + here->BSIM4vdes);                   vdes = (1.0 + xfact)* (*(ckt->CKTstate1 + here->BSIM4vdes))                         - (xfact * (*(ckt->CKTstate2 + here->BSIM4vdes)));                   *(ckt->CKTstate0 + here->BSIM4qdef) =                         *(ckt->CKTstate1 + here->BSIM4qdef);                   qdef = (1.0 + xfact)* (*(ckt->CKTstate1 + here->BSIM4qdef))                        -(xfact * (*(ckt->CKTstate2 + here->BSIM4qdef)));               }	       else	       {#endif /* PREDICTOR */                   vds = model->BSIM4type                       * (*(ckt->CKTrhsOld + here->BSIM4dNodePrime)                       - *(ckt->CKTrhsOld + here->BSIM4sNodePrime));                   vgs = model->BSIM4type                       * (*(ckt->CKTrhsOld + here->BSIM4gNodePrime)                        - *(ckt->CKTrhsOld + here->BSIM4sNodePrime));                   vbs = model->BSIM4type                       * (*(ckt->CKTrhsOld + here->BSIM4bNodePrime)                       - *(ckt->CKTrhsOld + here->BSIM4sNodePrime));                   vges = model->BSIM4type                        * (*(ckt->CKTrhsOld + here->BSIM4gNodeExt)                        - *(ckt->CKTrhsOld + here->BSIM4sNodePrime));                   vgms = model->BSIM4type                        * (*(ckt->CKTrhsOld + here->BSIM4gNodeMid)                        - *(ckt->CKTrhsOld + here->BSIM4sNodePrime));                   vdbs = model->BSIM4type                        * (*(ckt->CKTrhsOld + here->BSIM4dbNode)                        - *(ckt->CKTrhsOld + here->BSIM4sNodePrime));                   vsbs = model->BSIM4type                        * (*(ckt->CKTrhsOld + here->BSIM4sbNode)                        - *(ckt->CKTrhsOld + here->BSIM4sNodePrime));                   vses = model->BSIM4type                        * (*(ckt->CKTrhsOld + here->BSIM4sNode)                        - *(ckt->CKTrhsOld + here->BSIM4sNodePrime));                   vdes = model->BSIM4type                        * (*(ckt->CKTrhsOld + here->BSIM4dNode)                        - *(ckt->CKTrhsOld + here->BSIM4sNodePrime));                   qdef = model->BSIM4type                        * (*(ckt->CKTrhsOld + here->BSIM4qNode));#ifndef PREDICTOR               }#endif /* PREDICTOR */               vgdo = *(ckt->CKTstate0 + here->BSIM4vgs)                    - *(ckt->CKTstate0 + here->BSIM4vds);	       vgedo = *(ckt->CKTstate0 + here->BSIM4vges)                     - *(ckt->CKTstate0 + here->BSIM4vds);	       vgmdo = *(ckt->CKTstate0 + here->BSIM4vgms)                     - *(ckt->CKTstate0 + here->BSIM4vds);               vbd = vbs - vds;               vdbd = vdbs - vds;               vgd = vgs - vds;  	       vged = vges - vds;  	       vgmd = vgms - vds;               delvbd = vbd - *(ckt->CKTstate0 + here->BSIM4vbd);               delvdbd = vdbd - *(ckt->CKTstate0 + here->BSIM4vdbd);               delvgd = vgd - vgdo;	       delvged = vged - vgedo;	       delvgmd = vgmd - vgmdo;               delvds = vds - *(ckt->CKTstate0 + here->BSIM4vds);               delvgs = vgs - *(ckt->CKTstate0 + here->BSIM4vgs);	       delvges = vges - *(ckt->CKTstate0 + here->BSIM4vges);	       delvgms = vgms - *(ckt->CKTstate0 + here->BSIM4vgms);               delvbs = vbs - *(ckt->CKTstate0 + here->BSIM4vbs);               delvdbs = vdbs - *(ckt->CKTstate0 + here->BSIM4vdbs);               delvsbs = vsbs - *(ckt->CKTstate0 + here->BSIM4vsbs);               delvses = vses - (*(ckt->CKTstate0 + here->BSIM4vses));               vdedo = *(ckt->CKTstate0 + here->BSIM4vdes)                     - *(ckt->CKTstate0 + here->BSIM4vds);	       delvdes = vdes - *(ckt->CKTstate0 + here->BSIM4vdes);               delvded = vdes - vds - vdedo;               delvbd_jct = (!here->BSIM4rbodyMod) ? delvbd : delvdbd;               delvbs_jct = (!here->BSIM4rbodyMod) ? delvbs : delvsbs;               if (here->BSIM4mode >= 0)               {   Idtot = here->BSIM4cd + here->BSIM4csub - here->BSIM4cbd			 + here->BSIM4Igidl;                   cdhat = Idtot - here->BSIM4gbd * delvbd_jct                         + (here->BSIM4gmbs + here->BSIM4gbbs + here->BSIM4ggidlb) * delvbs                         + (here->BSIM4gm + here->BSIM4gbgs + here->BSIM4ggidlg) * delvgs                          + (here->BSIM4gds + here->BSIM4gbds + here->BSIM4ggidld) * delvds;                   Ibtot = here->BSIM4cbs + here->BSIM4cbd 			 - here->BSIM4Igidl - here->BSIM4Igisl - here->BSIM4csub;                   cbhat = Ibtot + here->BSIM4gbd * delvbd_jct                         + here->BSIM4gbs * delvbs_jct - (here->BSIM4gbbs + here->BSIM4ggidlb)                         * delvbs - (here->BSIM4gbgs + here->BSIM4ggidlg) * delvgs			 - (here->BSIM4gbds + here->BSIM4ggidld - here->BSIM4ggisls) * delvds 			 - here->BSIM4ggislg * delvgd - here->BSIM4ggislb* delvbd;		   Igstot = here->BSIM4Igs + here->BSIM4Igcs;		   cgshat = Igstot + (here->BSIM4gIgsg + here->BSIM4gIgcsg) * delvgs			  + here->BSIM4gIgcsd * delvds + here->BSIM4gIgcsb * delvbs;		   Igdtot = here->BSIM4Igd + here->BSIM4Igcd;		   cgdhat = Igdtot + here->BSIM4gIgdg * delvgd + here->BSIM4gIgcdg * delvgs                          + here->BSIM4gIgcdd * delvds + here->BSIM4gIgcdb * delvbs; 		   Igbtot = here->BSIM4Igb;		   cgbhat = here->BSIM4Igb + here->BSIM4gIgbg * delvgs + here->BSIM4gIgbd			  * delvds + here->BSIM4gIgbb * delvbs;               }               else               {   Idtot = here->BSIM4cd + here->BSIM4cbd - here->BSIM4Igidl; /* bugfix */                   cdhat = Idtot + here->BSIM4gbd * delvbd_jct + here->BSIM4gmbs                          * delvbd + here->BSIM4gm * delvgd                          - (here->BSIM4gds + here->BSIM4ggidls) * delvds                          - here->BSIM4ggidlg * delvgs - here->BSIM4ggidlb * delvbs;                   Ibtot = here->BSIM4cbs + here->BSIM4cbd 			 - here->BSIM4Igidl - here->BSIM4Igisl - here->BSIM4csub;                   cbhat = Ibtot + here->BSIM4gbs * delvbs_jct + here->BSIM4gbd                          * delvbd_jct - (here->BSIM4gbbs + here->BSIM4ggislb) * delvbd                         - (here->BSIM4gbgs + here->BSIM4ggislg) * delvgd			 + (here->BSIM4gbds + here->BSIM4ggisld - here->BSIM4ggidls) * delvds			 - here->BSIM4ggidlg * delvgs - here->BSIM4ggidlb * delvbs;                    Igstot = here->BSIM4Igs + here->BSIM4Igcd;                   cgshat = Igstot + here->BSIM4gIgsg * delvgs + here->BSIM4gIgcdg * delvgd                          - here->BSIM4gIgcdd * delvds + here->BSIM4gIgcdb * delvbd;                   Igdtot = here->BSIM4Igd + here->BSIM4Igcs;                   cgdhat = Igdtot + (here->BSIM4gIgdg + here->BSIM4gIgcsg) * delvgd                          - here->BSIM4gIgcsd * delvds + here->BSIM4gIgcsb * delvbd;                   Igbtot = here->BSIM4Igb;                   cgbhat = here->BSIM4Igb + here->BSIM4gIgbg * delvgd - here->BSIM4gIgbd                          * delvds + here->BSIM4gIgbb * delvbd;               }               Isestot = here->BSIM4gstot * (*(ckt->CKTstate0 + here->BSIM4vses));               cseshat = Isestot + here->BSIM4gstot * delvses                       + here->BSIM4gstotd * delvds + here->BSIM4gstotg * delvgs                       + here->BSIM4gstotb * delvbs;               Idedtot = here->BSIM4gdtot * vdedo;               cdedhat = Idedtot + here->BSIM4gdtot * delvded                       + here->BSIM4gdtotd * delvds + here->BSIM4gdtotg * delvgs                       + here->BSIM4gdtotb * delvbs;#ifndef NOBYPASS               /* Following should be one IF statement, but some C compilers                 * can't handle that all at once, so we split it into several                * successive IF's */               if ((!(ckt->CKTmode & MODEINITPRED)) && (ckt->CKTbypass))               if ((fabs(delvds) < (ckt->CKTreltol * MAX(fabs(vds),                   fabs(*(ckt->CKTstate0 + here->BSIM4vds))) + ckt->CKTvoltTol)))               if ((fabs(delvgs) < (ckt->CKTreltol * MAX(fabs(vgs),                   fabs(*(ckt->CKTstate0 + here->BSIM4vgs))) + ckt->CKTvoltTol)))               if ((fabs(delvbs) < (ckt->CKTreltol * MAX(fabs(vbs),                   fabs(*(ckt->CKTstate0 + here->BSIM4vbs))) + ckt->CKTvoltTol)))               if ((fabs(delvbd) < (ckt->CKTreltol * MAX(fabs(vbd),                   fabs(*(ckt->CKTstate0 + here->BSIM4vbd))) + ckt->CKTvoltTol)))	       if ((here->BSIM4rgateMod == 0) || (here->BSIM4rgateMod == 1)       		   || (fabs(delvges) < (ckt->CKTreltol * MAX(fabs(vges),		   fabs(*(ckt->CKTstate0 + here->BSIM4vges))) + ckt->CKTvoltTol)))	       if ((here->BSIM4rgateMod != 3) || (fabs(delvgms) < (ckt->CKTreltol                   * MAX(fabs(vgms), fabs(*(ckt->CKTstate0 + here->BSIM4vgms)))                   + ckt->CKTvoltTol)))               if ((!here->BSIM4rbodyMod) || (fabs(delvdbs) < (ckt->CKTreltol                   * MAX(fabs(vdbs), fabs(*(ckt->CKTstate0 + here->BSIM4vdbs)))                   + ckt->CKTvoltTol)))               if ((!here->BSIM4rbodyMod) || (fabs(delvdbd) < (ckt->CKTreltol                   * MAX(fabs(vdbd), fabs(*(ckt->CKTstate0 + here->BSIM4vdbd)))                   + ckt->CKTvoltTol)))               if ((!here->BSIM4rbodyMod) || (fabs(delvsbs) < (ckt->CKTreltol                   * MAX(fabs(vsbs), fabs(*(ckt->CKTstate0 + here->BSIM4vsbs)))                   + ckt->CKTvoltTol)))               if ((!model->BSIM4rdsMod) || (fabs(delvses) < (ckt->CKTreltol                   * MAX(fabs(vses), fabs(*(ckt->CKTstate0 + here->BSIM4vses)))                   + ckt->CKTvoltTol)))               if ((!model->BSIM4rdsMod) || (fabs(delvdes) < (ckt->CKTreltol                   * MAX(fabs(vdes), fabs(*(ckt->CKTstate0 + here->BSIM4vdes)))                   + ckt->CKTvoltTol)))               if ((fabs(cdhat - Idtot) < ckt->CKTreltol                   * MAX(fabs(cdhat), fabs(Idtot)) + ckt->CKTabstol))               if ((fabs(cbhat - Ibtot) < ckt->CKTreltol                   * MAX(fabs(cbhat), fabs(Ibtot)) + ckt->CKTabstol))               if ((!model->BSIM4igcMod) || ((fabs(cgshat - Igstot) < ckt->CKTreltol                   * MAX(fabs(cgshat), fabs(Igstot)) + ckt->CKTabstol)))               if ((!model->BSIM4igcMod) || ((fabs(cgdhat - Igdtot) < ckt->CKTreltol                   * MAX(fabs(cgdhat), fabs(Igdtot)) + ckt->CKTabstol)))               if ((!model->BSIM4igbMod) || ((fabs(cgbhat - Igbtot) < ckt->CKTreltol                   * MAX(fabs(cgbhat), fabs(Igbtot)) + ckt->CKTabstol)))               if ((!model->BSIM4rdsMod) || ((fabs(cseshat - Isestot) < ckt->CKTreltol                   * MAX(fabs(cseshat), fabs(Isestot)) + ckt->CKTabstol)))               if ((!model->BSIM4rdsMod) || ((fabs(cdedhat - Idedtot) < ckt->CKTreltol                   * MAX(fabs(cdedhat), fabs(Idedtot)) + ckt->CKTabstol)))               {   vds = *(ckt->CKTstate0 + here->BSIM4vds);                   vgs = *(ckt->CKTstate0 + here->BSIM4vgs);                   vbs = *(ckt->CKTstate0 + here->BSIM4vbs);		   vges = *(ckt->CKTstate0 + here->BSIM4vges);		   vgms = *(ckt->CKTstate0 + here->BSIM4vgms);                   vbd = *(ckt->CKTstate0 + here->BSIM4vbd);                   vdbs = *(ckt->CKTstate0 + here->BSIM4vdbs);                   vdbd = *(ckt->CKTstate0 + here->BSIM4vdbd);                   vsbs = *(ckt->CKTstate0 + here->BSIM4vsbs);                   vses = *(ckt->CKTstate0 + here->BSIM4vses);                   vdes = *(ckt->CKTstate0 + here->BSIM4vdes);                   vgd = vgs - vds;                   vgb = vgs - vbs;		   vged = vges - vds;		   vgmd = vgms - vds;		   vgmb = vgms - vbs;                   vbs_jct = (!here->BSIM4rbodyMod) ? vbs : vsbs;                   vbd_jct = (!here->BSIM4rbodyMod) ? vbd : vdbd;/*** qdef should not be kept fixed even if vgs, vds & vbs has converged ****               qdef = *(ckt->CKTstate0 + here->BSIM4qdef);  ***/                   cdrain = here->BSIM4cd;                   if ((ckt->CKTmode & (MODETRAN | MODEAC)) ||                        ((ckt->CKTmode & MODETRANOP) &&                        (ckt->CKTmode & MODEUIC)))		   {   ByPass = 1;                       qgate = here->BSIM4qgate;                       qbulk = here->BSIM4qbulk;                       qdrn = here->BSIM4qdrn;		       cgdo = here->BSIM4cgdo;		       qgdo = here->BSIM4qgdo;                       cgso = here->BSIM4cgso;                       qgso = here->BSIM4qgso;		       goto line755;                    }		    else		       goto line850;               }#endif /*NOBYPASS*/               von = here->BSIM4von;               if (*(ckt->CKTstate0 + here->BSIM4vds) >= 0.0)	       {   vgs = DEVfetlim(vgs, *(ckt->CKTstate0 + here->BSIM4vgs), von);                   vds = vgs - vgd;                   vds = DEVlimvds(vds, *(ckt->CKTstate0 + here->BSIM4vds));                   vgd = vgs - vds;                   if (here->BSIM4rgateMod == 3)                   {   vges = DEVfetlim(vges, *(ckt->CKTstate0 + here->BSIM4vges), von);                       vgms = DEVfetlim(vgms, *(ckt->CKTstate0 + here->BSIM4vgms), von);                       vged = vges - vds;                       vgmd = vgms - vds;                   }                   else if ((here->BSIM4rgateMod == 1) || (here->BSIM4rgateMod == 2))                   {   vges = DEVfetlim(vges, *(ckt->CKTstate0 + here->BSIM4vges), von);                       vged = vges - vds;                   }                   if (model->BSIM4rdsMod)		   {   vdes = DEVlimvds(vdes, *(ckt->CKTstate0 + here->BSIM4vdes));		       vses = -DEVlimvds(-vses, -(*(ckt->CKTstate0 + here->BSIM4vses)));		   }               }	       else	       {   vgd = DEVfetlim(vgd, vgdo, von);                   vds = vgs - vgd;                   vds = -DEVlimvds(-vds, -(*(ckt->CKTstate0 + here->BSIM4vds)));                   vgs = vgd + vds;		   if (here->BSIM4rgateMod == 3)                   {   vged = DEVfetlim(vged, vgedo, von);                       vges = vged + vds;                       vgmd = DEVfetlim(vgmd, vgmdo, von);                       vgms = vgmd + vds;                   }                   if ((here->BSIM4rgateMod == 1) || (here->BSIM4rgateMod == 2))                   {   vged = DEVfetlim(vged, vgedo, von);                       vges = vged + vds;                   }                   if (model->BSIM4rdsMod)                   {   vdes = -DEVlimvds(-vdes, -(*(ckt->CKTstate0 + here->BSIM4vdes)));                       vses = DEVlimvds(vses, *(ckt->CKTstate0 + here->BSIM4vses));                   }               }               if (vds >= 0.0)	       {   vbs = DEVpnjlim(vbs, *(ckt->CKTstate0 + here->BSIM4vbs),                                   CONSTvt0, model->BSIM4vcrit, &Check);                   vbd = vbs - vds;                   if (here->BSIM4rbodyMod)                   {   vdbs = DEVpnjlim(vdbs, *(ckt->CKTstate0 + here->BSIM4vdbs),                                        CONSTvt0, model->BSIM4vcrit, &Check1);                       vdbd = vdbs - vds;                       vsbs = DEVpnjlim(vsbs, *(ckt->CKTstate0 + here->BSIM4vsbs),                                        CONSTvt0, model->BSIM4vcrit, &Check2);                       if ((Check1 == 0) && (Check2 == 0))                           Check = 0;                       else                            Check = 1;                   }               }	       else               {   vbd = DEVpnjlim(vbd, *(ckt->CKTstate0 + here->BSIM4vbd),                                   CONSTvt0, model->BSIM4vcrit, &Check);                    vbs = vbd + vds;                   if (here->BSIM4rbodyMod)                   {   vdbd = DEVpnjlim(vdbd, *(ckt->CKTstate0 + here->BSIM4vdbd),                                        CONSTvt0, model->BSIM4vcrit, &Check1);                       vdbs = vdbd + vds;                       vsbdo = *(ckt->CKTstate0 + here->BSIM4vsbs)                             - *(ckt->CKTstate0 + here->BSIM4vds);                       vsbd = vsbs - vds;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -