My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dmux3to8.core.cpp
Go to the documentation of this file.
1 /*
2  * dmux3to8.core.cpp - device implementations for dmux3to8 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 "dmux3to8.core.h"
19 
20 #ifndef CIR_dmux3to8
21 #define CIR_dmux3to8 -1
22 #endif
23 
24 // external nodes
25 #define EN 0
26 #define A 1
27 #define B 2
28 #define C 3
29 #define Y7 4
30 #define Y6 5
31 #define Y5 6
32 #define Y4 7
33 #define Y3 8
34 #define Y2 9
35 #define Y1 10
36 #define Y0 11
37 // internal nodes
38 #define Y0n1 12
39 #define Y0n2 13
40 #define Y1n1 14
41 #define Y1n2 15
42 #define Y2n1 16
43 #define Y2n2 17
44 #define Y3n1 18
45 #define Y3n2 19
46 #define Y4n1 20
47 #define Y4n2 21
48 #define Y5n1 22
49 #define Y5n2 23
50 #define Y6n1 24
51 #define Y6n2 25
52 #define Y7n1 26
53 #define Y7n2 27
54 
55 // useful macro definitions
56 #define NP(node) real (getV (node))
57 #define BP(pnode,nnode) (NP(pnode) - NP(nnode))
58 #define _load_static_residual2(pnode,nnode,current)\
59  _rhs[pnode] -= current;\
60  _rhs[nnode] += current;
61 #define _load_static_augmented_residual2(pnode,nnode,current)\
62  _rhs[pnode] -= current;\
63  _rhs[nnode] += current;
64 #define _load_static_residual1(node,current)\
65  _rhs[node] -= current;
66 #define _load_static_augmented_residual1(node,current)\
67  _rhs[node] -= current;
68 #define _load_static_jacobian4(pnode,nnode,vpnode,vnnode,conductance)\
69  _jstat[pnode][vpnode] += conductance;\
70  _jstat[nnode][vnnode] += conductance;\
71  _jstat[pnode][vnnode] -= conductance;\
72  _jstat[nnode][vpnode] -= conductance;\
73  if (doHB) {\
74  _ghs[pnode] += conductance * BP(vpnode,vnnode);\
75  _ghs[nnode] -= conductance * BP(vpnode,vnnode);\
76  } else {\
77  _rhs[pnode] += conductance * BP(vpnode,vnnode);\
78  _rhs[nnode] -= conductance * BP(vpnode,vnnode);\
79  }
80 #define _load_static_jacobian2p(node,vpnode,vnnode,conductance)\
81  _jstat[node][vpnode] += conductance;\
82  _jstat[node][vnnode] -= conductance;\
83  if (doHB) {\
84  _ghs[node] += conductance * BP(vpnode,vnnode);\
85  } else {\
86  _rhs[node] += conductance * BP(vpnode,vnnode);\
87  }
88 #define _load_static_jacobian2s(pnode,nnode,node,conductance)\
89  _jstat[pnode][node] += conductance;\
90  _jstat[nnode][node] -= conductance;\
91  if (doHB) {\
92  _ghs[pnode] += conductance * NP(node);\
93  _ghs[nnode] -= conductance * NP(node);\
94  } else {\
95  _rhs[pnode] += conductance * NP(node);\
96  _rhs[nnode] -= conductance * NP(node);\
97  }
98 #define _load_static_jacobian1(node,vnode,conductance)\
99  _jstat[node][vnode] += conductance;\
100  if (doHB) {\
101  _ghs[node] += conductance * NP(vnode);\
102  } else {\
103  _rhs[node] += conductance * NP(vnode);\
104  }
105 #define _load_dynamic_residual2(pnode,nnode,charge)\
106  if (doTR) _charges[pnode][nnode] += charge;\
107  if (doHB) {\
108  _qhs[pnode] -= charge;\
109  _qhs[nnode] += charge;\
110  }
111 #define _load_dynamic_residual1(node,charge)\
112  if (doTR) _charges[node][node] += charge;\
113  if (doHB) {\
114  _qhs[node] -= charge;\
115  }
116 #define _load_dynamic_jacobian4(pnode,nnode,vpnode,vnnode,capacitance)\
117  if (doAC) {\
118  _jdyna[pnode][vpnode] += capacitance;\
119  _jdyna[nnode][vnnode] += capacitance;\
120  _jdyna[pnode][vnnode] -= capacitance;\
121  _jdyna[nnode][vpnode] -= capacitance;\
122  }\
123  if (doTR) {\
124  _caps[pnode][nnode][vpnode][vnnode] += capacitance;\
125  }\
126  if (doHB) {\
127  _chs[pnode] += capacitance * BP(vpnode,vnnode);\
128  _chs[nnode] -= capacitance * BP(vpnode,vnnode);\
129  }
130 #define _load_dynamic_jacobian2s(pnode,nnode,vnode,capacitance)\
131  if (doAC) {\
132  _jdyna[pnode][vnode] += capacitance;\
133  _jdyna[nnode][vnode] -= capacitance;\
134  }\
135  if (doTR) {\
136  _caps[pnode][nnode][vnode][vnode] += capacitance;\
137  }\
138  if (doHB) {\
139  _chs[pnode] += capacitance * NP(vnode);\
140  _chs[nnode] -= capacitance * NP(vnode);\
141  }
142 #define _load_dynamic_jacobian2p(node,vpnode,vnnode,capacitance)\
143  if (doAC) {\
144  _jdyna[node][vpnode] += capacitance;\
145  _jdyna[node][vnnode] -= capacitance;\
146  }\
147  if (doTR) {\
148  _caps[node][node][vpnode][vnnode] += capacitance;\
149  }\
150  if (doHB) {\
151  _chs[node] += capacitance * BP(vpnode,vnnode);\
152  }
153 #define _load_dynamic_jacobian1(node,vnode,capacitance)\
154  if (doAC) {\
155  _jdyna[node][vnode] += capacitance;\
156  }\
157  if (doTR) {\
158  _caps[node][node][vnode][vnode] += capacitance;\
159  }\
160  if (doHB) {\
161  _chs[node] += capacitance * NP(vnode);\
162  }
163 
164 #define _save_whitenoise1(n1,pwr,type)\
165  _white_pwr[n1][n1] += pwr;
166 #define _save_whitenoise2(n1,n2,pwr,type)\
167  _white_pwr[n1][n2] += pwr;
168 #define _save_flickernoise1(n1,pwr,exp,type)\
169  _flicker_pwr[n1][n1] += pwr;\
170  _flicker_exp[n1][n1] += exp;
171 #define _save_flickernoise2(n1,n2,pwr,exp,type)\
172  _flicker_pwr[n1][n2] += pwr;\
173  _flicker_exp[n1][n2] += exp;
174 #define _load_whitenoise2(n1,n2,pwr)\
175  cy (n1,n2) -= pwr/kB/T0; cy (n2,n1) -= pwr/kB/T0;\
176  cy (n1,n1) += pwr/kB/T0; cy (n2,n2) += pwr/kB/T0;
177 #define _load_whitenoise1(n1,pwr)\
178  cy (n1,n1) += pwr/kB/T0;
179 #define _load_flickernoise2(n1,n2,pwr,exp)\
180  cy (n1,n2) -= pwr*pow(_freq,-exp)/kB/T0;\
181  cy (n2,n1) -= pwr*pow(_freq,-exp)/kB/T0;\
182  cy (n1,n1) += pwr*pow(_freq,-exp)/kB/T0;\
183  cy (n2,n2) += pwr*pow(_freq,-exp)/kB/T0;
184 #define _load_flickernoise1(n1,pwr,exp)\
185  cy (n1,n1) += pwr*pow(_freq,-exp)/kB/T0;
186 
187 // derivative helper macros
188 #define m00_hypot(v00,x,y) v00 = xhypot(x,y);
189 #define m10_hypot(v10,v00,x,y) v10 = (x)/(v00);
190 #define m11_hypot(v11,v00,x,y) v11 = (y)/(v00);
191 #define m00_max(v00,x,y) v00 = ((x)>(y))?(x):(y);
192 #define m10_max(v10,v00,x,y) v10 = ((x)>(y))?1.0:0.0;
193 #define m11_max(v11,v00,x,y) v11 = ((x)>(y))?0.0:1.0;
194 #define m00_min(v00,x,y) v00 = ((x)<(y))?(x):(y);
195 #define m10_min(v10,v00,x,y) v10 = ((x)<(y))?1.0:0.0;
196 #define m11_min(v11,v00,x,y) v11 = ((x)<(y))?0.0:1.0;
197 #define m00_pow(v00,x,y) v00 = pow(x,y);
198 #define m10_pow(v10,v00,x,y) v10 = (x==0.0)?0.0:(v00)*(y)/(x);
199 #define m11_pow(v11,v00,x,y) v11 = (x==0.0)?0.0:(log(x)*(v00));
200 
201 #define m00_div(v00,v10,x,y) double v10=1/(y); double v00=(x)*v10;
202 #define m10_div(v10,v00,vv,x,y)
203 #define m11_div(v11,v00,vv,x,y) double v11 = -v00*vv;
204 
205 #define m00_mult(v00,v10,v11,x,y) double v10=(x); double v11=(y); double v00=v10*v11;
206 #define m00_add(v00,x,y) double v00=(x)+(y);
207 
208 #define m00_cos(v00,x) v00 = cos(x);
209 #define m10_cos(v10,v00,x) v10 = (-sin(x));
210 #define m00_sin(v00,x) v00 = sin(x);
211 #define m10_sin(v10,v00,x) v10 = (cos(x));
212 #define m00_tan(v00,x) v00 = tan(x);
213 #define m10_tan(v10,v00,x) v10 = (1.0/cos(x)/cos(x));
214 #define m00_cosh(v00,x) v00 = cosh(x);
215 #define m10_cosh(v10,v00,x) v10 = (sinh(x));
216 #define m00_sinh(v00,x) v00 = sinh(x);
217 #define m10_sinh(v10,v00,x) v10 = (cosh(x));
218 #define m00_tanh(v00,x) v00 = tanh(x);
219 #define m10_tanh(v10,v00,x) v10 = (1.0/cosh(x)/cosh(x));
220 #define m00_acos(v00,x) v00 = acos(x);
221 #define m10_acos(v10,v00,x) v10 = (-1.0/sqrt(1-x*x));
222 #define m00_asin(v00,x) v00 = asin(x);
223 #define m10_asin(v10,v00,x) v10 = (+1.0/sqrt(1-x*x));
224 #define m00_atan(v00,x) v00 = atan(x);
225 #define m10_atan(v10,v00,x) v10 = (+1.0/(1+x*x));
226 #define m00_atanh(v00,x) v00 = atanh(x);
227 #define m10_atanh(v10,v00,x) v10 = (+1.0/(1-x*x));
228 #define m00_logE(v00,x) v00 = log(x);
229 #define m10_logE(v10,v00,x) v10 = (1.0/x);
230 #define m00_log10(v00,x) v00 = log10(x);
231 #define m10_log10(v10,v00,x) v10 = (1.0/x/M_LN10);
232 #define m00_sqrt(v00,x) v00 = sqrt(x);
233 #define m10_sqrt(v10,v00,x) v10 = (0.5/v00);
234 #define m00_fabs(v00,x) v00 = fabs(x);
235 #define m10_fabs(v10,v00,x) v10 = (((x)>=0)?(+1.0):(-1.0));
236 
237 #define m00_exp(v00,x) v00 = exp(x);
238 #define m10_exp(v10,v00,x) v10 = v00;
239 
240 #define m00_abs(v00) ((v00)<(0)?(-(v00)):(v00))
241 #define m00_floor(v00,x) v00 = floor(x);
242 #define m00_limexp(v00,x) v00 = ((x)<80.0?exp(x):exp(80.0)*(x-79.0));
243 #define m10_limexp(v10,v00,x) v10 = ((x)<80.0?(v00):exp(80.0));
244 
245 #define m20_logE(v00) (-1.0/v00/v00)
246 #define m20_exp(v00) exp(v00)
247 #define m20_limexp(v00) ((v00)<80.0?exp(v00):0.0)
248 #define m20_sqrt(v00) (-0.25/(v00)/sqrt(v00))
249 #define m20_fabs(v00) 0.0
250 #define m20_pow(x,y) ((y)*((y)-1.0)*pow(x,y)/(x)/(x))
251 #define m00_vt(x) (kBoverQ*(x))
252 #define m10_vt(x) (kBoverQ)
253 
254 // simulator specific definitions
255 #define _modelname "dmux3to8"
256 #define _instancename getName()
257 #define _circuit_temp (getPropertyDouble("Temp")+273.15)
258 #define _param_given(p) (isPropertyGiven(p)?1:0)
259 
260 
261 // $vt and $vt() functions
262 #define _vt_nom (kBoverQ*_circuit_temp)
263 
264 using namespace device;
265 
266 /* Device constructor. */
268 {
269  type = CIR_dmux3to8;
270 }
271 
272 /* Initialization of model. */
273 void dmux3to8::initModel (void)
274 {
275  // create internal nodes
276  setInternalNode (Y0n1, "Y0n1");
277  setInternalNode (Y0n2, "Y0n2");
278  setInternalNode (Y1n1, "Y1n1");
279  setInternalNode (Y1n2, "Y1n2");
280  setInternalNode (Y2n1, "Y2n1");
281  setInternalNode (Y2n2, "Y2n2");
282  setInternalNode (Y3n1, "Y3n1");
283  setInternalNode (Y3n2, "Y3n2");
284  setInternalNode (Y4n1, "Y4n1");
285  setInternalNode (Y4n2, "Y4n2");
286  setInternalNode (Y5n1, "Y5n1");
287  setInternalNode (Y5n2, "Y5n2");
288  setInternalNode (Y6n1, "Y6n1");
289  setInternalNode (Y6n2, "Y6n2");
290  setInternalNode (Y7n1, "Y7n1");
291  setInternalNode (Y7n2, "Y7n2");
292 
293  // get device model parameters
294  loadVariables ();
295  // evaluate global model equations
296  initializeModel ();
297  // evaluate initial step equations
298  initialStep ();
299  // evaluate global instance equations
300  initializeInstance ();
301 }
302 
303 /* Initialization of DC analysis. */
304 void dmux3to8::initDC (void)
305 {
306  allocMatrixMNA ();
307  initModel ();
308  pol = 1;
309  restartDC ();
310  doAC = 1;
311  doTR = 0;
312  doHB = 0;
313 }
314 
315 /* Run when DC is restarted (fallback algorithms). */
317 {
318 }
319 
320 /* Initialize Verilog-AMS code. */
321 void dmux3to8::initVerilog (void)
322 {
323  // initialization of noise variables
324 
325  int i1, i2, i3, i4;
326 
327  // zero charges
328  for (i1 = 0; i1 < 28; i1++) {
329  for (i2 = 0; i2 < 28; i2++) {
330  _charges[i1][i2] = 0.0;
331  } }
332 
333  // zero capacitances
334  for (i1 = 0; i1 < 28; i1++) {
335  for (i2 = 0; i2 < 28; i2++) {
336  for (i3 = 0; i3 < 28; i3++) {
337  for (i4 = 0; i4 < 28; i4++) {
338  _caps[i1][i2][i3][i4] = 0.0;
339  } } } }
340 
341  // zero right hand side, static and dynamic jacobian
342  for (i1 = 0; i1 < 28; i1++) {
343  _rhs[i1] = 0.0;
344  _qhs[i1] = 0.0;
345  _chs[i1] = 0.0;
346  _ghs[i1] = 0.0;
347  for (i2 = 0; i2 < 28; i2++) {
348  _jstat[i1][i2] = 0.0;
349  _jdyna[i1][i2] = 0.0;
350  }
351  }
352 }
353 
354 /* Load device model input parameters. */
355 void dmux3to8::loadVariables (void)
356 {
357  TR = getPropertyDouble ("TR");
358  Delay = getPropertyDouble ("Delay");
359 }
360 
361 /* #define's for translated code */
362 #undef _DDT
363 #define _DDT(q) q
364 #define _DYNAMIC
365 #define _DERIVATE
366 #define _DDX
367 #define _DERIVATEFORDDX
368 
369 /* Evaluate Verilog-AMS equations in model initialization. */
370 void dmux3to8::initializeModel (void)
371 {
372 #if defined(_DYNAMIC)
373 #endif
374 {
375 Rd=1e3;
376 #if defined(_DYNAMIC)
377 Cd=((Delay*1.43)/Rd);
378 #endif
379 }
380 }
381 
382 /* Evaluate Verilog-AMS equations in instance initialization. */
383 void dmux3to8::initializeInstance (void)
384 {
385 }
386 
387 /* Evaluate Verilog-AMS equations in initial step. */
388 void dmux3to8::initialStep (void)
389 {
390 }
391 
392 /* Evaluate Verilog-AMS equations in final step. */
393 void dmux3to8::finalStep (void)
394 {
395 }
396 
397 /* Evaluate Verilog-AMS equations in analog block. */
398 void dmux3to8::calcVerilog (void)
399 {
400 
401 /* ----------------- evaluate verilog analog equations -------------------- */
402 double IY7;
403 #if defined(_DERIVATE)
404 double IY7_VEN_GND;
405 double IY7_VC_GND;
406 double IY7_VB_GND;
407 double IY7_VA_GND;
408 #endif
409 double IY6;
410 #if defined(_DERIVATE)
411 double IY6_VEN_GND;
412 double IY6_VC_GND;
413 double IY6_VB_GND;
414 double IY6_VA_GND;
415 #endif
416 double IY5;
417 #if defined(_DERIVATE)
418 double IY5_VEN_GND;
419 double IY5_VC_GND;
420 double IY5_VB_GND;
421 double IY5_VA_GND;
422 #endif
423 double IY4;
424 #if defined(_DERIVATE)
425 double IY4_VEN_GND;
426 double IY4_VC_GND;
427 double IY4_VB_GND;
428 double IY4_VA_GND;
429 #endif
430 double IY3;
431 #if defined(_DERIVATE)
432 double IY3_VEN_GND;
433 double IY3_VC_GND;
434 double IY3_VB_GND;
435 double IY3_VA_GND;
436 #endif
437 double IY2;
438 #if defined(_DERIVATE)
439 double IY2_VEN_GND;
440 double IY2_VC_GND;
441 double IY2_VB_GND;
442 double IY2_VA_GND;
443 #endif
444 double IY1;
445 #if defined(_DERIVATE)
446 double IY1_VEN_GND;
447 double IY1_VC_GND;
448 double IY1_VB_GND;
449 double IY1_VA_GND;
450 #endif
451 double IY0;
452 #if defined(_DERIVATE)
453 double IY0_VEN_GND;
454 double IY0_VC_GND;
455 double IY0_VB_GND;
456 double IY0_VA_GND;
457 #endif
458 double VCI;
459 #if defined(_DERIVATE)
460 double VCI_VC_GND;
461 #endif
462 double VBI;
463 #if defined(_DERIVATE)
464 double VBI_VB_GND;
465 #endif
466 double VAI;
467 #if defined(_DERIVATE)
468 double VAI_VA_GND;
469 #endif
470 double VENI;
471 #if defined(_DERIVATE)
472 double VENI_VEN_GND;
473 #endif
474 #if defined(_DERIVATE)
475 VENI_VEN_GND=(-1.0);
476 #endif
477 VENI=(1-NP(EN));
478 #if defined(_DERIVATE)
479 VAI_VA_GND=(-1.0);
480 #endif
481 VAI=(1-NP(A));
482 #if defined(_DERIVATE)
483 VBI_VB_GND=(-1.0);
484 #endif
485 VBI=(1-NP(B));
486 #if defined(_DERIVATE)
487 VCI_VC_GND=(-1.0);
488 #endif
489 VCI=(1-NP(C));
490 #if defined(_DERIVATE)
491 IY0_VEN_GND=VENI_VEN_GND*VCI*VBI*VAI;
492 IY0_VC_GND=(VENI*VCI_VC_GND)*VBI*VAI;
493 IY0_VB_GND=((VENI*VCI)*VBI_VB_GND)*VAI;
494 IY0_VA_GND=(((VENI*VCI)*VBI)*VAI_VA_GND);
495 #endif
496 IY0=(((VENI*VCI)*VBI)*VAI);
497 {
498 double m00_tanh(d00_tanh0,(TR*(IY0-0.5)))
499 #if defined(_DERIVATE)
500 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(IY0-0.5)))
501 #endif
502 _load_static_residual1(Y0n1,((-0.5)*(1+d00_tanh0)));
503 #if defined(_DERIVATE)
504 _load_static_jacobian1(Y0n1,A,((-0.5)*(TR*IY0_VA_GND)*d10_tanh0));
505 _load_static_jacobian1(Y0n1,B,((-0.5)*(TR*IY0_VB_GND)*d10_tanh0));
506 _load_static_jacobian1(Y0n1,C,((-0.5)*(TR*IY0_VC_GND)*d10_tanh0));
507 _load_static_jacobian1(Y0n1,EN,((-0.5)*(TR*IY0_VEN_GND)*d10_tanh0));
508 #endif
509 }
511 #if defined(_DERIVATE)
513 #endif
515 #if defined(_DERIVATE)
517 #endif
518 #if defined(_DYNAMIC)
520 #if defined(_DERIVATE)
522 #endif
523 #endif
525 #if defined(_DERIVATE)
527 #endif
529 #if defined(_DERIVATE)
531 #endif
532 #if defined(_DERIVATE)
533 IY1_VEN_GND=VENI_VEN_GND*VCI*VBI*NP(A);
534 IY1_VC_GND=(VENI*VCI_VC_GND)*VBI*NP(A);
535 IY1_VB_GND=((VENI*VCI)*VBI_VB_GND)*NP(A);
536 IY1_VA_GND=(((VENI*VCI)*VBI));
537 #endif
538 IY1=(((VENI*VCI)*VBI)*NP(A));
539 {
540 double m00_tanh(d00_tanh0,(TR*(IY1-0.5)))
541 #if defined(_DERIVATE)
542 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(IY1-0.5)))
543 #endif
544 _load_static_residual1(Y1n1,((-0.5)*(1+d00_tanh0)));
545 #if defined(_DERIVATE)
546 _load_static_jacobian1(Y1n1,A,((-0.5)*(TR*IY1_VA_GND)*d10_tanh0));
547 _load_static_jacobian1(Y1n1,B,((-0.5)*(TR*IY1_VB_GND)*d10_tanh0));
548 _load_static_jacobian1(Y1n1,C,((-0.5)*(TR*IY1_VC_GND)*d10_tanh0));
549 _load_static_jacobian1(Y1n1,EN,((-0.5)*(TR*IY1_VEN_GND)*d10_tanh0));
550 #endif
551 }
553 #if defined(_DERIVATE)
555 #endif
557 #if defined(_DERIVATE)
559 #endif
560 #if defined(_DYNAMIC)
562 #if defined(_DERIVATE)
564 #endif
565 #endif
567 #if defined(_DERIVATE)
569 #endif
571 #if defined(_DERIVATE)
573 #endif
574 #if defined(_DERIVATE)
575 IY2_VEN_GND=VENI_VEN_GND*VCI*NP(B)*VAI;
576 IY2_VC_GND=(VENI*VCI_VC_GND)*NP(B)*VAI;
577 IY2_VB_GND=((VENI*VCI))*VAI;
578 IY2_VA_GND=(((VENI*VCI)*NP(B))*VAI_VA_GND);
579 #endif
580 IY2=(((VENI*VCI)*NP(B))*VAI);
581 {
582 double m00_tanh(d00_tanh0,(TR*(IY2-0.5)))
583 #if defined(_DERIVATE)
584 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(IY2-0.5)))
585 #endif
586 _load_static_residual1(Y2n1,((-0.5)*(1+d00_tanh0)));
587 #if defined(_DERIVATE)
588 _load_static_jacobian1(Y2n1,A,((-0.5)*(TR*IY2_VA_GND)*d10_tanh0));
589 _load_static_jacobian1(Y2n1,B,((-0.5)*(TR*IY2_VB_GND)*d10_tanh0));
590 _load_static_jacobian1(Y2n1,C,((-0.5)*(TR*IY2_VC_GND)*d10_tanh0));
591 _load_static_jacobian1(Y2n1,EN,((-0.5)*(TR*IY2_VEN_GND)*d10_tanh0));
592 #endif
593 }
595 #if defined(_DERIVATE)
597 #endif
599 #if defined(_DERIVATE)
601 #endif
602 #if defined(_DYNAMIC)
604 #if defined(_DERIVATE)
606 #endif
607 #endif
609 #if defined(_DERIVATE)
611 #endif
613 #if defined(_DERIVATE)
615 #endif
616 #if defined(_DERIVATE)
617 IY3_VEN_GND=VENI_VEN_GND*VCI*NP(B)*NP(A);
618 IY3_VC_GND=(VENI*VCI_VC_GND)*NP(B)*NP(A);
619 IY3_VB_GND=((VENI*VCI))*NP(A);
620 IY3_VA_GND=(((VENI*VCI)*NP(B)));
621 #endif
622 IY3=(((VENI*VCI)*NP(B))*NP(A));
623 {
624 double m00_tanh(d00_tanh0,(TR*(IY3-0.5)))
625 #if defined(_DERIVATE)
626 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(IY3-0.5)))
627 #endif
628 _load_static_residual1(Y3n1,((-0.5)*(1+d00_tanh0)));
629 #if defined(_DERIVATE)
630 _load_static_jacobian1(Y3n1,A,((-0.5)*(TR*IY3_VA_GND)*d10_tanh0));
631 _load_static_jacobian1(Y3n1,B,((-0.5)*(TR*IY3_VB_GND)*d10_tanh0));
632 _load_static_jacobian1(Y3n1,C,((-0.5)*(TR*IY3_VC_GND)*d10_tanh0));
633 _load_static_jacobian1(Y3n1,EN,((-0.5)*(TR*IY3_VEN_GND)*d10_tanh0));
634 #endif
635 }
637 #if defined(_DERIVATE)
639 #endif
641 #if defined(_DERIVATE)
643 #endif
644 #if defined(_DYNAMIC)
646 #if defined(_DERIVATE)
648 #endif
649 #endif
651 #if defined(_DERIVATE)
653 #endif
655 #if defined(_DERIVATE)
657 #endif
658 #if defined(_DERIVATE)
659 IY4_VEN_GND=VENI_VEN_GND*NP(C)*VBI*VAI;
660 IY4_VC_GND=(VENI)*VBI*VAI;
661 IY4_VB_GND=((VENI*NP(C))*VBI_VB_GND)*VAI;
662 IY4_VA_GND=(((VENI*NP(C))*VBI)*VAI_VA_GND);
663 #endif
664 IY4=(((VENI*NP(C))*VBI)*VAI);
665 {
666 double m00_tanh(d00_tanh0,(TR*(IY4-0.5)))
667 #if defined(_DERIVATE)
668 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(IY4-0.5)))
669 #endif
670 _load_static_residual1(Y4n1,((-0.5)*(1+d00_tanh0)));
671 #if defined(_DERIVATE)
672 _load_static_jacobian1(Y4n1,A,((-0.5)*(TR*IY4_VA_GND)*d10_tanh0));
673 _load_static_jacobian1(Y4n1,B,((-0.5)*(TR*IY4_VB_GND)*d10_tanh0));
674 _load_static_jacobian1(Y4n1,C,((-0.5)*(TR*IY4_VC_GND)*d10_tanh0));
675 _load_static_jacobian1(Y4n1,EN,((-0.5)*(TR*IY4_VEN_GND)*d10_tanh0));
676 #endif
677 }
679 #if defined(_DERIVATE)
681 #endif
683 #if defined(_DERIVATE)
685 #endif
686 #if defined(_DYNAMIC)
688 #if defined(_DERIVATE)
690 #endif
691 #endif
693 #if defined(_DERIVATE)
695 #endif
697 #if defined(_DERIVATE)
699 #endif
700 #if defined(_DERIVATE)
701 IY5_VEN_GND=VENI_VEN_GND*NP(C)*VBI*NP(A);
702 IY5_VC_GND=(VENI)*VBI*NP(A);
703 IY5_VB_GND=((VENI*NP(C))*VBI_VB_GND)*NP(A);
704 IY5_VA_GND=(((VENI*NP(C))*VBI));
705 #endif
706 IY5=(((VENI*NP(C))*VBI)*NP(A));
707 {
708 double m00_tanh(d00_tanh0,(TR*(IY5-0.5)))
709 #if defined(_DERIVATE)
710 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(IY5-0.5)))
711 #endif
712 _load_static_residual1(Y5n1,((-0.5)*(1+d00_tanh0)));
713 #if defined(_DERIVATE)
714 _load_static_jacobian1(Y5n1,A,((-0.5)*(TR*IY5_VA_GND)*d10_tanh0));
715 _load_static_jacobian1(Y5n1,B,((-0.5)*(TR*IY5_VB_GND)*d10_tanh0));
716 _load_static_jacobian1(Y5n1,C,((-0.5)*(TR*IY5_VC_GND)*d10_tanh0));
717 _load_static_jacobian1(Y5n1,EN,((-0.5)*(TR*IY5_VEN_GND)*d10_tanh0));
718 #endif
719 }
721 #if defined(_DERIVATE)
723 #endif
725 #if defined(_DERIVATE)
727 #endif
728 #if defined(_DYNAMIC)
730 #if defined(_DERIVATE)
732 #endif
733 #endif
735 #if defined(_DERIVATE)
737 #endif
739 #if defined(_DERIVATE)
741 #endif
742 #if defined(_DERIVATE)
743 IY6_VEN_GND=VENI_VEN_GND*NP(C)*NP(B)*VAI;
744 IY6_VC_GND=(VENI)*NP(B)*VAI;
745 IY6_VB_GND=((VENI*NP(C)))*VAI;
746 IY6_VA_GND=(((VENI*NP(C))*NP(B))*VAI_VA_GND);
747 #endif
748 IY6=(((VENI*NP(C))*NP(B))*VAI);
749 {
750 double m00_tanh(d00_tanh0,(TR*(IY6-0.5)))
751 #if defined(_DERIVATE)
752 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(IY6-0.5)))
753 #endif
754 _load_static_residual1(Y6n1,((-0.5)*(1+d00_tanh0)));
755 #if defined(_DERIVATE)
756 _load_static_jacobian1(Y6n1,A,((-0.5)*(TR*IY6_VA_GND)*d10_tanh0));
757 _load_static_jacobian1(Y6n1,B,((-0.5)*(TR*IY6_VB_GND)*d10_tanh0));
758 _load_static_jacobian1(Y6n1,C,((-0.5)*(TR*IY6_VC_GND)*d10_tanh0));
759 _load_static_jacobian1(Y6n1,EN,((-0.5)*(TR*IY6_VEN_GND)*d10_tanh0));
760 #endif
761 }
763 #if defined(_DERIVATE)
765 #endif
767 #if defined(_DERIVATE)
769 #endif
770 #if defined(_DYNAMIC)
772 #if defined(_DERIVATE)
774 #endif
775 #endif
777 #if defined(_DERIVATE)
779 #endif
781 #if defined(_DERIVATE)
783 #endif
784 #if defined(_DERIVATE)
785 IY7_VEN_GND=VENI_VEN_GND*NP(C)*NP(B)*NP(A);
786 IY7_VC_GND=(VENI)*NP(B)*NP(A);
787 IY7_VB_GND=((VENI*NP(C)))*NP(A);
788 IY7_VA_GND=(((VENI*NP(C))*NP(B)));
789 #endif
790 IY7=(((VENI*NP(C))*NP(B))*NP(A));
791 {
792 double m00_tanh(d00_tanh0,(TR*(IY7-0.5)))
793 #if defined(_DERIVATE)
794 double m10_tanh(d10_tanh0,d00_tanh0,(TR*(IY7-0.5)))
795 #endif
796 _load_static_residual1(Y7n1,((-0.5)*(1+d00_tanh0)));
797 #if defined(_DERIVATE)
798 _load_static_jacobian1(Y7n1,A,((-0.5)*(TR*IY7_VA_GND)*d10_tanh0));
799 _load_static_jacobian1(Y7n1,B,((-0.5)*(TR*IY7_VB_GND)*d10_tanh0));
800 _load_static_jacobian1(Y7n1,C,((-0.5)*(TR*IY7_VC_GND)*d10_tanh0));
801 _load_static_jacobian1(Y7n1,EN,((-0.5)*(TR*IY7_VEN_GND)*d10_tanh0));
802 #endif
803 }
805 #if defined(_DERIVATE)
807 #endif
809 #if defined(_DERIVATE)
811 #endif
812 #if defined(_DYNAMIC)
814 #if defined(_DERIVATE)
816 #endif
817 #endif
819 #if defined(_DERIVATE)
821 #endif
823 #if defined(_DERIVATE)
825 #endif
826 
827 /* ------------------ end of verilog analog equations --------------------- */
828 
829 /* ------------------ evaluate verilog noise equations -------------------- */
830 
831 /* ------------------- end of verilog noise equations --------------------- */
832 }
833 
834 /* Perform DC iteration. */
835 void dmux3to8::calcDC (void)
836 {
837  // evaluate Verilog code
838  initVerilog ();
839  calcVerilog ();
840 
841  // fill right hand side and static jacobian
842  for (int i1 = 0; i1 < 28; i1++) {
843  setI (i1, _rhs[i1]);
844  for (int i2 = 0; i2 < 28; i2++) {
845  setY (i1, i2, _jstat[i1][i2]);
846  }
847  }
848 }
849 
850 /* Save operating points. */
852 {
853  // save global instance operating points
854 }
855 
856 /* Load operating points. */
858 {
859 }
860 
861 /* Calculate operating points. */
863 {
864 }
865 
866 /* Initialization of AC analysis. */
867 void dmux3to8::initAC (void)
868 {
869  allocMatrixMNA ();
870 }
871 
872 /* Perform AC calculations. */
873 void dmux3to8::calcAC (nr_double_t frequency)
874 {
875  setMatrixY (calcMatrixY (frequency));
876 }
877 
878 /* Compute Y-matrix for AC analysis. */
879 matrix dmux3to8::calcMatrixY (nr_double_t frequency)
880 {
881  _freq = frequency;
883  matrix y (28);
884 
885  for (int i1 = 0; i1 < 28; i1++) {
886  for (int i2 = 0; i2 < 28; i2++) {
887  y (i1,i2) = rect (_jstat[i1][i2], _jdyna[i1][i2] * 2 * M_PI * _freq);
888  }
889  }
890 
891  return y;
892 }
893 
894 /* Initialization of S-parameter analysis. */
895 void dmux3to8::initSP (void)
896 {
897  allocMatrixS ();
898 }
899 
900 /* Perform S-parameter calculations. */
901 void dmux3to8::calcSP (nr_double_t frequency)
902 {
903  setMatrixS (ytos (calcMatrixY (frequency)));
904 }
905 
906 /* Initialization of transient analysis. */
907 void dmux3to8::initTR (void)
908 {
909  setStates (2 * 28 * 28);
910  initDC ();
911 }
912 
913 /* Perform transient analysis iteration step. */
914 void dmux3to8::calcTR (nr_double_t)
915 {
916  doHB = 0;
917  doAC = 1;
918  doTR = 1;
919  calcDC ();
920 
921  int i1, i2, i3, i4, state;
922 
923  // 2-node charge integrations
924  for (i1 = 0; i1 < 28; i1++) {
925  for (i2 = 0; i2 < 28; i2++) {
926  state = 2 * (i2 + 28 * i1);
927  if (i1 != i2)
928  if (_charges[i1][i2] != 0.0)
929  transientCapacitanceQ (state, i1, i2, _charges[i1][i2]);
930  } }
931 
932  // 1-node charge integrations
933  for (i1 = 0; i1 < 28; i1++) {
934  state = 2 * (i1 + 28 * i1);
935  if (_charges[i1][i1] != 0.0)
936  transientCapacitanceQ (state, i1, _charges[i1][i1]);
937  }
938 
939  // charge: 2-node, voltage: 2-node
940  for (i1 = 0; i1 < 28; i1++) {
941  for (i2 = 0; i2 < 28; i2++) {
942  if (i1 != i2)
943  for (i3 = 0; i3 < 28; i3++) {
944  for (i4 = 0; i4 < 28; i4++) {
945  if (i3 != i4)
946  if (_caps[i1][i2][i3][i4] != 0.0)
947  transientCapacitanceC (i1, i2, i3, i4, _caps[i1][i2][i3][i4], BP(i3,i4));
948  } } } }
949 
950  // charge: 2-node, voltage: 1-node
951  for (i1 = 0; i1 < 28; i1++) {
952  for (i2 = 0; i2 < 28; i2++) {
953  if (i1 != i2)
954  for (i3 = 0; i3 < 28; i3++) {
955  if (_caps[i1][i2][i3][i3] != 0.0)
956  transientCapacitanceC2Q (i1, i2, i3, _caps[i1][i2][i3][i3], NP(i3));
957  } } }
958 
959  // charge: 1-node, voltage: 2-node
960  for (i1 = 0; i1 < 28; i1++) {
961  for (i3 = 0; i3 < 28; i3++) {
962  for (i4 = 0; i4 < 28; i4++) {
963  if (i3 != i4)
964  if (_caps[i1][i1][i3][i4] != 0.0)
965  transientCapacitanceC2V (i1, i3, i4, _caps[i1][i1][i3][i4], BP(i3,i4));
966  } } }
967 
968  // charge: 1-node, voltage: 1-node
969  for (i1 = 0; i1 < 28; i1++) {
970  for (i3 = 0; i3 < 28; i3++) {
971  if (_caps[i1][i1][i3][i3] != 0.0)
972  transientCapacitanceC (i1, i3, _caps[i1][i1][i3][i3], NP(i3));
973  } }
974 }
975 
976 /* Compute Cy-matrix for AC noise analysis. */
977 matrix dmux3to8::calcMatrixCy (nr_double_t frequency)
978 {
979  _freq = frequency;
980  matrix cy (28);
981 
982 
983  return cy;
984 }
985 
986 /* Perform AC noise computations. */
987 void dmux3to8::calcNoiseAC (nr_double_t frequency)
988 {
989  setMatrixN (calcMatrixCy (frequency));
990 }
991 
992 /* Perform S-parameter noise computations. */
993 void dmux3to8::calcNoiseSP (nr_double_t frequency)
994 {
995  setMatrixN (cytocs (calcMatrixCy (frequency) * z0, getMatrixS ()));
996 }
997 
998 /* Initialization of HB analysis. */
1000 {
1001  initDC ();
1002  allocMatrixHB ();
1003 }
1004 
1005 /* Perform HB analysis. */
1007 {
1008  doHB = 1;
1009  doAC = 1;
1010  doTR = 0;
1011 
1012  // jacobian dI/dV and currents get filled
1013  calcDC ();
1015 
1016  // fill in HB matrices
1017  for (int i1 = 0; i1 < 28; i1++) {
1018  setQ (i1, _qhs[i1]); // charges
1019  setCV (i1, _chs[i1]); // jacobian dQ/dV * V
1020  setGV (i1, _ghs[i1]); // jacobian dI/dV * V
1021  for (int i2 = 0; i2 < 28; i2++) {
1022  setQV (i1, i2, _jdyna[i1][i2]); // jacobian dQ/dV
1023  }
1024  }
1025 }
1026 
1027 #include "dmux3to8.defs.h"