1 /********** 2 Copyright 1990 Regents of the University of California. All rights reserved. 3 Author: 1985 Thomas L. Quarles 4 Modified: 2000 AlansFIxes 5 **********/ 6 7 #ifndef MOS2 8 #define MOS2 9 10 #include "ngspice/ifsim.h" 11 #include "ngspice/cktdefs.h" 12 #include "ngspice/gendefs.h" 13 #include "ngspice/complex.h" 14 #include "ngspice/noisedef.h" 15 16 /* declarations for level 2 MOSFETs */ 17 18 /* indices to the array of MOSFET(2) noise sources */ 19 20 enum { 21 MOS2RDNOIZ = 0, 22 MOS2RSNOIZ, 23 MOS2IDNOIZ, 24 MOS2FLNOIZ, 25 MOS2TOTNOIZ, 26 /* finally, the number of noise sources */ 27 MOS2NSRCS 28 }; 29 30 /* information needed for each instance */ 31 32 typedef struct sMOS2instance { 33 34 struct GENinstance gen; 35 36 #define MOS2modPtr(inst) ((struct sMOS2model *)((inst)->gen.GENmodPtr)) 37 #define MOS2nextInstance(inst) ((struct sMOS2instance *)((inst)->gen.GENnextInstance)) 38 #define MOS2name gen.GENname 39 #define MOS2states gen.GENstate 40 41 const int MOS2dNode; /* number of the gate node of the mosfet */ 42 const int MOS2gNode; /* number of the gate node of the mosfet */ 43 const int MOS2sNode; /* number of the source node of the mosfet */ 44 const int MOS2bNode; /* number of the bulk node of the mosfet */ 45 int MOS2dNodePrime; /* number of the internal drain node of the mosfet */ 46 int MOS2sNodePrime; /* number of the internal source node of the mosfet */ 47 48 49 int MOS2mode; /* device mode : 1 = normal, -1 = inverse */ 50 51 unsigned MOS2mGiven :1; 52 53 unsigned MOS2off :1;/* non-zero to indicate device is off for dc analysis*/ 54 unsigned MOS2lGiven :1; 55 unsigned MOS2wGiven :1; 56 unsigned MOS2drainAreaGiven :1; 57 unsigned MOS2sourceAreaGiven :1; 58 unsigned MOS2drainSquaresGiven :1; 59 unsigned MOS2sourceSquaresGiven :1; 60 unsigned MOS2drainPerimiterGiven :1; 61 unsigned MOS2sourcePerimiterGiven :1; 62 unsigned MOS2dNodePrimeSet :1; 63 unsigned MOS2sNodePrimeSet :1; 64 unsigned MOS2icVBSGiven :1; 65 unsigned MOS2icVDSGiven :1; 66 unsigned MOS2icVGSGiven :1; 67 unsigned MOS2vonGiven :1; 68 unsigned MOS2vdsatGiven :1; 69 unsigned MOS2tempGiven :1; /* per-instance temperature specified? */ 70 unsigned MOS2dtempGiven :1; /* per-instance temperature difference specified? */ 71 unsigned MOS2sens_l :1; /* field which indicates whether 72 length of the mosfet is a design 73 parameter or not */ 74 unsigned MOS2sens_w :1; /* field which indicates whether 75 width of the mosfet is a design 76 parameter or not */ 77 unsigned MOS2senPertFlag :1; /* indictes whether the the parameter of 78 the particular instance is to be perturbed */ 79 80 81 double *MOS2DdPtr; /* pointer to sparse matrix element at 82 * (Drain node,drain node) */ 83 double *MOS2GgPtr; /* pointer to sparse matrix element at 84 * (gate node,gate node) */ 85 double *MOS2SsPtr; /* pointer to sparse matrix element at 86 * (source node,source node) */ 87 double *MOS2BbPtr; /* pointer to sparse matrix element at 88 * (bulk node,bulk node) */ 89 double *MOS2DPdpPtr; /* pointer to sparse matrix element at 90 * (drain prime node,drain prime node) */ 91 double *MOS2SPspPtr; /* pointer to sparse matrix element at 92 * (source prime node,source prime node) */ 93 double *MOS2DdpPtr; /* pointer to sparse matrix element at 94 * (drain node,drain prime node) */ 95 double *MOS2GbPtr; /* pointer to sparse matrix element at 96 * (gate node,bulk node) */ 97 double *MOS2GdpPtr; /* pointer to sparse matrix element at 98 * (gate node,drain prime node) */ 99 double *MOS2GspPtr; /* pointer to sparse matrix element at 100 * (gate node,source prime node) */ 101 double *MOS2SspPtr; /* pointer to sparse matrix element at 102 * (source node,source prime node) */ 103 double *MOS2BdpPtr; /* pointer to sparse matrix element at 104 * (bulk node,drain prime node) */ 105 double *MOS2BspPtr; /* pointer to sparse matrix element at 106 * (bulk node,source prime node) */ 107 double *MOS2DPspPtr; /* pointer to sparse matrix element at 108 * (drain prime node,source prime node) */ 109 double *MOS2DPdPtr; /* pointer to sparse matrix element at 110 * (drain prime node,drain node) */ 111 double *MOS2BgPtr; /* pointer to sparse matrix element at 112 * (bulk node,gate node) */ 113 double *MOS2DPgPtr; /* pointer to sparse matrix element at 114 * (drain prime node,gate node) */ 115 116 double *MOS2SPgPtr; /* pointer to sparse matrix element at 117 * (source prime node,gate node) */ 118 double *MOS2SPsPtr; /* pointer to sparse matrix element at 119 * (source prime node,source node) */ 120 double *MOS2DPbPtr; /* pointer to sparse matrix element at 121 * (drain prime node,bulk node) */ 122 double *MOS2SPbPtr; /* pointer to sparse matrix element at 123 * (source prime node,bulk node) */ 124 double *MOS2SPdpPtr; /* pointer to sparse matrix element at 125 * (source prime node,drain prime node) */ 126 int MOS2senParmNo; /* parameter # for sensitivity use; 127 set equal to 0 if neither length 128 nor width of the mosfet is a design 129 parameter */ 130 double MOS2cgs; 131 double MOS2cgd; 132 double MOS2cgb; 133 double *MOS2sens; 134 135 #define MOS2senCgs MOS2sens /* contains pertured values of cgs */ 136 #define MOS2senCgd MOS2sens + 6 /* contains perturbed values of cgd*/ 137 #define MOS2senCgb MOS2sens + 12 /* contains perturbed values of cgb*/ 138 #define MOS2senCbd MOS2sens + 18 /* contains perturbed values of cbd*/ 139 #define MOS2senCbs MOS2sens + 24 /* contains perturbed values of cbs*/ 140 #define MOS2senGds MOS2sens + 30 /* contains perturbed values of gds*/ 141 #define MOS2senGbs MOS2sens + 36 /* contains perturbed values of gbs*/ 142 #define MOS2senGbd MOS2sens + 42 /* contains perturbed values of gbd*/ 143 #define MOS2senGm MOS2sens + 48 /* contains perturbed values of gm*/ 144 #define MOS2senGmbs MOS2sens + 54 /* contains perturbed values of gmbs*/ 145 #define MOS2dphigs_dl MOS2sens + 60 146 #define MOS2dphigd_dl MOS2sens + 61 147 #define MOS2dphigb_dl MOS2sens + 62 148 #define MOS2dphibs_dl MOS2sens + 63 149 #define MOS2dphibd_dl MOS2sens + 64 150 #define MOS2dphigs_dw MOS2sens + 65 151 #define MOS2dphigd_dw MOS2sens + 66 152 #define MOS2dphigb_dw MOS2sens + 67 153 #define MOS2dphibs_dw MOS2sens + 68 154 #define MOS2dphibd_dw MOS2sens + 69 155 156 double MOS2temp; /* temperature at which this instance operates */ 157 double MOS2dtemp; /* difference of instance temperature from circuit temperature */ 158 double MOS2tTransconductance; /* temperature corrected transconductance*/ 159 double MOS2tSurfMob; /* temperature corrected surface mobility */ 160 double MOS2tPhi; /* temperature corrected Phi */ 161 double MOS2tVto; /* temperature corrected Vto */ 162 double MOS2tSatCur; /* temperature corrected saturation Cur. */ 163 double MOS2tSatCurDens; /* temperature corrected saturation Cur. density*/ 164 double MOS2tCbd; /* temperature corrected B-D Capacitance */ 165 double MOS2tCbs; /* temperature corrected B-S Capacitance */ 166 double MOS2tCj; /* temperature corrected Bulk bottom Capacitance */ 167 double MOS2tCjsw; /* temperature corrected Bulk side Capacitance */ 168 double MOS2tBulkPot; /* temperature corrected Bulk potential */ 169 double MOS2tDepCap; /* temperature adjusted transition point in */ 170 /* the cureve matching Fc * Vj */ 171 double MOS2tVbi; /* temperature adjusted Vbi */ 172 173 double MOS2m; /* parallel device multiplier */ 174 175 double MOS2l; /* the length of the channel region */ 176 double MOS2w; /* the width of the channel region */ 177 double MOS2drainArea; /* the area of the drain diffusion */ 178 double MOS2sourceArea; /* the area of the source diffusion */ 179 double MOS2drainSquares; /* the length of the drain in squares */ 180 double MOS2sourceSquares; /* the length of the source in squares */ 181 double MOS2drainPerimiter; 182 double MOS2sourcePerimiter; 183 double MOS2sourceConductance; /*conductance of source(or 0):set in setup*/ 184 double MOS2drainConductance; /*conductance of drain(or 0):set in setup*/ 185 186 double MOS2icVBS; /* initial condition B-S voltage */ 187 double MOS2icVDS; /* initial condition D-S voltage */ 188 double MOS2icVGS; /* initial condition G-S voltage */ 189 double MOS2von; 190 double MOS2vdsat; 191 double MOS2sourceVcrit; /* Vcrit for pos. vds */ 192 double MOS2drainVcrit; /* Vcrit for pos. vds */ 193 double MOS2cd; 194 double MOS2cbs; 195 double MOS2cbd; 196 double MOS2gmbs; 197 double MOS2gm; 198 double MOS2gds; 199 double MOS2gbd; 200 double MOS2gbs; 201 double MOS2capbd; 202 double MOS2capbs; 203 double MOS2Cbd; 204 double MOS2Cbdsw; 205 double MOS2Cbs; 206 double MOS2Cbssw; 207 double MOS2f2d; 208 double MOS2f3d; 209 double MOS2f4d; 210 double MOS2f2s; 211 double MOS2f3s; 212 double MOS2f4s; 213 214 /* distortion stuff */ 215 /* 216 * naming convention: 217 * x = vgs 218 * y = vbs 219 * z = vds 220 * cdr = cdrain 221 */ 222 223 224 225 #define MOS2NDCOEFFS 30 226 227 #ifndef NODISTO 228 double MOS2dCoeffs[MOS2NDCOEFFS]; 229 #else /* NODISTO */ 230 double *MOS2dCoeffs; 231 #endif /* NODISTO */ 232 233 #ifndef CONFIG 234 235 #define capbs2 MOS2dCoeffs[0] 236 #define capbs3 MOS2dCoeffs[1] 237 #define capbd2 MOS2dCoeffs[2] 238 #define capbd3 MOS2dCoeffs[3] 239 #define gbs2 MOS2dCoeffs[4] 240 #define gbs3 MOS2dCoeffs[5] 241 #define gbd2 MOS2dCoeffs[6] 242 #define gbd3 MOS2dCoeffs[7] 243 #define capgb2 MOS2dCoeffs[8] 244 #define capgb3 MOS2dCoeffs[9] 245 #define cdr_x2 MOS2dCoeffs[10] 246 #define cdr_y2 MOS2dCoeffs[11] 247 #define cdr_z2 MOS2dCoeffs[12] 248 #define cdr_xy MOS2dCoeffs[13] 249 #define cdr_yz MOS2dCoeffs[14] 250 #define cdr_xz MOS2dCoeffs[15] 251 #define cdr_x3 MOS2dCoeffs[16] 252 #define cdr_y3 MOS2dCoeffs[17] 253 #define cdr_z3 MOS2dCoeffs[18] 254 #define cdr_x2z MOS2dCoeffs[19] 255 #define cdr_x2y MOS2dCoeffs[20] 256 #define cdr_y2z MOS2dCoeffs[21] 257 #define cdr_xy2 MOS2dCoeffs[22] 258 #define cdr_xz2 MOS2dCoeffs[23] 259 #define cdr_yz2 MOS2dCoeffs[24] 260 #define cdr_xyz MOS2dCoeffs[25] 261 #define capgs2 MOS2dCoeffs[26] 262 #define capgs3 MOS2dCoeffs[27] 263 #define capgd2 MOS2dCoeffs[28] 264 #define capgd3 MOS2dCoeffs[29] 265 /* end distortion coeffs. */ 266 267 #endif 268 269 #ifndef NONOISE 270 double MOS2nVar[NSTATVARS][MOS2NSRCS]; 271 #else /* NONOISE */ 272 double **MOS2nVar; 273 #endif /* NONOISE */ 274 275 276 277 } MOS2instance ; 278 279 280 #define MOS2vbd MOS2states+ 0 /* bulk-drain voltage */ 281 #define MOS2vbs MOS2states+ 1 /* bulk-source voltage */ 282 #define MOS2vgs MOS2states+ 2 /* gate-source voltage */ 283 #define MOS2vds MOS2states+ 3 /* drain-source voltage */ 284 285 #define MOS2capgs MOS2states+4 /* gate-source capacitor value */ 286 #define MOS2qgs MOS2states+ 5 /* gate-source capacitor charge */ 287 #define MOS2cqgs MOS2states+ 6 /* gate-source capacitor current */ 288 289 #define MOS2capgd MOS2states+ 7 /* gate-drain capacitor value */ 290 #define MOS2qgd MOS2states+ 8 /* gate-drain capacitor charge */ 291 #define MOS2cqgd MOS2states+ 9 /* gate-drain capacitor current */ 292 293 #define MOS2capgb MOS2states+10 /* gate-bulk capacitor value */ 294 #define MOS2qgb MOS2states+ 11 /* gate-bulk capacitor charge */ 295 #define MOS2cqgb MOS2states+ 12 /* gate-bulk capacitor current */ 296 297 #define MOS2qbd MOS2states+ 13 /* bulk-drain capacitor charge */ 298 #define MOS2cqbd MOS2states+ 14 /* bulk-drain capacitor current */ 299 300 #define MOS2qbs MOS2states+ 15 /* bulk-source capacitor charge */ 301 #define MOS2cqbs MOS2states+ 16 /* bulk-source capacitor current */ 302 303 #define MOS2numStates 17 304 305 306 #define MOS2sensxpgs MOS2states+17 /* charge sensitivities and their derivatives 307 * +18 for the derivatives 308 * pointer to the beginning of the array */ 309 310 #define MOS2sensxpgd MOS2states+19 311 #define MOS2sensxpgb MOS2states+21 312 #define MOS2sensxpbs MOS2states+23 313 #define MOS2sensxpbd MOS2states+25 314 315 #define MOS2numSenStates 10 316 317 318 /* per model data */ 319 320 321 /* NOTE: parameters makred 'input - use xxxx' are parameters for 322 * which a temperature correction is applied in MOS2temp, thus 323 * the MOS3xxxx value in the per-instance structure should be used 324 * instead in all calculations 325 */ 326 327 typedef struct sMOS2model { /* model structure for a resistor */ 328 329 struct GENmodel gen; 330 331 #define MOS2modType gen.GENmodType 332 #define MOS2nextModel(inst) ((struct sMOS2model *)((inst)->gen.GENnextModel)) 333 #define MOS2instances(inst) ((MOS2instance *)((inst)->gen.GENinstances)) 334 #define MOS2modName gen.GENmodName 335 336 int MOS2type; /* device type : 1 = nmos, -1 = pmos */ 337 int MOS2gateType; 338 339 double MOS2tnom; /* temperature at which parms were measured */ 340 double MOS2latDiff; 341 double MOS2jctSatCurDensity; /* input - use tSatCurDens */ 342 double MOS2jctSatCur; /* input - use tSatCur */ 343 double MOS2drainResistance; 344 double MOS2sourceResistance; 345 double MOS2sheetResistance; 346 double MOS2transconductance; /* input - use tTransconductance */ 347 double MOS2gateSourceOverlapCapFactor; 348 double MOS2gateDrainOverlapCapFactor; 349 double MOS2gateBulkOverlapCapFactor; 350 double MOS2oxideCapFactor; 351 double MOS2vt0; /* input - use tVto */ 352 double MOS2capBD; /* input - use tCbd */ 353 double MOS2capBS; /* input - use tCbs */ 354 double MOS2bulkCapFactor; /* input - use tCj */ 355 double MOS2sideWallCapFactor; /* input - use tCjsw */ 356 double MOS2bulkJctPotential; /* input - use tBulkPot */ 357 double MOS2bulkJctBotGradingCoeff; 358 double MOS2bulkJctSideGradingCoeff; 359 double MOS2fwdCapDepCoeff; 360 double MOS2phi; /* input - use tPhi */ 361 double MOS2gamma; 362 double MOS2lambda; 363 double MOS2substrateDoping; 364 double MOS2surfaceStateDensity; 365 double MOS2fastSurfaceStateDensity; /* nfs */ 366 double MOS2oxideThickness; 367 double MOS2surfaceMobility; 368 double MOS2fNcoef; 369 double MOS2fNexp; 370 371 double MOS2narrowFactor; /* delta */ 372 double MOS2critFieldExp; /* uexp */ 373 double MOS2critField; /* ucrit */ 374 double MOS2maxDriftVel; /* vmax */ 375 double MOS2xd; 376 double MOS2junctionDepth; /* xj */ 377 double MOS2channelCharge; /* neff */ 378 379 unsigned MOS2tnomGiven :1; /* user specified parm. meas. temp */ 380 unsigned MOS2typeGiven :1; 381 unsigned MOS2latDiffGiven :1; 382 unsigned MOS2jctSatCurDensityGiven :1; 383 unsigned MOS2jctSatCurGiven :1; 384 unsigned MOS2drainResistanceGiven :1; 385 unsigned MOS2sourceResistanceGiven :1; 386 unsigned MOS2sheetResistanceGiven :1; 387 unsigned MOS2transconductanceGiven :1; 388 unsigned MOS2gateSourceOverlapCapFactorGiven :1; 389 unsigned MOS2gateDrainOverlapCapFactorGiven :1; 390 unsigned MOS2gateBulkOverlapCapFactorGiven :1; 391 unsigned MOS2vt0Given :1; 392 unsigned MOS2capBDGiven :1; 393 unsigned MOS2capBSGiven :1; 394 unsigned MOS2bulkCapFactorGiven :1; 395 unsigned MOS2sideWallCapFactorGiven :1; 396 unsigned MOS2bulkJctPotentialGiven :1; 397 unsigned MOS2bulkJctBotGradingCoeffGiven :1; 398 unsigned MOS2bulkJctSideGradingCoeffGiven :1; 399 unsigned MOS2fwdCapDepCoeffGiven :1; 400 unsigned MOS2phiGiven :1; 401 unsigned MOS2gammaGiven :1; 402 unsigned MOS2lambdaGiven :1; 403 unsigned MOS2substrateDopingGiven :1; 404 unsigned MOS2gateTypeGiven :1; 405 unsigned MOS2surfaceStateDensityGiven :1; 406 unsigned MOS2fastSurfaceStateDensityGiven :1; /* nfs */ 407 unsigned MOS2oxideThicknessGiven :1; 408 unsigned MOS2surfaceMobilityGiven :1; 409 unsigned MOS2narrowFactorGiven :1; /* delta */ 410 unsigned MOS2critFieldExpGiven :1; /* uexp */ 411 unsigned MOS2critFieldGiven :1; /* ucrit */ 412 unsigned MOS2maxDriftVelGiven :1; /* vmax */ 413 unsigned MOS2junctionDepthGiven :1; /* xj */ 414 unsigned MOS2channelChargeGiven :1; /* neff */ 415 unsigned MOS2fNcoefGiven :1; 416 unsigned MOS2fNexpGiven :1; 417 418 } MOS2model; 419 420 #ifndef NMOS 421 #define NMOS 1 422 #define PMOS -1 423 #endif /*NMOS*/ 424 425 /* device parameters */ 426 enum { 427 MOS2_W = 1, 428 MOS2_L, 429 MOS2_AS, 430 MOS2_AD, 431 MOS2_PS, 432 MOS2_PD, 433 MOS2_NRS, 434 MOS2_NRD, 435 MOS2_OFF, 436 MOS2_IC, 437 MOS2_IC_VBS, 438 MOS2_IC_VDS, 439 MOS2_IC_VGS, 440 MOS2_W_SENS, 441 MOS2_L_SENS, 442 MOS2_CB, 443 MOS2_CG, 444 MOS2_CS, 445 MOS2_POWER, 446 MOS2_CGS, 447 MOS2_CGD, 448 MOS2_DNODE, 449 MOS2_GNODE, 450 MOS2_SNODE, 451 MOS2_BNODE, 452 MOS2_DNODEPRIME, 453 MOS2_SNODEPRIME, 454 MOS2_SOURCECONDUCT, 455 MOS2_DRAINCONDUCT, 456 MOS2_VON, 457 MOS2_VDSAT, 458 MOS2_SOURCEVCRIT, 459 MOS2_DRAINVCRIT, 460 MOS2_CD, 461 MOS2_CBS, 462 MOS2_CBD, 463 MOS2_GMBS, 464 MOS2_GM, 465 MOS2_GDS, 466 MOS2_GBD, 467 MOS2_GBS, 468 MOS2_CAPBD, 469 MOS2_CAPBS, 470 MOS2_CAPZEROBIASBD, 471 MOS2_CAPZEROBIASBDSW, 472 MOS2_CAPZEROBIASBS, 473 MOS2_CAPZEROBIASBSSW, 474 MOS2_VBD, 475 MOS2_VBS, 476 MOS2_VGS, 477 MOS2_VDS, 478 MOS2_CAPGS, 479 MOS2_QGS, 480 MOS2_CQGS, 481 MOS2_CAPGD, 482 MOS2_QGD, 483 MOS2_CQGD, 484 MOS2_CAPGB, 485 MOS2_QGB, 486 MOS2_CQGB, 487 MOS2_QBD, 488 MOS2_CQBD, 489 MOS2_QBS, 490 MOS2_CQBS, 491 MOS2_W_SENS_REAL, 492 MOS2_W_SENS_IMAG, 493 MOS2_W_SENS_MAG, 494 MOS2_W_SENS_PH, 495 MOS2_W_SENS_CPLX, 496 MOS2_L_SENS_REAL, 497 MOS2_L_SENS_IMAG, 498 MOS2_L_SENS_MAG, 499 MOS2_L_SENS_PH, 500 MOS2_L_SENS_CPLX, 501 MOS2_L_SENS_DC, 502 MOS2_W_SENS_DC, 503 MOS2_TEMP, 504 MOS2_SOURCERESIST, 505 MOS2_DRAINRESIST, 506 MOS2_M, 507 MOS2_DTEMP, 508 }; 509 510 /* model paramerers */ 511 enum { 512 MOS2_MOD_VTO = 101, 513 MOS2_MOD_KP, 514 MOS2_MOD_GAMMA, 515 MOS2_MOD_PHI, 516 MOS2_MOD_LAMBDA, 517 MOS2_MOD_RD, 518 MOS2_MOD_RS, 519 MOS2_MOD_CBD, 520 MOS2_MOD_CBS, 521 MOS2_MOD_IS, 522 MOS2_MOD_PB, 523 MOS2_MOD_CGSO, 524 MOS2_MOD_CGDO, 525 MOS2_MOD_CGBO, 526 MOS2_MOD_CJ, 527 MOS2_MOD_MJ, 528 MOS2_MOD_CJSW, 529 MOS2_MOD_MJSW, 530 MOS2_MOD_JS, 531 MOS2_MOD_TOX, 532 MOS2_MOD_LD, 533 MOS2_MOD_RSH, 534 MOS2_MOD_U0, 535 MOS2_MOD_FC, 536 MOS2_MOD_NSUB, 537 MOS2_MOD_TPG, 538 MOS2_MOD_NSS, 539 MOS2_MOD_NFS, 540 MOS2_MOD_DELTA, 541 MOS2_MOD_UEXP, 542 MOS2_MOD_VMAX, 543 MOS2_MOD_XJ, 544 MOS2_MOD_NEFF, 545 MOS2_MOD_UCRIT, 546 MOS2_MOD_NMOS, 547 MOS2_MOD_PMOS, 548 MOS2_MOD_TNOM, 549 }; 550 551 enum { 552 MOS2_MOD_KF = 139, 553 MOS2_MOD_AF, 554 MOS2_MOD_TYPE, 555 }; 556 557 /* model questions */ 558 559 #include "mos2ext.h" 560 561 #endif /*MOS2*/ 562 563