36 type (
LOWPASS), kind (
UNDEF), ord (n), fc (0), bw (0), imp (1),
37 ncomp (0), Comp (NULL) {
42 type (
LOWPASS), kind (
UNDEF), ord (0), fc (0), bw (0), imp (1),
43 ncomp (0), Comp (NULL) {
47 type (
t), kind (k), ord (
n), fc (0), bw (0), imp (1),
48 ncomp (0), Comp (NULL) {
53 type (
t), kind (k), fc (f), bw (
b), imp (r), ncomp (0), Comp (NULL) {
59 type (
t), kind (k), ord (0), fc (0), bw (0), imp (1),
60 ncomp (0), Comp (NULL) {
94 (pComp + 1)->val = c1;
95 (pComp + 2)->val = -Ws / (c1 * pl);
96 (pComp + 1)->val *= Ws;
99 BD =
BD - (
BN >> 1) * (1 / c1);
111 cal =
log10(cal) / 3.0;
112 if(cal < -0.2) cal -= 0.98;
115 if(expo >= -5)
if(expo <= 4)
117 case -5: c =
'f';
break;
118 case -4: c =
'p';
break;
119 case -3: c =
'n';
break;
120 case -2: c =
'u';
break;
121 case -1: c =
'm';
break;
122 case 1: c =
'k';
break;
123 case 2: c =
'M';
break;
124 case 3: c =
'G';
break;
125 case 4: c =
'T';
break;
131 std::stringstream str;
141 for (
unsigned i = 0;
i <
ncomp;
i++) {
142 switch (
Comp[
i].comp) {
144 std::cout <<
"Cap. from node ";
148 std::cout <<
"Ind. from node ";
152 std::cout <<
"Res. from node ";
159 if (
Comp[
i].node2 == 0)
160 std::cout <<
"ground, value = ";
162 std::cout <<
"node " <<
Comp[
i].
node2 <<
", value = ";
165 std::cout <<
Comp[
i].
val <<
" " << unit <<
'\n';
166 else if (
Comp[
i].val >= 1
e-3)
167 std::cout <<
Comp[
i].
val * 1e3 <<
" m" << unit <<
'\n';
168 else if (
Comp[
i].val >= 1
e-6)
169 std::cout <<
Comp[
i].
val * 1e6 <<
" u" << unit <<
'\n';
170 else if (
Comp[
i].val >= 1
e-9)
171 std::cout <<
Comp[
i].
val * 1e9 <<
" n" << unit <<
'\n';
172 else if (
Comp[
i].val >= 1
e-12)
173 std::cout <<
Comp[
i].
val * 1e12 <<
" p" << unit <<
'\n';
174 else if (
Comp[
i].val >= 1
e-15)
175 std::cout <<
Comp[
i].
val * 1e15 <<
" f" << unit <<
'\n';
177 std::cout <<
"0 " << unit <<
'\n';
182 std::ostringstream res;
185 res <<
"* SPICE netlist\n";
188 res <<
"* low-pass filter " <<
fc <<
" Hz cutoff\n";
191 res <<
"* high-pass filter " << fc <<
" Hz cutoff\n";
194 res <<
"* band-pass filter "
198 res <<
"* band-reject filter "
199 <<
fstart <<
" Hz ... " << fstop <<
" Hz\n";
202 res <<
"* PI-type, impedance matching " <<
imp <<
" Ohm\n";
204 for (
unsigned ic = 1, il = 1, ir = 1; i <
ncomp; i++) {
205 switch (
Comp[i].comp) {
207 res <<
"C" << ic <<
"\t";
211 res <<
"R" << ir <<
"\t";
218 res <<
"L" << il <<
"\t";
224 res <<
"R" << ir <<
"\t";
231 res <<
"R" << ir <<
"\t";
237 res <<
"RI\t10000\t1\t" << imp <<
"\n";
240 if (
Comp[i - 1].node2 == 0)
245 res <<
"\t0\t" << imp <<
"\n";
246 res <<
"VCC\t10000\t0\tDC\t1\tAC\t1\n";
256 std::ostringstream res;
257 std::ostringstream wir;
261 res <<
"<Qucs Schematic " << PACKAGE_VERSION <<
">\n";
264 res <<
"<Components>\n";
265 res <<
"<Pac P1 1 " << x <<
" 320 18 -26 0 1 \"1\" 1 \""
266 <<
imp <<
" Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0>\n";
267 res <<
"<GND * 1 " << x <<
" 350 0 0 0 0>\n";
269 int yc = 320, yl = 240;
270 unsigned int i, j = 0, k =
ord, repser = 0, gndser = 1;
276 wir <<
"<" << x <<
" 240 " << x <<
" 290 \"\" 0 0 0>\n"
277 <<
"<" << x <<
" 240 " << x2 <<
" 240 \"\" 0 0 0>\n";
281 for(i = 0; i < k && ncomp > 0; i++) {
284 while (
Comp[a].node2 != 0) {
292 if (
Comp[a].node2 == 0) {
294 wir <<
"<" << x <<
" 240 " << x <<
" 290 \"\" 0 0 0>\n";
295 wir <<
"<" << x-35 <<
" 240 " << x+35 <<
" 240 \"\" 0 0 0>\n";
297 for (c = 0, b = j; b <= a; b++, c++) {
299 switch (
Comp[b].comp) {
300 case CAP: res <<
"<C C";
break;
301 case IND: res <<
"<L L";
break;
302 case RES: res <<
"<R R";
break;
304 res << j+1 <<
" 1 " <<
x;
305 res <<
" " << yc+c*60 <<
" 17 -26 0 1";
308 res <<
" \"" << num2str(
Comp[b].val).c_str();
309 switch (
Comp[b].comp) {
310 case CAP: res <<
"F";
break;
311 case IND: res <<
"H";
break;
312 case RES: res <<
"Ohm";
break;
317 res <<
"<GND * 1 " << x <<
" " << yc+c*60-30 <<
" 0 0 0 0>\n";
319 if (gndser < c) gndser =
c;
327 wir <<
"<" << x-70 <<
" 240 " << x-30 <<
" 240 \"\" 0 0 0>\n";
329 wir <<
"<" << x+70 <<
" 240 " << x+30 <<
" 240 \"\" 0 0 0>\n";
330 unsigned int b = j, c = 0;
333 switch (
Comp[b].comp) {
334 case CAP: res <<
"<C C";
break;
335 case IND: res <<
"<L L";
break;
336 case RES: res <<
"<R R";
break;
338 res << j+1 <<
" 1 " <<
x;
339 res <<
" " << yl-c*35 <<
" -26 ";
342 wir <<
"<" << x-30 <<
" " << yl
343 <<
" " << x-30 <<
" " << yl-c*35 <<
" \"\" 0 0 0>\n"
344 <<
"<" << x+30 <<
" " << yl
345 <<
" " << x+30 <<
" " << yl-c*35 <<
" \"\" 0 0 0>\n";
352 res <<
" \"" << num2str(
Comp[b].val).c_str();
353 switch (
Comp[b].comp) {
354 case CAP: res <<
"F";
break;
355 case IND: res <<
"H";
break;
356 case RES: res <<
"Ohm";
break;
367 if (j >=
ncomp)
break;
375 res <<
"<Pac P2 1 "<< x <<
" 320 18 -26 0 1 \"2\" 1 \""
376 << imp <<
" Ohm\" 1 \"0 dBm\" 0 \"1 GHz\" 0>\n"
377 <<
"<GND * 1 " << x <<
" 350 0 0 0 0>\n";
379 yc += 20 + gndser * 60;
382 res <<
"<.SP SP1 1 70 " << yc <<
" 0 50 0 0 \"log\" 1 \""
383 << num2str(Value).c_str() <<
"Hz\" 1 \"" << num2str(Value2).c_str()
384 <<
"Hz\" 1 \"200\" 1 \"no\" 0 \"1\" 0 \"2\" 0>\n"
385 <<
"<Eqn Eqn1 1 260 " << yc+10
386 <<
" -28 15 0 0 \"dBS21=dB(S[2,1])\" 1 "
387 <<
"\"dBS11=dB(S[1,1])\" 1 \"yes\" 0>\n"
388 <<
"</Components>\n";
393 res << wir.str().c_str();
398 res <<
"<" << x <<
" 240 " << x <<
" 290 \"\" 0 0 0>\n"
399 <<
"<" << x2 <<
" 240 " << x <<
" 240 \"\" 0 0 0>\n";
406 res <<
"<Text 400 " << (yc+10) <<
" 12 #000000 0 \"";
409 case CAUER: res <<
"Cauer ";
break;
410 case BUTT: res <<
"Butterworth ";
break;
411 case CHEB: res <<
"Chebichev ";
break;
412 case ICHEB: res <<
"Inverse Chebichev ";
break;
413 case BESS: res <<
"Bessel ";
break;
414 case UNDEF: res <<
"Undefined ";
break;
419 res <<
"low-pass filter\\n"
420 << num2str(
fc).c_str() <<
"Hz cutoff";
423 res <<
"high-pass filter\\n"
424 << num2str(
fc).c_str() <<
"Hz cutoff";
427 res <<
"band-pass filter\\n"
428 << num2str(
fstart).c_str() <<
"Hz ... "
429 << num2str(
fstop).c_str() <<
"Hz";
432 res <<
"band-reject filter\\n"
433 << num2str(
fstart).c_str() <<
"Hz ... "
434 << num2str(
fstop).c_str() <<
"Hz";
437 res <<
", PI-type,\\nimpedance matching " << imp <<
" Ohm\">\n";
439 res <<
"</Paintings>\n";
444 std::cout <<
to_qucs().c_str();