1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Thomas L. Quarles
5 1989 Takayasu Sakurai
6 1993 Stephen R. Whiteley
7 ****************************************************************************/
8
9 #include "spice.h"
10 #include <stdio.h>
11 #include <math.h>
12 #include "mosdefs.h"
13 #include "const.h"
14 #include "sperror.h"
15 #include "util.h"
16 #include "cktext.h"
17
18
19 int
MOSsetup(matrix,inModel,ckt,states)20 MOSsetup(matrix,inModel,ckt,states)
21
22 SMPmatrix *matrix;
23 GENmodel *inModel;
24 CKTcircuit *ckt;
25 int *states;
26 /* load the MOS device structure with those pointers needed later
27 * for fast matrix loading
28 */
29 {
30 register MOSmodel *model = (MOSmodel *)inModel;
31 register MOSinstance *here;
32 int error;
33 CKTnode *tmp;
34
35 /* loop through all the MOS device models */
36 for( ; model != NULL; model = model->MOSnextModel ) {
37
38 if (!model->MOStypeGiven) {
39 model->MOStype = NMOS;
40 }
41
42 if (!model->MOSlevelGiven ||
43 (model->MOSlevel != 1 &&
44 model->MOSlevel != 2 &&
45 model->MOSlevel != 3 &&
46 model->MOSlevel != 6 &&
47 /* level 8, CryoMOS by Luong Huynh, 1/19/95 */
48 model->MOSlevel != 8)) {
49 model->MOSlevel = 1;
50 }
51
52 /* tnom */
53
54 /* vto */
55 if (!model->MOSvt0Given) {
56 model->MOSvt0 = 0;
57 }
58
59 /* kp */
60 if (!model->MOStransconductanceGiven) {
61 model->MOStransconductance = 2e-5;
62 }
63
64 /* gamma */
65 if (!model->MOSgammaGiven) {
66 model->MOSgamma = 0;
67 }
68
69 /* phi */
70 if (!model->MOSphiGiven) {
71 model->MOSphi = .6;
72 }
73
74 /* rd */
75 if (!model->MOSdrainResistanceGiven) {
76 model->MOSdrainResistance = 0;
77 }
78
79 /* rs */
80 if (!model->MOSsourceResistanceGiven) {
81 model->MOSsourceResistance = 0;
82 }
83
84 /* cbd */
85 if (!model->MOScapBDGiven) {
86 model->MOScapBD = 0;
87 }
88
89 /* cbs */
90 if (!model->MOScapBSGiven) {
91 model->MOScapBS = 0;
92 }
93
94 /* is */
95 if (!model->MOSjctSatCurGiven) {
96 model->MOSjctSatCur = 1e-14;
97 }
98
99 /* pb */
100 if (!model->MOSbulkJctPotentialGiven) {
101 model->MOSbulkJctPotential = .8;
102 }
103
104 /* cgso */
105 if (!model->MOSgateSourceOverlapCapFactorGiven) {
106 model->MOSgateSourceOverlapCapFactor = 0;
107 }
108
109 /* cgdo */
110 if (!model->MOSgateDrainOverlapCapFactorGiven) {
111 model->MOSgateDrainOverlapCapFactor = 0;
112 }
113
114 /* cgbo */
115 if (!model->MOSgateBulkOverlapCapFactorGiven) {
116 model->MOSgateBulkOverlapCapFactor = 0;
117 }
118
119 /* cj */
120 if (!model->MOSbulkCapFactorGiven) {
121 model->MOSbulkCapFactor = 0;
122 }
123
124 /* mj */
125 if (!model->MOSbulkJctBotGradingCoeffGiven) {
126 model->MOSbulkJctBotGradingCoeff = .5;
127 }
128
129 /* cjsw */
130 if (!model->MOSsideWallCapFactorGiven) {
131 model->MOSsideWallCapFactor = 0;
132 }
133
134 /* mjsw */
135 if (!model->MOSbulkJctSideGradingCoeffGiven) {
136 if (model->MOSlevel == 1 || model->MOSlevel == 6)
137 model->MOSbulkJctSideGradingCoeff = .5;
138 else
139 model->MOSbulkJctSideGradingCoeff = .33;
140 }
141
142 /* js */
143 if (!model->MOSjctSatCurDensityGiven) {
144 model->MOSjctSatCurDensity = 0;
145 }
146
147 /* tox */
148 if (!model->MOSoxideThicknessGiven) {
149 if (model->MOSlevel == 2 || model->MOSlevel == 3)
150 model->MOSoxideThickness = 1e-7;
151 else
152 model->MOSoxideThickness = 0;
153 }
154
155 /* ld */
156 if (!model->MOSlatDiffGiven) {
157 model->MOSlatDiff = 0;
158 }
159
160 /* rsh */
161 if (!model->MOSsheetResistanceGiven) {
162 model->MOSsheetResistance = 0;
163 }
164
165 /* u0 */
166
167 /* fc */
168 if (!model->MOSfwdCapDepCoeffGiven) {
169 model->MOSfwdCapDepCoeff = .5;
170 }
171
172 /* nss */
173 /* nsub */
174 /* tpg */
175
176 /* kf */
177 if (!model->MOSfNcoefGiven) {
178 model->MOSfNcoef = 0;
179 }
180
181 /* af */
182 if (!model->MOSfNexpGiven) {
183 model->MOSfNexp = 1;
184 }
185
186 /* lambda, 1,2 and 6*/
187 if (!model->MOSlambdaGiven) {
188 model->MOSlambda = 0;
189 }
190
191 /* uexp, 2 */
192 if (!model->MOScritFieldExpGiven) {
193 model->MOScritFieldExp = 0;
194 }
195
196 /* neff, 2 */
197 if (!model->MOSchannelChargeGiven) {
198 model->MOSchannelCharge = 1;
199 }
200
201 /* ucrit, 2 */
202 if (!model->MOScritFieldGiven) {
203 model->MOScritField = 1e4;
204 }
205
206 /* nfs, 2 and 3 */
207 if (!model->MOSfastSurfaceStateDensityGiven) {
208 model->MOSfastSurfaceStateDensity = 0;
209 }
210
211 /* delta, 2 and 3 */
212 if (!model->MOSdeltaGiven) {
213 model->MOSdelta = 0;
214 }
215 if (!model->MOSnarrowFactorGiven) {
216 model->MOSnarrowFactor = 0;
217 }
218
219 /* vmax, 2 and 3 */
220 if (!model->MOSmaxDriftVelGiven) {
221 model->MOSmaxDriftVel = 0;
222 }
223
224 /* xj, 2 and 3 */
225 if (!model->MOSjunctionDepthGiven) {
226 model->MOSjunctionDepth = 0;
227 }
228
229 /* eta, 3 */
230 if (!model->MOSetaGiven) {
231 model->MOSeta = 0;
232 }
233
234 /* theta, 3 */
235 if (!model->MOSthetaGiven) {
236 model->MOStheta = 0;
237 }
238
239 /* kappa, 3 */
240 if (!model->MOSkappaGiven) {
241 model->MOSkappa = .2;
242 }
243
244 /* level 6 */
245 if (!model->MOSkvGiven) {
246 model->MOSkv = 2;
247 }
248 if (!model->MOSnvGiven) {
249 model->MOSnv = 0.5;
250 }
251 if (!model->MOSkcGiven) {
252 model->MOSkc = 5e-5;
253 }
254 if (!model->MOSncGiven) {
255 model->MOSnc = 1;
256 }
257 if (!model->MOSlamda0Given) {
258 model->MOSlamda0 = 0;
259 if (model->MOSlambdaGiven) {
260 model->MOSlamda0 = model->MOSlambda;
261 }
262 }
263 if (!model->MOSlamda1Given) {
264 model->MOSlamda1 = 0;
265 }
266 if (!model->MOSsigmaGiven) {
267 model->MOSsigma = 0;
268 }
269 if(!model->MOSgamma1Given) {
270 model->MOSgamma1 = 0;
271 }
272
273 /* level 8, CryoMOS by Luong Huynh 1/19/95 */
274 if (!model->MOSa1Given) {
275 model->MOSa1 = 0;
276 }
277 if (!model->MOSa2Given) {
278 model->MOSa2 = 0;
279 }
280 if (!model->MOSk1Given) {
281 model->MOSk1 = 0;
282 }
283 if (!model->MOSk2Given) {
284 model->MOSk2 = 0;
285 }
286 if (!model->MOSk3Given) {
287 model->MOSk3 = 0;
288 }
289 if (!model->MOSk4Given) {
290 model->MOSk4 = 0;
291 }
292 if (!model->MOSemGiven) {
293 model->MOSem = 0;
294 }
295 if (!model->MOSpclmGiven) {
296 model->MOSpclm = 0;
297 }
298
299
300 /* loop through all the instances of the model */
301 for (here = model->MOSinstances; here != NULL;
302 here = here->MOSnextInstance) {
303
304 here->MOSmode = 1;
305 here->MOSvon = 0;
306
307 /* allocate a chunk of the state vector */
308 here->MOSstates = *states;
309 *states += MOSnumStates;
310
311 /* temp */
312 if (!here->MOStempGiven) {
313 here->MOStemp = ckt->CKTtemp;
314 }
315
316 /* pd */
317 if (!here->MOSdrainPerimeterGiven) {
318 here->MOSdrainPerimeter = 0;
319 }
320
321 /* nrd */
322 if (!here->MOSdrainSquaresGiven ||
323 here->MOSdrainSquares == 0) {
324 here->MOSdrainSquares = 1;
325 }
326
327 /* ps */
328 if (!here->MOSsourcePerimeterGiven) {
329 here->MOSsourcePerimeter = 0;
330 }
331
332 /* nrs */
333 if (!here->MOSsourceSquaresGiven ||
334 here->MOSsourceSquares == 0) {
335 here->MOSsourceSquares = 1;
336 }
337
338 /* ic: vbs */
339 if (!here->MOSicVBSGiven) {
340 here->MOSicVBS = 0;
341 }
342
343 /* ic: vds */
344 if (!here->MOSicVDSGiven) {
345 here->MOSicVDS = 0;
346 }
347
348 /* ic: vgs */
349 if (!here->MOSicVGSGiven) {
350 here->MOSicVGS = 0;
351 }
352
353 /* no assigned parameter? */
354 if (!here->MOSvdsatGiven) {
355 here->MOSvdsat = 0;
356 }
357
358 if (!here->MOSlGiven) {
359 here->MOSl = ckt->CKTdefaultMosL;
360 }
361 if (!here->MOSwGiven) {
362 here->MOSw = ckt->CKTdefaultMosW;
363 }
364 if (!here->MOSdrainAreaGiven) {
365 here->MOSdrainArea = ckt->CKTdefaultMosAD;
366 }
367
368 if (!here->MOSsourceAreaGiven) {
369 here->MOSsourceArea = ckt->CKTdefaultMosAS;
370 }
371
372 if (model->MOSdrainResistanceGiven) {
373 if (model->MOSdrainResistance != 0) {
374 here->MOSdrainConductance =
375 1/model->MOSdrainResistance;
376 }
377 else {
378 here->MOSdrainConductance = 0;
379 }
380 }
381 else if (model->MOSsheetResistanceGiven) {
382 if (model->MOSsheetResistance != 0) {
383 here->MOSdrainConductance =
384 1/(model->MOSsheetResistance*
385 here->MOSdrainSquares);
386 }
387 else {
388 here->MOSdrainConductance = 0;
389 }
390 }
391 else {
392 here->MOSdrainConductance = 0;
393 }
394 if (model->MOSsourceResistanceGiven) {
395 if (model->MOSsourceResistance != 0) {
396 here->MOSsourceConductance =
397 1/model->MOSsourceResistance;
398 }
399 else {
400 here->MOSsourceConductance = 0;
401 }
402 }
403 else if (model->MOSsheetResistanceGiven) {
404 if (model->MOSsheetResistance != 0) {
405 here->MOSsourceConductance =
406 1/(model->MOSsheetResistance*
407 here->MOSsourceSquares);
408 }
409 else {
410 here->MOSsourceConductance = 0;
411 }
412 }
413 else {
414 here->MOSsourceConductance = 0;
415 }
416
417 here->MOSeffectiveLength = here->MOSl - 2*model->MOSlatDiff;
418 if (here->MOSeffectiveLength < 0) {
419 (*(SPfrontEnd->IFerror))(ERR_WARNING,
420 "%s: effective channel length less than zero",
421 &(here->MOSname));
422 here->MOSeffectiveLength = 0;
423 }
424
425 /* assign internal nodes */
426
427 if ((model->MOSdrainResistance != 0
428 || model->MOSsheetResistance != 0)
429 && here->MOSdNodePrime == 0) {
430 error = CKTmkVolt(ckt,&tmp,here->MOSname,"internal#drain");
431 if (error) return(error);
432 here->MOSdNodePrime = tmp->number;
433 }
434 else {
435 here->MOSdNodePrime = here->MOSdNode;
436 }
437
438 if (((model->MOSsourceResistance != 0) ||
439 ((here->MOSsourceSquares != 0) &&
440 (model->MOSsheetResistance != 0))) &&
441 (here->MOSsNodePrime == 0)) {
442 error = CKTmkVolt(ckt,&tmp,here->MOSname,"internal#source");
443 if (error) return(error);
444 here->MOSsNodePrime = tmp->number;
445 }
446 else {
447 here->MOSsNodePrime = here->MOSsNode;
448 }
449
450 TSTALLOC(MOSDdPtr, MOSdNode, MOSdNode)
451 TSTALLOC(MOSGgPtr, MOSgNode, MOSgNode)
452 TSTALLOC(MOSSsPtr, MOSsNode, MOSsNode)
453 TSTALLOC(MOSBbPtr, MOSbNode, MOSbNode)
454 TSTALLOC(MOSDPdpPtr, MOSdNodePrime, MOSdNodePrime)
455 TSTALLOC(MOSSPspPtr, MOSsNodePrime, MOSsNodePrime)
456 TSTALLOC(MOSDdpPtr, MOSdNode, MOSdNodePrime)
457 TSTALLOC(MOSGbPtr, MOSgNode, MOSbNode)
458 TSTALLOC(MOSGdpPtr, MOSgNode, MOSdNodePrime)
459 TSTALLOC(MOSGspPtr, MOSgNode, MOSsNodePrime)
460 TSTALLOC(MOSSspPtr, MOSsNode, MOSsNodePrime)
461 TSTALLOC(MOSBdpPtr, MOSbNode, MOSdNodePrime)
462 TSTALLOC(MOSBspPtr, MOSbNode, MOSsNodePrime)
463 TSTALLOC(MOSDPspPtr, MOSdNodePrime, MOSsNodePrime)
464 TSTALLOC(MOSDPdPtr, MOSdNodePrime, MOSdNode)
465 TSTALLOC(MOSBgPtr, MOSbNode, MOSgNode)
466 TSTALLOC(MOSDPgPtr, MOSdNodePrime, MOSgNode)
467 TSTALLOC(MOSSPgPtr, MOSsNodePrime, MOSgNode)
468 TSTALLOC(MOSSPsPtr, MOSsNodePrime, MOSsNode)
469 TSTALLOC(MOSDPbPtr, MOSdNodePrime, MOSbNode)
470 TSTALLOC(MOSSPbPtr, MOSsNodePrime, MOSbNode)
471 TSTALLOC(MOSSPdpPtr, MOSsNodePrime, MOSdNodePrime)
472
473 }
474 }
475 return (OK);
476 }
477