1 /**** BSIM4.5.0 Released by Xuemei (Jane) Xi 07/29/2005 ****/
2
3 /**********
4 * Copyright 2005 Regents of the University of California. All rights reserved.
5 * File: b4check.c of BSIM4.5.0.
6 * Author: 2000 Weidong Liu
7 * Authors: 2001- Xuemei Xi, Mohan Dunga, Ali Niknejad, Chenming Hu.
8 * Project Director: Prof. Chenming Hu.
9 * Modified by Xuemei Xi, 04/06/2001.
10 * Modified by Xuemei Xi, 10/05/2001.
11 * Modified by Xuemei Xi, 11/15/2002.
12 * Modified by Xuemei Xi, 05/09/2003.
13 * Modified by Xuemei Xi, 03/04/2004.
14 * Modified by Xuemei Xi, 07/29/2005.
15 * Modified by Holger Vogt, 12/21/2020.
16 **********/
17
18 #include "ngspice/ngspice.h"
19 #include "ngspice/cktdefs.h"
20 #include "bsim4v5def.h"
21 #include "ngspice/trandefs.h"
22 #include "ngspice/const.h"
23 #include "ngspice/sperror.h"
24 #include "ngspice/devdefs.h"
25 #include "ngspice/suffix.h"
26 #include "ngspice/wordlist.h"
27 #include "ngspice/cpextern.h"
28
29 /* Check for correctness of the BSIM4.5 parameters:
30 If parameter excursions are found, put the warning or error message into a wordlist.
31 Only then open a file bsim4v5.out and print the data into the file. */
32 int
BSIM4v5checkModel(BSIM4v5model * model,BSIM4v5instance * here,CKTcircuit * ckt)33 BSIM4v5checkModel(
34 BSIM4v5model *model,
35 BSIM4v5instance *here,
36 CKTcircuit *ckt)
37 {
38 struct bsim4v5SizeDependParam *pParam;
39 int Fatal_Flag = 0;
40 FILE *fplog;
41 wordlist* wl, *wlstart;
42
43 if (cp_getvar("ng_nomodcheck", CP_BOOL, NULL, 0))
44 return(0);
45
46 static char modname[BSIZE_SP];
47 size_t mlen = strlen(model->BSIM4v5modName);
48
49 if (mlen < BSIZE_SP) {
50 /* Check the model named model->BSIM4v5modName only once,
51 because BSIM4v5checkModel() is called for each instance. */
52 if (!strncmp(modname, model->BSIM4v5modName, mlen))
53 return(0);
54 strcpy(modname, model->BSIM4v5modName);
55 }
56
57 pParam = here->pParam;
58
59 wl = wlstart = TMALLOC(wordlist, 1);
60 wl->wl_prev = NULL;
61 wl->wl_next = NULL;
62 wl->wl_word = tprintf("\nChecking parameters for BSIM 4.5 model %s\n", model->BSIM4v5modName);
63
64 if ((strcmp(model->BSIM4v5version, "4.5.0")) && (strncmp(model->BSIM4v5version, "4.50", 4)) && (strncmp(model->BSIM4v5version, "4.5", 3))
65 && (strcmp(model->BSIM4v5version, "4.4.0")) && (strncmp(model->BSIM4v5version, "4.40", 4)) && (strncmp(model->BSIM4v5version, "4.4", 3))
66 && (strcmp(model->BSIM4v5version, "4.3.0")) && (strncmp(model->BSIM4v5version, "4.30", 4)) && (strncmp(model->BSIM4v5version, "4.3", 3))
67 && (strcmp(model->BSIM4v5version, "4.2.0")) && (strncmp(model->BSIM4v5version, "4.20", 4)) && (strncmp(model->BSIM4v5version, "4.2", 3))
68 && (strcmp(model->BSIM4v5version, "4.1.0")) && (strncmp(model->BSIM4v5version, "4.10", 4)) && (strncmp(model->BSIM4v5version, "4.1", 3))
69 && (strcmp(model->BSIM4v5version, "4.0.0")) && (strncmp(model->BSIM4v5version, "4.00", 4)) && (strncmp(model->BSIM4v5version, "4.0", 3)))
70 {
71 printf("Warning: This model supports BSIM4 versions 4.0, 4.1, 4.2, 4.3, 4.4, 4.5\n");
72 printf("You specified a wrong version number. Working now with BSIM4v5\n");
73 wl_append_word(&wl, &wl, tprintf("Warning: This model supports BSIM4 versions 4.0, 4.1, 4.2, 4.3, 4.4, 4.5\n"));
74 wl_append_word(&wl, &wl, tprintf("You specified a wrong version number. Working now with BSIM4v5.\n"));
75 }
76
77 if ((here->BSIM4v5rgateMod == 2) || (here->BSIM4v5rgateMod == 3))
78 { if ((here->BSIM4v5trnqsMod == 1) || (here->BSIM4v5acnqsMod == 1)) {
79 wl_append_word(&wl, &wl, tprintf("Warning: You've selected both Rg and charge deficit NQS; select one only.\n"));
80 }
81 }
82
83 if (model->BSIM4v5toxe <= 0.0)
84 {
85 wl_append_word(&wl, &wl, tprintf("Fatal: Toxe = %g is not positive.\n",
86 model->BSIM4v5toxe));
87 Fatal_Flag = 1;
88 }
89
90 if (model->BSIM4v5toxp <= 0.0)
91 {
92 wl_append_word(&wl, &wl, tprintf("Fatal: Toxp = %g is not positive.\n", model->BSIM4v5toxp));
93 Fatal_Flag = 1;
94 }
95
96 if (model->BSIM4v5toxm <= 0.0)
97 {
98 wl_append_word(&wl, &wl, tprintf("Fatal: Toxm = %g is not positive.\n", model->BSIM4v5toxm));
99 Fatal_Flag = 1;
100 }
101
102 if (model->BSIM4v5toxref <= 0.0)
103 {
104 wl_append_word(&wl, &wl, tprintf("Fatal: Toxref = %g is not positive.\n", model->BSIM4v5toxref));
105 Fatal_Flag = 1;
106 }
107
108
109
110 if (pParam->BSIM4v5lpe0 < -pParam->BSIM4v5leff)
111 {
112 wl_append_word(&wl, &wl, tprintf("Fatal: Lpe0 = %g is less than -Leff.\n",
113 pParam->BSIM4v5lpe0));
114 Fatal_Flag = 1;
115 }
116 if (model->BSIM4v5lintnoi > pParam->BSIM4v5leff / 2)
117 {
118 wl_append_word(&wl, &wl, tprintf("Fatal: Lintnoi = %g is too large - Leff for noise is negative.\n",
119 model->BSIM4v5lintnoi));
120 Fatal_Flag = 1;
121 }
122 if (pParam->BSIM4v5lpeb < -pParam->BSIM4v5leff)
123 {
124 wl_append_word(&wl, &wl, tprintf("Fatal: Lpeb = %g is less than -Leff.\n",
125 pParam->BSIM4v5lpeb));
126 Fatal_Flag = 1;
127 }
128 if (pParam->BSIM4v5ndep <= 0.0)
129 {
130 wl_append_word(&wl, &wl, tprintf("Fatal: Ndep = %g is not positive.\n",
131 pParam->BSIM4v5ndep));
132 Fatal_Flag = 1;
133 }
134 if (pParam->BSIM4v5phi <= 0.0)
135 {
136 wl_append_word(&wl, &wl, tprintf("Fatal: Phi = %g is not positive. Please check Phin and Ndep\n",
137 pParam->BSIM4v5phi));
138 wl_append_word(&wl, &wl, tprintf(" Phin = %g Ndep = %g \n",
139 pParam->BSIM4v5phin, pParam->BSIM4v5ndep));
140 Fatal_Flag = 1;
141 }
142 if (pParam->BSIM4v5nsub <= 0.0)
143 {
144 wl_append_word(&wl, &wl, tprintf("Fatal: Nsub = %g is not positive.\n",
145 pParam->BSIM4v5nsub));
146 Fatal_Flag = 1;
147 }
148 if (pParam->BSIM4v5ngate < 0.0)
149 {
150 wl_append_word(&wl, &wl, tprintf("Fatal: Ngate = %g Ngate is not positive.\n",
151 pParam->BSIM4v5ngate));
152 Fatal_Flag = 1;
153 }
154 if (pParam->BSIM4v5ngate > 1.e25)
155 {
156 wl_append_word(&wl, &wl, tprintf("Fatal: Ngate = %g Ngate is too high\n",
157 pParam->BSIM4v5ngate));
158 Fatal_Flag = 1;
159 }
160 if (pParam->BSIM4v5xj <= 0.0)
161 {
162 wl_append_word(&wl, &wl, tprintf("Fatal: Xj = %g is not positive.\n", pParam->BSIM4v5xj));
163 Fatal_Flag = 1;
164 }
165
166 if (pParam->BSIM4v5dvt1 < 0.0)
167 {
168 wl_append_word(&wl, &wl, tprintf("Fatal: Dvt1 = %g is negative.\n", pParam->BSIM4v5dvt1));
169 Fatal_Flag = 1;
170 }
171
172 if (pParam->BSIM4v5dvt1w < 0.0)
173 {
174 wl_append_word(&wl, &wl, tprintf("Fatal: Dvt1w = %g is negative.\n", pParam->BSIM4v5dvt1w));
175 Fatal_Flag = 1;
176 }
177
178 if (pParam->BSIM4v5w0 == -pParam->BSIM4v5weff)
179 {
180 wl_append_word(&wl, &wl, tprintf("Fatal: (W0 + Weff) = 0 causing divided-by-zero.\n"));
181 Fatal_Flag = 1;
182 }
183
184 if (pParam->BSIM4v5dsub < 0.0)
185 {
186 wl_append_word(&wl, &wl, tprintf("Fatal: Dsub = %g is negative.\n", pParam->BSIM4v5dsub));
187 Fatal_Flag = 1;
188 }
189 if (pParam->BSIM4v5b1 == -pParam->BSIM4v5weff)
190 {
191 wl_append_word(&wl, &wl, tprintf("Fatal: (B1 + Weff) = 0 causing divided-by-zero.\n"));
192 Fatal_Flag = 1;
193 }
194 if (here->BSIM4v5u0temp <= 0.0)
195 {
196 wl_append_word(&wl, &wl, tprintf("Fatal: u0 at current temperature = %g is not positive.\n",
197 here->BSIM4v5u0temp));
198 Fatal_Flag = 1;
199 }
200
201 if (pParam->BSIM4v5delta < 0.0)
202 {
203 wl_append_word(&wl, &wl, tprintf("Fatal: Delta = %g is less than zero.\n", pParam->BSIM4v5delta));
204 Fatal_Flag = 1;
205 }
206
207 if (here->BSIM4v5vsattemp <= 0.0)
208 {
209 wl_append_word(&wl, &wl, tprintf("Fatal: Vsat at current temperature = %g is not positive.\n",
210 here->BSIM4v5vsattemp));
211 Fatal_Flag = 1;
212 }
213
214 if (pParam->BSIM4v5pclm <= 0.0)
215 {
216 wl_append_word(&wl, &wl, tprintf("Fatal: Pclm = %g is not positive.\n", pParam->BSIM4v5pclm));
217 Fatal_Flag = 1;
218 }
219
220 if (pParam->BSIM4v5drout < 0.0)
221 {
222 wl_append_word(&wl, &wl, tprintf("Fatal: Drout = %g is negative.\n", pParam->BSIM4v5drout));
223 Fatal_Flag = 1;
224 }
225
226 if (here->BSIM4v5m <= 0.0)
227 {
228 wl_append_word(&wl, &wl, tprintf("Fatal: multiplier = %g is not positive.\n", here->BSIM4v5m));
229 Fatal_Flag = 1;
230 }
231 if (here->BSIM4v5nf < 1.0)
232 {
233 wl_append_word(&wl, &wl, tprintf("Fatal: Number of finger = %g is smaller than one.\n", here->BSIM4v5nf));
234 Fatal_Flag = 1;
235 }
236
237 if ((here->BSIM4v5sa > 0.0) && (here->BSIM4v5sb > 0.0) &&
238 ((here->BSIM4v5nf == 1.0) || ((here->BSIM4v5nf > 1.0) && (here->BSIM4v5sd > 0.0))))
239 {
240 if (model->BSIM4v5saref <= 0.0)
241 {
242 wl_append_word(&wl, &wl, tprintf("Fatal: SAref = %g is not positive.\n", model->BSIM4v5saref));
243 Fatal_Flag = 1;
244 }
245 if (model->BSIM4v5sbref <= 0.0)
246 {
247 wl_append_word(&wl, &wl, tprintf("Fatal: SBref = %g is not positive.\n", model->BSIM4v5sbref));
248 Fatal_Flag = 1;
249 }
250 }
251
252 if ((here->BSIM4v5l + model->BSIM4v5xl) <= model->BSIM4v5xgl)
253 {
254 wl_append_word(&wl, &wl, tprintf("Fatal: The parameter xgl must be smaller than Ldrawn+XL.\n"));
255 Fatal_Flag = 1;
256 }
257 if (here->BSIM4v5ngcon < 1.0)
258 {
259 wl_append_word(&wl, &wl, tprintf("Fatal: The parameter ngcon cannot be smaller than one.\n"));
260 Fatal_Flag = 1;
261 }
262 if ((here->BSIM4v5ngcon != 1.0) && (here->BSIM4v5ngcon != 2.0))
263 {
264 here->BSIM4v5ngcon = 1.0;
265 wl_append_word(&wl, &wl, tprintf("Warning: Ngcon must be equal to one or two; reset to 1.0.\n"));
266 }
267
268 if (model->BSIM4v5gbmin < 1.0e-20)
269 {
270 wl_append_word(&wl, &wl, tprintf("Warning: Gbmin = %g is too small.\n", model->BSIM4v5gbmin));
271 }
272
273 /* Check saturation parameters */
274 if (pParam->BSIM4v5fprout < 0.0)
275 {
276 wl_append_word(&wl, &wl, tprintf("Fatal: fprout = %g is negative.\n", pParam->BSIM4v5fprout));
277 Fatal_Flag = 1;
278 }
279 if (pParam->BSIM4v5pdits < 0.0)
280 {
281 wl_append_word(&wl, &wl, tprintf("Fatal: pdits = %g is negative.\n", pParam->BSIM4v5pdits));
282 Fatal_Flag = 1;
283 }
284 if (model->BSIM4v5pditsl < 0.0)
285 {
286 wl_append_word(&wl, &wl, tprintf("Fatal: pditsl = %g is negative.\n", model->BSIM4v5pditsl));
287 Fatal_Flag = 1;
288 }
289
290 /* Check gate current parameters */
291 if (model->BSIM4v5igbMod) {
292 if (pParam->BSIM4v5nigbinv <= 0.0)
293 {
294 wl_append_word(&wl, &wl, tprintf("Fatal: nigbinv = %g is non-positive.\n", pParam->BSIM4v5nigbinv));
295 Fatal_Flag = 1;
296 }
297 if (pParam->BSIM4v5nigbacc <= 0.0)
298 {
299 wl_append_word(&wl, &wl, tprintf("Fatal: nigbacc = %g is non-positive.\n", pParam->BSIM4v5nigbacc));
300 Fatal_Flag = 1;
301 }
302 }
303 if (model->BSIM4v5igcMod) {
304 if (pParam->BSIM4v5nigc <= 0.0)
305 {
306 wl_append_word(&wl, &wl, tprintf("Fatal: nigc = %g is non-positive.\n", pParam->BSIM4v5nigc));
307 Fatal_Flag = 1;
308 }
309 if (pParam->BSIM4v5poxedge <= 0.0)
310 {
311 wl_append_word(&wl, &wl, tprintf("Fatal: poxedge = %g is non-positive.\n", pParam->BSIM4v5poxedge));
312 Fatal_Flag = 1;
313 }
314 if (pParam->BSIM4v5pigcd <= 0.0)
315 {
316 wl_append_word(&wl, &wl, tprintf("Fatal: pigcd = %g is non-positive.\n", pParam->BSIM4v5pigcd));
317 Fatal_Flag = 1;
318 }
319 }
320
321 /* Check capacitance parameters */
322 if (pParam->BSIM4v5clc < 0.0)
323 {
324 wl_append_word(&wl, &wl, tprintf("Fatal: Clc = %g is negative.\n", pParam->BSIM4v5clc));
325 Fatal_Flag = 1;
326 }
327
328 /* Check overlap capacitance parameters */
329 if (pParam->BSIM4v5ckappas < 0.02)
330 {
331 wl_append_word(&wl, &wl, tprintf("Warning: ckappas = %g is too small.\n", pParam->BSIM4v5ckappas));
332 pParam->BSIM4v5ckappas = 0.02;
333 }
334 if (pParam->BSIM4v5ckappad < 0.02)
335 {
336 wl_append_word(&wl, &wl, tprintf("Warning: ckappad = %g is too small.\n", pParam->BSIM4v5ckappad));
337 pParam->BSIM4v5ckappad = 0.02;
338 }
339
340 if (model->BSIM4v5vtss < 0.0)
341 {
342 wl_append_word(&wl, &wl, tprintf("Fatal: Vtss = %g is negative.\n",
343 model->BSIM4v5vtss));
344 Fatal_Flag = 1;
345 }
346 if (model->BSIM4v5vtsd < 0.0)
347 {
348 wl_append_word(&wl, &wl, tprintf("Fatal: Vtsd = %g is negative.\n",
349 model->BSIM4v5vtsd));
350 Fatal_Flag = 1;
351 }
352 if (model->BSIM4v5vtssws < 0.0)
353 {
354 wl_append_word(&wl, &wl, tprintf("Fatal: Vtssws = %g is negative.\n",
355 model->BSIM4v5vtssws));
356 Fatal_Flag = 1;
357 }
358 if (model->BSIM4v5vtsswd < 0.0)
359 {
360 wl_append_word(&wl, &wl, tprintf("Fatal: Vtsswd = %g is negative.\n",
361 model->BSIM4v5vtsswd));
362 Fatal_Flag = 1;
363 }
364 if (model->BSIM4v5vtsswgs < 0.0)
365 {
366 wl_append_word(&wl, &wl, tprintf("Fatal: Vtsswgs = %g is negative.\n",
367 model->BSIM4v5vtsswgs));
368 Fatal_Flag = 1;
369 }
370 if (model->BSIM4v5vtsswgd < 0.0)
371 {
372 wl_append_word(&wl, &wl, tprintf("Fatal: Vtsswgd = %g is negative.\n",
373 model->BSIM4v5vtsswgd));
374 Fatal_Flag = 1;
375 }
376
377
378 if (model->BSIM4v5paramChk == 1)
379 {
380 /* Check L and W parameters */
381 if (pParam->BSIM4v5leff <= 1.0e-9)
382 {
383 wl_append_word(&wl, &wl, tprintf("Warning: Leff = %g <= 1.0e-9. Recommended Leff >= 1e-8 \n",
384 pParam->BSIM4v5leff));
385 }
386
387 if (pParam->BSIM4v5leffCV <= 1.0e-9)
388 {
389 wl_append_word(&wl, &wl, tprintf("Warning: Leff for CV = %g <= 1.0e-9. Recommended LeffCV >=1e-8 \n",
390 pParam->BSIM4v5leffCV));
391 }
392
393 if (pParam->BSIM4v5weff <= 1.0e-9)
394 {
395 wl_append_word(&wl, &wl, tprintf("Warning: Weff = %g <= 1.0e-9. Recommended Weff >=1e-7 \n",
396 pParam->BSIM4v5weff));
397 }
398
399 if (pParam->BSIM4v5weffCV <= 1.0e-9)
400 {
401 wl_append_word(&wl, &wl, tprintf("Warning: Weff for CV = %g <= 1.0e-9. Recommended WeffCV >= 1e-7 \n",
402 pParam->BSIM4v5weffCV));
403 }
404
405 /* Check threshold voltage parameters */
406 if (model->BSIM4v5toxe < 1.0e-10)
407 {
408 wl_append_word(&wl, &wl, tprintf("Warning: Toxe = %g is less than 1A. Recommended Toxe >= 5A\n", model->BSIM4v5toxe));
409 }
410 if (model->BSIM4v5toxp < 1.0e-10)
411 {
412 wl_append_word(&wl, &wl, tprintf("Warning: Toxp = %g is less than 1A. Recommended Toxp >= 5A\n", model->BSIM4v5toxp));
413 }
414 if (model->BSIM4v5toxm < 1.0e-10)
415 {
416 wl_append_word(&wl, &wl, tprintf("Warning: Toxm = %g is less than 1A. Recommended Toxm >= 5A\n", model->BSIM4v5toxm));
417 }
418
419 if (pParam->BSIM4v5ndep <= 1.0e12)
420 {
421 wl_append_word(&wl, &wl, tprintf("Warning: Ndep = %g may be too small.\n",
422 pParam->BSIM4v5ndep));
423 }
424 else if (pParam->BSIM4v5ndep >= 1.0e21)
425 {
426 wl_append_word(&wl, &wl, tprintf("Warning: Ndep = %g may be too large.\n",
427 pParam->BSIM4v5ndep));
428 }
429
430 if (pParam->BSIM4v5nsub <= 1.0e14)
431 {
432 wl_append_word(&wl, &wl, tprintf("Warning: Nsub = %g may be too small.\n",
433 pParam->BSIM4v5nsub));
434 }
435 else if (pParam->BSIM4v5nsub >= 1.0e21)
436 {
437 wl_append_word(&wl, &wl, tprintf("Warning: Nsub = %g may be too large.\n",
438 pParam->BSIM4v5nsub));
439 }
440
441 if ((pParam->BSIM4v5ngate > 0.0) &&
442 (pParam->BSIM4v5ngate <= 1.e18))
443 {
444 wl_append_word(&wl, &wl, tprintf("Warning: Ngate = %g is less than 1.E18cm^-3.\n",
445 pParam->BSIM4v5ngate));
446 }
447
448 if (pParam->BSIM4v5dvt0 < 0.0)
449 {
450 wl_append_word(&wl, &wl, tprintf("Warning: Dvt0 = %g is negative.\n", pParam->BSIM4v5dvt0));
451 }
452
453 if (fabs(1.0e-8 / (pParam->BSIM4v5w0 + pParam->BSIM4v5weff)) > 10.0)
454 {
455 wl_append_word(&wl, &wl, tprintf("Warning: (W0 + Weff) may be too small.\n"));
456 }
457
458 /* Check subthreshold parameters */
459 if (pParam->BSIM4v5nfactor < 0.0)
460 {
461 wl_append_word(&wl, &wl, tprintf("Warning: Nfactor = %g is negative.\n", pParam->BSIM4v5nfactor));
462 }
463 if (pParam->BSIM4v5cdsc < 0.0)
464 {
465 wl_append_word(&wl, &wl, tprintf("Warning: Cdsc = %g is negative.\n", pParam->BSIM4v5cdsc));
466 }
467 if (pParam->BSIM4v5cdscd < 0.0)
468 {
469 wl_append_word(&wl, &wl, tprintf("Warning: Cdscd = %g is negative.\n", pParam->BSIM4v5cdscd));
470 }
471 /* Check DIBL parameters */
472 if (here->BSIM4v5eta0 < 0.0)
473 {
474 wl_append_word(&wl, &wl, tprintf("Warning: Eta0 = %g is negative.\n", here->BSIM4v5eta0));
475 }
476
477 /* Check Abulk parameters */
478 if (fabs(1.0e-8 / (pParam->BSIM4v5b1 + pParam->BSIM4v5weff)) > 10.0)
479 {
480 wl_append_word(&wl, &wl, tprintf("Warning: (B1 + Weff) may be too small.\n"));
481 }
482
483
484 /* Check Saturation parameters */
485 if (pParam->BSIM4v5a2 < 0.01)
486 {
487 wl_append_word(&wl, &wl, tprintf("Warning: A2 = %g is too small. Set to 0.01.\n",
488 pParam->BSIM4v5a2));
489 pParam->BSIM4v5a2 = 0.01;
490 }
491 else if (pParam->BSIM4v5a2 > 1.0)
492 {
493 wl_append_word(&wl, &wl, tprintf("Warning: A2 = %g is larger than 1. A2 is set to 1 and A1 is set to 0.\n",
494 pParam->BSIM4v5a2));
495 pParam->BSIM4v5a2 = 1.0;
496 pParam->BSIM4v5a1 = 0.0;
497 }
498
499 if (pParam->BSIM4v5prwg < 0.0)
500 {
501 wl_append_word(&wl, &wl, tprintf("Warning: Prwg = %g is negative. Set to zero.\n",
502 pParam->BSIM4v5prwg));
503 pParam->BSIM4v5prwg = 0.0;
504 }
505
506 if (pParam->BSIM4v5rdsw < 0.0)
507 {
508 wl_append_word(&wl, &wl, tprintf("Warning: Rdsw = %g is negative. Set to zero.\n",
509 pParam->BSIM4v5rdsw));
510 pParam->BSIM4v5rdsw = 0.0;
511 pParam->BSIM4v5rds0 = 0.0;
512 }
513
514 if (pParam->BSIM4v5rds0 < 0.0)
515 {
516 wl_append_word(&wl, &wl, tprintf("Warning: Rds at current temperature = %g is negative. Set to zero.\n",
517 pParam->BSIM4v5rds0));
518 pParam->BSIM4v5rds0 = 0.0;
519 }
520
521 if (pParam->BSIM4v5rdswmin < 0.0)
522 {
523 wl_append_word(&wl, &wl, tprintf("Warning: Rdswmin at current temperature = %g is negative. Set to zero.\n",
524 pParam->BSIM4v5rdswmin));
525 pParam->BSIM4v5rdswmin = 0.0;
526 }
527
528 if (pParam->BSIM4v5pscbe2 <= 0.0)
529 {
530 wl_append_word(&wl, &wl, tprintf("Warning: Pscbe2 = %g is not positive.\n", pParam->BSIM4v5pscbe2));
531 }
532
533 if (pParam->BSIM4v5vsattemp < 1.0e3)
534 {
535 wl_append_word(&wl, &wl, tprintf("Warning: Vsat at current temperature = %g may be too small.\n", pParam->BSIM4v5vsattemp));
536 }
537
538 if ((model->BSIM4v5lambdaGiven) && (pParam->BSIM4v5lambda > 0.0))
539 {
540 if (pParam->BSIM4v5lambda > 1.0e-9)
541 {
542 wl_append_word(&wl, &wl, tprintf("Warning: Lambda = %g may be too large.\n", pParam->BSIM4v5lambda));
543 }
544 }
545
546 if ((model->BSIM4v5vtlGiven) && (pParam->BSIM4v5vtl > 0.0))
547 {
548 if (pParam->BSIM4v5vtl < 6.0e4)
549 {
550 wl_append_word(&wl, &wl, tprintf("Warning: Thermal velocity vtl = %g may be too small.\n", pParam->BSIM4v5vtl));
551 }
552
553 if (pParam->BSIM4v5xn < 3.0)
554 {
555 wl_append_word(&wl, &wl, tprintf("Warning: back scattering coeff xn = %g is too small. Reset to 3.0 \n", pParam->BSIM4v5xn));
556 pParam->BSIM4v5xn = 3.0;
557 }
558
559 if (model->BSIM4v5lc < 0.0)
560 {
561 wl_append_word(&wl, &wl, tprintf("Warning: back scattering coeff lc = %g is too small. Reset to 0.0\n", model->BSIM4v5lc));
562 pParam->BSIM4v5lc = 0.0;
563 }
564 }
565
566 if (pParam->BSIM4v5pdibl1 < 0.0)
567 {
568 wl_append_word(&wl, &wl, tprintf("Warning: Pdibl1 = %g is negative.\n", pParam->BSIM4v5pdibl1));
569 }
570 }
571
572 if (pParam->BSIM4v5pdibl2 < 0.0)
573 {
574 wl_append_word(&wl, &wl, tprintf("Warning: Pdibl2 = %g is negative.\n", pParam->BSIM4v5pdibl2));
575 }
576
577 /* Check stress effect parameters */
578 if ((here->BSIM4v5sa > 0.0) && (here->BSIM4v5sb > 0.0) &&
579 ((here->BSIM4v5nf == 1.0) || ((here->BSIM4v5nf > 1.0) && (here->BSIM4v5sd > 0.0))))
580 {
581 if (model->BSIM4v5lodk2 <= 0.0)
582 {
583 wl_append_word(&wl, &wl, tprintf("Warning: LODK2 = %g is not positive.\n", model->BSIM4v5lodk2));
584 }
585 if (model->BSIM4v5lodeta0 <= 0.0)
586 {
587 wl_append_word(&wl, &wl, tprintf("Warning: LODETA0 = %g is not positive.\n", model->BSIM4v5lodeta0));
588 }
589 }
590
591 /* Check gate resistance parameters */
592 if (here->BSIM4v5rgateMod == 1)
593 {
594 if (model->BSIM4v5rshg <= 0.0)
595 wl_append_word(&wl, &wl, tprintf("Warning: rshg should be positive for rgateMod = 1.\n"));
596 }
597 else if (here->BSIM4v5rgateMod == 2)
598 {
599 if (model->BSIM4v5rshg <= 0.0)
600 wl_append_word(&wl, &wl, tprintf("Warning: rshg <= 0.0 for rgateMod = 2.\n"));
601 else if (pParam->BSIM4v5xrcrg1 <= 0.0)
602 wl_append_word(&wl, &wl, tprintf("Warning: xrcrg1 <= 0.0 for rgateMod = 2.\n"));
603 }
604 if (here->BSIM4v5rgateMod == 3)
605 {
606 if (model->BSIM4v5rshg <= 0.0)
607 wl_append_word(&wl, &wl, tprintf("Warning: rshg should be positive for rgateMod = 3.\n"));
608 else if (pParam->BSIM4v5xrcrg1 <= 0.0)
609 wl_append_word(&wl, &wl, tprintf("Warning: xrcrg1 should be positive for rgateMod = 3.\n"));
610 }
611
612 /* Check capacitance parameters */
613 if (pParam->BSIM4v5noff < 0.1)
614 {
615 wl_append_word(&wl, &wl, tprintf("Warning: Noff = %g is too small.\n", pParam->BSIM4v5noff));
616 }
617
618 if (pParam->BSIM4v5voffcv < -0.5)
619 {
620 wl_append_word(&wl, &wl, tprintf("Warning: Voffcv = %g is too small.\n", pParam->BSIM4v5voffcv));
621 }
622
623 if (pParam->BSIM4v5moin < 5.0)
624 {
625 wl_append_word(&wl, &wl, tprintf("Warning: Moin = %g is too small.\n", pParam->BSIM4v5moin));
626 }
627 if (pParam->BSIM4v5moin > 25.0)
628 {
629 wl_append_word(&wl, &wl, tprintf("Warning: Moin = %g is too large.\n", pParam->BSIM4v5moin));
630 }
631 if (model->BSIM4v5capMod == 2) {
632 if (pParam->BSIM4v5acde < 0.1)
633 {
634 wl_append_word(&wl, &wl, tprintf("Warning: Acde = %g is too small.\n", pParam->BSIM4v5acde));
635 }
636 if (pParam->BSIM4v5acde > 1.6)
637 {
638 wl_append_word(&wl, &wl, tprintf("Warning: Acde = %g is too large.\n", pParam->BSIM4v5acde));
639 }
640 }
641
642 /* Check overlap capacitance parameters */
643 if (model->BSIM4v5cgdo < 0.0)
644 {
645 wl_append_word(&wl, &wl, tprintf("Warning: cgdo = %g is negative. Set to zero.\n", model->BSIM4v5cgdo));
646 model->BSIM4v5cgdo = 0.0;
647 }
648 if (model->BSIM4v5cgso < 0.0)
649 {
650 wl_append_word(&wl, &wl, tprintf("Warning: cgso = %g is negative. Set to zero.\n", model->BSIM4v5cgso));
651 model->BSIM4v5cgso = 0.0;
652 }
653 if (model->BSIM4v5cgbo < 0.0)
654 {
655 wl_append_word(&wl, &wl, tprintf("Warning: cgbo = %g is negative. Set to zero.\n", model->BSIM4v5cgbo));
656 model->BSIM4v5cgbo = 0.0;
657 }
658 if (model->BSIM4v5tnoiMod == 1) {
659 if (model->BSIM4v5tnoia < 0.0)
660 {
661 wl_append_word(&wl, &wl, tprintf("Warning: tnoia = %g is negative. Set to zero.\n", model->BSIM4v5tnoia));
662 model->BSIM4v5tnoia = 0.0;
663 }
664 if (model->BSIM4v5tnoib < 0.0)
665 {
666 wl_append_word(&wl, &wl, tprintf("Warning: tnoib = %g is negative. Set to zero.\n", model->BSIM4v5tnoib));
667 model->BSIM4v5tnoib = 0.0;
668 }
669
670 if (model->BSIM4v5rnoia < 0.0)
671 {
672 wl_append_word(&wl, &wl, tprintf("Warning: rnoia = %g is negative. Set to zero.\n", model->BSIM4v5rnoia));
673 model->BSIM4v5rnoia = 0.0;
674 }
675 if (model->BSIM4v5rnoib < 0.0)
676 {
677 wl_append_word(&wl, &wl, tprintf("Warning: rnoib = %g is negative. Set to zero.\n", model->BSIM4v5rnoib));
678 model->BSIM4v5rnoib = 0.0;
679 }
680 }
681
682 if (model->BSIM4v5SjctEmissionCoeff < 0.0)
683 {
684 wl_append_word(&wl, &wl, tprintf("Warning: Njs = %g is negative.\n",
685 model->BSIM4v5SjctEmissionCoeff));
686 }
687 if (model->BSIM4v5DjctEmissionCoeff < 0.0)
688 {
689 wl_append_word(&wl, &wl, tprintf("Warning: Njd = %g is negative.\n",
690 model->BSIM4v5DjctEmissionCoeff));
691 }
692 if (model->BSIM4v5njtstemp < 0.0)
693 {
694 wl_append_word(&wl, &wl, tprintf("Warning: Njts = %g is negative at temperature = %g.\n",
695 model->BSIM4v5njtstemp, ckt->CKTtemp));
696 }
697 if (model->BSIM4v5njtsswtemp < 0.0)
698 {
699 wl_append_word(&wl, &wl, tprintf("Warning: Njtssw = %g is negative at temperature = %g.\n",
700 model->BSIM4v5njtsswtemp, ckt->CKTtemp));
701 }
702 if (model->BSIM4v5njtsswgtemp < 0.0)
703 {
704 wl_append_word(&wl, &wl, tprintf("Warning: Njtsswg = %g is negative at temperature = %g.\n",
705 model->BSIM4v5njtsswgtemp, ckt->CKTtemp));
706 }
707 if (model->BSIM4v5ntnoi < 0.0)
708 {
709 wl_append_word(&wl, &wl, tprintf("Warning: ntnoi = %g is negative. Set to zero.\n", model->BSIM4v5ntnoi));
710 model->BSIM4v5ntnoi = 0.0;
711 }
712
713 /* diode model */
714 if (model->BSIM4v5SbulkJctBotGradingCoeff >= 0.99)
715 {
716 wl_append_word(&wl, &wl, tprintf("Warning: MJS = %g is too big. Set to 0.99.\n", model->BSIM4v5SbulkJctBotGradingCoeff));
717 model->BSIM4v5SbulkJctBotGradingCoeff = 0.99;
718 }
719 if (model->BSIM4v5SbulkJctSideGradingCoeff >= 0.99)
720 {
721 wl_append_word(&wl, &wl, tprintf("Warning: MJSWS = %g is too big. Set to 0.99.\n", model->BSIM4v5SbulkJctSideGradingCoeff));
722 model->BSIM4v5SbulkJctSideGradingCoeff = 0.99;
723 }
724 if (model->BSIM4v5SbulkJctGateSideGradingCoeff >= 0.99)
725 {
726 wl_append_word(&wl, &wl, tprintf("Warning: MJSWGS = %g is too big. Set to 0.99.\n", model->BSIM4v5SbulkJctGateSideGradingCoeff));
727 model->BSIM4v5SbulkJctGateSideGradingCoeff = 0.99;
728 }
729
730 if (model->BSIM4v5DbulkJctBotGradingCoeff >= 0.99)
731 {
732 wl_append_word(&wl, &wl, tprintf("Warning: MJD = %g is too big. Set to 0.99.\n", model->BSIM4v5DbulkJctBotGradingCoeff));
733 model->BSIM4v5DbulkJctBotGradingCoeff = 0.99;
734 }
735 if (model->BSIM4v5DbulkJctSideGradingCoeff >= 0.99)
736 {
737 wl_append_word(&wl, &wl, tprintf("Warning: MJSWD = %g is too big. Set to 0.99.\n", model->BSIM4v5DbulkJctSideGradingCoeff));
738 model->BSIM4v5DbulkJctSideGradingCoeff = 0.99;
739 }
740 if (model->BSIM4v5DbulkJctGateSideGradingCoeff >= 0.99)
741 {
742 wl_append_word(&wl, &wl, tprintf("Warning: MJSWGD = %g is too big. Set to 0.99.\n", model->BSIM4v5DbulkJctGateSideGradingCoeff));
743 model->BSIM4v5DbulkJctGateSideGradingCoeff = 0.99;
744 }
745 if (model->BSIM4v5wpemod == 1)
746 {
747 if (model->BSIM4v5scref <= 0.0)
748 {
749 wl_append_word(&wl, &wl, tprintf("Warning: SCREF = %g is not positive. Set to 1e-6.\n", model->BSIM4v5scref));
750 model->BSIM4v5scref = 1e-6;
751 }
752 if (here->BSIM4v5sca < 0.0)
753 {
754 wl_append_word(&wl, &wl, tprintf("Warning: SCA = %g is negative. Set to 0.0.\n", here->BSIM4v5sca));
755 here->BSIM4v5sca = 0.0;
756 }
757 if (here->BSIM4v5scb < 0.0)
758 {
759 wl_append_word(&wl, &wl, tprintf("Warning: SCB = %g is negative. Set to 0.0.\n", here->BSIM4v5scb));
760 here->BSIM4v5scb = 0.0;
761 }
762 if (here->BSIM4v5scc < 0.0)
763 {
764 wl_append_word(&wl, &wl, tprintf("Warning: SCC = %g is negative. Set to 0.0.\n", here->BSIM4v5scc));
765 here->BSIM4v5scc = 0.0;
766 }
767 if (here->BSIM4v5sc < 0.0)
768 {
769 wl_append_word(&wl, &wl, tprintf("Warning: SC = %g is negative. Set to 0.0.\n", here->BSIM4v5sc));
770 here->BSIM4v5sc = 0.0;
771 }
772 }
773
774 if (wlstart->wl_next) {
775 if ((fplog = fopen("bsim4v5.out", "w")) != NULL) {
776 while (wlstart) {
777 fprintf(fplog, "%s", wlstart->wl_word);
778 fprintf(stderr, "%s", wlstart->wl_word);
779 wlstart = wlstart->wl_next;
780 }
781 fclose(fplog);
782 }
783 else {
784 while (wlstart) {
785 fprintf(stderr, "%s", wlstart->wl_word);
786 wlstart = wlstart->wl_next;
787 }
788 }
789 }
790
791 wl_free(wlstart);
792
793 return(Fatal_Flag);
794 }
795
796