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

📄 mos1load.c

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 C
📖 第 1 页 / 共 3 页
字号:
		  vds = *(ckt->CKTstate0 + here->MOS1vds);		  vgd = vgs - vds;		  vgb = vgs - vbs;		  cdrain = here->MOS1mode * (here->MOS1cd + here->MOS1cbd);		  if(ckt->CKTmode & (MODETRAN | MODETRANOP)) {		    capgs = ( *(ckt->CKTstate0+here->MOS1capgs)+ 			      *(ckt->CKTstate1+here->MOS1capgs) +			      GateSourceOverlapCap );		    capgd = ( *(ckt->CKTstate0+here->MOS1capgd)+ 			      *(ckt->CKTstate1+here->MOS1capgd) +			      GateDrainOverlapCap );		    capgb = ( *(ckt->CKTstate0+here->MOS1capgb)+ 			      *(ckt->CKTstate1+here->MOS1capgb) +			      GateBulkOverlapCap );		    		    if(ckt->CKTsenInfo){		      here->MOS1cgs = capgs;		      here->MOS1cgd = capgd;		      here->MOS1cgb = capgb;		    }		  }		  goto bypass;		}#endif /*NOBYPASS*//*  */                /* ok - bypass is out, do it the hard way */                von = model->MOS1type * here->MOS1von;#ifndef NODELIMITING                /*                  * limiting                 *  we want to keep device voltages from changing                 * so fast that the exponentials churn out overflows                 * and similar rudeness                 */                if(*(ckt->CKTstate0 + here->MOS1vds) >=0) {                    vgs = DEVfetlim(vgs,*(ckt->CKTstate0 + here->MOS1vgs)				    ,von);                    vds = vgs - vgd;                    vds = DEVlimvds(vds,*(ckt->CKTstate0 + here->MOS1vds));                    vgd = vgs - vds;                } else {                    vgd = DEVfetlim(vgd,vgdo,von);                    vds = vgs - vgd;                    if(!(ckt->CKTfixLimit)) {                        vds = -DEVlimvds(-vds,-(*(ckt->CKTstate0 + 						  here->MOS1vds)));                    }                    vgs = vgd + vds;                }                if(vds >= 0) {                    vbs = DEVpnjlim(vbs,*(ckt->CKTstate0 + here->MOS1vbs),				    vt,here->MOS1sourceVcrit,&Check);                    vbd = vbs-vds;                } else {                    vbd = DEVpnjlim(vbd,*(ckt->CKTstate0 + here->MOS1vbd),				    vt,here->MOS1drainVcrit,&Check);                    vbs = vbd + vds;                }#endif /*NODELIMITING*//*  */            } else {                /* ok - not one of the simple cases, so we have to                 * look at all of the possibilities for why we were                 * called.  We still just initialize the three voltages                 */                if((ckt->CKTmode & MODEINITJCT) && !here->MOS1off) {                    vds= model->MOS1type * here->MOS1icVDS;                    vgs= model->MOS1type * here->MOS1icVGS;                    vbs= model->MOS1type * here->MOS1icVBS;                    if((vds==0) && (vgs==0) && (vbs==0) && 		       ((ckt->CKTmode & 			 (MODETRAN|MODEDCOP|MODEDCTRANCURVE)) ||			(!(ckt->CKTmode & MODEUIC)))) {                        vbs = -1;                        vgs = model->MOS1type * here->MOS1tVto;                        vds = 0;                    }                } else {                    vbs=vgs=vds=0;                }             }/*  */            /*             * now all the preliminaries are over - we can start doing the             * real work             */            vbd = vbs - vds;            vgd = vgs - vds;            vgb = vgs - vbs;            /*             * bulk-source and bulk-drain diodes             *   here we just evaluate the ideal diode current and the             *   corresponding derivative (conductance).             */next1:      if(vbs <= -3*vt) {                here->MOS1gbs = ckt->CKTgmin;                here->MOS1cbs = here->MOS1gbs*vbs-SourceSatCur;            } else {                evbs = exp(MIN(MAX_EXP_ARG,vbs/vt));                here->MOS1gbs = SourceSatCur*evbs/vt + ckt->CKTgmin;                here->MOS1cbs = SourceSatCur*(evbs-1) + ckt->CKTgmin*vbs;            }            if(vbd <= -3*vt) {                here->MOS1gbd = ckt->CKTgmin;                here->MOS1cbd = here->MOS1gbd*vbd-DrainSatCur;            } else {                evbd = exp(MIN(MAX_EXP_ARG,vbd/vt));                here->MOS1gbd = DrainSatCur*evbd/vt + ckt->CKTgmin;                here->MOS1cbd = DrainSatCur*(evbd-1) + ckt->CKTgmin*vbd;            }            /* now to determine whether the user was able to correctly             * identify the source and drain of his device             */            if(vds >= 0) {                /* normal mode */                here->MOS1mode = 1;            } else {                /* inverse mode */                here->MOS1mode = -1;            }/*  */            {		/*		 *     this block of code evaluates the drain current and its 		 *     derivatives using the shichman-hodges model and the 		 *     charges associated with the gate, channel and bulk for 		 *     mosfets		 *		 */		/* the following 4 variables are local to this code block until 		 * it is obvious that they can be made global 		 */		double arg;		double betap;		double sarg;		double vgst;                if ((here->MOS1mode==1?vbs:vbd) <= 0 ) {                    sarg=sqrt(here->MOS1tPhi-(here->MOS1mode==1?vbs:vbd));                } else {                    sarg=sqrt(here->MOS1tPhi);                    sarg=sarg-(here->MOS1mode==1?vbs:vbd)/(sarg+sarg);                    sarg=MAX(0,sarg);                }                von=(here->MOS1tVbi*model->MOS1type)+model->MOS1gamma*sarg;                vgst=(here->MOS1mode==1?vgs:vgd)-von;                vdsat=MAX(vgst,0);                if (sarg <= 0) {                    arg=0;                } else {                    arg=model->MOS1gamma/(sarg+sarg);                }                if (vgst <= 0) {                    /*                     *     cutoff region                     */                    cdrain=0;                    here->MOS1gm=0;                    here->MOS1gds=0;                    here->MOS1gmbs=0;                } else{                    /*                     *     saturation region                     */                    betap=Beta*(1+model->MOS1lambda*(vds*here->MOS1mode));                    if (vgst <= (vds*here->MOS1mode)){                        cdrain=betap*vgst*vgst*.5;                        here->MOS1gm=betap*vgst;                        here->MOS1gds=model->MOS1lambda*Beta*vgst*vgst*.5;                        here->MOS1gmbs=here->MOS1gm*arg;                    } else {			/*			 *     linear region			 */                        cdrain=betap*(vds*here->MOS1mode)*                            (vgst-.5*(vds*here->MOS1mode));                        here->MOS1gm=betap*(vds*here->MOS1mode);                        here->MOS1gds=betap*(vgst-(vds*here->MOS1mode))+			    model->MOS1lambda*Beta*			    (vds*here->MOS1mode)*			    (vgst-.5*(vds*here->MOS1mode));                        here->MOS1gmbs=here->MOS1gm*arg;                    }                }                /*                 *     finished                 */            }/*  */            /* now deal with n vs p polarity */            here->MOS1von = model->MOS1type * von;            here->MOS1vdsat = model->MOS1type * vdsat;            /* line 490 */            /*             *  COMPUTE EQUIVALENT DRAIN CURRENT SOURCE             */            here->MOS1cd=here->MOS1mode * cdrain - here->MOS1cbd;            if (ckt->CKTmode & (MODETRAN | MODETRANOP | MODEINITSMSIG)) {                /*                  * now we do the hard part of the bulk-drain and bulk-source                 * diode - we evaluate the non-linear capacitance and                 * charge                 *                 * the basic equations are not hard, but the implementation                 * is somewhat long in an attempt to avoid log/exponential                 * evaluations                 */                /*                 *  charge storage elements                 *                 *.. bulk-drain and bulk-source depletion capacitances                 */#ifdef CAPBYPASS                if(((ckt->CKTmode & (MODEINITPRED | MODEINITTRAN) ) ||                        fabs(delvbs) >= ckt->CKTreltol * MAX(fabs(vbs),                        fabs(*(ckt->CKTstate0+here->MOS1vbs)))+                        ckt->CKTvoltTol)|| senflag)#endif /*CAPBYPASS*/		                 {                    /* can't bypass the diode capacitance calculations */#ifdef CAPZEROBYPASS		                        if(here->MOS1Cbs != 0 || here->MOS1Cbssw != 0 ) {#endif /*CAPZEROBYPASS*/		    			if (vbs < here->MOS1tDepCap){			    arg=1-vbs/here->MOS1tBulkPot;			    /*			     * the following block looks somewhat long and messy,			     * but since most users use the default grading			     * coefficients of .5, and sqrt is MUCH faster than an			     * exp(log()) we use this special case code to buy time.			     * (as much as 10% of total job time!)			     */#ifndef NOSQRT			    if(model->MOS1bulkJctBotGradingCoeff ==			       model->MOS1bulkJctSideGradingCoeff) {				if(model->MOS1bulkJctBotGradingCoeff == .5) {				    sarg = sargsw = 1/sqrt(arg);				} else {				    sarg = sargsw =                                        exp(-model->MOS1bulkJctBotGradingCoeff*					    log(arg));				}			    } else {				if(model->MOS1bulkJctBotGradingCoeff == .5) {				    sarg = 1/sqrt(arg);				} else {#endif /*NOSQRT*/				    sarg = exp(-model->MOS1bulkJctBotGradingCoeff*					       log(arg));#ifndef NOSQRT				}				if(model->MOS1bulkJctSideGradingCoeff == .5) {				    sargsw = 1/sqrt(arg);				} else {#endif /*NOSQRT*/				    sargsw =exp(-model->MOS1bulkJctSideGradingCoeff*						log(arg));#ifndef NOSQRT				}			    }#endif /*NOSQRT*/			    *(ckt->CKTstate0 + here->MOS1qbs) =				here->MOS1tBulkPot*(here->MOS1Cbs*						    (1-arg*sarg)/(1-model->MOS1bulkJctBotGradingCoeff)						    +here->MOS1Cbssw*						    (1-arg*sargsw)/						    (1-model->MOS1bulkJctSideGradingCoeff));			    here->MOS1capbs=here->MOS1Cbs*sarg+                                here->MOS1Cbssw*sargsw;			} else {			    *(ckt->CKTstate0 + here->MOS1qbs) = here->MOS1f4s +                                vbs*(here->MOS1f2s+vbs*(here->MOS1f3s/2));			    here->MOS1capbs=here->MOS1f2s+here->MOS1f3s*vbs;			}#ifdef CAPZEROBYPASS						                    } else {			*(ckt->CKTstate0 + here->MOS1qbs) = 0;                        here->MOS1capbs=0;                    }#endif /*CAPZEROBYPASS*/		                    }#ifdef CAPBYPASS                    if(((ckt->CKTmode & (MODEINITPRED | MODEINITTRAN) ) ||                        fabs(delvbd) >= ckt->CKTreltol * MAX(fabs(vbd),                        fabs(*(ckt->CKTstate0+here->MOS1vbd)))+                        ckt->CKTvoltTol)|| senflag)#endif /*CAPBYPASS*/		    		                    /* can't bypass the diode capacitance calculations */                {#ifdef CAPZEROBYPASS					                    if(here->MOS1Cbd != 0 || here->MOS1Cbdsw != 0 ) {#endif /*CAPZEROBYPASS*/		    		    

⌨️ 快捷键说明

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