16 #include "component.h"
21 #define CIR_dmux3to8 -1
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;\
74 _ghs[pnode] += conductance * BP(vpnode,vnnode);\
75 _ghs[nnode] -= conductance * BP(vpnode,vnnode);\
77 _rhs[pnode] += conductance * BP(vpnode,vnnode);\
78 _rhs[nnode] -= conductance * BP(vpnode,vnnode);\
80 #define _load_static_jacobian2p(node,vpnode,vnnode,conductance)\
81 _jstat[node][vpnode] += conductance;\
82 _jstat[node][vnnode] -= conductance;\
84 _ghs[node] += conductance * BP(vpnode,vnnode);\
86 _rhs[node] += conductance * BP(vpnode,vnnode);\
88 #define _load_static_jacobian2s(pnode,nnode,node,conductance)\
89 _jstat[pnode][node] += conductance;\
90 _jstat[nnode][node] -= conductance;\
92 _ghs[pnode] += conductance * NP(node);\
93 _ghs[nnode] -= conductance * NP(node);\
95 _rhs[pnode] += conductance * NP(node);\
96 _rhs[nnode] -= conductance * NP(node);\
98 #define _load_static_jacobian1(node,vnode,conductance)\
99 _jstat[node][vnode] += conductance;\
101 _ghs[node] += conductance * NP(vnode);\
103 _rhs[node] += conductance * NP(vnode);\
105 #define _load_dynamic_residual2(pnode,nnode,charge)\
106 if (doTR) _charges[pnode][nnode] += charge;\
108 _qhs[pnode] -= charge;\
109 _qhs[nnode] += charge;\
111 #define _load_dynamic_residual1(node,charge)\
112 if (doTR) _charges[node][node] += charge;\
114 _qhs[node] -= charge;\
116 #define _load_dynamic_jacobian4(pnode,nnode,vpnode,vnnode,capacitance)\
118 _jdyna[pnode][vpnode] += capacitance;\
119 _jdyna[nnode][vnnode] += capacitance;\
120 _jdyna[pnode][vnnode] -= capacitance;\
121 _jdyna[nnode][vpnode] -= capacitance;\
124 _caps[pnode][nnode][vpnode][vnnode] += capacitance;\
127 _chs[pnode] += capacitance * BP(vpnode,vnnode);\
128 _chs[nnode] -= capacitance * BP(vpnode,vnnode);\
130 #define _load_dynamic_jacobian2s(pnode,nnode,vnode,capacitance)\
132 _jdyna[pnode][vnode] += capacitance;\
133 _jdyna[nnode][vnode] -= capacitance;\
136 _caps[pnode][nnode][vnode][vnode] += capacitance;\
139 _chs[pnode] += capacitance * NP(vnode);\
140 _chs[nnode] -= capacitance * NP(vnode);\
142 #define _load_dynamic_jacobian2p(node,vpnode,vnnode,capacitance)\
144 _jdyna[node][vpnode] += capacitance;\
145 _jdyna[node][vnnode] -= capacitance;\
148 _caps[node][node][vpnode][vnnode] += capacitance;\
151 _chs[node] += capacitance * BP(vpnode,vnnode);\
153 #define _load_dynamic_jacobian1(node,vnode,capacitance)\
155 _jdyna[node][vnode] += capacitance;\
158 _caps[node][node][vnode][vnode] += capacitance;\
161 _chs[node] += capacitance * NP(vnode);\
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;
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));
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;
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);
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));
237 #define m00_exp(v00,x) v00 = exp(x);
238 #define m10_exp(v10,v00,x) v10 = v00;
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));
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)
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)
262 #define _vt_nom (kBoverQ*_circuit_temp)
264 using namespace device;
273 void dmux3to8::initModel (
void)
300 initializeInstance ();
321 void dmux3to8::initVerilog (
void)
328 for (i1 = 0; i1 < 28; i1++) {
329 for (i2 = 0; i2 < 28; i2++) {
330 _charges[i1][i2] = 0.0;
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;
342 for (i1 = 0; i1 < 28; i1++) {
347 for (i2 = 0; i2 < 28; i2++) {
348 _jstat[i1][i2] = 0.0;
349 _jdyna[i1][i2] = 0.0;
355 void dmux3to8::loadVariables (
void)
367 #define _DERIVATEFORDDX
370 void dmux3to8::initializeModel (
void)
372 #if defined(_DYNAMIC)
376 #if defined(_DYNAMIC)
377 Cd=((Delay*1.43)/Rd);
383 void dmux3to8::initializeInstance (
void)
388 void dmux3to8::initialStep (
void)
393 void dmux3to8::finalStep (
void)
398 void dmux3to8::calcVerilog (
void)
403 #if defined(_DERIVATE)
410 #if defined(_DERIVATE)
417 #if defined(_DERIVATE)
424 #if defined(_DERIVATE)
431 #if defined(_DERIVATE)
438 #if defined(_DERIVATE)
445 #if defined(_DERIVATE)
452 #if defined(_DERIVATE)
459 #if defined(_DERIVATE)
463 #if defined(_DERIVATE)
467 #if defined(_DERIVATE)
471 #if defined(_DERIVATE)
474 #if defined(_DERIVATE)
478 #if defined(_DERIVATE)
482 #if defined(_DERIVATE)
486 #if defined(_DERIVATE)
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);
496 IY0=(((VENI*VCI)*VBI)*VAI);
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)))
503 #if defined(_DERIVATE)
511 #if defined(_DERIVATE)
515 #if defined(_DERIVATE)
518 #if defined(_DYNAMIC)
520 #if defined(_DERIVATE)
525 #if defined(_DERIVATE)
529 #if defined(_DERIVATE)
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));
538 IY1=(((VENI*VCI)*VBI)*
NP(
A));
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)))
545 #if defined(_DERIVATE)
553 #if defined(_DERIVATE)
557 #if defined(_DERIVATE)
560 #if defined(_DYNAMIC)
562 #if defined(_DERIVATE)
567 #if defined(_DERIVATE)
571 #if defined(_DERIVATE)
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);
580 IY2=(((VENI*VCI)*
NP(
B))*VAI);
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)))
587 #if defined(_DERIVATE)
595 #if defined(_DERIVATE)
599 #if defined(_DERIVATE)
602 #if defined(_DYNAMIC)
604 #if defined(_DERIVATE)
609 #if defined(_DERIVATE)
613 #if defined(_DERIVATE)
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)));
622 IY3=(((VENI*VCI)*
NP(
B))*
NP(
A));
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)))
629 #if defined(_DERIVATE)
637 #if defined(_DERIVATE)
641 #if defined(_DERIVATE)
644 #if defined(_DYNAMIC)
646 #if defined(_DERIVATE)
651 #if defined(_DERIVATE)
655 #if defined(_DERIVATE)
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);
664 IY4=(((VENI*
NP(
C))*VBI)*VAI);
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)))
671 #if defined(_DERIVATE)
679 #if defined(_DERIVATE)
683 #if defined(_DERIVATE)
686 #if defined(_DYNAMIC)
688 #if defined(_DERIVATE)
693 #if defined(_DERIVATE)
697 #if defined(_DERIVATE)
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));
706 IY5=(((VENI*
NP(
C))*VBI)*
NP(
A));
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)))
713 #if defined(_DERIVATE)
721 #if defined(_DERIVATE)
725 #if defined(_DERIVATE)
728 #if defined(_DYNAMIC)
730 #if defined(_DERIVATE)
735 #if defined(_DERIVATE)
739 #if defined(_DERIVATE)
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);
748 IY6=(((VENI*
NP(
C))*
NP(
B))*VAI);
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)))
755 #if defined(_DERIVATE)
763 #if defined(_DERIVATE)
767 #if defined(_DERIVATE)
770 #if defined(_DYNAMIC)
772 #if defined(_DERIVATE)
777 #if defined(_DERIVATE)
781 #if defined(_DERIVATE)
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)));
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)))
797 #if defined(_DERIVATE)
805 #if defined(_DERIVATE)
809 #if defined(_DERIVATE)
812 #if defined(_DYNAMIC)
814 #if defined(_DERIVATE)
819 #if defined(_DERIVATE)
823 #if defined(_DERIVATE)
842 for (
int i1 = 0; i1 < 28; i1++) {
844 for (
int i2 = 0; i2 < 28; i2++) {
845 setY (i1, i2, _jstat[i1][i2]);
879 matrix dmux3to8::calcMatrixY (nr_double_t frequency)
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);
921 int i1, i2, i3, i4, state;
924 for (i1 = 0; i1 < 28; i1++) {
925 for (i2 = 0; i2 < 28; i2++) {
926 state = 2 * (i2 + 28 * i1);
928 if (_charges[i1][i2] != 0.0)
933 for (i1 = 0; i1 < 28; i1++) {
934 state = 2 * (i1 + 28 * i1);
935 if (_charges[i1][i1] != 0.0)
940 for (i1 = 0; i1 < 28; i1++) {
941 for (i2 = 0; i2 < 28; i2++) {
943 for (i3 = 0; i3 < 28; i3++) {
944 for (i4 = 0; i4 < 28; i4++) {
946 if (_caps[i1][i2][i3][i4] != 0.0)
951 for (i1 = 0; i1 < 28; i1++) {
952 for (i2 = 0; i2 < 28; i2++) {
954 for (i3 = 0; i3 < 28; i3++) {
955 if (_caps[i1][i2][i3][i3] != 0.0)
960 for (i1 = 0; i1 < 28; i1++) {
961 for (i3 = 0; i3 < 28; i3++) {
962 for (i4 = 0; i4 < 28; i4++) {
964 if (_caps[i1][i1][i3][i4] != 0.0)
969 for (i1 = 0; i1 < 28; i1++) {
970 for (i3 = 0; i3 < 28; i3++) {
971 if (_caps[i1][i1][i3][i3] != 0.0)
977 matrix dmux3to8::calcMatrixCy (nr_double_t frequency)
1017 for (
int i1 = 0; i1 < 28; i1++) {
1018 setQ (i1, _qhs[i1]);
1019 setCV (i1, _chs[i1]);
1020 setGV (i1, _ghs[i1]);
1021 for (
int i2 = 0; i2 < 28; i2++) {
1022 setQV (i1, i2, _jdyna[i1][i2]);