📄 mos1load.c
字号:
} } goto bypass; }#endif /*NOBYPASS*//**/#ifdef DETAILPROFasm(" .globl mosptc");asm("mosptc:");#endif /*DETAILPROF*/ /* 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*//**/#ifdef DETAILPROFasm(" .globl mosptd");asm("mosptd:");#endif /*DETAILPROF*/ } 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; } }/**/#ifdef DETAILPROFasm(" .globl mospte");asm("mospte:");#endif /*DETAILPROF*/ /* * 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 <= 0) { here->MOS1gbs = SourceSatCur/vt; here->MOS1cbs = here->MOS1gbs*vbs; here->MOS1gbs += ckt->CKTgmin; } else { evbs = exp(MIN(MAX_EXP_ARG,vbs/vt)); here->MOS1gbs = SourceSatCur*evbs/vt + ckt->CKTgmin; here->MOS1cbs = SourceSatCur * (evbs-1); } if(vbd <= 0) { here->MOS1gbd = DrainSatCur/vt; here->MOS1cbd = here->MOS1gbd *vbd; here->MOS1gbd += ckt->CKTgmin; } else { evbd = exp(MIN(MAX_EXP_ARG,vbd/vt)); here->MOS1gbd = DrainSatCur*evbd/vt +ckt->CKTgmin; here->MOS1cbd = DrainSatCur *(evbd-1); } /* 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; }/**/#ifdef DETAILPROFasm(" .globl mosptf");asm("mosptf:");#endif /*DETAILPROF*/ { /* * 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 */ }/**/#ifdef DETAILPROFasm(" .globl mosptg");asm("mosptg:");#endif /*DETAILPROF*/ /* 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*/ if (vbd < here->MOS1tDepCap) { arg=1-vbd/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 == .5 && model->MOS1bulkJctSideGradingCoeff == .5) { sarg = sargsw = 1/sqrt(arg); } else { if(model->MOS1bulkJctBotGradingCoeff == .5) { sarg = 1/sqrt(arg); } else {#endif /*NOSQRT*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -