📄 mos1dset.c
字号:
/* * COMPUTE EQUIVALENT DRAIN CURRENT SOURCE */ /* * 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 */ 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*/ /* lcapbs=here->MOS1Cbs*sarg+ here->MOS1Cbssw*sargsw; */ lcapbs2 = model->MOS1type*0.5/here->MOS1tBulkPot*( here->MOS1Cbs*model->MOS1bulkJctBotGradingCoeff* sarg/arg + here->MOS1Cbssw* model->MOS1bulkJctSideGradingCoeff*sargsw/arg); lcapbs3 = here->MOS1Cbs*sarg* model->MOS1bulkJctBotGradingCoeff* (model->MOS1bulkJctBotGradingCoeff+1); lcapbs3 += here->MOS1Cbssw*sargsw* model->MOS1bulkJctSideGradingCoeff* (model->MOS1bulkJctSideGradingCoeff+1); lcapbs3 = lcapbs3/(6*here->MOS1tBulkPot* here->MOS1tBulkPot*arg*arg); } else { /* *(ckt->CKTstate0 + here->MOS1qbs)= here->MOS1f4s + vbs*(here->MOS1f2s+vbs*(here->MOS1f3s/2));*/ /* lcapbs=here->MOS1f2s+here->MOS1f3s*vbs; */ lcapbs2 = 0.5*here->MOS1f3s; lcapbs3 = 0; } 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*/ 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*/ /* lcapbd=here->MOS1Cbd*sarg+ here->MOS1Cbdsw*sargsw; */ lcapbd2 = model->MOS1type*0.5/here->MOS1tBulkPot*( here->MOS1Cbd*model->MOS1bulkJctBotGradingCoeff* sarg/arg + here->MOS1Cbdsw* model->MOS1bulkJctSideGradingCoeff*sargsw/arg); lcapbd3 = here->MOS1Cbd*sarg* model->MOS1bulkJctBotGradingCoeff* (model->MOS1bulkJctBotGradingCoeff+1); lcapbd3 += here->MOS1Cbdsw*sargsw* model->MOS1bulkJctSideGradingCoeff* (model->MOS1bulkJctSideGradingCoeff+1); lcapbd3 = lcapbd3/(6*here->MOS1tBulkPot* here->MOS1tBulkPot*arg*arg); } else { /* lcapbd=here->MOS1f2d + vbd * here->MOS1f3d; */ lcapbd2=0.5*here->MOS1f3d; lcapbd3=0; } /* * meyer's capacitor model */ /* * the meyer capacitance equations are in DEVqmeyer * these expressions are derived from those equations. * these expressions are incorrect; they assume just one * controlling variable for each charge storage element * while actually there are several; the MOS1 small * signal ac linear model is also wrong because it * ignores controlled capacitive elements. these can be * corrected (as can the linear ss ac model) if the * expressions for the charge are available */ { double phi; double cox; double vddif; double vddif1; double vddif2; /* von, vgst and vdsat have already been adjusted for possible source-drain interchange */ phi = here->MOS1tPhi; cox = OxideCap; if (vgst <= -phi) { lcapgb2=lcapgb3=lcapgs2=lcapgs3=lcapgd2=lcapgd3=0; } else if (vgst <= -phi/2) { lcapgb2= -cox/(4*phi); lcapgb3=lcapgs2=lcapgs3=lcapgd2=lcapgd3=0; } else if (vgst <= 0) { lcapgb2= -cox/(4*phi); lcapgb3=lcapgs3=lcapgd2=lcapgd3=0; lcapgs2 = cox/(3*phi); } else { /* the MOS1modes are around because vds has not been adjusted */ if (vdsat <= here->MOS1mode*vds) { lcapgb2=lcapgb3=lcapgs2=lcapgs3=lcapgd2=lcapgd3=0; } else { vddif = 2.0*vdsat-here->MOS1mode*vds; vddif1 = vdsat-here->MOS1mode*vds/*-1.0e-12*/; vddif2 = vddif*vddif; lcapgd2 = -vdsat*here->MOS1mode*vds*cox/(3*vddif*vddif2); lcapgd3 = - here->MOS1mode*vds*cox*(vddif - 6*vdsat)/(9*vddif2*vddif2); lcapgs2 = -vddif1*here->MOS1mode*vds*cox/(3*vddif*vddif2); lcapgs3 = - here->MOS1mode*vds*cox*(vddif - 6*vddif1)/(9*vddif2*vddif2); lcapgb2=lcapgb3=0; } } } /* the b-s and b-d diodes need no processing ... */ here->capbs2 = lcapbs2; here->capbs3 = lcapbs3; here->capbd2 = lcapbd2; here->capbd3 = lcapbd3; here->gbs2 = lgbs2; here->gbs3 = lgbs3; here->gbd2 = lgbd2; here->gbd3 = lgbd3; here->capgb2 = model->MOS1type*lcapgb2; here->capgb3 = lcapgb3; /* * process to get Taylor coefficients, taking into * account type and mode. */ if (here->MOS1mode == 1) { /* normal mode - no source-drain interchange */ here->cdr_x2 = gm2; here->cdr_y2 = gb2;; here->cdr_z2 = gds2;; here->cdr_xy = gmb; here->cdr_yz = gbds; here->cdr_xz = gmds; here->cdr_x3 = gm3; here->cdr_y3 = gb3; here->cdr_z3 = gds3; here->cdr_x2z = gm2ds; here->cdr_x2y = gm2b; here->cdr_y2z = gb2ds; here->cdr_xy2 = gmb2; here->cdr_xz2 = gmds2; here->cdr_yz2 = gbds2; here->cdr_xyz = gmbds; /* the gate caps have been divided and made into Taylor coeffs., but not adjusted for type */ here->capgs2 = model->MOS1type*lcapgs2; here->capgs3 = lcapgs3; here->capgd2 = model->MOS1type*lcapgd2; here->capgd3 = lcapgd3;} else { /* * inverse mode - source and drain interchanged */here->cdr_x2 = -gm2;here->cdr_y2 = -gb2;here->cdr_z2 = -(gm2 + gb2 + gds2 + 2*(gmb + gmds + gbds));here->cdr_xy = -gmb;here->cdr_yz = gmb + gb2 + gbds;here->cdr_xz = gm2 + gmb + gmds;here->cdr_x3 = -gm3;here->cdr_y3 = -gb3;here->cdr_z3 = gm3 + gb3 + gds3 + 3*(gm2b + gm2ds + gmb2 + gb2ds + gmds2 + gbds2) + 6*gmbds ;here->cdr_x2z = gm3 + gm2b + gm2ds;here->cdr_x2y = -gm2b;here->cdr_y2z = gmb2 + gb3 + gb2ds;here->cdr_xy2 = -gmb2;here->cdr_xz2 = -(gm3 + 2*(gm2b + gm2ds + gmbds) + gmb2 + gmds2);here->cdr_yz2 = -(gb3 + 2*(gmb2 + gb2ds + gmbds) + gm2b + gbds2);here->cdr_xyz = gm2b + gmb2 + gmbds; here->capgs2 = model->MOS1type*lcapgd2; here->capgs3 = lcapgd3; here->capgd2 = model->MOS1type*lcapgs2; here->capgd3 = lcapgs3;}/* now to adjust for type and multiply by factors to convert to Taylor coeffs. */here->cdr_x2 = 0.5*model->MOS1type*here->cdr_x2;here->cdr_y2 = 0.5*model->MOS1type*here->cdr_y2;here->cdr_z2 = 0.5*model->MOS1type*here->cdr_z2;here->cdr_xy = model->MOS1type*here->cdr_xy;here->cdr_yz = model->MOS1type*here->cdr_yz;here->cdr_xz = model->MOS1type*here->cdr_xz;here->cdr_x3 = here->cdr_x3/6.;here->cdr_y3 = here->cdr_y3/6.;here->cdr_z3 = here->cdr_z3/6.;here->cdr_x2z = 0.5*here->cdr_x2z;here->cdr_x2y = 0.5*here->cdr_x2y;here->cdr_y2z = 0.5*here->cdr_y2z;here->cdr_xy2 = 0.5*here->cdr_xy2;here->cdr_xz2 = 0.5*here->cdr_xz2;here->cdr_yz2 = 0.5*here->cdr_yz2; } } return(OK); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -