1 /* ******************************************************************************
2 * BSIM4 4.8.1 released by Chetan Kumar Dabhi 2/15/2017 *
3 * BSIM4 Model Equations *
4 ******************************************************************************
5
6 ******************************************************************************
7 * Copyright 2017 Regents of the University of California. *
8 * All rights reserved. *
9 * *
10 * Project Director: Prof. Chenming Hu. *
11 * Authors: Gary W. Ng, Weidong Liu, Xuemei Xi, Mohan Dunga, Wenwei Yang *
12 * Ali Niknejad, Shivendra Singh Parihar, Chetan Kumar Dabhi *
13 * Yogesh Singh Chauhan, Sayeef Salahuddin, Chenming Hu *
14 ******************************************************************************
15
16 ******************************************************************************
17 * CMC In-Code Statement *
18 * *
19 * The Developer agrees that the following statement will appear in the *
20 * model code that has been adopted as a CMC Standard. *
21 * *
22 * Software is distributed as is, completely without warranty or service *
23 * support. The University of California and its employees are not liable *
24 * for the condition or performance of the software. *
25 * *
26 * The University of California owns the copyright and grants users a *
27 * perpetual, irrevocable, worldwide, non-exclusive, royalty-free license *
28 * with respect to the software as set forth below. *
29 * *
30 * The University of California hereby disclaims all implied warranties. *
31 * *
32 * The University of California grants the users the right to modify, *
33 * copy, and redistribute the software and documentation, both within *
34 * the user's organization and externally, subject to the following *
35 * restrictions: *
36 * *
37 * 1. The users agree not to charge for the University of California code *
38 * itself but may charge for additions, extensions, or support. *
39 * *
40 * 2. In any product based on the software, the users agree to *
41 * acknowledge the University of California that developed the *
42 * software. This acknowledgment shall appear in the product *
43 * documentation. *
44 * *
45 * 3. Redistributions to others of source code and documentation must *
46 * retain the copyright notice, disclaimer, and list of conditions. *
47 * *
48 * 4. Redistributions to others in binary form must reproduce the *
49 * copyright notice, disclaimer, and list of conditions in the *
50 * documentation and/or other materials provided with the *
51 * distribution. *
52 * *
53 * Agreed to on ______Feb. 15, 2017______________ *
54 * *
55 * By: ____University of California, Berkeley___ *
56 * ____Chenming Hu__________________________ *
57 * ____Professor in Graduate School ________ *
58 * *
59 ****************************************************************************** */
60
61 #include "ngspice/ngspice.h"
62 #include "ngspice/cktdefs.h"
63 #include "ngspice/complex.h"
64 #include "ngspice/sperror.h"
65 #include "bsim4def.h"
66 #include "ngspice/suffix.h"
67
68 int
BSIM4pzLoad(GENmodel * inModel,CKTcircuit * ckt,SPcomplex * s)69 BSIM4pzLoad(
70 GENmodel *inModel,
71 CKTcircuit *ckt,
72 SPcomplex *s)
73 {
74 BSIM4model *model = (BSIM4model*)inModel;
75 BSIM4instance *here;
76
77 double gjbd, gjbs, geltd, gcrg, gcrgg, gcrgd, gcrgs, gcrgb;
78 double xcggb, xcgdb, xcgsb, xcgbb, xcbgb, xcbdb, xcbsb, xcbbb;
79 double xcdgb, xcddb, xcdsb, xcdbb, xcsgb, xcsdb, xcssb, xcsbb;
80 double gds, capbd, capbs, FwdSum, RevSum, Gm, Gmbs;
81 double gstot, gstotd, gstotg, gstots, gstotb, gspr;
82 double gdtot, gdtotd, gdtotg, gdtots, gdtotb, gdpr;
83 double gIstotg, gIstotd, gIstots, gIstotb;
84 double gIdtotg, gIdtotd, gIdtots, gIdtotb;
85 double gIbtotg, gIbtotd, gIbtots, gIbtotb;
86 double gIgtotg, gIgtotd, gIgtots, gIgtotb;
87 double cgso, cgdo, cgbo;
88 double xcdbdb=0.0, xcsbsb=0.0, xcgmgmb=0.0, xcgmdb=0.0, xcgmsb=0.0, xcdgmb=0.0, xcsgmb=0.0;
89 double xcgmbb=0.0, xcbgmb=0.0;
90 double dxpart, sxpart, xgtg, xgtd, xgts, xgtb, xcqgb=0.0, xcqdb=0.0, xcqsb=0.0, xcqbb=0.0;
91 double gbspsp, gbbdp, gbbsp, gbspg, gbspb;
92 double gbspdp, gbdpdp, gbdpg, gbdpb, gbdpsp;
93 double ddxpart_dVd, ddxpart_dVg, ddxpart_dVb, ddxpart_dVs;
94 double dsxpart_dVd, dsxpart_dVg, dsxpart_dVb, dsxpart_dVs;
95 double T0=0.0, T1, CoxWL, qcheq, Cdg, Cdd, Cds, Csg, Csd, Css;
96 double ScalingFactor = 1.0e-9;
97 struct bsim4SizeDependParam *pParam;
98 double ggidld, ggidlg, ggidlb, ggislg, ggislb, ggisls;
99
100 double m;
101
102 for (; model != NULL; model = BSIM4nextModel(model))
103 { for (here = BSIM4instances(model); here!= NULL;
104 here = BSIM4nextInstance(here))
105 {
106 pParam = here->pParam;
107 capbd = here->BSIM4capbd;
108 capbs = here->BSIM4capbs;
109 cgso = here->BSIM4cgso;
110 cgdo = here->BSIM4cgdo;
111 cgbo = pParam->BSIM4cgbo;
112
113 if (here->BSIM4mode >= 0)
114 { Gm = here->BSIM4gm;
115 Gmbs = here->BSIM4gmbs;
116 FwdSum = Gm + Gmbs;
117 RevSum = 0.0;
118
119 gbbdp = -(here->BSIM4gbds);
120 gbbsp = here->BSIM4gbds + here->BSIM4gbgs + here->BSIM4gbbs;
121 gbdpg = here->BSIM4gbgs;
122 gbdpdp = here->BSIM4gbds;
123 gbdpb = here->BSIM4gbbs;
124 gbdpsp = -(gbdpg + gbdpdp + gbdpb);
125
126 gbspdp = 0.0;
127 gbspg = 0.0;
128 gbspb = 0.0;
129 gbspsp = 0.0;
130
131 if (model->BSIM4igcMod)
132 { gIstotg = here->BSIM4gIgsg + here->BSIM4gIgcsg;
133 gIstotd = here->BSIM4gIgcsd;
134 gIstots = here->BSIM4gIgss + here->BSIM4gIgcss;
135 gIstotb = here->BSIM4gIgcsb;
136
137 gIdtotg = here->BSIM4gIgdg + here->BSIM4gIgcdg;
138 gIdtotd = here->BSIM4gIgdd + here->BSIM4gIgcdd;
139 gIdtots = here->BSIM4gIgcds;
140 gIdtotb = here->BSIM4gIgcdb;
141 }
142 else
143 { gIstotg = gIstotd = gIstots = gIstotb = 0.0;
144 gIdtotg = gIdtotd = gIdtots = gIdtotb = 0.0;
145 }
146
147 if (model->BSIM4igbMod)
148 { gIbtotg = here->BSIM4gIgbg;
149 gIbtotd = here->BSIM4gIgbd;
150 gIbtots = here->BSIM4gIgbs;
151 gIbtotb = here->BSIM4gIgbb;
152 }
153 else
154 gIbtotg = gIbtotd = gIbtots = gIbtotb = 0.0;
155
156 if ((model->BSIM4igcMod != 0) || (model->BSIM4igbMod != 0))
157 { gIgtotg = gIstotg + gIdtotg + gIbtotg;
158 gIgtotd = gIstotd + gIdtotd + gIbtotd ;
159 gIgtots = gIstots + gIdtots + gIbtots;
160 gIgtotb = gIstotb + gIdtotb + gIbtotb;
161 }
162 else
163 gIgtotg = gIgtotd = gIgtots = gIgtotb = 0.0;
164
165 if (here->BSIM4rgateMod == 2)
166 T0 = *(ckt->CKTstates[0] + here->BSIM4vges)
167 - *(ckt->CKTstates[0] + here->BSIM4vgs);
168 else if (here->BSIM4rgateMod == 3)
169 T0 = *(ckt->CKTstates[0] + here->BSIM4vgms)
170 - *(ckt->CKTstates[0] + here->BSIM4vgs);
171 if (here->BSIM4rgateMod > 1)
172 { gcrgd = here->BSIM4gcrgd * T0;
173 gcrgg = here->BSIM4gcrgg * T0;
174 gcrgs = here->BSIM4gcrgs * T0;
175 gcrgb = here->BSIM4gcrgb * T0;
176 gcrgg -= here->BSIM4gcrg;
177 gcrg = here->BSIM4gcrg;
178 }
179 else
180 gcrg = gcrgd = gcrgg = gcrgs = gcrgb = 0.0;
181
182 if (here->BSIM4acnqsMod == 0)
183 { if (here->BSIM4rgateMod == 3)
184 { xcgmgmb = cgdo + cgso + pParam->BSIM4cgbo;
185 xcgmdb = -cgdo;
186 xcgmsb = -cgso;
187 xcgmbb = -pParam->BSIM4cgbo;
188
189 xcdgmb = xcgmdb;
190 xcsgmb = xcgmsb;
191 xcbgmb = xcgmbb;
192
193 xcggb = here->BSIM4cggb;
194 xcgdb = here->BSIM4cgdb;
195 xcgsb = here->BSIM4cgsb;
196 xcgbb = -(xcggb + xcgdb + xcgsb);
197
198 xcdgb = here->BSIM4cdgb;
199 xcsgb = -(here->BSIM4cggb + here->BSIM4cbgb
200 + here->BSIM4cdgb);
201 xcbgb = here->BSIM4cbgb;
202 }
203 else
204 { xcggb = here->BSIM4cggb + cgdo + cgso
205 + pParam->BSIM4cgbo;
206 xcgdb = here->BSIM4cgdb - cgdo;
207 xcgsb = here->BSIM4cgsb - cgso;
208 xcgbb = -(xcggb + xcgdb + xcgsb);
209
210 xcdgb = here->BSIM4cdgb - cgdo;
211 xcsgb = -(here->BSIM4cggb + here->BSIM4cbgb
212 + here->BSIM4cdgb + cgso);
213 xcbgb = here->BSIM4cbgb - pParam->BSIM4cgbo;
214
215 xcdgmb = xcsgmb = xcbgmb = 0.0;
216 }
217 xcddb = here->BSIM4cddb + here->BSIM4capbd + cgdo;
218 xcdsb = here->BSIM4cdsb;
219
220 xcsdb = -(here->BSIM4cgdb + here->BSIM4cbdb
221 + here->BSIM4cddb);
222 xcssb = here->BSIM4capbs + cgso - (here->BSIM4cgsb
223 + here->BSIM4cbsb + here->BSIM4cdsb);
224
225 if (!here->BSIM4rbodyMod)
226 { xcdbb = -(xcdgb + xcddb + xcdsb + xcdgmb);
227 xcsbb = -(xcsgb + xcsdb + xcssb + xcsgmb);
228 xcbdb = here->BSIM4cbdb - here->BSIM4capbd;
229 xcbsb = here->BSIM4cbsb - here->BSIM4capbs;
230 xcdbdb = 0.0;
231 }
232 else
233 { xcdbb = -(here->BSIM4cddb + here->BSIM4cdgb
234 + here->BSIM4cdsb);
235 xcsbb = -(xcsgb + xcsdb + xcssb + xcsgmb)
236 + here->BSIM4capbs;
237 xcbdb = here->BSIM4cbdb;
238 xcbsb = here->BSIM4cbsb;
239
240 xcdbdb = -here->BSIM4capbd;
241 xcsbsb = -here->BSIM4capbs;
242 }
243 xcbbb = -(xcbdb + xcbgb + xcbsb + xcbgmb);
244
245 xgtg = xgtd = xgts = xgtb = 0.0;
246 sxpart = 0.6;
247 dxpart = 0.4;
248 ddxpart_dVd = ddxpart_dVg = ddxpart_dVb
249 = ddxpart_dVs = 0.0;
250 dsxpart_dVd = dsxpart_dVg = dsxpart_dVb
251 = dsxpart_dVs = 0.0;
252 }
253 else
254 { xcggb = xcgdb = xcgsb = xcgbb = 0.0;
255 xcbgb = xcbdb = xcbsb = xcbbb = 0.0;
256 xcdgb = xcddb = xcdsb = xcdbb = 0.0;
257 xcsgb = xcsdb = xcssb = xcsbb = 0.0;
258
259 xgtg = here->BSIM4gtg;
260 xgtd = here->BSIM4gtd;
261 xgts = here->BSIM4gts;
262 xgtb = here->BSIM4gtb;
263
264 xcqgb = here->BSIM4cqgb;
265 xcqdb = here->BSIM4cqdb;
266 xcqsb = here->BSIM4cqsb;
267 xcqbb = here->BSIM4cqbb;
268
269 CoxWL = model->BSIM4coxe * here->pParam->BSIM4weffCV
270 * here->BSIM4nf * here->pParam->BSIM4leffCV;
271 qcheq = -(here->BSIM4qgate + here->BSIM4qbulk);
272 if (fabs(qcheq) <= 1.0e-5 * CoxWL)
273 { if (model->BSIM4xpart < 0.5)
274 { dxpart = 0.4;
275 }
276 else if (model->BSIM4xpart > 0.5)
277 { dxpart = 0.0;
278 }
279 else
280 { dxpart = 0.5;
281 }
282 ddxpart_dVd = ddxpart_dVg = ddxpart_dVb
283 = ddxpart_dVs = 0.0;
284 }
285 else
286 { dxpart = here->BSIM4qdrn / qcheq;
287 Cdd = here->BSIM4cddb;
288 Csd = -(here->BSIM4cgdb + here->BSIM4cddb
289 + here->BSIM4cbdb);
290 ddxpart_dVd = (Cdd - dxpart * (Cdd + Csd)) / qcheq;
291 Cdg = here->BSIM4cdgb;
292 Csg = -(here->BSIM4cggb + here->BSIM4cdgb
293 + here->BSIM4cbgb);
294 ddxpart_dVg = (Cdg - dxpart * (Cdg + Csg)) / qcheq;
295
296 Cds = here->BSIM4cdsb;
297 Css = -(here->BSIM4cgsb + here->BSIM4cdsb
298 + here->BSIM4cbsb);
299 ddxpart_dVs = (Cds - dxpart * (Cds + Css)) / qcheq;
300
301 ddxpart_dVb = -(ddxpart_dVd + ddxpart_dVg
302 + ddxpart_dVs);
303 }
304 sxpart = 1.0 - dxpart;
305 dsxpart_dVd = -ddxpart_dVd;
306 dsxpart_dVg = -ddxpart_dVg;
307 dsxpart_dVs = -ddxpart_dVs;
308 dsxpart_dVb = -(dsxpart_dVd + dsxpart_dVg + dsxpart_dVs);
309 }
310 }
311 else
312 { Gm = -here->BSIM4gm;
313 Gmbs = -here->BSIM4gmbs;
314 FwdSum = 0.0;
315 RevSum = -(Gm + Gmbs);
316
317 gbbsp = -(here->BSIM4gbds);
318 gbbdp = here->BSIM4gbds + here->BSIM4gbgs + here->BSIM4gbbs;
319
320 gbdpg = 0.0;
321 gbdpsp = 0.0;
322 gbdpb = 0.0;
323 gbdpdp = 0.0;
324
325 gbspg = here->BSIM4gbgs;
326 gbspsp = here->BSIM4gbds;
327 gbspb = here->BSIM4gbbs;
328 gbspdp = -(gbspg + gbspsp + gbspb);
329
330 if (model->BSIM4igcMod)
331 { gIstotg = here->BSIM4gIgsg + here->BSIM4gIgcdg;
332 gIstotd = here->BSIM4gIgcds;
333 gIstots = here->BSIM4gIgss + here->BSIM4gIgcdd;
334 gIstotb = here->BSIM4gIgcdb;
335
336 gIdtotg = here->BSIM4gIgdg + here->BSIM4gIgcsg;
337 gIdtotd = here->BSIM4gIgdd + here->BSIM4gIgcss;
338 gIdtots = here->BSIM4gIgcsd;
339 gIdtotb = here->BSIM4gIgcsb;
340 }
341 else
342 { gIstotg = gIstotd = gIstots = gIstotb = 0.0;
343 gIdtotg = gIdtotd = gIdtots = gIdtotb = 0.0;
344 }
345
346 if (model->BSIM4igbMod)
347 { gIbtotg = here->BSIM4gIgbg;
348 gIbtotd = here->BSIM4gIgbs;
349 gIbtots = here->BSIM4gIgbd;
350 gIbtotb = here->BSIM4gIgbb;
351 }
352 else
353 gIbtotg = gIbtotd = gIbtots = gIbtotb = 0.0;
354
355 if ((model->BSIM4igcMod != 0) || (model->BSIM4igbMod != 0))
356 { gIgtotg = gIstotg + gIdtotg + gIbtotg;
357 gIgtotd = gIstotd + gIdtotd + gIbtotd ;
358 gIgtots = gIstots + gIdtots + gIbtots;
359 gIgtotb = gIstotb + gIdtotb + gIbtotb;
360 }
361 else
362 gIgtotg = gIgtotd = gIgtots = gIgtotb = 0.0;
363
364 if (here->BSIM4rgateMod == 2)
365 T0 = *(ckt->CKTstates[0] + here->BSIM4vges)
366 - *(ckt->CKTstates[0] + here->BSIM4vgs);
367 else if (here->BSIM4rgateMod == 3)
368 T0 = *(ckt->CKTstates[0] + here->BSIM4vgms)
369 - *(ckt->CKTstates[0] + here->BSIM4vgs);
370 if (here->BSIM4rgateMod > 1)
371 { gcrgd = here->BSIM4gcrgs * T0;
372 gcrgg = here->BSIM4gcrgg * T0;
373 gcrgs = here->BSIM4gcrgd * T0;
374 gcrgb = here->BSIM4gcrgb * T0;
375 gcrgg -= here->BSIM4gcrg;
376 gcrg = here->BSIM4gcrg;
377 }
378 else
379 gcrg = gcrgd = gcrgg = gcrgs = gcrgb = 0.0;
380
381 if (here->BSIM4acnqsMod == 0)
382 { if (here->BSIM4rgateMod == 3)
383 { xcgmgmb = cgdo + cgso + pParam->BSIM4cgbo;
384 xcgmdb = -cgdo;
385 xcgmsb = -cgso;
386 xcgmbb = -pParam->BSIM4cgbo;
387
388 xcdgmb = xcgmdb;
389 xcsgmb = xcgmsb;
390 xcbgmb = xcgmbb;
391
392 xcggb = here->BSIM4cggb;
393 xcgdb = here->BSIM4cgsb;
394 xcgsb = here->BSIM4cgdb;
395 xcgbb = -(xcggb + xcgdb + xcgsb);
396
397 xcdgb = -(here->BSIM4cggb + here->BSIM4cbgb
398 + here->BSIM4cdgb);
399 xcsgb = here->BSIM4cdgb;
400 xcbgb = here->BSIM4cbgb;
401 }
402 else
403 { xcggb = here->BSIM4cggb + cgdo + cgso
404 + pParam->BSIM4cgbo;
405 xcgdb = here->BSIM4cgsb - cgdo;
406 xcgsb = here->BSIM4cgdb - cgso;
407 xcgbb = -(xcggb + xcgdb + xcgsb);
408
409 xcdgb = -(here->BSIM4cggb + here->BSIM4cbgb
410 + here->BSIM4cdgb + cgdo);
411 xcsgb = here->BSIM4cdgb - cgso;
412 xcbgb = here->BSIM4cbgb - pParam->BSIM4cgbo;
413
414 xcdgmb = xcsgmb = xcbgmb = 0.0;
415 }
416 xcddb = here->BSIM4capbd + cgdo - (here->BSIM4cgsb
417 + here->BSIM4cbsb + here->BSIM4cdsb);
418 xcdsb = -(here->BSIM4cgdb + here->BSIM4cbdb
419 + here->BSIM4cddb);
420
421 xcsdb = here->BSIM4cdsb;
422 xcssb = here->BSIM4cddb + here->BSIM4capbs + cgso;
423
424 if (!here->BSIM4rbodyMod)
425 { xcdbb = -(xcdgb + xcddb + xcdsb + xcdgmb);
426 xcsbb = -(xcsgb + xcsdb + xcssb + xcsgmb);
427 xcbdb = here->BSIM4cbsb - here->BSIM4capbd;
428 xcbsb = here->BSIM4cbdb - here->BSIM4capbs;
429 xcdbdb = 0.0;
430 }
431 else
432 { xcdbb = -(xcdgb + xcddb + xcdsb + xcdgmb)
433 + here->BSIM4capbd;
434 xcsbb = -(here->BSIM4cddb + here->BSIM4cdgb
435 + here->BSIM4cdsb);
436 xcbdb = here->BSIM4cbsb;
437 xcbsb = here->BSIM4cbdb;
438 xcdbdb = -here->BSIM4capbd;
439 xcsbsb = -here->BSIM4capbs;
440 }
441 xcbbb = -(xcbgb + xcbdb + xcbsb + xcbgmb);
442
443 xgtg = xgtd = xgts = xgtb = 0.0;
444 sxpart = 0.4;
445 dxpart = 0.6;
446 ddxpart_dVd = ddxpart_dVg = ddxpart_dVb
447 = ddxpart_dVs = 0.0;
448 dsxpart_dVd = dsxpart_dVg = dsxpart_dVb
449 = dsxpart_dVs = 0.0;
450 }
451 else
452 { xcggb = xcgdb = xcgsb = xcgbb = 0.0;
453 xcbgb = xcbdb = xcbsb = xcbbb = 0.0;
454 xcdgb = xcddb = xcdsb = xcdbb = 0.0;
455 xcsgb = xcsdb = xcssb = xcsbb = 0.0;
456
457 xgtg = here->BSIM4gtg;
458 xgtd = here->BSIM4gts;
459 xgts = here->BSIM4gtd;
460 xgtb = here->BSIM4gtb;
461
462 xcqgb = here->BSIM4cqgb;
463 xcqdb = here->BSIM4cqsb;
464 xcqsb = here->BSIM4cqdb;
465 xcqbb = here->BSIM4cqbb;
466
467 CoxWL = model->BSIM4coxe * here->pParam->BSIM4weffCV
468 * here->BSIM4nf * here->pParam->BSIM4leffCV;
469 qcheq = -(here->BSIM4qgate + here->BSIM4qbulk);
470 if (fabs(qcheq) <= 1.0e-5 * CoxWL)
471 { if (model->BSIM4xpart < 0.5)
472 { sxpart = 0.4;
473 }
474 else if (model->BSIM4xpart > 0.5)
475 { sxpart = 0.0;
476 }
477 else
478 { sxpart = 0.5;
479 }
480 dsxpart_dVd = dsxpart_dVg = dsxpart_dVb
481 = dsxpart_dVs = 0.0;
482 }
483 else
484 { sxpart = here->BSIM4qdrn / qcheq;
485 Css = here->BSIM4cddb;
486 Cds = -(here->BSIM4cgdb + here->BSIM4cddb
487 + here->BSIM4cbdb);
488 dsxpart_dVs = (Css - sxpart * (Css + Cds)) / qcheq;
489 Csg = here->BSIM4cdgb;
490 Cdg = -(here->BSIM4cggb + here->BSIM4cdgb
491 + here->BSIM4cbgb);
492 dsxpart_dVg = (Csg - sxpart * (Csg + Cdg)) / qcheq;
493
494 Csd = here->BSIM4cdsb;
495 Cdd = -(here->BSIM4cgsb + here->BSIM4cdsb
496 + here->BSIM4cbsb);
497 dsxpart_dVd = (Csd - sxpart * (Csd + Cdd)) / qcheq;
498
499 dsxpart_dVb = -(dsxpart_dVd + dsxpart_dVg
500 + dsxpart_dVs);
501 }
502 dxpart = 1.0 - sxpart;
503 ddxpart_dVd = -dsxpart_dVd;
504 ddxpart_dVg = -dsxpart_dVg;
505 ddxpart_dVs = -dsxpart_dVs;
506 ddxpart_dVb = -(ddxpart_dVd + ddxpart_dVg + ddxpart_dVs);
507 }
508 }
509
510 if (model->BSIM4rdsMod == 1)
511 { gstot = here->BSIM4gstot;
512 gstotd = here->BSIM4gstotd;
513 gstotg = here->BSIM4gstotg;
514 gstots = here->BSIM4gstots - gstot;
515 gstotb = here->BSIM4gstotb;
516
517 gdtot = here->BSIM4gdtot;
518 gdtotd = here->BSIM4gdtotd - gdtot;
519 gdtotg = here->BSIM4gdtotg;
520 gdtots = here->BSIM4gdtots;
521 gdtotb = here->BSIM4gdtotb;
522 }
523 else
524 { gstot = gstotd = gstotg = gstots = gstotb = 0.0;
525 gdtot = gdtotd = gdtotg = gdtots = gdtotb = 0.0;
526 }
527
528
529 T1 = *(ckt->CKTstate0 + here->BSIM4qdef) * here->BSIM4gtau;
530 gds = here->BSIM4gds;
531
532 /*
533 * Loading PZ matrix
534 */
535 m = here->BSIM4m;
536
537 if (!model->BSIM4rdsMod)
538 { gdpr = here->BSIM4drainConductance;
539 gspr = here->BSIM4sourceConductance;
540 }
541 else
542 gdpr = gspr = 0.0;
543
544 if (!here->BSIM4rbodyMod)
545 { gjbd = here->BSIM4gbd;
546 gjbs = here->BSIM4gbs;
547 }
548 else
549 gjbd = gjbs = 0.0;
550
551 geltd = here->BSIM4grgeltd;
552
553 if (here->BSIM4rgateMod == 1)
554 { *(here->BSIM4GEgePtr) += m * geltd;
555 *(here->BSIM4GPgePtr) -= m * geltd;
556 *(here->BSIM4GEgpPtr) -= m * geltd;
557
558 *(here->BSIM4GPgpPtr ) += m * xcggb * s->real;
559 *(here->BSIM4GPgpPtr +1) += m * xcggb * s->imag;
560 *(here->BSIM4GPgpPtr) += m * (geltd - xgtg + gIgtotg);
561 *(here->BSIM4GPdpPtr ) += m * xcgdb * s->real;
562 *(here->BSIM4GPdpPtr +1) += m * xcgdb * s->imag;
563 *(here->BSIM4GPdpPtr) -= m * (xgtd - gIgtotd);
564 *(here->BSIM4GPspPtr ) += m * xcgsb * s->real;
565 *(here->BSIM4GPspPtr +1) += m * xcgsb * s->imag;
566 *(here->BSIM4GPspPtr) -= m * (xgts - gIgtots);
567 *(here->BSIM4GPbpPtr ) += m * xcgbb * s->real;
568 *(here->BSIM4GPbpPtr +1) += m * xcgbb * s->imag;
569 *(here->BSIM4GPbpPtr) -= m * (xgtb - gIgtotb);
570 }
571 else if (here->BSIM4rgateMod == 2)
572 { *(here->BSIM4GEgePtr) += m * gcrg;
573 *(here->BSIM4GEgpPtr) += m * gcrgg;
574 *(here->BSIM4GEdpPtr) += m * gcrgd;
575 *(here->BSIM4GEspPtr) += m * gcrgs;
576 *(here->BSIM4GEbpPtr) += m * gcrgb;
577
578 *(here->BSIM4GPgePtr) -= m * gcrg;
579 *(here->BSIM4GPgpPtr ) += m * xcggb * s->real;
580 *(here->BSIM4GPgpPtr +1) += m * xcggb * s->imag;
581 *(here->BSIM4GPgpPtr) -= m * (gcrgg + xgtg - gIgtotg);
582 *(here->BSIM4GPdpPtr ) += m * xcgdb * s->real;
583 *(here->BSIM4GPdpPtr +1) += m * xcgdb * s->imag;
584 *(here->BSIM4GPdpPtr) -= m * (gcrgd + xgtd - gIgtotd);
585 *(here->BSIM4GPspPtr ) += m * xcgsb * s->real;
586 *(here->BSIM4GPspPtr +1) += m * xcgsb * s->imag;
587 *(here->BSIM4GPspPtr) -= m * (gcrgs + xgts - gIgtots);
588 *(here->BSIM4GPbpPtr ) += m * xcgbb * s->real;
589 *(here->BSIM4GPbpPtr +1) += m * xcgbb * s->imag;
590 *(here->BSIM4GPbpPtr) -= m * (gcrgb + xgtb - gIgtotb);
591 }
592 else if (here->BSIM4rgateMod == 3)
593 { *(here->BSIM4GEgePtr) += m * geltd;
594 *(here->BSIM4GEgmPtr) -= m * geltd;
595 *(here->BSIM4GMgePtr) -= m * geltd;
596 *(here->BSIM4GMgmPtr) += m * (geltd + gcrg);
597 *(here->BSIM4GMgmPtr ) += m * xcgmgmb * s->real;
598 *(here->BSIM4GMgmPtr +1) += m * xcgmgmb * s->imag;
599
600 *(here->BSIM4GMdpPtr) += m * gcrgd;
601 *(here->BSIM4GMdpPtr ) += m * xcgmdb * s->real;
602 *(here->BSIM4GMdpPtr +1) += m * xcgmdb * s->imag;
603 *(here->BSIM4GMgpPtr) += m * gcrgg;
604 *(here->BSIM4GMspPtr) += m * gcrgs;
605 *(here->BSIM4GMspPtr ) += m * xcgmsb * s->real;
606 *(here->BSIM4GMspPtr +1) += m * xcgmsb * s->imag;
607 *(here->BSIM4GMbpPtr) += m * gcrgb;
608 *(here->BSIM4GMbpPtr ) += m * xcgmbb * s->real;
609 *(here->BSIM4GMbpPtr +1) += m * xcgmbb * s->imag;
610
611 *(here->BSIM4DPgmPtr ) += m * xcdgmb * s->real;
612 *(here->BSIM4DPgmPtr +1) += m * xcdgmb * s->imag;
613 *(here->BSIM4GPgmPtr) -= m * gcrg;
614 *(here->BSIM4SPgmPtr ) += m * xcsgmb * s->real;
615 *(here->BSIM4SPgmPtr +1) += m * xcsgmb * s->imag;
616 *(here->BSIM4BPgmPtr ) += m * xcbgmb * s->real;
617 *(here->BSIM4BPgmPtr +1) += m * xcbgmb * s->imag;
618
619 *(here->BSIM4GPgpPtr) -= m * (gcrgg + xgtg - gIgtotg);
620 *(here->BSIM4GPgpPtr ) += m * xcggb * s->real;
621 *(here->BSIM4GPgpPtr +1) += m * xcggb * s->imag;
622 *(here->BSIM4GPdpPtr) -= m * (gcrgd + xgtd - gIgtotd);
623 *(here->BSIM4GPdpPtr ) += m * xcgdb * s->real;
624 *(here->BSIM4GPdpPtr +1) += m * xcgdb * s->imag;
625 *(here->BSIM4GPspPtr) -= m * (gcrgs + xgts - gIgtots);
626 *(here->BSIM4GPspPtr ) += m * xcgsb * s->real;
627 *(here->BSIM4GPspPtr +1) += m * xcgsb * s->imag;
628 *(here->BSIM4GPbpPtr) -= m * (gcrgb + xgtb - gIgtotb);
629 *(here->BSIM4GPbpPtr ) += m * xcgbb * s->real;
630 *(here->BSIM4GPbpPtr +1) += m * xcgbb * s->imag;
631 }
632 else
633 { *(here->BSIM4GPdpPtr ) += m * xcgdb * s->real;
634 *(here->BSIM4GPdpPtr +1) += m * xcgdb * s->imag;
635 *(here->BSIM4GPdpPtr) -= m * (xgtd - gIgtotd);
636 *(here->BSIM4GPgpPtr ) += m * xcggb * s->real;
637 *(here->BSIM4GPgpPtr +1) += m * xcggb * s->imag;
638 *(here->BSIM4GPgpPtr) -= m * (xgtg - gIgtotg);
639 *(here->BSIM4GPspPtr ) += m * xcgsb * s->real;
640 *(here->BSIM4GPspPtr +1) += m * xcgsb * s->imag;
641 *(here->BSIM4GPspPtr) -= m * (xgts - gIgtots);
642 *(here->BSIM4GPbpPtr ) += m * xcgbb * s->real;
643 *(here->BSIM4GPbpPtr +1) += m * xcgbb * s->imag;
644 *(here->BSIM4GPbpPtr) -= m * (xgtb - gIgtotb);
645 }
646
647 if (model->BSIM4rdsMod)
648 { (*(here->BSIM4DgpPtr) += m * gdtotg);
649 (*(here->BSIM4DspPtr) += m * gdtots);
650 (*(here->BSIM4DbpPtr) += m * gdtotb);
651 (*(here->BSIM4SdpPtr) += m * gstotd);
652 (*(here->BSIM4SgpPtr) += m * gstotg);
653 (*(here->BSIM4SbpPtr) += m * gstotb);
654 }
655
656 *(here->BSIM4DPdpPtr ) += m * xcddb * s->real;
657 *(here->BSIM4DPdpPtr +1) += m * xcddb * s->imag;
658 *(here->BSIM4DPdpPtr) += m * (gdpr + gds + here->BSIM4gbd
659 - gdtotd + RevSum + gbdpdp - gIdtotd
660 + dxpart * xgtd + T1 * ddxpart_dVd);
661 *(here->BSIM4DPdPtr) -= m * (gdpr + gdtot);
662 *(here->BSIM4DPgpPtr ) += m * xcdgb * s->real;
663 *(here->BSIM4DPgpPtr +1) += m * xcdgb * s->imag;
664 *(here->BSIM4DPgpPtr) += m * (Gm - gdtotg + gbdpg - gIdtotg
665 + T1 * ddxpart_dVg + dxpart * xgtg);
666 *(here->BSIM4DPspPtr ) += m * xcdsb * s->real;
667 *(here->BSIM4DPspPtr +1) += m * xcdsb * s->imag;
668 *(here->BSIM4DPspPtr) -= m * (gds + FwdSum + gdtots - gbdpsp + gIdtots
669 - T1 * ddxpart_dVs - dxpart * xgts);
670 *(here->BSIM4DPbpPtr ) += m * xcdbb * s->real;
671 *(here->BSIM4DPbpPtr +1) += m * xcdbb * s->imag;
672 *(here->BSIM4DPbpPtr) -= m * (gjbd + gdtotb - Gmbs - gbdpb + gIdtotb
673 - T1 * ddxpart_dVb - dxpart * xgtb);
674
675 *(here->BSIM4DdpPtr) -= m * (gdpr - gdtotd);
676 *(here->BSIM4DdPtr) += m * (gdpr + gdtot);
677
678 *(here->BSIM4SPdpPtr ) += m * xcsdb * s->real;
679 *(here->BSIM4SPdpPtr +1) += m * xcsdb * s->imag;
680 *(here->BSIM4SPdpPtr) -= m * (gds + gstotd + RevSum - gbspdp + gIstotd
681 - T1 * dsxpart_dVd - sxpart * xgtd);
682 *(here->BSIM4SPgpPtr ) += m * xcsgb * s->real;
683 *(here->BSIM4SPgpPtr +1) += m * xcsgb * s->imag;
684 *(here->BSIM4SPgpPtr) -= m * (Gm + gstotg - gbspg + gIstotg
685 - T1 * dsxpart_dVg - sxpart * xgtg);
686 *(here->BSIM4SPspPtr ) += m * xcssb * s->real;
687 *(here->BSIM4SPspPtr +1) += m * xcssb * s->imag;
688 *(here->BSIM4SPspPtr) += m * (gspr + gds + here->BSIM4gbs - gIstots
689 - gstots + FwdSum + gbspsp
690 + sxpart * xgts + T1 * dsxpart_dVs);
691 *(here->BSIM4SPsPtr) -= m * (gspr + gstot);
692 *(here->BSIM4SPbpPtr ) += m * xcsbb * s->real;
693 *(here->BSIM4SPbpPtr +1) += m * xcsbb * s->imag;
694 *(here->BSIM4SPbpPtr) -= m * (gjbs + gstotb + Gmbs - gbspb + gIstotb
695 - T1 * dsxpart_dVb - sxpart * xgtb);
696
697 *(here->BSIM4SspPtr) -= m * (gspr - gstots);
698 *(here->BSIM4SsPtr) += m * (gspr + gstot);
699
700 *(here->BSIM4BPdpPtr ) += m * xcbdb * s->real;
701 *(here->BSIM4BPdpPtr +1) += m * xcbdb * s->imag;
702 *(here->BSIM4BPdpPtr) -= m * (gjbd - gbbdp + gIbtotd);
703 *(here->BSIM4BPgpPtr ) += m * xcbgb * s->real;
704 *(here->BSIM4BPgpPtr +1) += m * xcbgb * s->imag;
705 *(here->BSIM4BPgpPtr) -= m * (here->BSIM4gbgs + gIbtotg);
706 *(here->BSIM4BPspPtr ) += m * xcbsb * s->real;
707 *(here->BSIM4BPspPtr +1) += m * xcbsb * s->imag;
708 *(here->BSIM4BPspPtr) -= m * (gjbs - gbbsp + gIbtots);
709 *(here->BSIM4BPbpPtr ) += m * xcbbb * s->real;
710 *(here->BSIM4BPbpPtr +1) += m * xcbbb * s->imag;
711 *(here->BSIM4BPbpPtr) += m * (gjbd + gjbs - here->BSIM4gbbs
712 - gIbtotb);
713 ggidld = here->BSIM4ggidld;
714 ggidlg = here->BSIM4ggidlg;
715 ggidlb = here->BSIM4ggidlb;
716 ggislg = here->BSIM4ggislg;
717 ggisls = here->BSIM4ggisls;
718 ggislb = here->BSIM4ggislb;
719
720 /* stamp gidl */
721 (*(here->BSIM4DPdpPtr) += m * ggidld);
722 (*(here->BSIM4DPgpPtr) += m * ggidlg);
723 (*(here->BSIM4DPspPtr) -= m * ((ggidlg + ggidld) + ggidlb));
724 (*(here->BSIM4DPbpPtr) += m * ggidlb);
725 (*(here->BSIM4BPdpPtr) -= m * ggidld);
726 (*(here->BSIM4BPgpPtr) -= m * ggidlg);
727 (*(here->BSIM4BPspPtr) += m * ((ggidlg + ggidld) + ggidlb));
728 (*(here->BSIM4BPbpPtr) -= m * ggidlb);
729 /* stamp gisl */
730 (*(here->BSIM4SPdpPtr) -= m * ((ggisls + ggislg) + ggislb));
731 (*(here->BSIM4SPgpPtr) += m * ggislg);
732 (*(here->BSIM4SPspPtr) += m * ggisls);
733 (*(here->BSIM4SPbpPtr) += m * ggislb);
734 (*(here->BSIM4BPdpPtr) += m * ((ggislg + ggisls) + ggislb));
735 (*(here->BSIM4BPgpPtr) -= m * ggislg);
736 (*(here->BSIM4BPspPtr) -= m * ggisls);
737 (*(here->BSIM4BPbpPtr) -= m * ggislb);
738
739 if (here->BSIM4rbodyMod)
740 { (*(here->BSIM4DPdbPtr ) += m * xcdbdb * s->real);
741 (*(here->BSIM4DPdbPtr +1) += m * xcdbdb * s->imag);
742 (*(here->BSIM4DPdbPtr) -= m * here->BSIM4gbd);
743 (*(here->BSIM4SPsbPtr ) += m * xcsbsb * s->real);
744 (*(here->BSIM4SPsbPtr +1) += m * xcsbsb * s->imag);
745 (*(here->BSIM4SPsbPtr) -= m * here->BSIM4gbs);
746
747 (*(here->BSIM4DBdpPtr ) += m * xcdbdb * s->real);
748 (*(here->BSIM4DBdpPtr +1) += m * xcdbdb * s->imag);
749 (*(here->BSIM4DBdpPtr) -= m * here->BSIM4gbd);
750 (*(here->BSIM4DBdbPtr ) -= m * xcdbdb * s->real);
751 (*(here->BSIM4DBdbPtr +1) -= m * xcdbdb * s->imag);
752 (*(here->BSIM4DBdbPtr) += m * (here->BSIM4gbd + here->BSIM4grbpd
753 + here->BSIM4grbdb));
754 (*(here->BSIM4DBbpPtr) -= m * here->BSIM4grbpd);
755 (*(here->BSIM4DBbPtr) -= m * here->BSIM4grbdb);
756
757 (*(here->BSIM4BPdbPtr) -= m * here->BSIM4grbpd);
758 (*(here->BSIM4BPbPtr) -= m * here->BSIM4grbpb);
759 (*(here->BSIM4BPsbPtr) -= m * here->BSIM4grbps);
760 (*(here->BSIM4BPbpPtr) += m * (here->BSIM4grbpd + here->BSIM4grbps
761 + here->BSIM4grbpb));
762 /* WDL: (-here->BSIM4gbbs) already added to BPbpPtr */
763
764 (*(here->BSIM4SBspPtr ) += m * xcsbsb * s->real);
765 (*(here->BSIM4SBspPtr +1) += m * xcsbsb * s->imag);
766 (*(here->BSIM4SBspPtr) -= m * here->BSIM4gbs);
767 (*(here->BSIM4SBbpPtr) -= m * here->BSIM4grbps);
768 (*(here->BSIM4SBbPtr) -= m * here->BSIM4grbsb);
769 (*(here->BSIM4SBsbPtr ) -= m * xcsbsb * s->real);
770 (*(here->BSIM4SBsbPtr +1) -= m * xcsbsb * s->imag);
771 (*(here->BSIM4SBsbPtr) += m * (here->BSIM4gbs
772 + here->BSIM4grbps + here->BSIM4grbsb));
773
774 (*(here->BSIM4BdbPtr) -= m * here->BSIM4grbdb);
775 (*(here->BSIM4BbpPtr) -= m * here->BSIM4grbpb);
776 (*(here->BSIM4BsbPtr) -= m * here->BSIM4grbsb);
777 (*(here->BSIM4BbPtr) += m * (here->BSIM4grbsb + here->BSIM4grbdb
778 + here->BSIM4grbpb));
779 }
780
781 if (here->BSIM4acnqsMod)
782 { *(here->BSIM4QqPtr ) += m * s->real * ScalingFactor;
783 *(here->BSIM4QqPtr +1) += m * s->imag * ScalingFactor;
784 *(here->BSIM4QgpPtr ) -= m * xcqgb * s->real;
785 *(here->BSIM4QgpPtr +1) -= m * xcqgb * s->imag;
786 *(here->BSIM4QdpPtr ) -= m * xcqdb * s->real;
787 *(here->BSIM4QdpPtr +1) -= m * xcqdb * s->imag;
788 *(here->BSIM4QbpPtr ) -= m * xcqbb * s->real;
789 *(here->BSIM4QbpPtr +1) -= m * xcqbb * s->imag;
790 *(here->BSIM4QspPtr ) -= m * xcqsb * s->real;
791 *(here->BSIM4QspPtr +1) -= m * xcqsb * s->imag;
792
793 *(here->BSIM4GPqPtr) -= m * here->BSIM4gtau;
794 *(here->BSIM4DPqPtr) += m * dxpart * here->BSIM4gtau;
795 *(here->BSIM4SPqPtr) += m * sxpart * here->BSIM4gtau;
796
797 *(here->BSIM4QqPtr) += m * here->BSIM4gtau;
798 *(here->BSIM4QgpPtr) += m * xgtg;
799 *(here->BSIM4QdpPtr) += m * xgtd;
800 *(here->BSIM4QbpPtr) += m * xgtb;
801 *(here->BSIM4QspPtr) += m * xgts;
802 }
803 }
804 }
805 return(OK);
806 }
807