My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
andor4x4.core.cpp
Go to the documentation of this file.
1 /*
2  * andor4x4.core.cpp - device implementations for andor4x4 module
3  *
4  * This is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2, or (at your option)
7  * any later version.
8  *
9  */
10 
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14 
16 #include "component.h"
17 #include "device.h"
18 #include "andor4x4.core.h"
19 
20 #ifndef CIR_andor4x4
21 #define CIR_andor4x4 -1
22 #endif
23 
24 // external nodes
25 #define A11 0
26 #define A12 1
27 #define A13 2
28 #define A14 3
29 #define A21 4
30 #define A22 5
31 #define A23 6
32 #define A24 7
33 #define A31 8
34 #define A32 9
35 #define A33 10
36 #define A34 11
37 #define A41 12
38 #define A42 13
39 #define A43 14
40 #define A44 15
41 #define Y 16
42 // internal nodes
43 #define n1 17
44 #define n2 18
45 
46 // useful macro definitions
47 #define NP(node) real (getV (node))
48 #define BP(pnode,nnode) (NP(pnode) - NP(nnode))
49 #define _load_static_residual2(pnode,nnode,current)\
50  _rhs[pnode] -= current;\
51  _rhs[nnode] += current;
52 #define _load_static_augmented_residual2(pnode,nnode,current)\
53  _rhs[pnode] -= current;\
54  _rhs[nnode] += current;
55 #define _load_static_residual1(node,current)\
56  _rhs[node] -= current;
57 #define _load_static_augmented_residual1(node,current)\
58  _rhs[node] -= current;
59 #define _load_static_jacobian4(pnode,nnode,vpnode,vnnode,conductance)\
60  _jstat[pnode][vpnode] += conductance;\
61  _jstat[nnode][vnnode] += conductance;\
62  _jstat[pnode][vnnode] -= conductance;\
63  _jstat[nnode][vpnode] -= conductance;\
64  if (doHB) {\
65  _ghs[pnode] += conductance * BP(vpnode,vnnode);\
66  _ghs[nnode] -= conductance * BP(vpnode,vnnode);\
67  } else {\
68  _rhs[pnode] += conductance * BP(vpnode,vnnode);\
69  _rhs[nnode] -= conductance * BP(vpnode,vnnode);\
70  }
71 #define _load_static_jacobian2p(node,vpnode,vnnode,conductance)\
72  _jstat[node][vpnode] += conductance;\
73  _jstat[node][vnnode] -= conductance;\
74  if (doHB) {\
75  _ghs[node] += conductance * BP(vpnode,vnnode);\
76  } else {\
77  _rhs[node] += conductance * BP(vpnode,vnnode);\
78  }
79 #define _load_static_jacobian2s(pnode,nnode,node,conductance)\
80  _jstat[pnode][node] += conductance;\
81  _jstat[nnode][node] -= conductance;\
82  if (doHB) {\
83  _ghs[pnode] += conductance * NP(node);\
84  _ghs[nnode] -= conductance * NP(node);\
85  } else {\
86  _rhs[pnode] += conductance * NP(node);\
87  _rhs[nnode] -= conductance * NP(node);\
88  }
89 #define _load_static_jacobian1(node,vnode,conductance)\
90  _jstat[node][vnode] += conductance;\
91  if (doHB) {\
92  _ghs[node] += conductance * NP(vnode);\
93  } else {\
94  _rhs[node] += conductance * NP(vnode);\
95  }
96 #define _load_dynamic_residual2(pnode,nnode,charge)\
97  if (doTR) _charges[pnode][nnode] += charge;\
98  if (doHB) {\
99  _qhs[pnode] -= charge;\
100  _qhs[nnode] += charge;\
101  }
102 #define _load_dynamic_residual1(node,charge)\
103  if (doTR) _charges[node][node] += charge;\
104  if (doHB) {\
105  _qhs[node] -= charge;\
106  }
107 #define _load_dynamic_jacobian4(pnode,nnode,vpnode,vnnode,capacitance)\
108  if (doAC) {\
109  _jdyna[pnode][vpnode] += capacitance;\
110  _jdyna[nnode][vnnode] += capacitance;\
111  _jdyna[pnode][vnnode] -= capacitance;\
112  _jdyna[nnode][vpnode] -= capacitance;\
113  }\
114  if (doTR) {\
115  _caps[pnode][nnode][vpnode][vnnode] += capacitance;\
116  }\
117  if (doHB) {\
118  _chs[pnode] += capacitance * BP(vpnode,vnnode);\
119  _chs[nnode] -= capacitance * BP(vpnode,vnnode);\
120  }
121 #define _load_dynamic_jacobian2s(pnode,nnode,vnode,capacitance)\
122  if (doAC) {\
123  _jdyna[pnode][vnode] += capacitance;\
124  _jdyna[nnode][vnode] -= capacitance;\
125  }\
126  if (doTR) {\
127  _caps[pnode][nnode][vnode][vnode] += capacitance;\
128  }\
129  if (doHB) {\
130  _chs[pnode] += capacitance * NP(vnode);\
131  _chs[nnode] -= capacitance * NP(vnode);\
132  }
133 #define _load_dynamic_jacobian2p(node,vpnode,vnnode,capacitance)\
134  if (doAC) {\
135  _jdyna[node][vpnode] += capacitance;\
136  _jdyna[node][vnnode] -= capacitance;\
137  }\
138  if (doTR) {\
139  _caps[node][node][vpnode][vnnode] += capacitance;\
140  }\
141  if (doHB) {\
142  _chs[node] += capacitance * BP(vpnode,vnnode);\
143  }
144 #define _load_dynamic_jacobian1(node,vnode,capacitance)\
145  if (doAC) {\
146  _jdyna[node][vnode] += capacitance;\
147  }\
148  if (doTR) {\
149  _caps[node][node][vnode][vnode] += capacitance;\
150  }\
151  if (doHB) {\
152  _chs[node] += capacitance * NP(vnode);\
153  }
154 
155 #define _save_whitenoise1(n1,pwr,type)\
156  _white_pwr[n1][n1] += pwr;
157 #define _save_whitenoise2(n1,n2,pwr,type)\
158  _white_pwr[n1][n2] += pwr;
159 #define _save_flickernoise1(n1,pwr,exp,type)\
160  _flicker_pwr[n1][n1] += pwr;\
161  _flicker_exp[n1][n1] += exp;
162 #define _save_flickernoise2(n1,n2,pwr,exp,type)\
163  _flicker_pwr[n1][n2] += pwr;\
164  _flicker_exp[n1][n2] += exp;
165 #define _load_whitenoise2(n1,n2,pwr)\
166  cy (n1,n2) -= pwr/kB/T0; cy (n2,n1) -= pwr/kB/T0;\
167  cy (n1,n1) += pwr/kB/T0; cy (n2,n2) += pwr/kB/T0;
168 #define _load_whitenoise1(n1,pwr)\
169  cy (n1,n1) += pwr/kB/T0;
170 #define _load_flickernoise2(n1,n2,pwr,exp)\
171  cy (n1,n2) -= pwr*pow(_freq,-exp)/kB/T0;\
172  cy (n2,n1) -= pwr*pow(_freq,-exp)/kB/T0;\
173  cy (n1,n1) += pwr*pow(_freq,-exp)/kB/T0;\
174  cy (n2,n2) += pwr*pow(_freq,-exp)/kB/T0;
175 #define _load_flickernoise1(n1,pwr,exp)\
176  cy (n1,n1) += pwr*pow(_freq,-exp)/kB/T0;
177 
178 // derivative helper macros
179 #define m00_hypot(v00,x,y) v00 = xhypot(x,y);
180 #define m10_hypot(v10,v00,x,y) v10 = (x)/(v00);
181 #define m11_hypot(v11,v00,x,y) v11 = (y)/(v00);
182 #define m00_max(v00,x,y) v00 = ((x)>(y))?(x):(y);
183 #define m10_max(v10,v00,x,y) v10 = ((x)>(y))?1.0:0.0;
184 #define m11_max(v11,v00,x,y) v11 = ((x)>(y))?0.0:1.0;
185 #define m00_min(v00,x,y) v00 = ((x)<(y))?(x):(y);
186 #define m10_min(v10,v00,x,y) v10 = ((x)<(y))?1.0:0.0;
187 #define m11_min(v11,v00,x,y) v11 = ((x)<(y))?0.0:1.0;
188 #define m00_pow(v00,x,y) v00 = pow(x,y);
189 #define m10_pow(v10,v00,x,y) v10 = (x==0.0)?0.0:(v00)*(y)/(x);
190 #define m11_pow(v11,v00,x,y) v11 = (x==0.0)?0.0:(log(x)*(v00));
191 
192 #define m00_div(v00,v10,x,y) double v10=1/(y); double v00=(x)*v10;
193 #define m10_div(v10,v00,vv,x,y)
194 #define m11_div(v11,v00,vv,x,y) double v11 = -v00*vv;
195 
196 #define m00_mult(v00,v10,v11,x,y) double v10=(x); double v11=(y); double v00=v10*v11;
197 #define m00_add(v00,x,y) double v00=(x)+(y);
198 
199 #define m00_cos(v00,x) v00 = cos(x);
200 #define m10_cos(v10,v00,x) v10 = (-sin(x));
201 #define m00_sin(v00,x) v00 = sin(x);
202 #define m10_sin(v10,v00,x) v10 = (cos(x));
203 #define m00_tan(v00,x) v00 = tan(x);
204 #define m10_tan(v10,v00,x) v10 = (1.0/cos(x)/cos(x));
205 #define m00_cosh(v00,x) v00 = cosh(x);
206 #define m10_cosh(v10,v00,x) v10 = (sinh(x));
207 #define m00_sinh(v00,x) v00 = sinh(x);
208 #define m10_sinh(v10,v00,x) v10 = (cosh(x));
209 #define m00_tanh(v00,x) v00 = tanh(x);
210 #define m10_tanh(v10,v00,x) v10 = (1.0/cosh(x)/cosh(x));
211 #define m00_acos(v00,x) v00 = acos(x);
212 #define m10_acos(v10,v00,x) v10 = (-1.0/sqrt(1-x*x));
213 #define m00_asin(v00,x) v00 = asin(x);
214 #define m10_asin(v10,v00,x) v10 = (+1.0/sqrt(1-x*x));
215 #define m00_atan(v00,x) v00 = atan(x);
216 #define m10_atan(v10,v00,x) v10 = (+1.0/(1+x*x));
217 #define m00_atanh(v00,x) v00 = atanh(x);
218 #define m10_atanh(v10,v00,x) v10 = (+1.0/(1-x*x));
219 #define m00_logE(v00,x) v00 = log(x);
220 #define m10_logE(v10,v00,x) v10 = (1.0/x);
221 #define m00_log10(v00,x) v00 = log10(x);
222 #define m10_log10(v10,v00,x) v10 = (1.0/x/M_LN10);
223 #define m00_sqrt(v00,x) v00 = sqrt(x);
224 #define m10_sqrt(v10,v00,x) v10 = (0.5/v00);
225 #define m00_fabs(v00,x) v00 = fabs(x);
226 #define m10_fabs(v10,v00,x) v10 = (((x)>=0)?(+1.0):(-1.0));
227 
228 #define m00_exp(v00,x) v00 = exp(x);
229 #define m10_exp(v10,v00,x) v10 = v00;
230 
231 #define m00_abs(v00) ((v00)<(0)?(-(v00)):(v00))
232 #define m00_floor(v00,x) v00 = floor(x);
233 #define m00_limexp(v00,x) v00 = ((x)<80.0?exp(x):exp(80.0)*(x-79.0));
234 #define m10_limexp(v10,v00,x) v10 = ((x)<80.0?(v00):exp(80.0));
235 
236 #define m20_logE(v00) (-1.0/v00/v00)
237 #define m20_exp(v00) exp(v00)
238 #define m20_limexp(v00) ((v00)<80.0?exp(v00):0.0)
239 #define m20_sqrt(v00) (-0.25/(v00)/sqrt(v00))
240 #define m20_fabs(v00) 0.0
241 #define m20_pow(x,y) ((y)*((y)-1.0)*pow(x,y)/(x)/(x))
242 #define m00_vt(x) (kBoverQ*(x))
243 #define m10_vt(x) (kBoverQ)
244 
245 // simulator specific definitions
246 #define _modelname "andor4x4"
247 #define _instancename getName()
248 #define _circuit_temp (getPropertyDouble("Temp")+273.15)
249 #define _param_given(p) (isPropertyGiven(p)?1:0)
250 
251 
252 // $vt and $vt() functions
253 #define _vt_nom (kBoverQ*_circuit_temp)
254 
255 using namespace device;
256 
257 /* Device constructor. */
259 {
260  type = CIR_andor4x4;
261 }
262 
263 /* Initialization of model. */
264 void andor4x4::initModel (void)
265 {
266  // create internal nodes
267  setInternalNode (n1, "n1");
268  setInternalNode (n2, "n2");
269 
270  // get device model parameters
271  loadVariables ();
272  // evaluate global model equations
273  initializeModel ();
274  // evaluate initial step equations
275  initialStep ();
276  // evaluate global instance equations
277  initializeInstance ();
278 }
279 
280 /* Initialization of DC analysis. */
281 void andor4x4::initDC (void)
282 {
283  allocMatrixMNA ();
284  initModel ();
285  pol = 1;
286  restartDC ();
287  doAC = 1;
288  doTR = 0;
289  doHB = 0;
290 }
291 
292 /* Run when DC is restarted (fallback algorithms). */
294 {
295 }
296 
297 /* Initialize Verilog-AMS code. */
298 void andor4x4::initVerilog (void)
299 {
300  // initialization of noise variables
301 
302  int i1, i2, i3, i4;
303 
304  // zero charges
305  for (i1 = 0; i1 < 19; i1++) {
306  for (i2 = 0; i2 < 19; i2++) {
307  _charges[i1][i2] = 0.0;
308  } }
309 
310  // zero capacitances
311  for (i1 = 0; i1 < 19; i1++) {
312  for (i2 = 0; i2 < 19; i2++) {
313  for (i3 = 0; i3 < 19; i3++) {
314  for (i4 = 0; i4 < 19; i4++) {
315  _caps[i1][i2][i3][i4] = 0.0;
316  } } } }
317 
318  // zero right hand side, static and dynamic jacobian
319  for (i1 = 0; i1 < 19; i1++) {
320  _rhs[i1] = 0.0;
321  _qhs[i1] = 0.0;
322  _chs[i1] = 0.0;
323  _ghs[i1] = 0.0;
324  for (i2 = 0; i2 < 19; i2++) {
325  _jstat[i1][i2] = 0.0;
326  _jdyna[i1][i2] = 0.0;
327  }
328  }
329 }
330 
331 /* Load device model input parameters. */
332 void andor4x4::loadVariables (void)
333 {
334  TR = getPropertyDouble ("TR");
335  Delay = getPropertyDouble ("Delay");
336 }
337 
338 /* #define's for translated code */
339 #undef _DDT
340 #define _DDT(q) q
341 #define _DYNAMIC
342 #define _DERIVATE
343 #define _DDX
344 #define _DERIVATEFORDDX
345 
346 /* Evaluate Verilog-AMS equations in model initialization. */
347 void andor4x4::initializeModel (void)
348 {
349 #if defined(_DYNAMIC)
350 #endif
351 {
352 Rd=1e3;
353 #if defined(_DYNAMIC)
354 Cd=((Delay*1.43)/Rd);
355 #endif
356 }
357 }
358 
359 /* Evaluate Verilog-AMS equations in instance initialization. */
360 void andor4x4::initializeInstance (void)
361 {
362 }
363 
364 /* Evaluate Verilog-AMS equations in initial step. */
365 void andor4x4::initialStep (void)
366 {
367 }
368 
369 /* Evaluate Verilog-AMS equations in final step. */
370 void andor4x4::finalStep (void)
371 {
372 }
373 
374 /* Evaluate Verilog-AMS equations in analog block. */
375 void andor4x4::calcVerilog (void)
376 {
377 
378 /* ----------------- evaluate verilog analog equations -------------------- */
379 double Iand;
380 #if defined(_DERIVATE)
381 double Iand_VA11_GND;
382 double Iand_VA12_GND;
383 double Iand_VA13_GND;
384 double Iand_VA14_GND;
385 double Iand_VA21_GND;
386 double Iand_VA22_GND;
387 double Iand_VA23_GND;
388 double Iand_VA24_GND;
389 double Iand_VA31_GND;
390 double Iand_VA32_GND;
391 double Iand_VA33_GND;
392 double Iand_VA34_GND;
393 double Iand_VA41_GND;
394 double Iand_VA42_GND;
395 double Iand_VA43_GND;
396 double Iand_VA44_GND;
397 #endif
398 double m4;
399 #if defined(_DERIVATE)
400 double m4_VA41_GND;
401 double m4_VA42_GND;
402 double m4_VA43_GND;
403 double m4_VA44_GND;
404 #endif
405 double m3;
406 #if defined(_DERIVATE)
407 double m3_VA31_GND;
408 double m3_VA32_GND;
409 double m3_VA33_GND;
410 double m3_VA34_GND;
411 #endif
412 double m2;
413 #if defined(_DERIVATE)
414 double m2_VA21_GND;
415 double m2_VA22_GND;
416 double m2_VA23_GND;
417 double m2_VA24_GND;
418 #endif
419 double m1;
420 #if defined(_DERIVATE)
421 double m1_VA11_GND;
422 double m1_VA12_GND;
423 double m1_VA13_GND;
424 double m1_VA14_GND;
425 #endif
426 #if defined(_DERIVATE)
427 m1_VA11_GND=(NP(A12))*NP(A13)*NP(A14);
428 m1_VA12_GND=(NP(A11))*NP(A13)*NP(A14);
429 m1_VA13_GND=((NP(A11)*NP(A12)))*NP(A14);
430 m1_VA14_GND=(((NP(A11)*NP(A12))*NP(A13)));
431 #endif
432 m1=(((NP(A11)*NP(A12))*NP(A13))*NP(A14));
433 #if defined(_DERIVATE)
434 m2_VA21_GND=(NP(A22))*NP(A23)*NP(A24);
435 m2_VA22_GND=(NP(A21))*NP(A23)*NP(A24);
436 m2_VA23_GND=((NP(A21)*NP(A22)))*NP(A24);
437 m2_VA24_GND=(((NP(A21)*NP(A22))*NP(A23)));
438 #endif
439 m2=(((NP(A21)*NP(A22))*NP(A23))*NP(A24));
440 #if defined(_DERIVATE)
441 m3_VA31_GND=(NP(A32))*NP(A33)*NP(A34);
442 m3_VA32_GND=(NP(A31))*NP(A33)*NP(A34);
443 m3_VA33_GND=((NP(A31)*NP(A32)))*NP(A34);
444 m3_VA34_GND=(((NP(A31)*NP(A32))*NP(A33)));
445 #endif
446 m3=(((NP(A31)*NP(A32))*NP(A33))*NP(A34));
447 #if defined(_DERIVATE)
448 m4_VA41_GND=(NP(A42))*NP(A43)*NP(A44);
449 m4_VA42_GND=(NP(A41))*NP(A43)*NP(A44);
450 m4_VA43_GND=((NP(A41)*NP(A42)))*NP(A44);
451 m4_VA44_GND=(((NP(A41)*NP(A42))*NP(A43)));
452 #endif
453 m4=(((NP(A41)*NP(A42))*NP(A43))*NP(A44));
454 #if defined(_DERIVATE)
455 Iand_VA11_GND=m1_VA11_GND;
456 Iand_VA12_GND=m1_VA12_GND;
457 Iand_VA13_GND=m1_VA13_GND;
458 Iand_VA14_GND=m1_VA14_GND;
459 Iand_VA21_GND=m2_VA21_GND;
460 Iand_VA22_GND=m2_VA22_GND;
461 Iand_VA23_GND=m2_VA23_GND;
462 Iand_VA24_GND=m2_VA24_GND;
463 Iand_VA31_GND=m3_VA31_GND;
464 Iand_VA32_GND=m3_VA32_GND;
465 Iand_VA33_GND=m3_VA33_GND;
466 Iand_VA34_GND=m3_VA34_GND;
467 Iand_VA41_GND=m4_VA41_GND;
468 Iand_VA42_GND=m4_VA42_GND;
469 Iand_VA43_GND=m4_VA43_GND;
470 Iand_VA44_GND=m4_VA44_GND;
471 #endif
472 Iand=(((m1+m2)+m3)+m4);
473 if
474 ((Iand>0.5))
475 {
476 #if defined(_DERIVATE)
477 Iand_VA11_GND=0.0;
478 Iand_VA12_GND=0.0;
479 Iand_VA13_GND=0.0;
480 Iand_VA14_GND=0.0;
481 Iand_VA21_GND=0.0;
482 Iand_VA22_GND=0.0;
483 Iand_VA23_GND=0.0;
484 Iand_VA24_GND=0.0;
485 Iand_VA31_GND=0.0;
486 Iand_VA32_GND=0.0;
487 Iand_VA33_GND=0.0;
488 Iand_VA34_GND=0.0;
489 Iand_VA41_GND=0.0;
490 Iand_VA42_GND=0.0;
491 Iand_VA43_GND=0.0;
492 Iand_VA44_GND=0.0;
493 #endif
494 Iand=1;
495 }
496 else
497 {
498 #if defined(_DERIVATE)
499 Iand_VA11_GND=0.0;
500 Iand_VA12_GND=0.0;
501 Iand_VA13_GND=0.0;
502 Iand_VA14_GND=0.0;
503 Iand_VA21_GND=0.0;
504 Iand_VA22_GND=0.0;
505 Iand_VA23_GND=0.0;
506 Iand_VA24_GND=0.0;
507 Iand_VA31_GND=0.0;
508 Iand_VA32_GND=0.0;
509 Iand_VA33_GND=0.0;
510 Iand_VA34_GND=0.0;
511 Iand_VA41_GND=0.0;
512 Iand_VA42_GND=0.0;
513 Iand_VA43_GND=0.0;
514 Iand_VA44_GND=0.0;
515 #endif
516 Iand=0;
517 }
518 {
519 double m00_tanh(d00_tanh0,(TR*(Iand-0.5)))
520 #if defined(_DERIVATE)
521 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(Iand-0.5)))
522 #endif
523 _load_static_residual1(n1,((-0.5)*(1+d00_tanh0)));
524 #if defined(_DERIVATE)
525 _load_static_jacobian1(n1,A44,((-0.5)*(TR*Iand_VA44_GND)*d10_tanh0));
526 _load_static_jacobian1(n1,A43,((-0.5)*(TR*Iand_VA43_GND)*d10_tanh0));
527 _load_static_jacobian1(n1,A42,((-0.5)*(TR*Iand_VA42_GND)*d10_tanh0));
528 _load_static_jacobian1(n1,A41,((-0.5)*(TR*Iand_VA41_GND)*d10_tanh0));
529 _load_static_jacobian1(n1,A34,((-0.5)*(TR*Iand_VA34_GND)*d10_tanh0));
530 _load_static_jacobian1(n1,A33,((-0.5)*(TR*Iand_VA33_GND)*d10_tanh0));
531 _load_static_jacobian1(n1,A32,((-0.5)*(TR*Iand_VA32_GND)*d10_tanh0));
532 _load_static_jacobian1(n1,A31,((-0.5)*(TR*Iand_VA31_GND)*d10_tanh0));
533 _load_static_jacobian1(n1,A24,((-0.5)*(TR*Iand_VA24_GND)*d10_tanh0));
534 _load_static_jacobian1(n1,A23,((-0.5)*(TR*Iand_VA23_GND)*d10_tanh0));
535 _load_static_jacobian1(n1,A22,((-0.5)*(TR*Iand_VA22_GND)*d10_tanh0));
536 _load_static_jacobian1(n1,A21,((-0.5)*(TR*Iand_VA21_GND)*d10_tanh0));
537 _load_static_jacobian1(n1,A14,((-0.5)*(TR*Iand_VA14_GND)*d10_tanh0));
538 _load_static_jacobian1(n1,A13,((-0.5)*(TR*Iand_VA13_GND)*d10_tanh0));
539 _load_static_jacobian1(n1,A12,((-0.5)*(TR*Iand_VA12_GND)*d10_tanh0));
540 _load_static_jacobian1(n1,A11,((-0.5)*(TR*Iand_VA11_GND)*d10_tanh0));
541 #endif
542 }
544 #if defined(_DERIVATE)
546 #endif
548 #if defined(_DERIVATE)
550 #endif
551 #if defined(_DYNAMIC)
553 #if defined(_DERIVATE)
555 #endif
556 #endif
558 #if defined(_DERIVATE)
559 _load_static_jacobian1(Y,n2,(-1.0));
560 #endif
562 #if defined(_DERIVATE)
564 #endif
565 
566 /* ------------------ end of verilog analog equations --------------------- */
567 
568 /* ------------------ evaluate verilog noise equations -------------------- */
569 
570 /* ------------------- end of verilog noise equations --------------------- */
571 }
572 
573 /* Perform DC iteration. */
574 void andor4x4::calcDC (void)
575 {
576  // evaluate Verilog code
577  initVerilog ();
578  calcVerilog ();
579 
580  // fill right hand side and static jacobian
581  for (int i1 = 0; i1 < 19; i1++) {
582  setI (i1, _rhs[i1]);
583  for (int i2 = 0; i2 < 19; i2++) {
584  setY (i1, i2, _jstat[i1][i2]);
585  }
586  }
587 }
588 
589 /* Save operating points. */
591 {
592  // save global instance operating points
593 }
594 
595 /* Load operating points. */
597 {
598 }
599 
600 /* Calculate operating points. */
602 {
603 }
604 
605 /* Initialization of AC analysis. */
606 void andor4x4::initAC (void)
607 {
608  allocMatrixMNA ();
609 }
610 
611 /* Perform AC calculations. */
612 void andor4x4::calcAC (nr_double_t frequency)
613 {
614  setMatrixY (calcMatrixY (frequency));
615 }
616 
617 /* Compute Y-matrix for AC analysis. */
618 matrix andor4x4::calcMatrixY (nr_double_t frequency)
619 {
620  _freq = frequency;
622  matrix y (19);
623 
624  for (int i1 = 0; i1 < 19; i1++) {
625  for (int i2 = 0; i2 < 19; i2++) {
626  y (i1,i2) = rect (_jstat[i1][i2], _jdyna[i1][i2] * 2 * M_PI * _freq);
627  }
628  }
629 
630  return y;
631 }
632 
633 /* Initialization of S-parameter analysis. */
634 void andor4x4::initSP (void)
635 {
636  allocMatrixS ();
637 }
638 
639 /* Perform S-parameter calculations. */
640 void andor4x4::calcSP (nr_double_t frequency)
641 {
642  setMatrixS (ytos (calcMatrixY (frequency)));
643 }
644 
645 /* Initialization of transient analysis. */
646 void andor4x4::initTR (void)
647 {
648  setStates (2 * 19 * 19);
649  initDC ();
650 }
651 
652 /* Perform transient analysis iteration step. */
653 void andor4x4::calcTR (nr_double_t)
654 {
655  doHB = 0;
656  doAC = 1;
657  doTR = 1;
658  calcDC ();
659 
660  int i1, i2, i3, i4, state;
661 
662  // 2-node charge integrations
663  for (i1 = 0; i1 < 19; i1++) {
664  for (i2 = 0; i2 < 19; i2++) {
665  state = 2 * (i2 + 19 * i1);
666  if (i1 != i2)
667  if (_charges[i1][i2] != 0.0)
668  transientCapacitanceQ (state, i1, i2, _charges[i1][i2]);
669  } }
670 
671  // 1-node charge integrations
672  for (i1 = 0; i1 < 19; i1++) {
673  state = 2 * (i1 + 19 * i1);
674  if (_charges[i1][i1] != 0.0)
675  transientCapacitanceQ (state, i1, _charges[i1][i1]);
676  }
677 
678  // charge: 2-node, voltage: 2-node
679  for (i1 = 0; i1 < 19; i1++) {
680  for (i2 = 0; i2 < 19; i2++) {
681  if (i1 != i2)
682  for (i3 = 0; i3 < 19; i3++) {
683  for (i4 = 0; i4 < 19; i4++) {
684  if (i3 != i4)
685  if (_caps[i1][i2][i3][i4] != 0.0)
686  transientCapacitanceC (i1, i2, i3, i4, _caps[i1][i2][i3][i4], BP(i3,i4));
687  } } } }
688 
689  // charge: 2-node, voltage: 1-node
690  for (i1 = 0; i1 < 19; i1++) {
691  for (i2 = 0; i2 < 19; i2++) {
692  if (i1 != i2)
693  for (i3 = 0; i3 < 19; i3++) {
694  if (_caps[i1][i2][i3][i3] != 0.0)
695  transientCapacitanceC2Q (i1, i2, i3, _caps[i1][i2][i3][i3], NP(i3));
696  } } }
697 
698  // charge: 1-node, voltage: 2-node
699  for (i1 = 0; i1 < 19; i1++) {
700  for (i3 = 0; i3 < 19; i3++) {
701  for (i4 = 0; i4 < 19; i4++) {
702  if (i3 != i4)
703  if (_caps[i1][i1][i3][i4] != 0.0)
704  transientCapacitanceC2V (i1, i3, i4, _caps[i1][i1][i3][i4], BP(i3,i4));
705  } } }
706 
707  // charge: 1-node, voltage: 1-node
708  for (i1 = 0; i1 < 19; i1++) {
709  for (i3 = 0; i3 < 19; i3++) {
710  if (_caps[i1][i1][i3][i3] != 0.0)
711  transientCapacitanceC (i1, i3, _caps[i1][i1][i3][i3], NP(i3));
712  } }
713 }
714 
715 /* Compute Cy-matrix for AC noise analysis. */
716 matrix andor4x4::calcMatrixCy (nr_double_t frequency)
717 {
718  _freq = frequency;
719  matrix cy (19);
720 
721 
722  return cy;
723 }
724 
725 /* Perform AC noise computations. */
726 void andor4x4::calcNoiseAC (nr_double_t frequency)
727 {
728  setMatrixN (calcMatrixCy (frequency));
729 }
730 
731 /* Perform S-parameter noise computations. */
732 void andor4x4::calcNoiseSP (nr_double_t frequency)
733 {
734  setMatrixN (cytocs (calcMatrixCy (frequency) * z0, getMatrixS ()));
735 }
736 
737 /* Initialization of HB analysis. */
739 {
740  initDC ();
741  allocMatrixHB ();
742 }
743 
744 /* Perform HB analysis. */
746 {
747  doHB = 1;
748  doAC = 1;
749  doTR = 0;
750 
751  // jacobian dI/dV and currents get filled
752  calcDC ();
754 
755  // fill in HB matrices
756  for (int i1 = 0; i1 < 19; i1++) {
757  setQ (i1, _qhs[i1]); // charges
758  setCV (i1, _chs[i1]); // jacobian dQ/dV * V
759  setGV (i1, _ghs[i1]); // jacobian dI/dV * V
760  for (int i2 = 0; i2 < 19; i2++) {
761  setQV (i1, i2, _jdyna[i1][i2]); // jacobian dQ/dV
762  }
763  }
764 }
765 
766 #include "andor4x4.defs.h"