diff --git a/qucs/components/ac_sim.cpp b/qucs/components/ac_sim.cpp index 24cceb5c..e0eb31db 100644 --- a/qucs/components/ac_sim.cpp +++ b/qucs/components/ac_sim.cpp @@ -79,7 +79,7 @@ void AC_Sim::recreate(Schematic*) } } -QString AC_Sim::spice_netlist(bool isXyce) +QString AC_Sim::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = SpiceModel + " "; QString unit; @@ -100,7 +100,7 @@ QString AC_Sim::spice_netlist(bool isXyce) QString fstart = spicecompat::normalize_value(Props.at(1)->Value); // Start freq. QString fstop = spicecompat::normalize_value(Props.at(2)->Value); // Stop freq. s += QStringLiteral("%1 %2 \n").arg(fstart).arg(fstop); - if (!isXyce) s.remove(0,1); + if (dialect != spicecompat::SPICEXyce) s.remove(0,1); return s.toLower(); } diff --git a/qucs/components/ac_sim.h b/qucs/components/ac_sim.h index 3ce3b46d..3699b8fe 100644 --- a/qucs/components/ac_sim.h +++ b/qucs/components/ac_sim.h @@ -28,7 +28,7 @@ class AC_Sim : public qucs::component::SimulationComponent { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); void recreate(Schematic*); - QString spice_netlist(bool isXyce=false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/ampere_ac.cpp b/qucs/components/ampere_ac.cpp index d56e848c..697aca2c 100644 --- a/qucs/components/ampere_ac.cpp +++ b/qucs/components/ampere_ac.cpp @@ -78,8 +78,10 @@ Element* Ampere_ac::info(QString& Name, char* &BitmapFile, bool getNewOne) } -QString Ampere_ac::spice_netlist(bool) +QString Ampere_ac::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); QString plus = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); diff --git a/qucs/components/ampere_ac.h b/qucs/components/ampere_ac.h index 2e8b96ff..67713489 100644 --- a/qucs/components/ampere_ac.h +++ b/qucs/components/ampere_ac.h @@ -28,7 +28,7 @@ class Ampere_ac : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/ampere_dc.cpp b/qucs/components/ampere_dc.cpp index c14d21c2..b3a6458b 100644 --- a/qucs/components/ampere_dc.cpp +++ b/qucs/components/ampere_dc.cpp @@ -47,7 +47,7 @@ Ampere_dc::Ampere_dc() SpiceModel = "I"; Props.append(new Property("I", "1 mA", true, - QObject::tr("current in Ampere"))); + QObject::tr("current in Ampere"))); rotate(); // fix historical flaw } @@ -56,8 +56,10 @@ Ampere_dc::~Ampere_dc() { } -QString Ampere_dc::spice_netlist(bool) +QString Ampere_dc::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); QString plus = Ports.at(1)->Connection->Name; @@ -68,6 +70,12 @@ QString Ampere_dc::spice_netlist(bool) .arg(spicecompat::normalize_value(Props.at(0)->Value)); return s; } + +QString Ampere_dc::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + Component* Ampere_dc::newOne() { return new Ampere_dc(); diff --git a/qucs/components/ampere_dc.h b/qucs/components/ampere_dc.h index c349b351..2d173680 100644 --- a/qucs/components/ampere_dc.h +++ b/qucs/components/ampere_dc.h @@ -27,7 +27,8 @@ class Ampere_dc : public Component { ~Ampere_dc(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/components/biast.cpp b/qucs/components/biast.cpp index b3f7735c..ff1a21ce 100644 --- a/qucs/components/biast.cpp +++ b/qucs/components/biast.cpp @@ -80,9 +80,10 @@ Element* BiasT::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString BiasT::spice_netlist(bool isXyce) +QString BiasT::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString s; QString L = spicecompat::normalize_value(getProperty("L")->Value); QString C = spicecompat::normalize_value(getProperty("C")->Value); diff --git a/qucs/components/biast.h b/qucs/components/biast.h index 45a97749..58762670 100644 --- a/qucs/components/biast.h +++ b/qucs/components/biast.h @@ -28,7 +28,7 @@ class BiasT : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/bjt.cpp b/qucs/components/bjt.cpp index b65a425b..9d32738c 100644 --- a/qucs/components/bjt.cpp +++ b/qucs/components/bjt.cpp @@ -42,7 +42,7 @@ Component* BJT::newOne() return p; } -QString BJT::spice_netlist(bool) +QString BJT::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); QList pin_seq; @@ -60,17 +60,28 @@ QString BJT::spice_netlist(bool) QString par_str = form_spice_param_list(spice_incompat,spice_tr); - if (getProperty("UseGlobTemp")->Value == "yes") { - s += QStringLiteral(" QMOD_%1 AREA=%2\n").arg(Name).arg(getProperty("Area")->Value); + const bool isDialectCDL(dialect == spicecompat::CDL); + + if (getProperty("UseGlobTemp")->Value == "yes" || isDialectCDL) { + s += QStringLiteral(" QMOD_%1 %2=%3\n").arg(Name).arg(isDialectCDL ? "$EA" : "AREA").arg(getProperty("Area")->Value); } else { - s += QStringLiteral(" QMOD_%1 AREA=%2 TEMP=%3\n").arg(Name).arg(getProperty("Area")->Value) - .arg(getProperty("Temp")->Value); + s += QStringLiteral(" QMOD_%1 AREA=%2 TEMP=%3\n").arg(Name).arg(getProperty("Area")->Value) + .arg(getProperty("Temp")->Value); + } + + if (!isDialectCDL) + { + s += QStringLiteral(".MODEL QMOD_%1 %2 (%3)\n").arg(Name).arg(getProperty("Type")->Value).arg(par_str); } - s += QStringLiteral(".MODEL QMOD_%1 %2 (%3)\n").arg(Name).arg(getProperty("Type")->Value).arg(par_str); return s; } +QString BJT::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + // ------------------------------------------------------- Element* BJT::info(QString& Name, char* &BitmapFile, bool getNewOne) { diff --git a/qucs/components/bjt.h b/qucs/components/bjt.h index c035033a..2be3cf90 100644 --- a/qucs/components/bjt.h +++ b/qucs/components/bjt.h @@ -32,7 +32,8 @@ class BJT : public Basic_BJT { protected: void createSymbol(); QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/components/bjtsub.cpp b/qucs/components/bjtsub.cpp index c955e222..5a1947d3 100644 --- a/qucs/components/bjtsub.cpp +++ b/qucs/components/bjtsub.cpp @@ -201,7 +201,7 @@ void BJTsub::createSymbol() x2 = 30; y2 = 30; } -QString BJTsub::spice_netlist(bool) +QString BJTsub::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); QList pin_seq; @@ -219,14 +219,24 @@ QString BJTsub::spice_netlist(bool) QString par_str = form_spice_param_list(spice_incompat,spice_tr); - if (getProperty("UseGlobTemp")->Value == "yes") { - s += QStringLiteral(" QMOD_%1 AREA=%2\n").arg(Name).arg(getProperty("Area")->Value); + const bool isDialectCDL(dialect == spicecompat::CDL); + + if (getProperty("UseGlobTemp")->Value == "yes" || isDialectCDL) { + s += QStringLiteral(" QMOD_%1 %2=%3\n").arg(Name).arg(isDialectCDL ? "$EA" : "AREA").arg(getProperty("Area")->Value); } else { - s += QStringLiteral(" QMOD_%1 AREA=%2 TEMP=%3\n").arg(Name).arg(getProperty("Area")->Value) - .arg(getProperty("Temp")->Value); + s += QStringLiteral(" QMOD_%1 AREA=%2 TEMP=%3\n").arg(Name).arg(getProperty("Area")->Value) + .arg(getProperty("Temp")->Value); } - s += QStringLiteral(".MODEL QMOD_%1 %2 (%3)\n").arg(Name).arg(getProperty("Type")->Value).arg(par_str); + if (!isDialectCDL) + { + s += QStringLiteral(".MODEL QMOD_%1 %2 (%3)\n").arg(Name).arg(getProperty("Type")->Value).arg(par_str); + } return s; } + +QString BJTsub::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/components/bjtsub.h b/qucs/components/bjtsub.h index 02b57ba7..29699261 100644 --- a/qucs/components/bjtsub.h +++ b/qucs/components/bjtsub.h @@ -36,7 +36,8 @@ class BJTsub : public Basic_BJT { static Element* info_pnp(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); void createSymbol(); }; diff --git a/qucs/components/capacitor.cpp b/qucs/components/capacitor.cpp index 14377aa2..38cdb20b 100644 --- a/qucs/components/capacitor.cpp +++ b/qucs/components/capacitor.cpp @@ -25,11 +25,11 @@ Capacitor::Capacitor() Description = QObject::tr("capacitor"); Props.append(new Property("C", "1 nF", true, - QObject::tr("capacitance in Farad"))); + QObject::tr("capacitance in Farad"))); Props.append(new Property("V", "", false, - QObject::tr("initial voltage for transient simulation"))); + QObject::tr("initial voltage for transient simulation"))); Props.append(new Property("Symbol", "neutral", false, - QObject::tr("schematic symbol")+" [neutral, polar]")); + QObject::tr("schematic symbol")+" [neutral, polar]")); createSymbol(); tx = x1+4; @@ -53,7 +53,7 @@ Element* Capacitor::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString Capacitor::spice_netlist(bool) +QString Capacitor::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); @@ -64,24 +64,29 @@ QString Capacitor::spice_netlist(bool) s += " "+spicecompat::normalize_value(Props.at(0)->Value) + " "; QString val = Props.at(1)->Value; // add inial voltage if presents val = val.remove(' ').toUpper(); - if (!val.isEmpty()) { + if (!val.isEmpty() && dialect != spicecompat::CDL) { s += " IC=" + val; } return s+'\n'; } +QString Capacitor::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + QString Capacitor::va_code() { QString val = vacompat::normalize_value(Props.at(0)->Value); QString plus = Ports.at(0)->Connection->Name; - QString minus = Ports.at(1)->Connection->Name; + QString minus = Ports.at(1)->Connection->Name; QString s = ""; QString Vpm = vacompat::normalize_voltage(plus,minus); if (Vpm.startsWith("(-")) Vpm.remove(1,1); // Make capacitor unipolar, remove starting minus - QString Ipm = vacompat::normalize_current(plus,minus,true); + QString Ipm = vacompat::normalize_current(plus,minus,true); s += QStringLiteral("%1 <+ ddt( %2 * %3 );\n").arg(Ipm).arg(Vpm).arg(val); - + return s; } diff --git a/qucs/components/capacitor.h b/qucs/components/capacitor.h index 32881186..58176f4b 100644 --- a/qucs/components/capacitor.h +++ b/qucs/components/capacitor.h @@ -30,7 +30,8 @@ class Capacitor : public MultiViewComponent { protected: void createSymbol(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); QString va_code(); }; diff --git a/qucs/components/capq.cpp b/qucs/components/capq.cpp index cbf32b55..787937dc 100644 --- a/qucs/components/capq.cpp +++ b/qucs/components/capq.cpp @@ -91,9 +91,10 @@ Element* CapQ::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString CapQ::spice_netlist(bool isXyce) +QString CapQ::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString s; QString pin1 = Ports.at(0)->Connection->Name; pin1 = spicecompat::normalize_node_name(pin1); @@ -124,3 +125,4 @@ QString CapQ::spice_netlist(bool isXyce) return s; } + diff --git a/qucs/components/capq.h b/qucs/components/capq.h index 4a1b3a20..b65e331e 100644 --- a/qucs/components/capq.h +++ b/qucs/components/capq.h @@ -34,7 +34,7 @@ class CapQ : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/cccs.cpp b/qucs/components/cccs.cpp index 2244d16d..25f1424f 100644 --- a/qucs/components/cccs.cpp +++ b/qucs/components/cccs.cpp @@ -82,27 +82,29 @@ Element* CCCS::info(QString& Name, char* &BitmapFile, bool getNewOne) } QString CCCS::va_code() -{ - - QString Gain = vacompat::normalize_value(Props.at(0)->Value); - QString P1 = Ports.at(0)->Connection->Name; +{ + + QString Gain = vacompat::normalize_value(Props.at(0)->Value); + QString P1 = Ports.at(0)->Connection->Name; QString P4 = Ports.at(1)->Connection->Name; QString P3 = Ports.at(2)->Connection->Name; QString P2 = Ports.at(3)->Connection->Name; QString s = ""; - + QString Vpm = vacompat::normalize_voltage(P1,P2); - QString Ipm = vacompat::normalize_current(P1,P2,true); + QString Ipm = vacompat::normalize_current(P1,P2,true); s += QStringLiteral(" %1 <+ %2 * 1e3;\n").arg(Ipm).arg(Vpm); QString Vpm2 = vacompat::normalize_voltage(P4,P3); - QString Ipm2 = vacompat::normalize_current(P4,P3,true); + QString Ipm2 = vacompat::normalize_current(P4,P3,true); s += QStringLiteral("%1 <+ %2 * 1e-9;\n").arg(Ipm2).arg(Vpm2); s += QStringLiteral("%1 <+ %2 * 1e3 * %3 ;\n").arg(Ipm2).arg(Vpm).arg(Gain); - + return s; } -QString CCCS::spice_netlist(bool) +QString CCCS::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); // spice CCCS consists two sources: output source // and zero value controlling source QString val = spicecompat::normalize_value(Props.at(0)->Value); diff --git a/qucs/components/cccs.h b/qucs/components/cccs.h index 530aa985..fc2621ce 100644 --- a/qucs/components/cccs.h +++ b/qucs/components/cccs.h @@ -28,7 +28,7 @@ class CCCS : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString va_code(); }; diff --git a/qucs/components/ccvs.cpp b/qucs/components/ccvs.cpp index 108bde52..424d1a25 100644 --- a/qucs/components/ccvs.cpp +++ b/qucs/components/ccvs.cpp @@ -59,7 +59,7 @@ CCVS::CCVS() SpiceModel = "H"; Props.append(new Property("G", "1 Ohm", true, - QObject::tr("forward transfer factor"))); + QObject::tr("forward transfer factor"))); Props.append(new Property("T", "0", false, QObject::tr("delay time (Qucsator only)"))); } @@ -82,28 +82,30 @@ Element* CCVS::info(QString& Name, char* &BitmapFile, bool getNewOne) } QString CCVS::va_code() -{ +{ QString Gain = vacompat::normalize_value(Props.at(0)->Value); - QString P1 = Ports.at(0)->Connection->Name; + QString P1 = Ports.at(0)->Connection->Name; QString P4 = Ports.at(1)->Connection->Name; QString P3 = Ports.at(2)->Connection->Name; QString P2 = Ports.at(3)->Connection->Name; QString s = ""; - + QString Vpm = vacompat::normalize_voltage(P1,P2); - QString Ipm = vacompat::normalize_current(P1,P2,true); + QString Ipm = vacompat::normalize_current(P1,P2,true); s += QStringLiteral(" %1 <+ %2 * 1e3;\n").arg(Ipm).arg(Vpm); QString Vpm2 = vacompat::normalize_voltage(P3,P4); - QString Ipm2 = vacompat::normalize_current(P3,P4,true); + QString Ipm2 = vacompat::normalize_current(P3,P4,true); s += QStringLiteral("%1 <+ -(%2 * 1e3);\n").arg(Ipm2).arg(Vpm2); s += QStringLiteral("%1 <+ -(%2 * 1e6* %3) ;\n").arg(Ipm2).arg(Vpm).arg(Gain); - + return s; } // ------------------------------------------------------- -QString CCVS::spice_netlist(bool) +QString CCVS::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); // spice CCVS consists two sources: output source // and zero value controlling source QString val = spicecompat::normalize_value(Props.at(0)->Value); diff --git a/qucs/components/ccvs.h b/qucs/components/ccvs.h index 09b9245d..92a540c1 100644 --- a/qucs/components/ccvs.h +++ b/qucs/components/ccvs.h @@ -28,7 +28,7 @@ class CCVS : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString va_code(); }; diff --git a/qucs/components/component.cpp b/qucs/components/component.cpp index 87588a7c..912dab0e 100644 --- a/qucs/components/component.cpp +++ b/qucs/components/component.cpp @@ -758,7 +758,11 @@ QString Component::form_spice_param_list(QStringList &ignore_list, QStringList & return par_str; } -QString Component::spice_netlist(bool) { +QString Component::spice_netlist(spicecompat::SpiceDialect) { + return QStringLiteral("\n"); // ignore if not implemented +} + +QString Component::cdl_netlist() { return QStringLiteral("\n"); // ignore if not implemented } @@ -787,11 +791,11 @@ QString Component::getNetlist() { return s; } -QString Component::getSpiceNetlist(bool isXyce) { +QString Component::getSpiceNetlist(spicecompat::SpiceDialect dialect /* = SPICEDefault */) { QString s; switch (isActive) { case COMP_IS_ACTIVE: - s = spice_netlist(isXyce); + s = dialect == spicecompat::CDL ? cdl_netlist() : spice_netlist(dialect); s.replace(" gnd ", " 0 "); return s; case COMP_IS_OPEN: @@ -824,7 +828,7 @@ QString Component::getVerilogACode() { } } -QString Component::getExpression(bool) { +QString Component::getExpression(bool, bool) { return QString(); } @@ -1537,8 +1541,11 @@ QString GateComponent::netlist() { return s; } -QString GateComponent::spice_netlist(bool isXyce) { - if (isXyce) return {""}; +QString GateComponent::spice_netlist(spicecompat::SpiceDialect dialect) { + if (dialect == spicecompat::SPICEXyce) + { + return QString(); + } QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/component.h b/qucs/components/component.h index 64966355..cf553ae0 100644 --- a/qucs/components/component.h +++ b/qucs/components/component.h @@ -42,9 +42,9 @@ class Component : public Element { virtual Component* newOne(); virtual void recreate(Schematic*) {}; QString getNetlist(); - QString getSpiceNetlist(bool isXyce = false); + QString getSpiceNetlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString getVerilogACode(); - virtual QString getExpression(bool isXyce = false); + virtual QString getExpression(bool isXyce = false, bool isCdl = false); virtual QString getEquations(QString sim, QStringList &dep_vars); virtual QStringList getExtraVariables(); virtual QString getProbeVariable(bool isXyce = false); @@ -114,7 +114,8 @@ class Component : public Element { protected: virtual QString netlist(); - virtual QString spice_netlist(bool isXyce = false); + virtual QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); virtual QString va_code(); virtual QString vhdlCode(int); virtual QString verilogCode(int); @@ -149,7 +150,7 @@ class GateComponent : public MultiViewComponent { public: GateComponent(); QString netlist(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString vhdlCode(int); QString verilogCode(int); diff --git a/qucs/components/d_flipflop.cpp b/qucs/components/d_flipflop.cpp index 2296881d..47520fc0 100644 --- a/qucs/components/d_flipflop.cpp +++ b/qucs/components/d_flipflop.cpp @@ -120,9 +120,9 @@ Element* D_FlipFlop::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString D_FlipFlop::spice_netlist(bool isXyce) +QString D_FlipFlop::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - if (isXyce) return QString(); + if (dialect == spicecompat::SPICEXyce) return QString(); QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/d_flipflop.h b/qucs/components/d_flipflop.h index b216b7f3..6370ae38 100644 --- a/qucs/components/d_flipflop.h +++ b/qucs/components/d_flipflop.h @@ -31,7 +31,7 @@ class D_FlipFlop : public Component { protected: QString vhdlCode(int); QString verilogCode(int); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/dc_sim.cpp b/qucs/components/dc_sim.cpp index 2bcb1855..d5ebb358 100644 --- a/qucs/components/dc_sim.cpp +++ b/qucs/components/dc_sim.cpp @@ -67,10 +67,10 @@ Element* DC_Sim::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString DC_Sim::spice_netlist(bool isXyce) +QString DC_Sim::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; - if ( !isXyce ) { + if (dialect != spicecompat::SPICEXyce) { s += "op\n"; } diff --git a/qucs/components/dc_sim.h b/qucs/components/dc_sim.h index 10b16e64..c08bb78f 100644 --- a/qucs/components/dc_sim.h +++ b/qucs/components/dc_sim.h @@ -29,7 +29,7 @@ class DC_Sim : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/dcblock.cpp b/qucs/components/dcblock.cpp index b8217344..a3df1528 100644 --- a/qucs/components/dcblock.cpp +++ b/qucs/components/dcblock.cpp @@ -47,7 +47,7 @@ dcBlock::dcBlock() SpiceModel = "C"; Props.append(new Property("C", "1 uF", false, - QObject::tr("for transient simulation: capacitance in Farad"))); + QObject::tr("for transient simulation: capacitance in Farad"))); } dcBlock::~dcBlock() @@ -68,9 +68,10 @@ Element* dcBlock::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString dcBlock::spice_netlist(bool isXyce) +QString dcBlock::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString p1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); QString p2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); QString val = spicecompat::normalize_value(getProperty("C")->Value); @@ -79,3 +80,8 @@ QString dcBlock::spice_netlist(bool isXyce) s = QStringLiteral("%1 %2 %3 %4\n").arg(name, p1, p2, val); return s; } + +QString dcBlock::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/components/dcblock.h b/qucs/components/dcblock.h index a4493714..eb27a327 100644 --- a/qucs/components/dcblock.h +++ b/qucs/components/dcblock.h @@ -27,8 +27,10 @@ class dcBlock : public Component { ~dcBlock(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/components/dcfeed.cpp b/qucs/components/dcfeed.cpp index 63b4dceb..8288db16 100644 --- a/qucs/components/dcfeed.cpp +++ b/qucs/components/dcfeed.cpp @@ -69,9 +69,10 @@ Element* dcFeed::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString dcFeed::spice_netlist(bool isXyce) +QString dcFeed::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString p1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); QString p2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); QString val = spicecompat::normalize_value(getProperty("L")->Value); @@ -80,3 +81,9 @@ QString dcFeed::spice_netlist(bool isXyce) s = QStringLiteral("%1 %2 %3 %4\n").arg(name, p1, p2, val); return s; } + + +QString dcFeed::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/components/dcfeed.h b/qucs/components/dcfeed.h index 48b75ca2..8ef741db 100644 --- a/qucs/components/dcfeed.h +++ b/qucs/components/dcfeed.h @@ -27,8 +27,10 @@ class dcFeed : public Component { ~dcFeed(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/components/dff_SR.cpp b/qucs/components/dff_SR.cpp index c72ca211..c550a520 100644 --- a/qucs/components/dff_SR.cpp +++ b/qucs/components/dff_SR.cpp @@ -13,7 +13,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * */ #include "dff_SR.h" #include "node.h" @@ -46,7 +46,7 @@ Component * dff_SR::newOne() dff_SR * p = new dff_SR(); p->Props.front()->Value = Props.front()->Value; - p->recreate(0); + p->recreate(0); return p; } @@ -85,7 +85,7 @@ void dff_SR::createSymbol() Texts.append(new Text( 15.5, 12, "Q", Qt::darkBlue, 12.0)); Texts.last()->over=true; Texts.append(new Text( -4, 24, "R", Qt::darkBlue, 12.0)); - + Ports.append(new Port(0, -60)); // S Ports.append(new Port(-50,-20)); // D Ports.append(new Port(-50, 20)); // CLK @@ -121,7 +121,7 @@ QString dff_SR::vhdlCode( int ) " state := '0';\n"+ " elsif ("+CLK+" = '1' and "+CLK+"'event) then\n"+ " state := "+D+";\n"+ - " end if;\n"+ + " end if;\n"+ " "+Q+" <= state"+td+ " "+QB+" <= not state"+td+ " end process;\n"; @@ -132,9 +132,9 @@ QString dff_SR::verilogCode( int ) { QString td = Props.at(2)->Value; // delay time if(!misc::Verilog_Delay(td, Name)) return td; // time does not have VHDL format - + QString l = ""; - + QString S = Ports.at(0)->Connection->Name; QString D = Ports.at(1)->Connection->Name; QString CLK = Ports.at(2)->Connection->Name; @@ -175,9 +175,9 @@ QString dff_SR::verilogCode( int ) return l; } -QString dff_SR::spice_netlist(bool isXyce) +QString dff_SR::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - if (isXyce) return QString(); + if (dialect == spicecompat::SPICEXyce) return QString(); QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/dff_SR.h b/qucs/components/dff_SR.h index 72ae7c11..00478052 100644 --- a/qucs/components/dff_SR.h +++ b/qucs/components/dff_SR.h @@ -24,7 +24,7 @@ class dff_SR : public Component void createSymbol(); QString vhdlCode(int); QString verilogCode(int); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif /* dff_SR_H */ diff --git a/qucs/components/digi_source.cpp b/qucs/components/digi_source.cpp index acf3a975..07552524 100644 --- a/qucs/components/digi_source.cpp +++ b/qucs/components/digi_source.cpp @@ -88,7 +88,7 @@ QString Digi_Source::netlist() // output node names s += " "+Ports.first()->Connection->Name; - + // output all properties // first property not needed auto pp = Props.begin(); @@ -134,7 +134,7 @@ QString Digi_Source::vhdlCode(int NumPorts) else { // truth table simulation State = '0'; int Num = Props.at(0)->Value.toInt() - 1; - + s += Out + State + "';"; // first value for signal s += " wait for "+QString::number(1 << Num)+" ns;\n"; State ^= 1; @@ -179,7 +179,7 @@ QString Digi_Source::verilogCode(int NumPorts) } } else { // truth table simulation - int Num = Props.front()->Value.toInt() - 1; + int Num = Props.front()->Value.toInt() - 1; s += " always begin\n"; s += " " + r + " = 0;\n"; s += " #"+ QString::number(1 << Num) + ";\n"; @@ -191,8 +191,10 @@ QString Digi_Source::verilogCode(int NumPorts) return s; } -QString Digi_Source::spice_netlist(bool) +QString Digi_Source::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = SpiceModel + Name; QString port = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); s += " " + port + " 0 "; // node names diff --git a/qucs/components/digi_source.h b/qucs/components/digi_source.h index 23b389d3..1cae314f 100644 --- a/qucs/components/digi_source.h +++ b/qucs/components/digi_source.h @@ -32,7 +32,7 @@ class Digi_Source : public Component { QString netlist(); QString vhdlCode(int); QString verilogCode(int); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/diode.cpp b/qucs/components/diode.cpp index 7e76446e..327f395d 100644 --- a/qucs/components/diode.cpp +++ b/qucs/components/diode.cpp @@ -99,7 +99,7 @@ Component* Diode::newOne() return new Diode(); } -QString Diode::spice_netlist(bool isXyce) +QString Diode::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); // output all node names @@ -113,7 +113,7 @@ QString Diode::spice_netlist(bool isXyce) } QStringList spice_incompat,spice_tr; - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { spice_tr<<"Tbv"<<"Tbv1"<<"Trs"<<"Trs1"; // parameters that need conversion of names spice_incompat<<"Ttt1"<<"Ttt2"<<"Tm1"<<"Tm2"<<"Cp"<<"Isr" <<"Nr"<<"Ffe"<<"Temp"<<"Area"<<"Symbol"<<"UseGlobTemp"; // spice-incompatible parameters @@ -149,15 +149,21 @@ QString Diode::spice_netlist(bool isXyce) .arg(getProperty("Temp")->Value); } - if (isXyce) { - s += QStringLiteral(".MODEL DMOD_%1 D (LEVEL = 2 %2)\n").arg(Name).arg(par_str); - } else { - s += QStringLiteral(".MODEL DMOD_%1 D (%2)\n").arg(Name).arg(par_str); + if (dialect != spicecompat::CDL) + { + if (dialect == spicecompat::SPICEXyce) { + s += QStringLiteral(".MODEL DMOD_%1 D (LEVEL = 2 %2)\n").arg(Name).arg(par_str); + } else { + s += QStringLiteral(".MODEL DMOD_%1 D (%2)\n").arg(Name).arg(par_str); + } } - return s; +} +QString Diode::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); } Element* Diode::info(QString& Name, char* &BitmapFile, bool getNewOne) diff --git a/qucs/components/diode.h b/qucs/components/diode.h index a71b0c2d..898b5a6d 100644 --- a/qucs/components/diode.h +++ b/qucs/components/diode.h @@ -29,7 +29,8 @@ class Diode : public MultiViewComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); void createSymbol(); }; diff --git a/qucs/components/eqndefined.cpp b/qucs/components/eqndefined.cpp index bd5de38e..a813ee7b 100644 --- a/qucs/components/eqndefined.cpp +++ b/qucs/components/eqndefined.cpp @@ -96,8 +96,8 @@ QString EqnDefined::netlist() return s+e; } -QString EqnDefined::spice_netlist(bool isXyce) -{ +QString EqnDefined::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) +{ QString s; QList used_currents; @@ -123,7 +123,7 @@ QString EqnDefined::spice_netlist(bool isXyce) Ieqn.replace("^","**"); QStringList Itokens; spicecompat::splitEqn(Ieqn,Itokens); - spicecompat::convert_functions(Itokens,isXyce); + spicecompat::convert_functions(Itokens, dialect == spicecompat::SPICEXyce); subsVoltages(Itokens,Nbranch); subsCurrents(Itokens); QString plus = Ports.at(2*i)->Connection->Name; @@ -137,11 +137,11 @@ QString EqnDefined::spice_netlist(bool isXyce) QString Qeqn = Props.at(2*(i+1)+1)->Value; // parse charge equation only for Xyce if (Qeqn!="0") { - //if (isXyce) { + //if (dialect == spicecompat::SPICEXyce) { Qeqn.replace("^","**"); QStringList Qtokens; spicecompat::splitEqn(Qeqn,Qtokens); - spicecompat::convert_functions(Qtokens,isXyce); + spicecompat::convert_functions(Qtokens, dialect == spicecompat::SPICEXyce); subsVoltages(Qtokens,Nbranch); subsCurrents(Qtokens); s += QStringLiteral("G%1Q%2 %3 %4 n%1Q%2 %4 1.0\n").arg(Name).arg(i).arg(plus).arg(minus); @@ -182,7 +182,7 @@ QString EqnDefined::va_code() vacompat::convert_functions(Qtokens); subsVoltages(Qtokens,Nbranch); if (plus=="gnd") s += QStringLiteral("%1 <+ -ddt( %2 );\n").arg(Ipm).arg(Qtokens.join("")); - else s += QStringLiteral("%1 <+ ddt( %2 );\n").arg(Ipm).arg(Qtokens.join("")); + else s += QStringLiteral("%1 <+ ddt( %2 );\n").arg(Ipm).arg(Qtokens.join("")); } } } else { @@ -252,13 +252,13 @@ void EqnDefined::subsCurrents(QStringList &tokens) // ------------------------------------------------------- void EqnDefined::createSymbol() -{ +{ QFont Font(QucsSettings.font); // default application font // symbol text is smaller (10 pt default) //Font.setPointSizeF(Font.pointSizeF()/1.2); // symbol text size proportional to default font size Font.setPointSize(10); // symbol text size fixed at 10 pt // get the small font size; use the screen-compatible metric - QFontMetrics smallmetrics(Font, 0); + QFontMetrics smallmetrics(Font, 0); int fHeight = smallmetrics.lineSpacing(); QString tmp; int i, PortDistance = 60; @@ -277,9 +277,9 @@ void EqnDefined::createSymbol() if (NumProps < Num) { for(i = NumProps; i < Num; i++) { Props.append(new Property("I"+QString::number(i+1), "0", false, - QObject::tr("current equation") + " " +QString::number(i+1))); + QObject::tr("current equation") + " " +QString::number(i+1))); Props.append(new Property("Q"+QString::number(i+1), "0", false, - QObject::tr("charge equation") + " " +QString::number(i+1))); + QObject::tr("charge equation") + " " +QString::number(i+1))); } } else { for(i = Num; i < NumProps; i++) { diff --git a/qucs/components/eqndefined.h b/qucs/components/eqndefined.h index b70216e5..6470f72f 100644 --- a/qucs/components/eqndefined.h +++ b/qucs/components/eqndefined.h @@ -36,7 +36,7 @@ class EqnDefined : public MultiViewComponent { protected: QString netlist(); void createSymbol(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString va_code(); }; diff --git a/qucs/components/equation.cpp b/qucs/components/equation.cpp index b1567333..25bd4daf 100644 --- a/qucs/components/equation.cpp +++ b/qucs/components/equation.cpp @@ -39,7 +39,7 @@ Equation::Equation() Lines.append(new qucs::Line(-xb, -yb, -xb, yb,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-xb, yb, xb+3,yb,QPen(Qt::darkBlue,2))); Texts.append(new Text(-xb+4, -yb-3, QObject::tr("Equation"), - QColor(0,0,0), QFontInfo(f).pixelSize())); + QColor(0,0,0), QFontInfo(f).pixelSize())); x1 = -xb-3; y1 = -yb-5; x2 = xb+9; y2 = yb+3; @@ -51,7 +51,7 @@ Equation::Equation() Props.append(new Property("y", "1", true)); Props.append(new Property("Export", "yes", false, - QObject::tr("put result into dataset")+" [yes, no]")); + QObject::tr("put result into dataset")+" [yes, no]")); } Equation::~Equation() @@ -120,10 +120,13 @@ QString Equation::getVAExpressions() * \brief Equation::getExpression Extract equations that don't contain simulation variables * (voltages/cureents) in .PARAM section of spice netlist * \param isXyce True if Xyce is used. + * \param isCdl True if CDL is used. * \return .PARAM section of spice netlist as a single string. */ -QString Equation::getExpression(bool isXyce) +QString Equation::getExpression(bool isXyce, bool isCdl /* = false */) { + Q_UNUSED(isCdl); + if (isActive != COMP_IS_ACTIVE) return QString(); QStringList ng_vars,ngsims; diff --git a/qucs/components/equation.h b/qucs/components/equation.h index 091e46cc..e8ff266d 100644 --- a/qucs/components/equation.h +++ b/qucs/components/equation.h @@ -28,7 +28,7 @@ class Equation : public Component { ~Equation(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString getExpression(bool isXyce); + QString getExpression(bool isXyce, bool isCdl = false); QString getEquations(QString sim, QStringList &dep_vars); QString getVAvariables(); QString getVAExpressions(); diff --git a/qucs/components/ground.cpp b/qucs/components/ground.cpp index 9d3c0612..58a0c667 100644 --- a/qucs/components/ground.cpp +++ b/qucs/components/ground.cpp @@ -66,7 +66,9 @@ QString Ground::netlist() return QString(); } -QString Ground::spice_netlist(bool) +QString Ground::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + return QString(); } diff --git a/qucs/components/ground.h b/qucs/components/ground.h index f6e1cf96..fc46a9b1 100644 --- a/qucs/components/ground.h +++ b/qucs/components/ground.h @@ -30,7 +30,7 @@ class Ground : public Component { protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/gyrator.cpp b/qucs/components/gyrator.cpp index c3625605..0a4125c7 100644 --- a/qucs/components/gyrator.cpp +++ b/qucs/components/gyrator.cpp @@ -79,8 +79,10 @@ Element* Gyrator::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString Gyrator::spice_netlist(bool) +QString Gyrator::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s; QString R = spicecompat::normalize_value(Props.at(0)->Value); QString n1 = Ports.at(0)->Connection->Name; diff --git a/qucs/components/gyrator.h b/qucs/components/gyrator.h index 6e395846..8e0c802c 100644 --- a/qucs/components/gyrator.h +++ b/qucs/components/gyrator.h @@ -28,7 +28,7 @@ class Gyrator : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/hb_sim.cpp b/qucs/components/hb_sim.cpp index f95abd55..d8b4c9ae 100644 --- a/qucs/components/hb_sim.cpp +++ b/qucs/components/hb_sim.cpp @@ -63,10 +63,10 @@ Element* HB_Sim::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString HB_Sim::spice_netlist(bool isXyce) +QString HB_Sim::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s=""; - if (isXyce) { // Only in Xyce + if (dialect == spicecompat::SPICEXyce) { // Only in Xyce s += QStringLiteral(".options hbint numfreq=%1 STARTUPPERIODS=2\n").arg(Props.at(1)->Value); QStringList freqs = Props.at(0)->Value.split(QRegularExpression("\\s+(?=[0-9])")); // split frequencyes list by space before digit diff --git a/qucs/components/hb_sim.h b/qucs/components/hb_sim.h index 6508abba..8108f920 100644 --- a/qucs/components/hb_sim.h +++ b/qucs/components/hb_sim.h @@ -28,7 +28,7 @@ class HB_Sim : public qucs::component::SimulationComponent { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/iexp.cpp b/qucs/components/iexp.cpp index 90281e64..b5a868ed 100644 --- a/qucs/components/iexp.cpp +++ b/qucs/components/iexp.cpp @@ -85,19 +85,21 @@ Element* iExp::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString iExp::spice_netlist(bool) +QString iExp::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); - s += " " + spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); - s += " " + spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); + s += " " + spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); + s += " " + spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); - QString U1= spicecompat::normalize_value(Props.at(0)->Value); - QString U2 = spicecompat::normalize_value(Props.at(1)->Value); - QString T1 = spicecompat::normalize_value(Props.at(2)->Value); - QString T2 = spicecompat::normalize_value(Props.at(3)->Value); - QString Tr = spicecompat::normalize_value(Props.at(4)->Value); - QString Tf = spicecompat::normalize_value(Props.at(5)->Value); + QString U1 = spicecompat::normalize_value(Props.at(0)->Value); + QString U2 = spicecompat::normalize_value(Props.at(1)->Value); + QString T1 = spicecompat::normalize_value(Props.at(2)->Value); + QString T2 = spicecompat::normalize_value(Props.at(3)->Value); + QString Tr = spicecompat::normalize_value(Props.at(4)->Value); + QString Tf = spicecompat::normalize_value(Props.at(5)->Value); s += QStringLiteral(" DC 0 EXP(%1 %2 %3 %4 %5 %6) AC 0\n").arg(U1).arg(U2).arg(T1).arg(Tr).arg(T2).arg(Tf); return s; diff --git a/qucs/components/iexp.h b/qucs/components/iexp.h index 474a9778..a79e84c5 100644 --- a/qucs/components/iexp.h +++ b/qucs/components/iexp.h @@ -31,7 +31,7 @@ class iExp : public Component { ~iExp(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/ifile.cpp b/qucs/components/ifile.cpp index cce85f49..91fdeeea 100644 --- a/qucs/components/ifile.cpp +++ b/qucs/components/ifile.cpp @@ -109,9 +109,10 @@ QString iFile::netlist() return s + "\n"; } -QString iFile::spice_netlist(bool isXyce) +QString iFile::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString s = SpiceModel + Name; QString modname = "mod_" + Model + Name; QString p1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); diff --git a/qucs/components/ifile.h b/qucs/components/ifile.h index 1352e010..567a4053 100644 --- a/qucs/components/ifile.h +++ b/qucs/components/ifile.h @@ -32,7 +32,7 @@ class iFile : public Component { protected: QString netlist(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/indq.cpp b/qucs/components/indq.cpp index 89cabdb3..e426ff29 100644 --- a/qucs/components/indq.cpp +++ b/qucs/components/indq.cpp @@ -92,9 +92,10 @@ Element* IndQ::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString IndQ::spice_netlist(bool isXyce) +QString IndQ::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString s; QString pin1 = Ports.at(0)->Connection->Name; pin1 = spicecompat::normalize_node_name(pin1); @@ -126,3 +127,4 @@ QString IndQ::spice_netlist(bool isXyce) return s; } + diff --git a/qucs/components/indq.h b/qucs/components/indq.h index 0b4de80f..06c872ef 100644 --- a/qucs/components/indq.h +++ b/qucs/components/indq.h @@ -32,8 +32,9 @@ class IndQ : public Component { ~IndQ(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/inductor.cpp b/qucs/components/inductor.cpp index a41e4e37..e3db8f64 100644 --- a/qucs/components/inductor.cpp +++ b/qucs/components/inductor.cpp @@ -58,7 +58,7 @@ Component* Inductor::newOne() } -QString Inductor::spice_netlist(bool) +QString Inductor::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); @@ -69,7 +69,7 @@ QString Inductor::spice_netlist(bool) s += " "+spicecompat::normalize_value(Props.at(0)->Value) + " "; QString val = Props.at(1)->Value; // add inial voltage if presents val = val.remove(' ').toUpper(); - if (!val.isEmpty()) { + if (!val.isEmpty() && dialect != spicecompat::CDL) { s += " IC=" + val; } s += '\n'; @@ -77,6 +77,11 @@ QString Inductor::spice_netlist(bool) return s; } +QString Inductor::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + QString Inductor::va_code() { QString val = vacompat::normalize_value(Props.at(0)->Value); diff --git a/qucs/components/inductor.h b/qucs/components/inductor.h index c17c993e..5b72db88 100644 --- a/qucs/components/inductor.h +++ b/qucs/components/inductor.h @@ -27,10 +27,12 @@ class Inductor : public Component { ~Inductor(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: QString va_code(); void getExtraVANodes(QStringList& nodes); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/components/iprobe.cpp b/qucs/components/iprobe.cpp index 16287543..17b9864e 100644 --- a/qucs/components/iprobe.cpp +++ b/qucs/components/iprobe.cpp @@ -79,8 +79,10 @@ Element* iProbe::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString iProbe::spice_netlist(bool) +QString iProbe::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = QStringLiteral("V%1 %2 %3 DC 0\n").arg(Name).arg(Ports.at(0)->Connection->Name) .arg(Ports.at(1)->Connection->Name); return s; diff --git a/qucs/components/iprobe.h b/qucs/components/iprobe.h index ce49b068..5ebfd45f 100644 --- a/qucs/components/iprobe.h +++ b/qucs/components/iprobe.h @@ -27,10 +27,11 @@ class iProbe : public Component { ~iProbe(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString getExpression(bool) { return "";} + QString getExpression(bool, bool) { return "";} QString getProbeVariable(bool isXyce = false); + protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/ipulse.cpp b/qucs/components/ipulse.cpp index e553e922..2564096d 100644 --- a/qucs/components/ipulse.cpp +++ b/qucs/components/ipulse.cpp @@ -89,8 +89,10 @@ Element* iPulse::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString iPulse::spice_netlist(bool) +QString iPulse::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); s += " " + spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); @@ -101,7 +103,7 @@ QString iPulse::spice_netlist(bool) QString VL = spicecompat::normalize_value(Props.at(0)->Value); // VL QString VH = spicecompat::normalize_value(Props.at(1)->Value); // VH - QString Tr = spicecompat::normalize_value(Props.at(4)->Value); // Tr + QString Tr = spicecompat::normalize_value(Props.at(4)->Value); // Tr QString Tf = spicecompat::normalize_value(Props.at(5)->Value); // Tf misc::str2num(Props.at(2)->Value,T1,unit,fac); // Td diff --git a/qucs/components/ipulse.h b/qucs/components/ipulse.h index 443208e1..0b5eaa06 100644 --- a/qucs/components/ipulse.h +++ b/qucs/components/ipulse.h @@ -30,7 +30,7 @@ class iPulse : public Component { ~iPulse(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/irect.cpp b/qucs/components/irect.cpp index 4166224b..fc9d4301 100644 --- a/qucs/components/irect.cpp +++ b/qucs/components/irect.cpp @@ -80,15 +80,17 @@ iRect::~iRect() { } -QString iRect::spice_netlist(bool) +QString iRect::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam; // node names - } + } double T, TL, TH, Trval, Tfval, fac; QString unit; @@ -101,11 +103,11 @@ QString iRect::spice_netlist(bool) TH *= fac; // TH = pw misc::str2num(Props.at(2)->Value,TL,unit,fac); T = TL*fac+TH; - misc::str2num(Props.at(3)->Value,Trval,unit,fac); - T = Trval*fac+T; - misc::str2num(Props.at(4)->Value,Tfval,unit,fac); - T = Tfval*fac+T; - + misc::str2num(Props.at(3)->Value,Trval,unit,fac); + T = Trval*fac+T; + misc::str2num(Props.at(4)->Value,Tfval,unit,fac); + T = Tfval*fac+T; + s += QStringLiteral(" DC 0 PULSE( 0 -%1 %2 %3 %4 %5 %6) AC 0\n").arg(U).arg(Td).arg(Tr).arg(Tf).arg(TH).arg(T); return s; diff --git a/qucs/components/irect.h b/qucs/components/irect.h index bbce4c04..1f74621c 100644 --- a/qucs/components/irect.h +++ b/qucs/components/irect.h @@ -27,7 +27,7 @@ class iRect : public Component { ~iRect(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/jfet.cpp b/qucs/components/jfet.cpp index a49ac7e4..5e1e17e0 100644 --- a/qucs/components/jfet.cpp +++ b/qucs/components/jfet.cpp @@ -94,7 +94,7 @@ Component* JFET::newOne() return p; } -QString JFET::spice_netlist(bool isXyce) +QString JFET::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); QList pin_seq; @@ -108,7 +108,7 @@ QString JFET::spice_netlist(bool isXyce) QStringList spice_incompat,spice_tr; - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { spice_incompat<<"Type"<<"Area"<<"Temp"<<"Ffe"<<"N" <<"Isr"<<"Nr"<<"M"<<"Xti"<<"Betatce"<<"Vt0tc"<<"UseGLobTemp"; // spice-incompatible parameters @@ -131,11 +131,19 @@ QString JFET::spice_netlist(bool isXyce) .arg(getProperty("Temp")->Value); } - s += QStringLiteral(".MODEL JMOD_%1 %2JF (%3)\n").arg(Name).arg(jfet_type).arg(par_str); + if (dialect != spicecompat::CDL) + { + s += QStringLiteral(".MODEL JMOD_%1 %2JF (%3)\n").arg(Name).arg(jfet_type).arg(par_str); + } return s; } +QString JFET::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + // ------------------------------------------------------- Element* JFET::info(QString& Name, char* &BitmapFile, bool getNewOne) { diff --git a/qucs/components/jfet.h b/qucs/components/jfet.h index 04917eda..a0ff03df 100644 --- a/qucs/components/jfet.h +++ b/qucs/components/jfet.h @@ -31,7 +31,8 @@ class JFET : public MultiViewComponent { protected: void createSymbol(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/components/jkff_SR.cpp b/qucs/components/jkff_SR.cpp index ebc71ee7..7d9f40d8 100644 --- a/qucs/components/jkff_SR.cpp +++ b/qucs/components/jkff_SR.cpp @@ -184,9 +184,9 @@ QString jkff_SR::verilogCode( int ) return l; } -QString jkff_SR::spice_netlist(bool isXyce) +QString jkff_SR::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - if (isXyce) return QString(); + if (dialect == spicecompat::SPICEXyce) return QString(); QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/jkff_SR.h b/qucs/components/jkff_SR.h index 8a06993b..dd7dd9b5 100644 --- a/qucs/components/jkff_SR.h +++ b/qucs/components/jkff_SR.h @@ -24,7 +24,7 @@ class jkff_SR : public Component void createSymbol(); QString vhdlCode(int); QString verilogCode(int); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif /* jkff_SR_H */ diff --git a/qucs/components/libcomp.cpp b/qucs/components/libcomp.cpp index eab40cd5..12b2fc07 100644 --- a/qucs/components/libcomp.cpp +++ b/qucs/components/libcomp.cpp @@ -361,8 +361,10 @@ QString LibComp::vhdlCode(int) return s; } -QString LibComp::spice_netlist(bool) +QString LibComp::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = SpiceModel + Name + " 0 "; // connect ground of subckt to circuit ground for (Port *p1 : Ports) s += " "+p1->Connection->Name; // node names @@ -378,6 +380,11 @@ QString LibComp::spice_netlist(bool) return s; } +QString LibComp::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + QStringList LibComp::getAttachedIFS() { QString content; diff --git a/qucs/components/libcomp.h b/qucs/components/libcomp.h index 6237fc3c..d14cd746 100644 --- a/qucs/components/libcomp.h +++ b/qucs/components/libcomp.h @@ -37,7 +37,8 @@ class LibComp : public MultiViewComponent { protected: QString netlist(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); QString vhdlCode(int); QString verilogCode(int); void createSymbol(); diff --git a/qucs/components/logical_buf.cpp b/qucs/components/logical_buf.cpp index 849ebd15..f5c4790e 100644 --- a/qucs/components/logical_buf.cpp +++ b/qucs/components/logical_buf.cpp @@ -135,9 +135,9 @@ Element* Logical_Buf::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString Logical_Buf::spice_netlist(bool isXyce) +QString Logical_Buf::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - if (isXyce) return QString(); + if (dialect == spicecompat::SPICEXyce) return QString(); QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/logical_buf.h b/qucs/components/logical_buf.h index 28d7dee6..a1eae2f2 100644 --- a/qucs/components/logical_buf.h +++ b/qucs/components/logical_buf.h @@ -31,7 +31,7 @@ class Logical_Buf : public MultiViewComponent { protected: QString vhdlCode(int); QString verilogCode(int); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); void createSymbol(); }; diff --git a/qucs/components/logical_inv.cpp b/qucs/components/logical_inv.cpp index 5489b34a..b4036e55 100644 --- a/qucs/components/logical_inv.cpp +++ b/qucs/components/logical_inv.cpp @@ -152,9 +152,9 @@ Element* Logical_Inv::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString Logical_Inv::spice_netlist(bool isXyce) +QString Logical_Inv::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - if (isXyce) return QString(); + if (dialect == spicecompat::SPICEXyce) return QString(); QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/logical_inv.h b/qucs/components/logical_inv.h index 43f4d440..b358e3b3 100644 --- a/qucs/components/logical_inv.h +++ b/qucs/components/logical_inv.h @@ -29,7 +29,7 @@ class Logical_Inv : public MultiViewComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString vhdlCode(int); QString verilogCode(int); void createSymbol(); diff --git a/qucs/components/mosfet.cpp b/qucs/components/mosfet.cpp index 8668ba32..6fe1179e 100644 --- a/qucs/components/mosfet.cpp +++ b/qucs/components/mosfet.cpp @@ -140,7 +140,7 @@ QString MOSFET::netlist() return s + '\n'; } -QString MOSFET::spice_netlist(bool isXyce) +QString MOSFET::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); QList pin_seq; @@ -156,7 +156,7 @@ QString MOSFET::spice_netlist(bool isXyce) spice_incompat<<"Type"<<"Temp"<<"L"<<"W"<<"Ad"<<"As"<<"Pd"<<"Ps" <<"Rg"<<"N"<<"Tt"<<"Nrd"<<"Nrs"<<"Ffe"<<"UseGlobTemp"; // spice-incompatible parameters - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { spice_tr<<"Vt0"<<"VtO"; // parameters that need conversion of names } else { spice_tr.clear(); @@ -199,7 +199,17 @@ QString MOSFET::spice_netlist(bool isXyce) s += QStringLiteral(" MMOD_%1 L=%2 W=%3 Ad=%4 As=%5 Pd=%6 Ps=%7 Temp=%8\n") .arg(Name).arg(l).arg(w).arg(ad).arg(as).arg(pd).arg(ps).arg(getProperty("Temp")->Value); } - s += QStringLiteral(".MODEL MMOD_%1 %2MOS (%3)\n").arg(Name).arg(mosfet_type).arg(par_str); + + if (dialect != spicecompat::CDL) + { + s += QStringLiteral(".MODEL MMOD_%1 %2MOS (%3)\n").arg(Name).arg(mosfet_type).arg(par_str); + } return s; } + +QString MOSFET::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + diff --git a/qucs/components/mosfet.h b/qucs/components/mosfet.h index 77fb721c..94a95e8e 100644 --- a/qucs/components/mosfet.h +++ b/qucs/components/mosfet.h @@ -33,7 +33,8 @@ class MOSFET : public Basic_MOSFET { protected: void createSymbol(); QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/components/mosfet_sub.cpp b/qucs/components/mosfet_sub.cpp index 841638c8..fc9584fa 100644 --- a/qucs/components/mosfet_sub.cpp +++ b/qucs/components/mosfet_sub.cpp @@ -150,7 +150,7 @@ Component* MOSFET_sub::newOne() return p; } -QString MOSFET_sub::spice_netlist(bool isXyce) +QString MOSFET_sub::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); QList pin_seq; @@ -166,7 +166,7 @@ QString MOSFET_sub::spice_netlist(bool isXyce) spice_incompat<<"Type"<<"Temp"<<"L"<<"W"<<"Ad"<<"As"<<"Pd"<<"Ps" <<"Rg"<<"N"<<"Tt"<<"Nrd"<<"Nrs"<<"Ffe"<<"UseGlobTemp"; // spice-incompatible parameters - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { spice_tr<<"Vt0"<<"VtO"; // parameters that need conversion of names } else { spice_tr.clear(); @@ -208,11 +208,20 @@ QString MOSFET_sub::spice_netlist(bool isXyce) s += QStringLiteral(" MMOD_%1 L=%2 W=%3 Ad=%4 As=%5 Pd=%6 Ps=%7 Temp=%8\n") .arg(Name).arg(l).arg(w).arg(ad).arg(as).arg(pd).arg(ps).arg(getProperty("Temp")->Value); } - s += QStringLiteral(".MODEL MMOD_%1 %2MOS (%3)\n").arg(Name).arg(mosfet_type).arg(par_str); + + if (dialect != spicecompat::CDL) + { + s += QStringLiteral(".MODEL MMOD_%1 %2MOS (%3)\n").arg(Name).arg(mosfet_type).arg(par_str); + } return s; } +QString MOSFET_sub::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + // ------------------------------------------------------- Element* MOSFET_sub::info(QString& Name, char* &BitmapFile, bool getNewOne) { diff --git a/qucs/components/mosfet_sub.h b/qucs/components/mosfet_sub.h index f5462f9d..8050e5fc 100644 --- a/qucs/components/mosfet_sub.h +++ b/qucs/components/mosfet_sub.h @@ -38,7 +38,8 @@ class MOSFET_sub : public Basic_MOSFET { protected: void createSymbol(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/components/mutual.cpp b/qucs/components/mutual.cpp index 1b6edeb5..1a5c3ca7 100644 --- a/qucs/components/mutual.cpp +++ b/qucs/components/mutual.cpp @@ -59,11 +59,11 @@ Mutual::Mutual() SpiceModel = "K"; Props.append(new Property("L1", "1 mH", false, - QObject::tr("inductance of coil 1"))); + QObject::tr("inductance of coil 1"))); Props.append(new Property("L2", "1 mH", false, - QObject::tr("inductance of coil 2"))); + QObject::tr("inductance of coil 2"))); Props.append(new Property("k", "0.9", false, - QObject::tr("coupling factor between coil 1 and 2"))); + QObject::tr("coupling factor between coil 1 and 2"))); } Mutual::~Mutual() @@ -84,9 +84,10 @@ Element* Mutual::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString Mutual::spice_netlist(bool isXyce) +QString Mutual::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString l1 = "L" + Name + "_L1"; QString l2 = "L" + Name + "_L2"; QString k1 = "K" + Name; diff --git a/qucs/components/mutual.h b/qucs/components/mutual.h index 6b7a00e4..a9abb930 100644 --- a/qucs/components/mutual.h +++ b/qucs/components/mutual.h @@ -27,8 +27,9 @@ class Mutual : public Component { ~Mutual(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/mutual2.cpp b/qucs/components/mutual2.cpp index d18b20f2..a3adc7ac 100644 --- a/qucs/components/mutual2.cpp +++ b/qucs/components/mutual2.cpp @@ -114,10 +114,10 @@ Element* Mutual2::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString Mutual2::spice_netlist(bool isXyce) +QString Mutual2::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString l1 = "L" + Name + "_L1"; QString l2 = "L" + Name + "_L2"; QString l3 = "L" + Name + "_L3"; @@ -147,4 +147,3 @@ QString Mutual2::spice_netlist(bool isXyce) .arg(spicecompat::normalize_value(getProperty("k23")->Value)); return s; } - diff --git a/qucs/components/mutual2.h b/qucs/components/mutual2.h index b09da1e3..46c67392 100644 --- a/qucs/components/mutual2.h +++ b/qucs/components/mutual2.h @@ -27,8 +27,9 @@ class Mutual2 : public Component { ~Mutual2(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/mutualx.cpp b/qucs/components/mutualx.cpp index 3b569559..8ced1850 100644 --- a/qucs/components/mutualx.cpp +++ b/qucs/components/mutualx.cpp @@ -169,10 +169,10 @@ void MutualX::createSymbol() } else { // add new coils for(int i = 0; i < dCoils; i++) { // add new properties for coils - Props.insert(oldCoils+1, new Property("L"+QString::number(Num-i), - "1 mH", - false, - QObject::tr("inductance of coil") + " " + QString::number(Num-i))); + Props.insert(oldCoils+1, new Property("L"+QString::number(Num-i), + "1 mH", + false, + QObject::tr("inductance of coil") + " " + QString::number(Num-i))); } for(int i = 1,state=1; i < Num; i++) @@ -196,7 +196,7 @@ void MutualX::createSymbol() p1++; } // adjust coupling coeffs names - for(int i = 1,state=1; i < Num; i++) + for(int i = 1,state=1; i < Num; i++) for(int j = i+1; j <= Num; j++,state++) { Props.at(Num+state)->Name = "k" + QString::number(i) + QString::number(j); Props.at(Num+state)->Description = @@ -229,9 +229,10 @@ void MutualX::createSymbol() } } -QString MutualX::spice_netlist(bool isXyce) +QString MutualX::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + int coils = getProperty("coils")->Value.toInt(); QString s; @@ -257,6 +258,7 @@ QString MutualX::spice_netlist(bool isXyce) s += QStringLiteral("%1 %2 %3 %4\n").arg(kij).arg(li).arg(lj).arg(val_k); } } - return s; + return s; } + diff --git a/qucs/components/mutualx.h b/qucs/components/mutualx.h index 4ad877ce..0e8a1fa7 100644 --- a/qucs/components/mutualx.h +++ b/qucs/components/mutualx.h @@ -35,7 +35,7 @@ class MutualX : public MultiViewComponent { protected: void createSymbol(); QString netlist(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/opamp.cpp b/qucs/components/opamp.cpp index 4a58029b..f3e94f38 100644 --- a/qucs/components/opamp.cpp +++ b/qucs/components/opamp.cpp @@ -74,7 +74,7 @@ Element* OpAmp::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString OpAmp::spice_netlist(bool isXyce) +QString OpAmp::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString in_m = Ports.at(0)->Connection->Name; if (in_m=="gnd") in_m="0"; @@ -89,7 +89,7 @@ QString OpAmp::spice_netlist(bool isXyce) QString s; s = QStringLiteral("B_%1 %2 0 V = ").arg(Name).arg(out); - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { s += QStringLiteral("%1*V(%2,%3)*stp(%4-%1*V(%2,%3))*stp(%1*V(%2,%3)-(-%4))" "+%4*stp(%1*V(%2,%3)-%4)" "+(-%4)*stp((-%4)-%1*V(%2,%3))\n").arg(G).arg(in_p).arg(in_m).arg(Vmax); diff --git a/qucs/components/opamp.h b/qucs/components/opamp.h index 605bcd11..4eda0911 100644 --- a/qucs/components/opamp.h +++ b/qucs/components/opamp.h @@ -28,7 +28,7 @@ class OpAmp : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/param_sweep.cpp b/qucs/components/param_sweep.cpp index b6010da8..a6ef3e0e 100644 --- a/qucs/components/param_sweep.cpp +++ b/qucs/components/param_sweep.cpp @@ -193,14 +193,14 @@ QString Param_Sweep::getCounterVar() return s; } -QString Param_Sweep::spice_netlist(bool isXyce) +QString Param_Sweep::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { double start,stop,step,fac,points; QString unit; QString s; - if(getProperty("Type")->Value=="list") { // List STEP variance Xyce-only - if(isXyce) { + if (getProperty("Type")->Value=="list") { // List STEP variance Xyce-only + if(dialect == spicecompat::SPICEXyce) { QString var = getProperty("Param")->Value; QString list = getProperty("Values")->Value; list.remove('[').remove(']'); @@ -209,7 +209,7 @@ QString Param_Sweep::spice_netlist(bool isXyce) return s.toLower(); } } - if(getProperty("Type")->Value!="list" && getProperty("Type")->Value!="const"){ + if (getProperty("Type")->Value!="list" && getProperty("Type")->Value!="const"){ misc::str2num(getProperty("Start")->Value,start,unit,fac); start *= fac; misc::str2num(getProperty("Stop")->Value,stop,unit,fac); @@ -222,8 +222,8 @@ QString Param_Sweep::spice_netlist(bool isXyce) if (Props.at(0)->Value.toLower().startsWith("dc")) { QString src = getProperty("Param")->Value; s = QStringLiteral("DC %1 %2 %3 %4\n").arg(src).arg(start).arg(stop).arg(step); - if (isXyce) s.prepend('.'); - } else if (isXyce) { + if (dialect == spicecompat::SPICEXyce) s.prepend('.'); + } else if (dialect == spicecompat::SPICEXyce) { QString var = getProperty("Param")->Value; s = QStringLiteral(".STEP %1 %2 %3 %4\n").arg(var).arg(start).arg(stop).arg(step); } else { diff --git a/qucs/components/param_sweep.h b/qucs/components/param_sweep.h index 608964e0..ed306605 100644 --- a/qucs/components/param_sweep.h +++ b/qucs/components/param_sweep.h @@ -34,7 +34,7 @@ class Param_Sweep : public qucs::component::SimulationComponent { QString getCounterVar(); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString param_split_str=";"; }; diff --git a/qucs/components/potentiometer.cpp b/qucs/components/potentiometer.cpp index 7c2a5aa5..365d88fc 100644 --- a/qucs/components/potentiometer.cpp +++ b/qucs/components/potentiometer.cpp @@ -111,9 +111,10 @@ void potentiometer::createSymbol() x2 = 40; y2 = 15; } -QString potentiometer::spice_netlist(bool isXyce) +QString potentiometer::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString s; QString R = spicecompat::normalize_value(getProperty("R_pot")->Value); QString rot = spicecompat::normalize_value(getProperty("Rotation")->Value); diff --git a/qucs/components/potentiometer.h b/qucs/components/potentiometer.h index a289ac90..2f7f97ea 100644 --- a/qucs/components/potentiometer.h +++ b/qucs/components/potentiometer.h @@ -22,7 +22,7 @@ class potentiometer : public Component static Element* info(QString&, char* &, bool getNewOne=false); protected: void createSymbol(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif /* potentiometer_H */ diff --git a/qucs/components/relais.cpp b/qucs/components/relais.cpp index 98d3cde9..a59d2528 100644 --- a/qucs/components/relais.cpp +++ b/qucs/components/relais.cpp @@ -85,7 +85,7 @@ Component* Relais::newOne() return new Relais(); } -QString Relais::spice_netlist(bool isXyce) +QString Relais::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = Name; QString unit; @@ -114,7 +114,7 @@ QString Relais::spice_netlist(bool isXyce) QString Ron = spicecompat::normalize_value(Props.at(2)->Value); QString Roff = spicecompat::normalize_value(Props.at(3)->Value); - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { s += QStringLiteral(".MODEL %1 vswitch von=%2 voff=%3 ron=%4 roff=%5 \n").arg(model).arg(Vt).arg(Vt-Vh).arg(Ron).arg(Roff); } else { s += QStringLiteral(".MODEL %1 sw vt=%2 vh=%3 ron=%4 roff=%5 \n").arg(model).arg(Vt).arg(Vh).arg(Ron).arg(Roff); diff --git a/qucs/components/relais.h b/qucs/components/relais.h index 81645bcb..e07f26cf 100644 --- a/qucs/components/relais.h +++ b/qucs/components/relais.h @@ -27,7 +27,7 @@ class Relais : public Component { ~Relais(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/resistor.cpp b/qucs/components/resistor.cpp index fa477cb3..dc698b0f 100644 --- a/qucs/components/resistor.cpp +++ b/qucs/components/resistor.cpp @@ -53,7 +53,7 @@ Component* Resistor::newOne() return new Resistor(Props.back()->Value != "US"); } -QString Resistor::spice_netlist(bool ) +QString Resistor::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); @@ -66,12 +66,15 @@ QString Resistor::spice_netlist(bool ) s += QStringLiteral(" %1").arg(spicecompat::normalize_value(Props.at(0)->Value)); - if (!Tc1.isEmpty()) { - s += " tc1=" + Tc1; - } + if (dialect != spicecompat::CDL) + { + if (!Tc1.isEmpty()) { + s += " tc1=" + Tc1; + } - if (!Tc2.isEmpty()) { - s += " tc2=" + Tc2; + if (!Tc2.isEmpty()) { + s += " tc2=" + Tc2; + } } s += QStringLiteral(" \n"); @@ -79,6 +82,11 @@ QString Resistor::spice_netlist(bool ) return s; } +QString Resistor::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + QString Resistor::va_code() { QString val = vacompat::normalize_value(Props.at(0)->Value); @@ -88,12 +96,12 @@ QString Resistor::va_code() QString s = ""; QString Vpm = vacompat::normalize_voltage(plus,minus); QString Ipm = vacompat::normalize_current(plus,minus,true); - + if (plus=="gnd") s += QStringLiteral("%1 <+ -(%2/( %3 ));\n").arg(Ipm).arg(Vpm).arg(val); else s+= QStringLiteral("%1 <+ %2/( %3 );\n").arg(Ipm).arg(Vpm).arg(val); s += QStringLiteral("%1 <+ white_noise( 4.0*`P_K*( %2 + 273.15) / ( %3 ), \"thermal\" );\n") .arg(Ipm).arg(valTemp).arg(val); - + return s; } diff --git a/qucs/components/resistor.h b/qucs/components/resistor.h index 3a143ae7..fb86f78a 100644 --- a/qucs/components/resistor.h +++ b/qucs/components/resistor.h @@ -30,7 +30,8 @@ class Resistor : public MultiViewComponent { static Element* info_us(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); QString va_code(); void createSymbol(); }; diff --git a/qucs/components/rlcg.cpp b/qucs/components/rlcg.cpp index ded850ea..d12acf68 100644 --- a/qucs/components/rlcg.cpp +++ b/qucs/components/rlcg.cpp @@ -93,9 +93,10 @@ Element* RLCG::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString RLCG::spice_netlist(bool isXyce) +QString RLCG::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString s; QString in = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); QString out = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); @@ -106,7 +107,9 @@ QString RLCG::spice_netlist(bool isXyce) QString LEN = spicecompat::normalize_value(getProperty("Length")->Value); QString modname = "mod_" + Name; s += QStringLiteral("O%1 %2 0 %3 0 %4\n").arg(Name).arg(in).arg(out).arg(modname); + s += QStringLiteral(".MODEL %1 LTRA(R=%2 C=%3 L=%4 G=%5 LEN=%6)\n") - .arg(modname).arg(R).arg(C).arg(L).arg(G).arg(LEN); + .arg(modname).arg(R).arg(C).arg(L).arg(G).arg(LEN); return s; } + diff --git a/qucs/components/rlcg.h b/qucs/components/rlcg.h index 1ea76d06..5b5e201d 100644 --- a/qucs/components/rlcg.h +++ b/qucs/components/rlcg.h @@ -26,8 +26,9 @@ class RLCG : public Component { ~RLCG(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/source_ac.cpp b/qucs/components/source_ac.cpp index 913047da..66e674d7 100644 --- a/qucs/components/source_ac.cpp +++ b/qucs/components/source_ac.cpp @@ -159,9 +159,9 @@ QString Source_ac::xyce_netlist() return s; } -QString Source_ac::spice_netlist(bool isXyce) +QString Source_ac::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { return xyce_netlist(); } else { return ngspice_netlist(); diff --git a/qucs/components/source_ac.h b/qucs/components/source_ac.h index bde03b82..0dd75bad 100644 --- a/qucs/components/source_ac.h +++ b/qucs/components/source_ac.h @@ -30,7 +30,7 @@ class Source_ac : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString netlist(); }; diff --git a/qucs/components/sp_sim.cpp b/qucs/components/sp_sim.cpp index 0e340a6d..ab750ddb 100644 --- a/qucs/components/sp_sim.cpp +++ b/qucs/components/sp_sim.cpp @@ -206,9 +206,9 @@ QString SP_Sim::xyce_netlist() return s; } -QString SP_Sim::spice_netlist(bool isXyce) +QString SP_Sim::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { return xyce_netlist(); } else { return ngspice_netlist(); diff --git a/qucs/components/sp_sim.h b/qucs/components/sp_sim.h index 9a4ff12e..edc49aef 100644 --- a/qucs/components/sp_sim.h +++ b/qucs/components/sp_sim.h @@ -36,7 +36,7 @@ class SP_Sim : public qucs::component::SimulationComponent { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); void recreate(Schematic*); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QStringList getExtraVariables(); }; diff --git a/qucs/components/sparamfile.cpp b/qucs/components/sparamfile.cpp index ba92265e..e242896e 100644 --- a/qucs/components/sparamfile.cpp +++ b/qucs/components/sparamfile.cpp @@ -196,10 +196,10 @@ void SParamFile::createSymbol() ty = y1 - 2*metrics.lineSpacing() - 4; } -QString SParamFile::spice_netlist(bool isXyce) +QString SParamFile::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { int Np = getProperty("Ports")->Value.toInt(); s = "YLIN YLIN_" + Name; QString s_mod = "YLIN_" + Name + "_model"; diff --git a/qucs/components/sparamfile.h b/qucs/components/sparamfile.h index 0871535b..59f29af3 100644 --- a/qucs/components/sparamfile.h +++ b/qucs/components/sparamfile.h @@ -35,7 +35,7 @@ class SParamFile : public MultiViewComponent { protected: QString netlist(); void createSymbol(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/spicefile.cpp b/qucs/components/spicefile.cpp index ef84d255..e5998d7f 100644 --- a/qucs/components/spicefile.cpp +++ b/qucs/components/spicefile.cpp @@ -479,8 +479,10 @@ void SpiceFile::slotExited() } } -QString SpiceFile::spice_netlist(bool) +QString SpiceFile::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QStringList ports_lst = Props.at(1)->Value.split(","); for (auto & it : ports_lst) { if (it.startsWith("_net")) it.remove(0,4); @@ -506,3 +508,8 @@ QString SpiceFile::spice_netlist(bool) s += " " + spicecompat::getSubcktName(getSubcircuitFile()) + "\n"; return s; } + +QString SpiceFile::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/components/spicefile.h b/qucs/components/spicefile.h index a117719b..13c881a8 100644 --- a/qucs/components/spicefile.h +++ b/qucs/components/spicefile.h @@ -53,7 +53,8 @@ class SpiceFile : public QObject, public MultiViewComponent { protected: QString netlist(); void createSymbol(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); private slots: void slotGetNetlist(); diff --git a/qucs/components/subcircuit.cpp b/qucs/components/subcircuit.cpp index 87bfa72e..23b7f761 100644 --- a/qucs/components/subcircuit.cpp +++ b/qucs/components/subcircuit.cpp @@ -219,7 +219,10 @@ QString Subcircuit::netlist() { return s + '\n'; } -QString Subcircuit::spice_netlist(bool) { +QString Subcircuit::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) +{ + Q_UNUSED(dialect); + QString s; QString f = misc::properFileName(Props.at(0)->Value); s += spicecompat::check_refdes(Name, SpiceModel); @@ -238,6 +241,11 @@ QString Subcircuit::spice_netlist(bool) { return s; } +QString Subcircuit::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + // ------------------------------------------------------- QString Subcircuit::vhdlCode(int) { QString f = misc::properFileName(Props.at(0)->Value); diff --git a/qucs/components/subcircuit.h b/qucs/components/subcircuit.h index 6c155962..e7541d91 100644 --- a/qucs/components/subcircuit.h +++ b/qucs/components/subcircuit.h @@ -32,7 +32,8 @@ class Subcircuit : public MultiViewComponent { protected: QString netlist(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); QString vhdlCode(int); QString verilogCode(int); void createSymbol(); diff --git a/qucs/components/subcirport.cpp b/qucs/components/subcirport.cpp index 400e4de8..ebc0139c 100644 --- a/qucs/components/subcirport.cpp +++ b/qucs/components/subcirport.cpp @@ -105,8 +105,10 @@ QString SubCirPort::netlist() } // ------------------------------------------------------- -QString SubCirPort::spice_netlist(bool) +QString SubCirPort::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + return QString(); } diff --git a/qucs/components/subcirport.h b/qucs/components/subcirport.h index 86e577b5..0798c289 100644 --- a/qucs/components/subcirport.h +++ b/qucs/components/subcirport.h @@ -30,7 +30,7 @@ class SubCirPort : public MultiViewComponent { protected: QString netlist(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString vhdlCode(int); QString verilogCode(int); void createSymbol(); diff --git a/qucs/components/switch.cpp b/qucs/components/switch.cpp index b14c083b..15bedd1d 100644 --- a/qucs/components/switch.cpp +++ b/qucs/components/switch.cpp @@ -84,8 +84,10 @@ QString Switch::netlist() return s + '\n'; } -QString Switch::spice_netlist(bool) +QString Switch::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); QString port1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); QString port2 = spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); diff --git a/qucs/components/switch.h b/qucs/components/switch.h index 322ad432..7800bb8e 100644 --- a/qucs/components/switch.h +++ b/qucs/components/switch.h @@ -29,7 +29,7 @@ class Switch : public MultiViewComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString netlist(); void createSymbol(); }; diff --git a/qucs/components/tff_SR.cpp b/qucs/components/tff_SR.cpp index 6b01852e..6c047c34 100644 --- a/qucs/components/tff_SR.cpp +++ b/qucs/components/tff_SR.cpp @@ -175,9 +175,9 @@ QString tff_SR::verilogCode( int ) return l; } -QString tff_SR::spice_netlist(bool isXyce) +QString tff_SR::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - if (isXyce) return QString(); + if (dialect == spicecompat::SPICEXyce) return QString(); QString s = SpiceModel + Name; QString tmp_model = "model_" + Name; diff --git a/qucs/components/tff_SR.h b/qucs/components/tff_SR.h index 2fc3a082..ead997e6 100644 --- a/qucs/components/tff_SR.h +++ b/qucs/components/tff_SR.h @@ -24,7 +24,7 @@ class tff_SR : public Component void createSymbol(); QString vhdlCode(int); QString verilogCode(int); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif /* tff_SR_H */ diff --git a/qucs/components/tr_sim.cpp b/qucs/components/tr_sim.cpp index 92135280..43d22f77 100644 --- a/qucs/components/tr_sim.cpp +++ b/qucs/components/tr_sim.cpp @@ -91,7 +91,7 @@ Element* TR_Sim::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString TR_Sim::spice_netlist(bool isXyce) +QString TR_Sim::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = SpiceModel; QString unit; @@ -109,11 +109,11 @@ QString TR_Sim::spice_netlist(bool isXyce) QString max_step = spicecompat::normalize_value(getProperty("MaxStep")->Value); if (max_step!="0") s+= max_step; - if (!isXyce) { // Xyce ignores this parameter + if (dialect != spicecompat::SPICEXyce) { // Xyce ignores this parameter if (Props.at(18)->Value == "no") s += " UIC"; } s += "\n"; - if (!isXyce) s.remove(0,1); + if (dialect != spicecompat::SPICEXyce) s.remove(0,1); return s.toLower(); } diff --git a/qucs/components/tr_sim.h b/qucs/components/tr_sim.h index 58ca5e66..70f2a0f1 100644 --- a/qucs/components/tr_sim.h +++ b/qucs/components/tr_sim.h @@ -27,7 +27,7 @@ class TR_Sim : public qucs::component::SimulationComponent { ~TR_Sim(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); void recreate(Schematic*); }; diff --git a/qucs/components/vacomponent.cpp b/qucs/components/vacomponent.cpp index 9b7c5d30..81753907 100644 --- a/qucs/components/vacomponent.cpp +++ b/qucs/components/vacomponent.cpp @@ -296,9 +296,9 @@ void vacomponent::createSymbol(QJsonObject json) } -QString vacomponent::spice_netlist(bool isXyce) +QString vacomponent::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - if (isXyce) return QString(); + if (dialect == spicecompat::SPICEXyce) return QString(); QString s = SpiceModel + Name + " "; for(const auto pp: Ports) { diff --git a/qucs/components/vacomponent.h b/qucs/components/vacomponent.h index 94794c09..39ff24b8 100644 --- a/qucs/components/vacomponent.h +++ b/qucs/components/vacomponent.h @@ -41,7 +41,7 @@ class vacomponent : public Component protected: void createSymbol(QJsonObject json); void parseJson(QJsonObject json); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; diff --git a/qucs/components/vccs.cpp b/qucs/components/vccs.cpp index 341d5202..74b1a7ca 100644 --- a/qucs/components/vccs.cpp +++ b/qucs/components/vccs.cpp @@ -84,30 +84,30 @@ Element* VCCS::info(QString& Name, char* &BitmapFile, bool getNewOne) } QString VCCS::va_code() -{ - - QString Gain = vacompat::normalize_value(Props.at(0)->Value); - QString P1 = Ports.at(0)->Connection->Name; +{ + QString Gain = vacompat::normalize_value(Props.at(0)->Value); + QString P1 = Ports.at(0)->Connection->Name; QString P4 = Ports.at(1)->Connection->Name; QString P3 = Ports.at(2)->Connection->Name; QString P2 = Ports.at(3)->Connection->Name; QString s = ""; - + QString Vpm = vacompat::normalize_voltage(P1,P2); - QString Ipm = vacompat::normalize_current(P1,P2,true); + QString Ipm = vacompat::normalize_current(P1,P2,true); s += QStringLiteral(" %1 <+ %2 * 1e-9;\n").arg(Ipm).arg(Vpm); QString Vpm2 = vacompat::normalize_voltage(P4,P3); - QString Ipm2 = vacompat::normalize_current(P4,P3,true); + QString Ipm2 = vacompat::normalize_current(P4,P3,true); s += QStringLiteral("%1 <+ %2 * 1e-9;\n").arg(Ipm2).arg(Vpm2); s += QStringLiteral("%1 <+ %2 * %3 ;\n").arg(Ipm2).arg(Vpm).arg(Gain); - - return s; + return s; } -QString VCCS::spice_netlist(bool) +QString VCCS::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - QString s = spicecompat::check_refdes(Name,SpiceModel); + Q_UNUSED(dialect); + + QString s = spicecompat::check_refdes(Name,SpiceModel); QList seq; // nodes sequence seq<<1<<2<<0<<3; // output all node names diff --git a/qucs/components/vccs.h b/qucs/components/vccs.h index 4b62d780..fafda437 100644 --- a/qucs/components/vccs.h +++ b/qucs/components/vccs.h @@ -29,7 +29,7 @@ class VCCS : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString va_code(); }; diff --git a/qucs/components/vcresistor.cpp b/qucs/components/vcresistor.cpp index af236c06..37a835f3 100644 --- a/qucs/components/vcresistor.cpp +++ b/qucs/components/vcresistor.cpp @@ -109,9 +109,10 @@ QString vcresistor::netlist() return s; } -QString vcresistor::spice_netlist(bool isXyce) +QString vcresistor::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString s; QString gain = spicecompat::normalize_value(getProperty("gain")->Value); QString in1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); diff --git a/qucs/components/vcresistor.h b/qucs/components/vcresistor.h index 33c813c8..e1248b91 100644 --- a/qucs/components/vcresistor.h +++ b/qucs/components/vcresistor.h @@ -29,7 +29,7 @@ class vcresistor : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/vcvs.cpp b/qucs/components/vcvs.cpp index 1d492a41..fa8a0e23 100644 --- a/qucs/components/vcvs.cpp +++ b/qucs/components/vcvs.cpp @@ -64,7 +64,7 @@ VCVS::VCVS() SpiceModel = "E"; Props.append(new Property("G", "1", true, - QObject::tr("forward transfer factor"))); + QObject::tr("forward transfer factor"))); Props.append(new Property("T", "0", false, QObject::tr("delay time (Qucsator only)"))); } @@ -89,25 +89,28 @@ Element* VCVS::info(QString& Name, char* &BitmapFile, bool getNewOne) QString VCVS::va_code() { QString Gain = vacompat::normalize_value(Props.at(0)->Value); - QString P1 = Ports.at(0)->Connection->Name; + QString P1 = Ports.at(0)->Connection->Name; QString P4 = Ports.at(1)->Connection->Name; QString P3 = Ports.at(2)->Connection->Name; QString P2 = Ports.at(3)->Connection->Name; QString s = ""; - + QString Vpm = vacompat::normalize_voltage(P1,P2); - QString Ipm = vacompat::normalize_current(P1,P2,true); + QString Ipm = vacompat::normalize_current(P1,P2,true); s += QStringLiteral(" %1 <+ %2 * 1e-9;\n").arg(Ipm).arg(Vpm); QString Vpm2 = vacompat::normalize_voltage(P3,P4); - QString Ipm2 = vacompat::normalize_current(P3,P4,true); + QString Ipm2 = vacompat::normalize_current(P3,P4,true); s += QStringLiteral("%1 <+ -(%2 * 1e3);\n").arg(Ipm2).arg(Vpm2); s += QStringLiteral("%1 <+ -(%2 * 1e3* %3) ;\n").arg(Ipm2).arg(Vpm).arg(Gain); - + return s; - } -QString VCVS::spice_netlist(bool) +} + +QString VCVS::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - QString s = spicecompat::check_refdes(Name,SpiceModel); + Q_UNUSED(dialect); + + QString s = spicecompat::check_refdes(Name,SpiceModel); QList seq; // nodes sequence seq<<1<<2<<0<<3; // output all node names diff --git a/qucs/components/vcvs.h b/qucs/components/vcvs.h index 448d2e53..2ac9bd38 100644 --- a/qucs/components/vcvs.h +++ b/qucs/components/vcvs.h @@ -29,7 +29,7 @@ class VCVS : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString va_code(); }; diff --git a/qucs/components/vexp.cpp b/qucs/components/vexp.cpp index 97635c5d..b19e3179 100644 --- a/qucs/components/vexp.cpp +++ b/qucs/components/vexp.cpp @@ -86,8 +86,10 @@ Element* vExp::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString vExp::spice_netlist(bool) +QString vExp::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -95,12 +97,12 @@ QString vExp::spice_netlist(bool) s += " "+ nam; // node names } - QString U1= spicecompat::normalize_value(Props.at(0)->Value); - QString U2 = spicecompat::normalize_value(Props.at(1)->Value); - QString T1 = spicecompat::normalize_value(Props.at(2)->Value); - QString T2 = spicecompat::normalize_value(Props.at(3)->Value); - QString Tr = spicecompat::normalize_value(Props.at(4)->Value); - QString Tf = spicecompat::normalize_value(Props.at(5)->Value); + QString U1= spicecompat::normalize_value(Props.at(0)->Value); + QString U2 = spicecompat::normalize_value(Props.at(1)->Value); + QString T1 = spicecompat::normalize_value(Props.at(2)->Value); + QString T2 = spicecompat::normalize_value(Props.at(3)->Value); + QString Tr = spicecompat::normalize_value(Props.at(4)->Value); + QString Tf = spicecompat::normalize_value(Props.at(5)->Value); s += QStringLiteral(" DC 0 EXP(%1 %2 %3 %4 %5 %6) AC 0\n").arg(U1).arg(U2).arg(T1).arg(Tr).arg(T2).arg(Tf); return s; diff --git a/qucs/components/vexp.h b/qucs/components/vexp.h index 61e99eac..55e8092a 100644 --- a/qucs/components/vexp.h +++ b/qucs/components/vexp.h @@ -31,7 +31,7 @@ class vExp : public Component { ~vExp(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/vfile.cpp b/qucs/components/vfile.cpp index e91276bd..4af50c5d 100644 --- a/qucs/components/vfile.cpp +++ b/qucs/components/vfile.cpp @@ -112,9 +112,10 @@ QString vFile::netlist() return s + "\n"; } -QString vFile::spice_netlist(bool isXyce) +QString vFile::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); + QString s = SpiceModel + Name; QString modname = "mod_" + Model + Name; QString p1 = spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); diff --git a/qucs/components/vfile.h b/qucs/components/vfile.h index a1afa850..eb9f40ca 100644 --- a/qucs/components/vfile.h +++ b/qucs/components/vfile.h @@ -32,7 +32,7 @@ class vFile : public Component { protected: QString netlist(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/volt_ac.cpp b/qucs/components/volt_ac.cpp index 19537692..f17231db 100644 --- a/qucs/components/volt_ac.cpp +++ b/qucs/components/volt_ac.cpp @@ -83,8 +83,10 @@ Element* Volt_ac::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString Volt_ac::spice_netlist(bool) +QString Volt_ac::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; diff --git a/qucs/components/volt_ac.h b/qucs/components/volt_ac.h index b6250b02..716e12fd 100644 --- a/qucs/components/volt_ac.h +++ b/qucs/components/volt_ac.h @@ -29,7 +29,7 @@ class Volt_ac : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString netlist(); }; diff --git a/qucs/components/volt_dc.cpp b/qucs/components/volt_dc.cpp index c8a84f7a..d9ac038f 100644 --- a/qucs/components/volt_dc.cpp +++ b/qucs/components/volt_dc.cpp @@ -45,7 +45,7 @@ Volt_dc::Volt_dc() SpiceModel = "V"; Props.append(new Property("U", "1 V", true, - QObject::tr("voltage in Volts"))); + QObject::tr("voltage in Volts"))); rotate(); // fix historical flaw } @@ -59,7 +59,7 @@ Component* Volt_dc::newOne() return new Volt_dc(); } -QString Volt_dc::spice_netlist(bool) +QString Volt_dc::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { @@ -68,10 +68,16 @@ QString Volt_dc::spice_netlist(bool) s += " "+ nam; // node names } - s += QStringLiteral(" DC %1\n").arg(spicecompat::normalize_value(Props.at(0)->Value)); + s += QStringLiteral(" %1%2\n").arg(dialect == spicecompat::CDL ? "" : "DC ").arg(spicecompat::normalize_value(Props.at(0)->Value)); + return s; } +QString Volt_dc::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + Element* Volt_dc::info(QString& Name, char* &BitmapFile, bool getNewOne) { Name = QObject::tr("dc Voltage Source"); diff --git a/qucs/components/volt_dc.h b/qucs/components/volt_dc.h index 0a923990..8703b116 100644 --- a/qucs/components/volt_dc.h +++ b/qucs/components/volt_dc.h @@ -27,7 +27,10 @@ class Volt_dc : public Component { ~Volt_dc(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString spice_netlist(bool isXyce = false); + +protected: + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/components/vprobe.cpp b/qucs/components/vprobe.cpp index 70e97761..7068f9a6 100644 --- a/qucs/components/vprobe.cpp +++ b/qucs/components/vprobe.cpp @@ -39,7 +39,7 @@ vProbe::vProbe() Lines.append(new qucs::Line(-10, 0,-10, 6,QPen(Qt::red,2))); Lines.append(new qucs::Line(-13, 3, -7, 3,QPen(Qt::red,2))); Lines.append(new qucs::Line( 7, 3, 13, 3,QPen(Qt::black,2))); - + Lines.append(new qucs::Line(-10, 9,-10, 20,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 10, 9, 10, 20,QPen(Qt::darkBlue,2))); Ports.append(new Port(-10, 20)); @@ -78,8 +78,10 @@ QString vProbe::getProbeVariable(bool) return Name; } -QString vProbe::spice_netlist(bool) +QString vProbe::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = QStringLiteral("E%1 %2 0 %3 %4 1.0\nR%1%2 %2 0 1E8\nR%1%3 %3 %4 1E8\n").arg(Name).arg(Name) .arg(Ports.at(0)->Connection->Name).arg(Ports.at(1)->Connection->Name); return s; diff --git a/qucs/components/vprobe.h b/qucs/components/vprobe.h index be29ba5a..14776277 100644 --- a/qucs/components/vprobe.h +++ b/qucs/components/vprobe.h @@ -29,7 +29,7 @@ class vProbe : public Component { static Element* info(QString&, char* &, bool getNewOne=false); QString getProbeVariable(bool isXyce = false); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/vpulse.cpp b/qucs/components/vpulse.cpp index a794bd15..aa6d4e57 100644 --- a/qucs/components/vpulse.cpp +++ b/qucs/components/vpulse.cpp @@ -73,8 +73,10 @@ vPulse::~vPulse() { } -QString vPulse::spice_netlist(bool) +QString vPulse::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { @@ -88,7 +90,7 @@ QString vPulse::spice_netlist(bool) QString VL = spicecompat::normalize_value(Props.at(0)->Value); // VL QString VH = spicecompat::normalize_value(Props.at(1)->Value); // VH - QString Tr = spicecompat::normalize_value(Props.at(4)->Value); // Tr + QString Tr = spicecompat::normalize_value(Props.at(4)->Value); // Tr QString Tf = spicecompat::normalize_value(Props.at(5)->Value); // Tf misc::str2num(Props.at(2)->Value,T1,unit,fac); // Td diff --git a/qucs/components/vpulse.h b/qucs/components/vpulse.h index fa8cb5cd..86aa3987 100644 --- a/qucs/components/vpulse.h +++ b/qucs/components/vpulse.h @@ -30,7 +30,7 @@ class vPulse : public Component { ~vPulse(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/components/vrect.cpp b/qucs/components/vrect.cpp index 7bfb8610..411d4c38 100644 --- a/qucs/components/vrect.cpp +++ b/qucs/components/vrect.cpp @@ -74,8 +74,10 @@ vRect::~vRect() { } -QString vRect::spice_netlist(bool) +QString vRect::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { diff --git a/qucs/components/vrect.h b/qucs/components/vrect.h index 5d8aa7a3..080862b8 100644 --- a/qucs/components/vrect.h +++ b/qucs/components/vrect.h @@ -29,7 +29,7 @@ class vRect : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString netlist(); }; diff --git a/qucs/element.h b/qucs/element.h index d37a5349..70908eb6 100644 --- a/qucs/element.h +++ b/qucs/element.h @@ -48,6 +48,7 @@ namespace qucs { // otherwise conflict with class DrawingPrimitive { public: + virtual ~DrawingPrimitive() {} virtual void draw([[maybe_unused]] QPainter* painter) const {}; virtual QBrush brushHint() const { return Qt::NoBrush; } virtual QPen penHint() const { return Qt::NoPen; } @@ -56,6 +57,7 @@ class DrawingPrimitive { struct Line : DrawingPrimitive { Line(double _x1, double _y1, double _x2, double _y2, QPen _style) : x1(_x1), y1(_y1), x2(_x2), y2(_y2), style(_style) {}; + virtual ~Line() {} double x1, y1, x2, y2; QPen style; void draw(QPainter* painter) const override; @@ -66,6 +68,7 @@ struct Arc : DrawingPrimitive { Arc(double _x, double _y, double _w, double _h, int _angle, int _arclen, QPen _style) : x(_x), y(_y), w(_w), h(_h), angle(_angle), arclen(_arclen), style(_style) {}; + virtual ~Arc() {} double x, y, w, h; int angle, arclen; QPen style; @@ -128,6 +131,7 @@ struct Text : qucs::DrawingPrimitive { double _Size = 10.0, double _mCos=1.0, double _mSin=0.0) : x(_x), y(_y), s(_s), Color(_Color), Size(_Size), mSin(_mSin), mCos(_mCos) { over = under = false; }; + virtual ~Text() {} double x, y; QString s; QColor Color; diff --git a/qucs/extsimkernels/CMakeLists.txt b/qucs/extsimkernels/CMakeLists.txt index a74fbc10..7358bda8 100755 --- a/qucs/extsimkernels/CMakeLists.txt +++ b/qucs/extsimkernels/CMakeLists.txt @@ -32,6 +32,7 @@ spicecompat.cpp customsimdialog.cpp simsettingsdialog.cpp verilogawriter.cpp +CdlNetlistWriter.cpp s2spice.cpp spicelibcompdialog.cpp #xspice_cmbuilder.cpp diff --git a/qucs/extsimkernels/CdlNetlistWriter.cpp b/qucs/extsimkernels/CdlNetlistWriter.cpp new file mode 100644 index 00000000..3fe8d12d --- /dev/null +++ b/qucs/extsimkernels/CdlNetlistWriter.cpp @@ -0,0 +1,182 @@ +/* + * CdlNetlistWriter.cpp - Schematic to CDL netlist converter implementation + * + * This file is part of Qucs-s + * + * Qucs is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Qucs. If not, see . + * + */ + +#include "CdlNetlistWriter.h" +#include "abstractspicekernel.h" + +#include "schematic.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +CdlNetlistWriter::CdlNetlistWriter(QTextStream& netlistStream, Schematic* schematic) : + a_netlistStream(netlistStream), + a_schematic(schematic) +{ +} + +bool CdlNetlistWriter::write() +{ + a_netlistStream << "* Qucs " << PACKAGE_VERSION << " " << a_schematic->getDocName() << "\n"; + + a_netlistStream << AbstractSpiceKernel::collectSpiceLibs(a_schematic); + + if (prepareNetlist() == -10) + { + return false; + } + + startNetlist(); + + a_netlistStream << ".END\n"; + + return true; +} + +int CdlNetlistWriter::prepareNetlist() +{ + if (a_schematic->getShowBias() > 0) + { + a_schematic->setShowBias(-1); // do not show DC bias anymore + } + + a_schematic->setIsVerilog(false); + a_schematic->setIsAnalog(true); + + bool isTruthTable = false; + int allTypes = 0; + int numPorts = 0; + + // Detect simulation domain (analog/digital) by looking at component types. + for (Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) + { + if (pc->isActive == COMP_IS_OPEN) + { + continue; + } + if (pc->Model.at(0) == '.') + { + if (pc->Model == ".Digi") + { + if (pc->Props.front()->Value != "TimeList") + { + isTruthTable = true; + } + if (pc->Props.back()->Value != "VHDL") + { + a_schematic->setIsVerilog(true); + } + + allTypes |= isDigitalComponent; + a_schematic->setIsAnalog(false); + } + else + { + allTypes |= isAnalogComponent; + } + } + else if (pc->Model == "DigiSource") + { + numPorts++; + } + } + + if ((allTypes & isAnalogComponent) == 0) + { + if (allTypes == 0) + { + // If no simulation exists, assume analog simulation. There may + // be a simulation within a SPICE file. Otherwise Qucsator will + // output an error. + a_schematic->setIsAnalog(true); + allTypes |= isAnalogComponent; + numPorts = -1; + } + else + { + if (!isTruthTable) + { + numPorts = 0; + } + } + } + else + { + numPorts = -1; + a_schematic->setIsAnalog(true); + } + + int countInit = 0; // counts the nodesets to give them unique names + + QStringList collect; + QPlainTextEdit errorText; + + if (!a_schematic->giveNodeNames(&a_netlistStream, countInit, collect, &errorText, numPorts)) + { + fprintf(stderr, "Error giving NodeNames\n"); + return -10; + } + + return numPorts; +} + +void CdlNetlistWriter::startNetlist() +{ + QString s; + + // Parameters, Initial conditions, Options + for (Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) + { + if (pc->isEquation) + { + s = pc->getExpression(false, true); + a_netlistStream << s; + } + } + + // global net 0 is always ground + a_netlistStream << ".GLOBAL 0:G\n"; + + // Components + for (Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) + { + if (a_schematic->getIsAnalog() && !pc->isSimulation && !pc->isEquation) + { + s = pc->getSpiceNetlist(spicecompat::CDL); + a_netlistStream << s; + } + } + + //TODO: Clarification of whether models should be exported + // Modelcards + /*for (Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) + { + if (pc->SpiceModel==".MODEL") + { + s = pc->getSpiceModel(); + a_netlistStream << s; + } + }*/ +} + + diff --git a/qucs/extsimkernels/CdlNetlistWriter.h b/qucs/extsimkernels/CdlNetlistWriter.h new file mode 100644 index 00000000..c4f54dac --- /dev/null +++ b/qucs/extsimkernels/CdlNetlistWriter.h @@ -0,0 +1,43 @@ +/* + * CdlNetlistWriter.h - Schematic to CDL netlist converter declaration + * + * This file is part of Qucs-s + * + * Qucs is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Qucs. If not, see . + * + */ + +#ifndef CDL_NETLIST_WRITER_H +#define CDL_NETLIST_WRITER_H + +class QTextStream; +class Schematic; + +class CdlNetlistWriter +{ +public: + CdlNetlistWriter(QTextStream& netlistStream, Schematic* schematic); + ~CdlNetlistWriter() {}; + + bool write(); + +private: + int prepareNetlist(); + void startNetlist(); + + QTextStream& a_netlistStream; + Schematic* a_schematic; +}; + +#endif // CDL_NETLIST_WRITER_H diff --git a/qucs/extsimkernels/abstractspicekernel.cpp b/qucs/extsimkernels/abstractspicekernel.cpp index 75e36e66..1fa21a16 100644 --- a/qucs/extsimkernels/abstractspicekernel.cpp +++ b/qucs/extsimkernels/abstractspicekernel.cpp @@ -191,7 +191,7 @@ bool AbstractSpiceKernel::checkDCSimulation() * \param xyce Default is false. Should be set in true if netlist is * prepared for Xyce simulator. For Ngspice should be false. */ -void AbstractSpiceKernel::startNetlist(QTextStream &stream, bool xyce) +void AbstractSpiceKernel::startNetlist(QTextStream &stream, spicecompat::SpiceDialect dialect) { QString s; @@ -235,7 +235,7 @@ void AbstractSpiceKernel::startNetlist(QTextStream &stream, bool xyce) // Parameters, Initial conditions, Options for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) { if (pc->isEquation) { - s = pc->getExpression(xyce); + s = pc->getExpression(dialect); stream<getIsAnalog() && !(pc->isSimulation) && !(pc->isEquation)) { - s = pc->getSpiceNetlist(xyce); + s = pc->getSpiceNetlist(dialect); stream<a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) { // Xyce can run if(pc->isSimulation && pc->isActive == COMP_IS_ACTIVE) { // only one simulations per time. QString sim_typ = pc->Model; // Multiple simulations are forbidden. - QString s = pc->getSpiceNetlist(true); + QString s = pc->getSpiceNetlist(spicecompat::SPICEXyce); if ((sim_typ==".AC")&&(sim=="ac")) stream<Model==".FOURIER") { if (pc1->Props.at(0)->Value==pc->Name) { - QString s1 = pc1->getSpiceNetlist(true); + QString s1 = pc1->getSpiceNetlist(spicecompat::SPICEXyce); outputs.append("spice4qucs.tran.cir.four0"); stream<currentWidget())) + { + Schematic* schematic = dynamic_cast(DocumentTab->currentWidget()); + Q_ASSERT(schematic != nullptr); + +#ifdef NETLIST_CDL_TO_CONSOLE // for fast testing purposes + QString netlistString; + { + QTextStream netlistStream(&netlistString); + CdlNetlistWriter cdlWriter(netlistStream, schematic); + if (!cdlWriter.write()) + { + QMessageBox::critical( + this, + tr("Save CDL netlist"), + tr("Save CDL netlist failed!"), + QMessageBox::Ok); + } + printf("\nCDL netlist:\n%s\n", netlistString.toUtf8().constData()); + Content->refresh(); + } +#else + QFileInfo inf(schematic->getDocName()); + QString filename = QFileDialog::getSaveFileName( + this, + tr("Save CDL netlist"), + inf.path() + QDir::separator() + "netlist.cdl", + "CDL netlist (*.cdl)"); + + if (filename.isEmpty()) + { + return; + } + + QFile netlistFile(filename); + if (netlistFile.open(QIODevice::WriteOnly)) + { + QTextStream netlistStream(&netlistFile); + CdlNetlistWriter cdlWriter(netlistStream, schematic); + if (!cdlWriter.write()) + { + QMessageBox::critical( + this, + tr("Save CDL netlist"), + tr("Save CDL netlist failed!"), + QMessageBox::Ok); + } + netlistFile.close(); + Content->refresh(); + } +#endif + + } +} + void QucsApp::slotAfterSpiceSimulation(ExternSimDialog *SimDlg) { Schematic *sch = (Schematic*)DocumentTab->currentWidget(); diff --git a/qucs/qucs.h b/qucs/qucs.h index f6ce01d1..7e9f7319 100644 --- a/qucs/qucs.h +++ b/qucs/qucs.h @@ -191,6 +191,7 @@ private slots: void slotFileChanged(bool); void slotSimSettings(); void slotSaveNetlist(); + void slotSaveCdlNetlist(); void slotAfterSpiceSimulation(ExternSimDialog *SimDlg); void slotBuildVAModule(); /*void slotBuildXSPICEIfs(int mode = 0); @@ -223,7 +224,8 @@ private slots: *fileSaveAll, *fileClose, *fileExamples, *fileSettings, *filePrint, *fileQuit, *projNew, *projOpen, *projDel, *projClose, *applSettings, *refreshSchPath, *editCut, *editCopy, *magAll, *magSel, *magOne, *magMinus, *filePrintFit, *tune, - *symEdit, *intoH, *popH, *simulate, *save_netlist, *dpl_sch, *undo, *redo, *dcbias; + *symEdit, *intoH, *popH, *simulate, *save_netlist, *dpl_sch, *undo, *redo, *dcbias, + *saveCdlNetlist; QAction *exportAsImage; diff --git a/qucs/qucs_init.cpp b/qucs/qucs_init.cpp index e500ee18..d90e638c 100644 --- a/qucs/qucs_init.cpp +++ b/qucs/qucs_init.cpp @@ -577,6 +577,11 @@ void QucsApp::initActions() save_netlist->setWhatsThis(tr("Save netlist to file")); connect(save_netlist, SIGNAL(triggered()), SLOT(slotSaveNetlist())); + saveCdlNetlist = new QAction(tr("Save CDL netlist"), this); + saveCdlNetlist->setStatusTip(tr("Save CDL netlist")); + saveCdlNetlist->setWhatsThis(tr("Save CDL netlist to file")); + connect(saveCdlNetlist, SIGNAL(triggered()), SLOT(slotSaveCdlNetlist())); + setMarker = new QAction(QIcon((":/bitmaps/svg/marker.svg")), tr("Set Marker on Graph"), this); setMarker->setShortcut(Qt::CTRL|Qt::Key_B); setMarker->setStatusTip(tr("Sets a marker on a diagram's graph")); @@ -796,6 +801,7 @@ void QucsApp::initMenuBar() simMenu->addAction(showMsg); simMenu->addAction(showNet); simMenu->addAction(save_netlist); + simMenu->addAction(saveCdlNetlist); simMenu->addAction(simSettings); diff --git a/qucs/schematic.h b/qucs/schematic.h index a52aa812..95daa041 100644 --- a/qucs/schematic.h +++ b/qucs/schematic.h @@ -515,6 +515,7 @@ protected slots: bool getIsAnalog() const { return a_isAnalog; } void setIsVerilog(bool value) { a_isVerilog = value; } bool getIsVerilog() const { return a_isVerilog; } + bool giveNodeNames(QTextStream *, int&, QStringList&, QPlainTextEdit*, int); private: int saveDocument(); @@ -540,7 +541,6 @@ protected slots: void throughAllNodes(bool, QStringList&, int&); void propagateNode(QStringList&, int&, Node*); void collectDigitalSignals(void); - bool giveNodeNames(QTextStream *, int&, QStringList&, QPlainTextEdit*, int); void beginNetlistDigital(QTextStream &); void endNetlistDigital(QTextStream &); bool throughAllComps(QTextStream *, int&, QStringList&, QPlainTextEdit *, int); diff --git a/qucs/spicecomponents/BJT_SPICE.cpp b/qucs/spicecomponents/BJT_SPICE.cpp index 68fda672..2591133c 100644 --- a/qucs/spicecomponents/BJT_SPICE.cpp +++ b/qucs/spicecomponents/BJT_SPICE.cpp @@ -186,8 +186,10 @@ QString BJT_SPICE::netlist() return QString(); } -QString BJT_SPICE::spice_netlist(bool) +QString BJT_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString ltr =getProperty("Letter")->Value; QString s = spicecompat::check_refdes(Name,ltr); for (Port *p1 : Ports) { @@ -195,7 +197,7 @@ QString BJT_SPICE::spice_netlist(bool) if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString Q= Props.at(3)->Value; QString Q_Line_2= Props.at(4)->Value; QString Q_Line_3= Props.at(5)->Value; @@ -211,3 +213,9 @@ QString BJT_SPICE::spice_netlist(bool) return s; } + +QString BJT_SPICE::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + diff --git a/qucs/spicecomponents/BJT_SPICE.h b/qucs/spicecomponents/BJT_SPICE.h index 175a125e..e0c6a940 100644 --- a/qucs/spicecomponents/BJT_SPICE.h +++ b/qucs/spicecomponents/BJT_SPICE.h @@ -18,7 +18,8 @@ * (at your option) any later version. * * * ***************************************************************************/ - #ifndef BJT_SPICE_H + +#ifndef BJT_SPICE_H #define BJT_SPICE_H #include "components/component.h" @@ -33,10 +34,12 @@ class BJT_SPICE : public MultiViewComponent { static Element* infoPNP4(QString&, char* &, bool getNewOne=false); static Element* infoNPN5(QString&, char* &, bool getNewOne=false); static Element* infoPNP5(QString&, char* &, bool getNewOne=false); + protected: void createSymbol(); QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // NPN_SPICE_H diff --git a/qucs/spicecomponents/C_SPICE.cpp b/qucs/spicecomponents/C_SPICE.cpp index c4d3f3c0..13292c98 100644 --- a/qucs/spicecomponents/C_SPICE.cpp +++ b/qucs/spicecomponents/C_SPICE.cpp @@ -109,8 +109,10 @@ QString C_SPICE::netlist() return QString(); } -QString C_SPICE::spice_netlist(bool) +QString C_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString ltr = getProperty("Letter")->Value; QString s = spicecompat::check_refdes(Name,ltr); for (Port *p1 : Ports) { @@ -130,6 +132,18 @@ QString C_SPICE::spice_netlist(bool) if( C_Line_3.length() > 0 ) s += QStringLiteral("\n%1").arg(C_Line_3); if( C_Line_4.length() > 0 ) s += QStringLiteral("\n%1").arg(C_Line_4); if( C_Line_5.length() > 0 ) s += QStringLiteral("\n%1").arg(C_Line_5); + s += "\n"; + return s; } + +QString C_SPICE::cdl_netlist() +{ + if (Ports.size() == 2) + { + return spice_netlist(spicecompat::CDL); + } + + return QString(); +} diff --git a/qucs/spicecomponents/C_SPICE.h b/qucs/spicecomponents/C_SPICE.h index 20ae3f6f..c0e52a36 100644 --- a/qucs/spicecomponents/C_SPICE.h +++ b/qucs/spicecomponents/C_SPICE.h @@ -30,10 +30,12 @@ class C_SPICE: public MultiViewComponent { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); static Element* info_C3(QString&, char* &, bool getNewOne=false); + protected: void createSymbol(); QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // C_SPICE_H diff --git a/qucs/spicecomponents/DIODE_SPICE.cpp b/qucs/spicecomponents/DIODE_SPICE.cpp index 745d65d0..5fdd6b17 100644 --- a/qucs/spicecomponents/DIODE_SPICE.cpp +++ b/qucs/spicecomponents/DIODE_SPICE.cpp @@ -114,8 +114,10 @@ QString DIODE_SPICE::netlist() return QString(); } -QString DIODE_SPICE::spice_netlist(bool) +QString DIODE_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString ltr = getProperty("Letter")->Value; QString s = spicecompat::check_refdes(Name,ltr); for (Port *p1 : Ports) { @@ -123,7 +125,7 @@ QString DIODE_SPICE::spice_netlist(bool) if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString D= Props.at(0)->Value; QString D_Line_2= Props.at(1)->Value; QString D_Line_3= Props.at(2)->Value; @@ -135,6 +137,18 @@ QString DIODE_SPICE::spice_netlist(bool) if( D_Line_3.length() > 0 ) s += QStringLiteral("\n%1").arg(D_Line_3); if( D_Line_4.length() > 0 ) s += QStringLiteral("\n%1").arg(D_Line_4); if( D_Line_5.length() > 0 ) s += QStringLiteral("\n%1").arg(D_Line_5); + s += "\n"; + return s; } + +QString DIODE_SPICE::cdl_netlist() +{ + if (Ports.size() == 2) + { + return spice_netlist(spicecompat::CDL); + } + + return QString(); +} diff --git a/qucs/spicecomponents/DIODE_SPICE.h b/qucs/spicecomponents/DIODE_SPICE.h index b8b9af6f..53a7f7ee 100644 --- a/qucs/spicecomponents/DIODE_SPICE.h +++ b/qucs/spicecomponents/DIODE_SPICE.h @@ -30,10 +30,12 @@ class DIODE_SPICE : public MultiViewComponent { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); static Element* info_DIODE3(QString&, char* &, bool getNewOne=false); + protected: void createSymbol(); QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // DIODE_SPICE_H diff --git a/qucs/spicecomponents/Icouple.cpp b/qucs/spicecomponents/Icouple.cpp index 68a0f49d..5e184d86 100644 --- a/qucs/spicecomponents/Icouple.cpp +++ b/qucs/spicecomponents/Icouple.cpp @@ -27,11 +27,11 @@ Icouple::Icouple() Simulator = spicecompat::simSpice; Lines.append(new qucs::Line(-40, -40, -40, -30,QPen(Qt::darkBlue,2))); // L1 - Lines.append(new qucs::Line(-40, -30, -40, -25,QPen(Qt::blue,3))); // L2 - Lines.append(new qucs::Line(-40, -25, -30, -25,QPen(Qt::blue,3))); // L3 - Lines.append(new qucs::Line(-30, -25, -30, -15,QPen(Qt::blue,3))); // L4 - Lines.append(new qucs::Line(-30, -15, -40, -15,QPen(Qt::blue,3))); // L5 - Lines.append(new qucs::Line(-30, -15, -40, -15,QPen(Qt::blue,3))); // L6 + Lines.append(new qucs::Line(-40, -30, -40, -25,QPen(Qt::blue,3))); // L2 + Lines.append(new qucs::Line(-40, -25, -30, -25,QPen(Qt::blue,3))); // L3 + Lines.append(new qucs::Line(-30, -25, -30, -15,QPen(Qt::blue,3))); // L4 + Lines.append(new qucs::Line(-30, -15, -40, -15,QPen(Qt::blue,3))); // L5 + Lines.append(new qucs::Line(-30, -15, -40, -15,QPen(Qt::blue,3))); // L6 Lines.append(new qucs::Line(-40, -15, -40, -5,QPen(Qt::blue,3))); // L7 Lines.append(new qucs::Line(-40, -5, -30, -5,QPen(Qt::blue,3))); // L8 Lines.append(new qucs::Line(-30, -5, -30, 5,QPen(Qt::blue,3))); // L9 @@ -39,23 +39,23 @@ Icouple::Icouple() Lines.append(new qucs::Line(-40, 5, -40, 15,QPen(Qt::blue,3))); // L11 Lines.append(new qucs::Line(-40, 15, -30, 15,QPen(Qt::blue,3))); // L12 Lines.append(new qucs::Line(-30, 15, -30, 25,QPen(Qt::blue,3))); // L13 - Lines.append(new qucs::Line(-30, 25, -40, 25,QPen(Qt::blue,3))); // L14 - Lines.append(new qucs::Line(-40, 25, -40, 30,QPen(Qt::blue,3))); // L15 - Lines.append(new qucs::Line(-40, 30, -40, 40,QPen(Qt::darkBlue,2))); // L16 - + Lines.append(new qucs::Line(-30, 25, -40, 25,QPen(Qt::blue,3))); // L14 + Lines.append(new qucs::Line(-40, 25, -40, 30,QPen(Qt::blue,3))); // L15 + Lines.append(new qucs::Line(-40, 30, -40, 40,QPen(Qt::darkBlue,2))); // L16 + Lines.append(new qucs::Line( 40, -40, 40, -30,QPen(Qt::darkBlue,2))); // L17 Lines.append(new qucs::Line( 40, -30, 40, -20,QPen(Qt::blue,3))); // L18 Lines.append(new qucs::Line( 40, -20, 20, 0,QPen(Qt::blue,3))); // L19 Lines.append(new qucs::Line( 20, 0, 40, 20,QPen(Qt::blue,3))); // L20 Lines.append(new qucs::Line( 40, 20, 60, 0,QPen(Qt::blue,3))); // L21 - Lines.append(new qucs::Line( 60, 00, 40, -20,QPen(Qt::blue,3))); // L22 + Lines.append(new qucs::Line( 60, 00, 40, -20,QPen(Qt::blue,3))); // L22 Lines.append(new qucs::Line( 40, 20, 40, 30,QPen(Qt::blue,3))); // L23 - Lines.append(new qucs::Line( 40, 30, 40, 40,QPen(Qt::darkBlue,2))); // L24 - + Lines.append(new qucs::Line( 40, 30, 40, 40,QPen(Qt::darkBlue,2))); // L24 + Lines.append(new qucs::Line( 20, -20, 20, -10,QPen(Qt::red,3))); // + Lines.append(new qucs::Line( 15, -15, 25, -15,QPen(Qt::red,3))); - Lines.append(new qucs::Line( 15, 20, 25, 20,QPen(Qt::black,3))); // - - + Lines.append(new qucs::Line( 15, 20, 25, 20,QPen(Qt::black,3))); // - + Ports.append(new Port( -40, -40)); // Pplus Ports.append(new Port( -40, 40)); // Pneg Ports.append(new Port( 40, -40)); // PVplus @@ -70,10 +70,10 @@ Icouple::Icouple() Model = "Icouple"; SpiceModel = "A"; Name = "ICOUPLE"; - + Props.append(new Property("A ", "", true,"Parameter list and\n .model spec.")); Props.append(new Property("A_Line 2", "", false,".model line")); - + //rotate(); // fix historical flaw } @@ -89,7 +89,7 @@ Component* Icouple::newOne() Element* Icouple::info(QString& Name, char* &BitmapFile, bool getNewOne) { Name = QObject::tr("Icouple"); - BitmapFile = (char *) "Icouple"; + BitmapFile = (char *) "Icouple"; if(getNewOne) return new Icouple(); return 0; @@ -100,17 +100,18 @@ QString Icouple::netlist() return QString(); } -QString Icouple::spice_netlist(bool) +QString Icouple::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); QString P1 = Ports.at(0)->Connection->Name; QString P2 = Ports.at(1)->Connection->Name; QString P3 = Ports.at(2)->Connection->Name; QString P4 = Ports.at(3)->Connection->Name; - - s += " " + P1 + " " + P2 + " " + P3 + " " + P4 + " "; - + + s += " " + P1 + " " + P2 + " " + P3 + " " + P4 + " "; + QString A= Props.at(0)->Value; QString A_Line_2= Props.at(1)->Value; if( A.length() > 0) s += QStringLiteral("%1").arg(A); diff --git a/qucs/spicecomponents/Icouple.h b/qucs/spicecomponents/Icouple.h index ed441157..61110ee7 100644 --- a/qucs/spicecomponents/Icouple.h +++ b/qucs/spicecomponents/Icouple.h @@ -31,7 +31,7 @@ class Icouple: public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // Icouple diff --git a/qucs/spicecomponents/K_SPICE.cpp b/qucs/spicecomponents/K_SPICE.cpp index d07e71cb..8275f244 100644 --- a/qucs/spicecomponents/K_SPICE.cpp +++ b/qucs/spicecomponents/K_SPICE.cpp @@ -44,11 +44,11 @@ K_SPICE::K_SPICE() SpiceModel = "K"; Name = "K"; - + Props.append(new Property("Ind1", "L1", true, "Inductance 1 name")); Props.append(new Property("Ind2", "L2", true, "Inductance 2 name")); Props.append(new Property("K", "0.1", true, QObject::tr("Coupling factor ( 0 < K <= 1)"))); - + rotate(); // fix historical flaw } @@ -75,20 +75,25 @@ QString K_SPICE::netlist() return QString(); } -QString K_SPICE::spice_netlist(bool) +QString K_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - QString s = spicecompat::check_refdes(Name,SpiceModel); - for (Port *p1 : Ports) { + Q_UNUSED(dialect); + + QString s = spicecompat::check_refdes(Name,SpiceModel); + + for (Port *p1 : Ports) + { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; - s += " "+ nam+" "; // node names -} - QString Ind1 = Props.at(0) ->Value; - QString Ind2 = Props.at(1) ->Value; - QString K = spicecompat::normalize_value(Props.at(2)->Value); - - s+= QStringLiteral(" %1 %2 %3 \n").arg(Ind1).arg(Ind2).arg(K); - + s += " " + nam + " "; // node names + } + + QString Ind1 = Props.at(0) ->Value; + QString Ind2 = Props.at(1) ->Value; + QString K = spicecompat::normalize_value(Props.at(2)->Value); + + s+= QStringLiteral(" %1 %2 %3 \n").arg(Ind1).arg(Ind2).arg(K); + return s; } diff --git a/qucs/spicecomponents/K_SPICE.h b/qucs/spicecomponents/K_SPICE.h index 51ce27f4..414e3194 100644 --- a/qucs/spicecomponents/K_SPICE.h +++ b/qucs/spicecomponents/K_SPICE.h @@ -31,7 +31,7 @@ class K_SPICE: public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // K_SPICE_H diff --git a/qucs/spicecomponents/LTL_SPICE.cpp b/qucs/spicecomponents/LTL_SPICE.cpp index 77ea1842..4133d2d7 100644 --- a/qucs/spicecomponents/LTL_SPICE.cpp +++ b/qucs/spicecomponents/LTL_SPICE.cpp @@ -24,7 +24,7 @@ LTL_SPICE::LTL_SPICE() { Description = QObject::tr("SPICE T:"); Simulator = spicecompat::simSpice; - + Arcs.append(new qucs::Arc(-28,-40, 18, 38,16*232, 16*33,QPen(Qt::darkBlue,2))); Arcs.append(new qucs::Arc(-28, 2, 18, 38, 16*95, 16*33,QPen(Qt::darkBlue,2))); @@ -42,8 +42,8 @@ LTL_SPICE::LTL_SPICE() Ports.append(new Port(-30,-10)); Ports.append(new Port(-30, 10)); Ports.append(new Port( 30,-10)); - Ports.append(new Port( 30, 10)); - + Ports.append(new Port( 30, 10)); + x1 = -30; y1 =-12; x2 = 30; y2 = 12; @@ -61,7 +61,7 @@ LTL_SPICE::LTL_SPICE() Props.append(new Property("V1", "0", true, QObject::tr("Initial voltage at end 1"))); Props.append(new Property("I1", "0", true, QObject::tr("Initial current at end 1"))); Props.append(new Property("V2", "0", true, QObject::tr("Initial voltage at end 2"))); - Props.append(new Property("I2", "0", true, QObject::tr("Initial current at end 2"))); + Props.append(new Property("I2", "0", true, QObject::tr("Initial current at end 2"))); } @@ -88,8 +88,10 @@ QString LTL_SPICE::netlist() return QString(); } -QString LTL_SPICE::spice_netlist(bool) +QString LTL_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -97,29 +99,29 @@ QString LTL_SPICE::spice_netlist(bool) s += " "+ nam; // node names } - QString Z0 = spicecompat::normalize_value(Props.at(0)->Value); - QString Td = spicecompat::normalize_value(Props.at(1)->Value); - QString Freq = spicecompat::normalize_value(Props.at(2)->Value); - QString Nl = spicecompat::normalize_value(Props.at(3)->Value); - QString V1 = spicecompat::normalize_value(Props.at(4)->Value); - QString I1 = spicecompat::normalize_value(Props.at(5)->Value); - QString V2 = spicecompat::normalize_value(Props.at(6)->Value); - QString I2 = spicecompat::normalize_value(Props.at(7)->Value); - - - - if( Z0.trimmed().length() > 0) { - s += QStringLiteral(" Z0=%1").arg(Z0); - } - if( Td.trimmed().length() > 0 ) { - s += QStringLiteral(" Td=%1").arg(Td); - } - if( Freq.trimmed().length() > 0 ) { - s += QStringLiteral(" F=%1").arg(Freq); - } - if( Nl.trimmed().length() > 0 ) { - s += QStringLiteral(" NL=%1").arg(Nl); - } - s += QStringLiteral(" IC=%5, %6, %7, %8 \n").arg(V1).arg(I1).arg(V2).arg(I2); + QString Z0 = spicecompat::normalize_value(Props.at(0)->Value); + QString Td = spicecompat::normalize_value(Props.at(1)->Value); + QString Freq = spicecompat::normalize_value(Props.at(2)->Value); + QString Nl = spicecompat::normalize_value(Props.at(3)->Value); + QString V1 = spicecompat::normalize_value(Props.at(4)->Value); + QString I1 = spicecompat::normalize_value(Props.at(5)->Value); + QString V2 = spicecompat::normalize_value(Props.at(6)->Value); + QString I2 = spicecompat::normalize_value(Props.at(7)->Value); + + if( Z0.trimmed().length() > 0) { + s += QStringLiteral(" Z0=%1").arg(Z0); + } + if( Td.trimmed().length() > 0 ) { + s += QStringLiteral(" Td=%1").arg(Td); + } + if( Freq.trimmed().length() > 0 ) { + s += QStringLiteral(" F=%1").arg(Freq); + } + if( Nl.trimmed().length() > 0 ) { + s += QStringLiteral(" NL=%1").arg(Nl); + } + + s += QStringLiteral(" IC=%5, %6, %7, %8 \n").arg(V1).arg(I1).arg(V2).arg(I2); + return s; } diff --git a/qucs/spicecomponents/LTL_SPICE.h b/qucs/spicecomponents/LTL_SPICE.h index 23cb9026..cd23df9e 100644 --- a/qucs/spicecomponents/LTL_SPICE.h +++ b/qucs/spicecomponents/LTL_SPICE.h @@ -29,7 +29,7 @@ class LTL_SPICE : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // LTL_SPICE_H diff --git a/qucs/spicecomponents/LTRA_SPICE.cpp b/qucs/spicecomponents/LTRA_SPICE.cpp index e0e9b713..ce8d8a65 100644 --- a/qucs/spicecomponents/LTRA_SPICE.cpp +++ b/qucs/spicecomponents/LTRA_SPICE.cpp @@ -29,29 +29,29 @@ LTRA_SPICE::LTRA_SPICE() Simulator = spicecompat::simSpice; Lines.append(new qucs::Line(-60, -20,-45, -20,QPen(Qt::darkBlue,2))); - Lines.append(new qucs::Line(-45, -20, 45, -20,QPen(Qt::darkRed,4))); + Lines.append(new qucs::Line(-45, -20, 45, -20,QPen(Qt::darkRed,4))); Lines.append(new qucs::Line( 45, -20, 60, -20,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line(-60, 20,-45, 20,QPen(Qt::darkBlue,2))); - Lines.append(new qucs::Line(-45, 20, 45, 20,QPen(Qt::darkRed,4))); + Lines.append(new qucs::Line(-45, 20, 45, 20,QPen(Qt::darkRed,4))); Lines.append(new qucs::Line( 45, 20, 60, 20,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line(-45, 0, -37, 0,QPen(Qt::darkRed,4))); Lines.append(new qucs::Line(-37, 0, -30, -10,QPen(Qt::darkRed,4))); Lines.append(new qucs::Line(-30, -10, -15, 10,QPen(Qt::darkRed,4))); Lines.append(new qucs::Line(-15, 10, 0, -10,QPen(Qt::darkRed,4))); Lines.append(new qucs::Line( 0, -10, 15, 10,QPen(Qt::darkRed,4))); - Lines.append(new qucs::Line( 15, 10, 30, -10,QPen(Qt::darkRed,4))); - Lines.append(new qucs::Line( 30, -10, 37, 0,QPen(Qt::darkRed,4))); - Lines.append(new qucs::Line( 37, 0, 45, 0,QPen(Qt::darkRed,4))); + Lines.append(new qucs::Line( 15, 10, 30, -10,QPen(Qt::darkRed,4))); + Lines.append(new qucs::Line( 30, -10, 37, 0,QPen(Qt::darkRed,4))); + Lines.append(new qucs::Line( 37, 0, 45, 0,QPen(Qt::darkRed,4))); + + - - Ports.append(new Port( -60, -20)); // P1 Ports.append(new Port( -60, 20)); // P2 Ports.append(new Port( 60, -20)); // P3 Ports.append(new Port( 60, 20)); // P4 - + x1 = -40; y1 = -20; x2 = 40; y2 = 30; @@ -94,15 +94,17 @@ QString LTRA_SPICE::netlist() return QString(); } -QString LTRA_SPICE::spice_netlist(bool) +QString LTRA_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString O= Props.at(0)->Value; QString O_Line_2= Props.at(1)->Value; QString O_Line_3= Props.at(2)->Value; diff --git a/qucs/spicecomponents/LTRA_SPICE.h b/qucs/spicecomponents/LTRA_SPICE.h index 2007c0fd..bbb01413 100644 --- a/qucs/spicecomponents/LTRA_SPICE.h +++ b/qucs/spicecomponents/LTRA_SPICE.h @@ -29,7 +29,7 @@ class LTRA_SPICE : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // LTRA_SPICE_H diff --git a/qucs/spicecomponents/L_SPICE.cpp b/qucs/spicecomponents/L_SPICE.cpp index 6534d3ac..60db018e 100644 --- a/qucs/spicecomponents/L_SPICE.cpp +++ b/qucs/spicecomponents/L_SPICE.cpp @@ -83,15 +83,17 @@ QString L_SPICE::netlist() return QString(); } -QString L_SPICE::spice_netlist(bool) +QString L_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString L= Props.at(0)->Value; QString L_Line_2= Props.at(1)->Value; QString L_Line_3= Props.at(2)->Value; @@ -107,3 +109,8 @@ QString L_SPICE::spice_netlist(bool) return s; } + +QString L_SPICE::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/L_SPICE.h b/qucs/spicecomponents/L_SPICE.h index 6400a13c..ab54b5e5 100644 --- a/qucs/spicecomponents/L_SPICE.h +++ b/qucs/spicecomponents/L_SPICE.h @@ -29,9 +29,11 @@ class L_SPICE : public Component { ~L_SPICE(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // L_SPICE_H diff --git a/qucs/spicecomponents/MESFET_SPICE.cpp b/qucs/spicecomponents/MESFET_SPICE.cpp index 207dc38b..1a13d6c1 100644 --- a/qucs/spicecomponents/MESFET_SPICE.cpp +++ b/qucs/spicecomponents/MESFET_SPICE.cpp @@ -32,13 +32,13 @@ MESFET_SPICE::MESFET_SPICE() Lines.append(new qucs::Line(-30, 0,-10, 0,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line(-10,-10, 0,-10,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0,-10, 0,-20,QPen(Qt::darkRed,3))); - Lines.append(new qucs::Line( 0,-20, 0,-30,QPen(Qt::darkBlue,3))); + Lines.append(new qucs::Line( 0,-20, 0,-30,QPen(Qt::darkBlue,3))); Lines.append(new qucs::Line(-10, 10, 0, 10,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 10, 0, 20,QPen(Qt::darkRed,3))); - Lines.append(new qucs::Line( 0, 20, 0, 30,QPen(Qt::darkBlue,3))); + Lines.append(new qucs::Line( 0, 20, 0, 30,QPen(Qt::darkBlue,3))); Lines.append(new qucs::Line( -4, 24, 4, 20,QPen(Qt::darkRed,2))); - + Ports.append(new Port( 0,-30)); Ports.append(new Port(-30, 0)); Ports.append(new Port( 0, 30)); @@ -58,7 +58,7 @@ MESFET_SPICE::MESFET_SPICE() Props.append(new Property("Z_Line 3", "", false,"+ continuation line 2")); Props.append(new Property("Z_Line 4", "", false,"+ continuation line 3")); Props.append(new Property("Z_Line 5", "", false,"+ continuation line 4")); - + Texts.append(new Text(30,12,"NMF",Qt::darkRed,10.0,0.0,-1.0)); } @@ -86,15 +86,17 @@ QString MESFET_SPICE::netlist() return QString(); } -QString MESFET_SPICE::spice_netlist(bool) +QString MESFET_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString Z= Props.at(0)->Value; QString Z_Line_2= Props.at(1)->Value; QString Z_Line_3= Props.at(2)->Value; diff --git a/qucs/spicecomponents/MESFET_SPICE.h b/qucs/spicecomponents/MESFET_SPICE.h index 1781583d..156a9c8d 100644 --- a/qucs/spicecomponents/MESFET_SPICE.h +++ b/qucs/spicecomponents/MESFET_SPICE.h @@ -31,7 +31,7 @@ class MESFET_SPICE : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // MESFET_SPICE_H diff --git a/qucs/spicecomponents/MOS_SPICE.cpp b/qucs/spicecomponents/MOS_SPICE.cpp index a32f4db9..429a79ae 100644 --- a/qucs/spicecomponents/MOS_SPICE.cpp +++ b/qucs/spicecomponents/MOS_SPICE.cpp @@ -225,15 +225,17 @@ void MOS_SPICE::createSymbol() x2 = 4; y2 = 30; } -QString MOS_SPICE::spice_netlist(bool) +QString MOS_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,Props.at(0)->Value); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString M= Props.at(3)->Value; QString M_Line_2= Props.at(4)->Value; QString M_Line_3= Props.at(5)->Value; @@ -249,3 +251,13 @@ QString MOS_SPICE::spice_netlist(bool) return s; } + +QString MOS_SPICE::cdl_netlist() +{ + if (Ports.size() == 4) + { + return spice_netlist(spicecompat::CDL); + } + + return QString(); +} diff --git a/qucs/spicecomponents/MOS_SPICE.h b/qucs/spicecomponents/MOS_SPICE.h index f3ed82cb..584e8305 100644 --- a/qucs/spicecomponents/MOS_SPICE.h +++ b/qucs/spicecomponents/MOS_SPICE.h @@ -35,10 +35,12 @@ class MOS_SPICE : public MultiViewComponent { static Element* info_PX3pin(QString&, char* &, bool getNewOne=false); static Element* info_NX4pin(QString&, char* &, bool getNewOne=false); static Element* info_PX4pin(QString&, char* &, bool getNewOne=false); + protected: void createSymbol(); QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // MOS_SPICE_H diff --git a/qucs/spicecomponents/NJF_SPICE.cpp b/qucs/spicecomponents/NJF_SPICE.cpp index 70cf26db..bc466789 100644 --- a/qucs/spicecomponents/NJF_SPICE.cpp +++ b/qucs/spicecomponents/NJF_SPICE.cpp @@ -29,23 +29,23 @@ NJF_SPICE::NJF_SPICE() Simulator = spicecompat::simSpice; Lines.append(new qucs::Line(-10,-15,-10, 15,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line(-30, 0,-20, 0,QPen(Qt::darkBlue,3))); - Lines.append(new qucs::Line(-20, 0,-10, 0,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line(-20, 0,-10, 0,QPen(Qt::darkRed,3))); + Lines.append(new qucs::Line(-10,-10, 0,-10,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0,-10, 0,-20,QPen(Qt::darkRed,3))); - Lines.append(new qucs::Line( 0,-20, 0,-30,QPen(Qt::darkBlue,3))); - + Lines.append(new qucs::Line( 0,-20, 0,-30,QPen(Qt::darkBlue,3))); + Lines.append(new qucs::Line(-10, 10, 0, 10,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 10, 0, 20,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 20, 0, 30,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line(-16, -5,-11, 0,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line(-16, 5,-11, 0,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( -4, 24, 4, 20,QPen(Qt::darkRed,2))); - + //Texts.append(new Text(30,12,"NJF",Qt::darkRed,10.0,0.0,-1.0)); Ports.append(new Port( 0,-30)); //D @@ -93,15 +93,17 @@ QString NJF_SPICE::netlist() return QString(); } -QString NJF_SPICE::spice_netlist(bool) +QString NJF_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString J= Props.at(0)->Value; QString J_Line_2= Props.at(1)->Value; QString J_Line_3= Props.at(2)->Value; @@ -117,3 +119,8 @@ QString NJF_SPICE::spice_netlist(bool) return s; } + +QString NJF_SPICE::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/NJF_SPICE.h b/qucs/spicecomponents/NJF_SPICE.h index e907933c..0a008949 100644 --- a/qucs/spicecomponents/NJF_SPICE.h +++ b/qucs/spicecomponents/NJF_SPICE.h @@ -29,9 +29,11 @@ class NJF_SPICE : public Component { ~NJF_SPICE(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // NJF_SPICE_H diff --git a/qucs/spicecomponents/NMOS_SPICE.cpp b/qucs/spicecomponents/NMOS_SPICE.cpp index 302c86da..5b454e14 100644 --- a/qucs/spicecomponents/NMOS_SPICE.cpp +++ b/qucs/spicecomponents/NMOS_SPICE.cpp @@ -32,7 +32,7 @@ NMOS_SPICE::NMOS_SPICE() Lines.append(new qucs::Line(-30, 0,-20, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-20, 0,-14, 0,QPen(Qt::darkRed,2))); - + Lines.append(new qucs::Line(-10,-11, 0,-11,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( 0,-11, 0,-20,QPen(Qt::darkRed,2))); @@ -41,21 +41,21 @@ NMOS_SPICE::NMOS_SPICE() Lines.append(new qucs::Line(-10, 11, 0, 11,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( 0, 11, 0, 20,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( 0, 20, 0, 30,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line(-10, 0, 10, 0,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( 10, 0, 20, 0,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line(-10,-16,-10, -7,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line(-10, 7,-10, 16,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( -9, 0, -4, -5,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( -9, 0, -4, 5,QPen(Qt::darkRed,2))); - + Lines.append(new qucs::Line(-10, -8,-10, 8,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( -4, 24, 4, 20,QPen(Qt::darkRed,2))); - + //Texts.append(new Text(30,12,"NMOS",Qt::darkRed,10.0,0.0,-1.0)); - + Ports.append(new Port( 0,-30)); //D Ports.append(new Port(-30, 0)); //G Ports.append(new Port( 0, 30)); //S @@ -102,15 +102,17 @@ QString NMOS_SPICE::netlist() return QString(); } -QString NMOS_SPICE::spice_netlist(bool) +QString NMOS_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString M= Props.at(0)->Value; QString M_Line_2= Props.at(1)->Value; QString M_Line_3= Props.at(2)->Value; @@ -126,3 +128,8 @@ QString NMOS_SPICE::spice_netlist(bool) return s; } + +QString NMOS_SPICE::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/NMOS_SPICE.h b/qucs/spicecomponents/NMOS_SPICE.h index 745470a4..debf3cf9 100644 --- a/qucs/spicecomponents/NMOS_SPICE.h +++ b/qucs/spicecomponents/NMOS_SPICE.h @@ -29,9 +29,11 @@ class NMOS_SPICE : public Component { ~NMOS_SPICE(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // NMOS_SPICE_H diff --git a/qucs/spicecomponents/NPN_SPICE.cpp b/qucs/spicecomponents/NPN_SPICE.cpp index d2dea4ff..da10f3cb 100644 --- a/qucs/spicecomponents/NPN_SPICE.cpp +++ b/qucs/spicecomponents/NPN_SPICE.cpp @@ -29,25 +29,25 @@ NPN_SPICE::NPN_SPICE() Simulator = spicecompat::simSpice; Lines.append(new qucs::Line(-10,-15,-10, 15,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line(-30, 0,-20, 0,QPen(Qt::darkBlue,3))); Lines.append(new qucs::Line(-20, 0,-10, 0,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line(-10, -5, 0,-15,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line( 0,-15, 0,-20,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0,-20, 0,-30,QPen(Qt::darkBlue,3))); - + Lines.append(new qucs::Line(-10, 5, 0, 15,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line( 0, 15, 0, 20,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 20, 0, 30,QPen(Qt::darkBlue,3))); Lines.append(new qucs::Line( -6, 15, 0, 15,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 9, 0, 15,QPen(Qt::darkRed,3))); - + Texts.append(new Text(30,12,"NPN",Qt::darkRed,10.0,0.0,-1.0)); - + Ports.append(new Port(0, -30)); Ports.append(new Port(-30, 0)); @@ -94,15 +94,17 @@ QString NPN_SPICE::netlist() return QString(); } -QString NPN_SPICE::spice_netlist(bool) +QString NPN_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString Q= Props.at(0)->Value; QString Q_Line_2= Props.at(1)->Value; QString Q_Line_3= Props.at(2)->Value; @@ -118,3 +120,8 @@ QString NPN_SPICE::spice_netlist(bool) return s; } + +QString NPN_SPICE::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/NPN_SPICE.h b/qucs/spicecomponents/NPN_SPICE.h index 19b6c863..88d1d509 100644 --- a/qucs/spicecomponents/NPN_SPICE.h +++ b/qucs/spicecomponents/NPN_SPICE.h @@ -29,9 +29,11 @@ class NPN_SPICE : public Component { ~NPN_SPICE(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // NPN_SPICE_H diff --git a/qucs/spicecomponents/PJF_SPICE.cpp b/qucs/spicecomponents/PJF_SPICE.cpp index 63125830..bf4fd9d5 100644 --- a/qucs/spicecomponents/PJF_SPICE.cpp +++ b/qucs/spicecomponents/PJF_SPICE.cpp @@ -29,25 +29,25 @@ PJF_SPICE::PJF_SPICE() Simulator = spicecompat::simSpice; Lines.append(new qucs::Line(-10,-15,-10, 15,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line(-30, 0,-20, 0,QPen(Qt::darkBlue,3))); - Lines.append(new qucs::Line(-20, 0,-10, 0,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line(-20, 0,-10, 0,QPen(Qt::darkRed,3))); + Lines.append(new qucs::Line(-10,-10, 0,-10,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0,-10, 0,-20,QPen(Qt::darkRed,3))); - Lines.append(new qucs::Line( 0,-20, 0,-30,QPen(Qt::darkBlue,3))); - + Lines.append(new qucs::Line( 0,-20, 0,-30,QPen(Qt::darkBlue,3))); + Lines.append(new qucs::Line(-10, 10, 0, 10,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 10, 0, 20,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 20, 0, 30,QPen(Qt::darkBlue,3))); - + Lines.append(new qucs::Line(-16, -5,-21, 0,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line(-16, 5,-21, 0,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( -4, 24, 4, 20,QPen(Qt::darkRed,2))); - + //Texts.append(new Text(30,12,"PJF",Qt::darkRed,10.0,0.0,-1.0)); - + Ports.append(new Port( 0,-30)); //D Ports.append(new Port(-30, 0)); //G Ports.append(new Port( 0, 30)); //S @@ -93,15 +93,17 @@ QString PJF_SPICE::netlist() return QString(); } -QString PJF_SPICE::spice_netlist(bool) +QString PJF_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString J= Props.at(0)->Value; QString J_Line_2= Props.at(1)->Value; QString J_Line_3= Props.at(2)->Value; @@ -117,3 +119,8 @@ QString PJF_SPICE::spice_netlist(bool) return s; } + +QString PJF_SPICE::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/PJF_SPICE.h b/qucs/spicecomponents/PJF_SPICE.h index 327667a0..ba43bd36 100644 --- a/qucs/spicecomponents/PJF_SPICE.h +++ b/qucs/spicecomponents/PJF_SPICE.h @@ -29,9 +29,11 @@ class PJF_SPICE : public Component { ~PJF_SPICE(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // PJF_SPICE_H diff --git a/qucs/spicecomponents/PMF_MESFET_SPICE.cpp b/qucs/spicecomponents/PMF_MESFET_SPICE.cpp index 199975c9..4106e364 100644 --- a/qucs/spicecomponents/PMF_MESFET_SPICE.cpp +++ b/qucs/spicecomponents/PMF_MESFET_SPICE.cpp @@ -33,14 +33,14 @@ PMF_MESFET_SPICE::PMF_MESFET_SPICE() Lines.append(new qucs::Line(-10,-10, 0,-10,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0,-10, 0,-20,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0,-20, 0,-30,QPen(Qt::darkBlue,3))); - + Lines.append(new qucs::Line(-10, 10, 0, 10,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 10, 0, 20,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 20, 0, 30,QPen(Qt::darkBlue,3))); Lines.append(new qucs::Line( -4, 24, 4, 20,QPen(Qt::darkRed,2))); Texts.append(new Text(30,12,"PMF",Qt::darkRed,10.0,0.0,-1.0)); - + Ports.append(new Port( 0,-30)); Ports.append(new Port(-30, 0)); Ports.append(new Port( 0, 30)); @@ -67,7 +67,7 @@ PMF_MESFET_SPICE::~PMF_MESFET_SPICE() { } -Component* PMF_MESFET_SPICE::newOne() +Component* PMF_MESFET_SPICE::newOne() { return new PMF_MESFET_SPICE(); } @@ -86,15 +86,17 @@ QString PMF_MESFET_SPICE::netlist() return QString(); } -QString PMF_MESFET_SPICE::spice_netlist(bool) +QString PMF_MESFET_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString Z= Props.at(0)->Value; QString Z_Line_2= Props.at(1)->Value; QString Z_Line_3= Props.at(2)->Value; diff --git a/qucs/spicecomponents/PMF_MESFET_SPICE.h b/qucs/spicecomponents/PMF_MESFET_SPICE.h index eab184b0..3bd455e6 100644 --- a/qucs/spicecomponents/PMF_MESFET_SPICE.h +++ b/qucs/spicecomponents/PMF_MESFET_SPICE.h @@ -31,7 +31,7 @@ class PMF_MESFET_SPICE : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // PMF_MESFET_SPICE_H diff --git a/qucs/spicecomponents/PMOS_SPICE.cpp b/qucs/spicecomponents/PMOS_SPICE.cpp index 039d4928..f568a5a2 100644 --- a/qucs/spicecomponents/PMOS_SPICE.cpp +++ b/qucs/spicecomponents/PMOS_SPICE.cpp @@ -32,7 +32,7 @@ PMOS_SPICE::PMOS_SPICE() Lines.append(new qucs::Line(-30, 0,-20, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line(-20, 0,-14, 0,QPen(Qt::darkRed,2))); - + Lines.append(new qucs::Line(-10,-11, 0,-11,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( 0,-11, 0,-20,QPen(Qt::darkRed,2))); @@ -41,21 +41,21 @@ PMOS_SPICE::PMOS_SPICE() Lines.append(new qucs::Line(-10, 11, 0, 11,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( 0, 11, 0, 20,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( 0, 20, 0, 30,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line(-10, 0, 10, 0,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( 10, 0, 20, 0,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line(-10,-16,-10, -7,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line(-10, 7,-10, 16,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( -1, 0, -6, -5,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( -1, 0, -6, 5,QPen(Qt::darkRed,2))); - + Lines.append(new qucs::Line(-10, -8,-10, 8,QPen(Qt::darkRed,2))); Lines.append(new qucs::Line( -4, 24, 4, 20,QPen(Qt::darkRed,2))); - + //Texts.append(new Text(30,12,"PMOS",Qt::darkRed,10.0,0.0,-1.0)); - + Ports.append(new Port( 0,-30)); //D Ports.append(new Port(-30, 0)); //G Ports.append(new Port( 0, 30)); //S @@ -102,15 +102,17 @@ QString PMOS_SPICE::netlist() return QString(); } -QString PMOS_SPICE::spice_netlist(bool) +QString PMOS_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString M= Props.at(0)->Value; QString M_Line_2= Props.at(1)->Value; QString M_Line_3= Props.at(2)->Value; @@ -126,3 +128,8 @@ QString PMOS_SPICE::spice_netlist(bool) return s; } + +QString PMOS_SPICE::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/PMOS_SPICE.h b/qucs/spicecomponents/PMOS_SPICE.h index 776dfce2..ada80ed0 100644 --- a/qucs/spicecomponents/PMOS_SPICE.h +++ b/qucs/spicecomponents/PMOS_SPICE.h @@ -29,9 +29,11 @@ class PMOS_SPICE : public Component { ~PMOS_SPICE(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // PMOS_SPICE_H diff --git a/qucs/spicecomponents/PNP_SPICE.cpp b/qucs/spicecomponents/PNP_SPICE.cpp index 01ac56cd..1916494e 100644 --- a/qucs/spicecomponents/PNP_SPICE.cpp +++ b/qucs/spicecomponents/PNP_SPICE.cpp @@ -29,27 +29,27 @@ PNP_SPICE::PNP_SPICE() Simulator = spicecompat::simSpice; Lines.append(new qucs::Line(-10,-15,-10, 15,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line(-30, 0,-20, 0,QPen(Qt::darkBlue,3))); Lines.append(new qucs::Line(-20, 0,-10, 0,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line(-10, -5, 0,-15,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line( 0,-15, 0,-20,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0,-20, 0,-30,QPen(Qt::darkBlue,3))); - + Lines.append(new qucs::Line(-10, 5, 0, 15,QPen(Qt::darkRed,3))); - + Lines.append(new qucs::Line( 0, 15, 0, 20,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( 0, 20, 0, 30,QPen(Qt::darkBlue,3))); - + Lines.append(new qucs::Line( -5, 10, -5, 16,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( -5, 10, 1, 10,QPen(Qt::darkRed,3))); - + Texts.append(new Text(30,12,"PNP",Qt::darkRed,10.0,0.0,-1.0)); - + Ports.append(new Port( 0,-30)); Ports.append(new Port(-30, 0)); Ports.append(new Port( 0, 30)); @@ -95,15 +95,17 @@ QString PNP_SPICE::netlist() return QString(); } -QString PNP_SPICE::spice_netlist(bool) +QString PNP_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString Q= Props.at(0)->Value; QString Q_Line_2= Props.at(1)->Value; QString Q_Line_3= Props.at(2)->Value; @@ -119,3 +121,8 @@ QString PNP_SPICE::spice_netlist(bool) return s; } + +QString PNP_SPICE::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/PNP_SPICE.h b/qucs/spicecomponents/PNP_SPICE.h index 752cab2b..50a32596 100644 --- a/qucs/spicecomponents/PNP_SPICE.h +++ b/qucs/spicecomponents/PNP_SPICE.h @@ -29,9 +29,11 @@ class PNP_SPICE : public Component { ~PNP_SPICE(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // PNP_SPICE_H diff --git a/qucs/spicecomponents/R_SPICE.cpp b/qucs/spicecomponents/R_SPICE.cpp index 18be43c8..ff7351c5 100644 --- a/qucs/spicecomponents/R_SPICE.cpp +++ b/qucs/spicecomponents/R_SPICE.cpp @@ -113,8 +113,10 @@ QString R_SPICE::netlist() return QString(); } -QString R_SPICE::spice_netlist(bool) +QString R_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString ltr = getProperty("Letter")->Value; QString s = spicecompat::check_refdes(Name,ltr); for (Port *p1 : Ports) { @@ -138,3 +140,13 @@ QString R_SPICE::spice_netlist(bool) return s; } + +QString R_SPICE::cdl_netlist() +{ + if (Ports.size() == 2) + { + return spice_netlist(spicecompat::CDL); + } + + return QString(); +} diff --git a/qucs/spicecomponents/R_SPICE.h b/qucs/spicecomponents/R_SPICE.h index 1ad0538c..c196366a 100644 --- a/qucs/spicecomponents/R_SPICE.h +++ b/qucs/spicecomponents/R_SPICE.h @@ -30,10 +30,12 @@ class R_SPICE : public MultiViewComponent { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); static Element* info_R3(QString&, char* &, bool getNewOne=false); + protected: void createSymbol(); QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif // R_SPICE_H diff --git a/qucs/spicecomponents/S4Q_I.cpp b/qucs/spicecomponents/S4Q_I.cpp index 3d8f7517..7d65a538 100644 --- a/qucs/spicecomponents/S4Q_I.cpp +++ b/qucs/spicecomponents/S4Q_I.cpp @@ -4,7 +4,6 @@ begin : Thu May 21 2015 copyright : (C) 2015 by Vadim Kuznetsov email : ra3xdh@gmail.com - SPICE Version : Friday Sept 11 2015 copyright : (C) 2015 Mike Brinson email : mbrin72043@yahoo.co.uk @@ -37,8 +36,8 @@ S4Q_I::S4Q_I() Lines.append(new qucs::Line( -8, 0, 8, 0,QPen(Qt::darkRed,3, Qt::SolidLine, Qt::FlatCap))); Lines.append(new qucs::Line( -8, 0, -4, -4,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( -8, 0, -4, 4,QPen(Qt::darkRed,3))); - - Ports.append(new Port( 30, 0)); + + Ports.append(new Port( 30, 0)); Ports.append(new Port(-30, 0)); x1 = -30; y1 = -14; @@ -77,8 +76,10 @@ Element* S4Q_I::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString S4Q_I::spice_netlist(bool) +QString S4Q_I::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -101,3 +102,8 @@ QString S4Q_I::spice_netlist(bool) return s; } + +QString S4Q_I::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/S4Q_I.h b/qucs/spicecomponents/S4Q_I.h index 6204faf3..584f72b3 100644 --- a/qucs/spicecomponents/S4Q_I.h +++ b/qucs/spicecomponents/S4Q_I.h @@ -4,7 +4,6 @@ begin : Thu May 21 2015 copyright : (C) 2015 by Vadim Kuznetsov email : ra3xdh@gmail.com - SPICE Version : Friday Sept 11 2015 copyright : (C) 2015 Mike Brinson email : mbrin72043@yahoo.co.uk @@ -31,8 +30,10 @@ class S4Q_I : public Component { ~S4Q_I(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/spicecomponents/S4Q_Ieqndef.cpp b/qucs/spicecomponents/S4Q_Ieqndef.cpp index 0ca34c71..8f5d7799 100644 --- a/qucs/spicecomponents/S4Q_Ieqndef.cpp +++ b/qucs/spicecomponents/S4Q_Ieqndef.cpp @@ -4,7 +4,7 @@ begin : 13 September 2015 copyright : (C) 2015 by Vadim Kaznetsov and Mike Brinson email : ra3xdh@gmil.co and mbrin72043@yahoo.co.uk - + ***************************************************************************/ /*************************************************************************** @@ -29,14 +29,14 @@ S4Q_Ieqndef::S4Q_Ieqndef() // pins Lines.append(new qucs::Line(-30, 0,-14, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 30, 0, 14, 0,QPen(Qt::darkBlue,2))); - + // arrow Lines.append(new qucs::Line( -8, 0, 8, 0,QPen(Qt::darkRed,3, Qt::SolidLine, Qt::FlatCap))); Lines.append(new qucs::Line( -8, 0, -4, -4,QPen(Qt::darkRed,3))); Lines.append(new qucs::Line( -8, 0, -4, 4,QPen(Qt::darkRed,3))); - + Texts.append(new Text(25,-30,"Eqn",Qt::darkRed,12.0,0.0,-1.0)); - + Ports.append(new Port( 30, 0)); Ports.append(new Port(-30, 0)); @@ -49,7 +49,7 @@ S4Q_Ieqndef::S4Q_Ieqndef() Model = "S4Q_Ieqndef"; SpiceModel = "B"; Name = "B"; - + Props.append(new Property("I", "", true,"B(I) specification.")); Props.append(new Property("Line_2", "", false,"+ continuation line 1")); Props.append(new Property("Line_3", "", false,"+ continuation line 2")); @@ -86,15 +86,17 @@ QString S4Q_Ieqndef::netlist() return QString(); } -QString S4Q_Ieqndef::spice_netlist(bool) +QString S4Q_Ieqndef::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam + " "; // node names } - + QString VI = Props.at(0)-> Name; QString VI2 = Props.at(0)->Value; QString Line_2 = Props.at(1)->Value; diff --git a/qucs/spicecomponents/S4Q_Ieqndef.h b/qucs/spicecomponents/S4Q_Ieqndef.h index 4bbf23d7..97c58595 100644 --- a/qucs/spicecomponents/S4Q_Ieqndef.h +++ b/qucs/spicecomponents/S4Q_Ieqndef.h @@ -11,7 +11,7 @@ class S4Q_Ieqndef : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString va_code(); }; diff --git a/qucs/spicecomponents/S4Q_S.cpp b/qucs/spicecomponents/S4Q_S.cpp index f3228cc5..004cda1d 100644 --- a/qucs/spicecomponents/S4Q_S.cpp +++ b/qucs/spicecomponents/S4Q_S.cpp @@ -39,11 +39,11 @@ S4Q_S::S4Q_S() Lines.append(new qucs::Line( 5, 0, 0, 8,QPen(Qt::darkRed,3, Qt::SolidLine, Qt::FlatCap))); Lines.append(new qucs::Line(-10, -30, -10, -15,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 10, -30, 10, -15,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line(22, -20, 18, -20,QPen(Qt::red,2))); Lines.append(new qucs::Line(20, -22, 20,-18,QPen(Qt::red,2))); Lines.append(new qucs::Line(-20, -22, -20,-18,QPen(Qt::black,2))); - + Ports.append(new Port(-30, 0)); // Ps+ Ports.append(new Port( 30, 0)); // Ps- Ports.append(new Port( 10,-30)); // Pc+ @@ -93,8 +93,10 @@ Element* S4Q_S::info(QString& Name, char* &BitmapFile, bool getNewOne) // return QString(); //} -QString S4Q_S::spice_netlist(bool) +QString S4Q_S::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; diff --git a/qucs/spicecomponents/S4Q_S.h b/qucs/spicecomponents/S4Q_S.h index 350afe38..d8a4d506 100644 --- a/qucs/spicecomponents/S4Q_S.h +++ b/qucs/spicecomponents/S4Q_S.h @@ -32,7 +32,7 @@ class S4Q_S : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/S4Q_V.cpp b/qucs/spicecomponents/S4Q_V.cpp index 2ac06074..a2f2046c 100644 --- a/qucs/spicecomponents/S4Q_V.cpp +++ b/qucs/spicecomponents/S4Q_V.cpp @@ -4,7 +4,6 @@ begin : Thu May 21 2015 copyright : (C) 2015 by Vadim Kuznetsov email : ra3xdh@gmail.com - SPICE Version : Friday Sept 11 2015 copyright : (C) 2015 Mike Brinson email : mbrin72043@yahoo.co.uk @@ -33,7 +32,7 @@ S4Q_V::S4Q_V() Lines.append(new qucs::Line(-30, 0,-12, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 30, 0, 12, 0,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line( 18, 5, 18, 11,QPen(Qt::red,2))); Lines.append(new qucs::Line( 21, 8, 15, 8,QPen(Qt::red,2))); Lines.append(new qucs::Line(-18, 5,-18, 11,QPen(Qt::black,2))); @@ -77,8 +76,10 @@ Element* S4Q_V::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString S4Q_V::spice_netlist(bool) +QString S4Q_V::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -101,3 +102,8 @@ QString S4Q_V::spice_netlist(bool) return s; } + +QString S4Q_V::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/S4Q_V.h b/qucs/spicecomponents/S4Q_V.h index 2c705eec..7fd1e537 100644 --- a/qucs/spicecomponents/S4Q_V.h +++ b/qucs/spicecomponents/S4Q_V.h @@ -4,7 +4,6 @@ begin : Thu May 21 2015 copyright : (C) 2015 by Vadim Kuznetsov email : ra3xdh@gmail.com - SPICE Version : Friday Sept 11 2015 copyright : (C) 2015 Mike Brinson email : mbrin72043@yahoo.co.uk @@ -31,8 +30,10 @@ class S4Q_V : public Component { ~S4Q_V(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/spicecomponents/S4Q_W.cpp b/qucs/spicecomponents/S4Q_W.cpp index 2b99a77f..db6fa4f3 100644 --- a/qucs/spicecomponents/S4Q_W.cpp +++ b/qucs/spicecomponents/S4Q_W.cpp @@ -81,8 +81,10 @@ Element* S4Q_W::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString S4Q_W::spice_netlist(bool) +QString S4Q_W::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; diff --git a/qucs/spicecomponents/S4Q_W.h b/qucs/spicecomponents/S4Q_W.h index 7c49d767..7115b0fc 100644 --- a/qucs/spicecomponents/S4Q_W.h +++ b/qucs/spicecomponents/S4Q_W.h @@ -4,7 +4,7 @@ begin : Thu May 21 2015 copyright : (C) 2015 by Vadim Kuznetsov email : ra3xdh@gmail.com - + SPICE Version : Wednesday Sept 16 2015 copyright : (C) 2015 Mike Brinson email : mbrin72043@yahoo.co.uk @@ -32,7 +32,7 @@ class S4Q_W : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/SDTF.cpp b/qucs/spicecomponents/SDTF.cpp index 94109959..fdbcd998 100644 --- a/qucs/spicecomponents/SDTF.cpp +++ b/qucs/spicecomponents/SDTF.cpp @@ -29,15 +29,15 @@ SDTF::SDTF() Lines.append(new qucs::Line(-80, 0,-70, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 80, 0, 70, 0,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line( -70, 35, -70, -35,QPen(Qt::blue,3))); Lines.append(new qucs::Line( -70, -35, 70, -35,QPen(Qt::blue,3))); - Lines.append(new qucs::Line( 70, -35, 70, 35,QPen(Qt::blue,3))); - Lines.append(new qucs::Line( 70, 35, -70, 35,QPen(Qt::blue,3))); - + Lines.append(new qucs::Line( 70, -35, 70, 35,QPen(Qt::blue,3))); + Lines.append(new qucs::Line( 70, 35, -70, 35,QPen(Qt::blue,3))); + Texts.append(new Text( -60, -25," S Domain ",Qt::blue,12.0,1.0,0)); Texts.append(new Text( -60, 5,"Transfer Function",Qt::blue,12.0,1.0,0)); - + Ports.append(new Port( -80, 0)); // PIn Ports.append(new Port( 80, 0)); // POut @@ -49,14 +49,14 @@ SDTF::SDTF() Model = "SDTF"; SpiceModel = "A"; Name = "SDTF"; - + Props.append(new Property("A", " A_XSDFTmod", true,"Parameter list and\n .model spec.")); Props.append(new Property("A_Line 2", ".MODEL A_XSDFTmod s_xfer ( gain=1.0", false,".model line")); Props.append(new Property("A_Line 3", "+ num_coeff=[1.0]", false,".model line")); Props.append(new Property("A_Line 4", "+ den_coeff=[1.0 1.09775 1.0]", false,".model line")); Props.append(new Property("A_Line 5", "+ int_ic=[0 0 0]", false,".model line")); - Props.append(new Property("A_Line 6", "+ denormalized_freq=1500.0 )", false,".model line")); - Props.append(new Property("A_Line 7", "", false,".model line")); + Props.append(new Property("A_Line 6", "+ denormalized_freq=1500.0 )", false,".model line")); + Props.append(new Property("A_Line 7", "", false,".model line")); } @@ -72,7 +72,7 @@ Component* SDTF::newOne() Element* SDTF::info(QString& Name, char* &BitmapFile, bool getNewOne) { Name = QObject::tr("SDTF"); - BitmapFile = (char *) "SDTF"; + BitmapFile = (char *) "SDTF"; if(getNewOne) return new SDTF(); return 0; @@ -83,24 +83,25 @@ QString SDTF::netlist() return QString(); } -QString SDTF::spice_netlist(bool) +QString SDTF::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); QString P1 = Ports.at(0)->Connection->Name; if (P1=="gnd") P1 = "0"; QString P2 = Ports.at(1)->Connection->Name; if (P2=="gnd") P2 = "0"; s += " " + P1 + " " + P2 + " "; - + QString A = Props.at(0)->Value; QString A_Line_2 = Props.at(1)->Value; - QString A_Line_3 = Props.at(2)->Value; - QString A_Line_4 = Props.at(3)->Value; + QString A_Line_3 = Props.at(2)->Value; + QString A_Line_4 = Props.at(3)->Value; QString A_Line_5 = Props.at(4)->Value; QString A_Line_6 = Props.at(5)->Value; - QString A_Line_7 = Props.at(6)->Value; - + QString A_Line_7 = Props.at(6)->Value; + if( A.length() > 0) s += QStringLiteral("%1").arg(A); if( A_Line_2.length() > 0 ) s += QStringLiteral("\n%1").arg(A_Line_2); if( A_Line_3.length() > 0 ) s += QStringLiteral("\n%1").arg(A_Line_3); diff --git a/qucs/spicecomponents/SDTF.h b/qucs/spicecomponents/SDTF.h index 14f161ce..5f5c086a 100644 --- a/qucs/spicecomponents/SDTF.h +++ b/qucs/spicecomponents/SDTF.h @@ -31,7 +31,7 @@ class SDTF: public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // SDTF_H diff --git a/qucs/spicecomponents/UDRCTL_SPICE.cpp b/qucs/spicecomponents/UDRCTL_SPICE.cpp index 49eccd85..0099ec6a 100644 --- a/qucs/spicecomponents/UDRCTL_SPICE.cpp +++ b/qucs/spicecomponents/UDRCTL_SPICE.cpp @@ -28,12 +28,11 @@ UDRCTL_SPICE::UDRCTL_SPICE() Description = QObject::tr("SPICE U(URC):\nMultiple line ngspice or Xyce U specifications allowed using \"+\" continuation lines.\nLeave continuation lines blank when NOT in use."); Simulator = spicecompat::simSpice; - - Lines.append(new qucs::Line( -60, 0, -45, 0,QPen(Qt::darkBlue,2))); + Lines.append(new qucs::Line( -60, 0, -45, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( -45, 20, 45, 20,QPen(Qt::blue,4))); - Lines.append(new qucs::Line( 60, 0, 45, 0,QPen(Qt::darkBlue,2))); - Lines.append(new qucs::Line( 0, 20, 0, 40,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line( 60, 0, 45, 0,QPen(Qt::darkBlue,2))); + Lines.append(new qucs::Line( 0, 20, 0, 40,QPen(Qt::darkBlue,2))); + Lines.append(new qucs::Line(-45, 0, -37, 0,QPen(Qt::blue,4))); Lines.append(new qucs::Line(-37, 0, -30, -10,QPen(Qt::blue,4))); Lines.append(new qucs::Line(-30, -10, -15, 10,QPen(Qt::blue,4))); @@ -43,9 +42,6 @@ UDRCTL_SPICE::UDRCTL_SPICE() Lines.append(new qucs::Line( 30, -10, 37, 0,QPen(Qt::blue,4))); Lines.append(new qucs::Line( 37, 0, 45, 0,QPen(Qt::blue,4))); - - - Ports.append(new Port( -60, 0)); // P1 Ports.append(new Port( 60, 0)); // P2 Ports.append(new Port( 0, 40)); // P3 @@ -92,15 +88,17 @@ QString UDRCTL_SPICE::netlist() return QString(); } -QString UDRCTL_SPICE::spice_netlist(bool) +QString UDRCTL_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } - + QString U= Props.at(0)->Value; QString U_Line_2= Props.at(1)->Value; QString U_Line_3= Props.at(2)->Value; diff --git a/qucs/spicecomponents/UDRCTL_SPICE.h b/qucs/spicecomponents/UDRCTL_SPICE.h index 0aa6ba64..e02e7efc 100644 --- a/qucs/spicecomponents/UDRCTL_SPICE.h +++ b/qucs/spicecomponents/UDRCTL_SPICE.h @@ -5,7 +5,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * */ #ifndef UDRCTL_SPICE_H @@ -14,15 +14,15 @@ #include "components/component.h" class UDRCTL_SPICE : public Component { - public: +public: UDRCTL_SPICE(); ~UDRCTL_SPICE(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - protected: -// void createSymbol(); + +protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif /* UDRCTL_SPICE_H */ diff --git a/qucs/spicecomponents/XAPWL.cpp b/qucs/spicecomponents/XAPWL.cpp index bb346f2b..3c0e4825 100644 --- a/qucs/spicecomponents/XAPWL.cpp +++ b/qucs/spicecomponents/XAPWL.cpp @@ -26,18 +26,17 @@ XAPWL::XAPWL() Description = QObject::tr("PWL controlled voltage source:\nSeven line XSPICE specification. "); Simulator = spicecompat::simSpice; - Lines.append(new qucs::Line(-80, 0,-70, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 80, 0, 70, 0,QPen(Qt::darkBlue,2))); - + Lines.append(new qucs::Line( -70, 35, -70, -35,QPen(Qt::blue,3))); Lines.append(new qucs::Line( -70, -35, 70, -35,QPen(Qt::blue,3))); - Lines.append(new qucs::Line( 70, -35, 70, 35,QPen(Qt::blue,3))); - Lines.append(new qucs::Line( 70, 35, -70, 35,QPen(Qt::blue,3))); - + Lines.append(new qucs::Line( 70, -35, 70, 35,QPen(Qt::blue,3))); + Lines.append(new qucs::Line( 70, 35, -70, 35,QPen(Qt::blue,3))); + Texts.append(new Text( -60, -25," PWL controlled ",Qt::blue,12.0,1.0,0)); Texts.append(new Text( -60, 5," voltage source ",Qt::blue,12.0,1.0,0)); - + Ports.append(new Port( -80, 0)); // PIn Ports.append(new Port( 80, 0)); // POut @@ -49,15 +48,14 @@ XAPWL::XAPWL() Model = "XAPWL"; SpiceModel = "A"; Name = "XAPWL"; - + Props.append(new Property("A", " A_PWLmod", true,"Parameter list and\n .model spec.")); Props.append(new Property("A_Line 2", ".MODEL A_PWLmod pwl ( ", false,".model line")); Props.append(new Property("A_Line 3", "+ x_array=[-2.0 -1.0 2.0 4.0 5.0]", false,".model line")); Props.append(new Property("A_Line 4", "+ y_array=[-2.0 -0.2 0.1 2.0 10.0]", false,".model line")); Props.append(new Property("A_Line 5", "+ input_domain=0.05", false,".model line")); - Props.append(new Property("A_Line 6", "+ fraction=TRUE )", false,".model line")); - Props.append(new Property("A_Line 7", "", false,".model line")); - + Props.append(new Property("A_Line 6", "+ fraction=TRUE )", false,".model line")); + Props.append(new Property("A_Line 7", "", false,".model line")); } XAPWL::~XAPWL() @@ -72,7 +70,7 @@ Component* XAPWL::newOne() Element* XAPWL::info(QString& Name, char* &BitmapFile, bool getNewOne) { Name = QObject::tr("XAPWL"); - BitmapFile = (char *) "XAPWL"; + BitmapFile = (char *) "XAPWL"; if(getNewOne) return new XAPWL(); return 0; @@ -83,24 +81,25 @@ QString XAPWL::netlist() return QString(); } -QString XAPWL::spice_netlist(bool) +QString XAPWL::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); QString P1 = Ports.at(0)->Connection->Name; if (P1=="gnd") P1 = "0"; QString P2 = Ports.at(1)->Connection->Name; if (P2=="gnd") P2 = "0"; s += " " + P1 + " " + P2 + " "; - + QString A = Props.at(0)->Value; QString A_Line_2 = Props.at(1)->Value; - QString A_Line_3 = Props.at(2)->Value; - QString A_Line_4 = Props.at(3)->Value; + QString A_Line_3 = Props.at(2)->Value; + QString A_Line_4 = Props.at(3)->Value; QString A_Line_5 = Props.at(4)->Value; QString A_Line_6 = Props.at(5)->Value; - QString A_Line_7 = Props.at(6)->Value; - + QString A_Line_7 = Props.at(6)->Value; + if( A.length() > 0) s += QStringLiteral("%1").arg(A); if( A_Line_2.length() > 0 ) s += QStringLiteral("\n%1").arg(A_Line_2); if( A_Line_3.length() > 0 ) s += QStringLiteral("\n%1").arg(A_Line_3); diff --git a/qucs/spicecomponents/XAPWL.h b/qucs/spicecomponents/XAPWL.h index 8247b6e0..03675b4f 100644 --- a/qucs/spicecomponents/XAPWL.h +++ b/qucs/spicecomponents/XAPWL.h @@ -31,7 +31,7 @@ class XAPWL: public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // XAPWL_H diff --git a/qucs/spicecomponents/core.cpp b/qucs/spicecomponents/core.cpp index 6b09b29f..099fe54c 100644 --- a/qucs/spicecomponents/core.cpp +++ b/qucs/spicecomponents/core.cpp @@ -3,7 +3,7 @@ -------------------------------------- begin : Sun 22 Nov 2015 copyright : (C) by Mike Brinson (mbrin72043@yahoo.co.uk), - : Vadim Kuznetsov (ra3xdh@gmail.com) + : Vadim Kuznetsov (ra3xdh@gmail.com) ***************************************************************************/ @@ -27,23 +27,22 @@ core::core() Simulator = spicecompat::simSpice; Lines.append(new qucs::Line(-40, 0, -30, 0,QPen(Qt::darkBlue,2))); // L1 - Lines.append(new qucs::Line(-30, -15, 30, -15,QPen(Qt::blue,3))); // L2 - Lines.append(new qucs::Line( 30, -15, 30, 15,QPen(Qt::blue,3))); // L3 - Lines.append(new qucs::Line( 30, 15, -30, 15,QPen(Qt::blue,3))); // L4 - Lines.append(new qucs::Line(-30, 15, -30, -15,QPen(Qt::blue,3))); // L5 - + Lines.append(new qucs::Line(-30, -15, 30, -15,QPen(Qt::blue,3))); // L2 + Lines.append(new qucs::Line( 30, -15, 30, 15,QPen(Qt::blue,3))); // L3 + Lines.append(new qucs::Line( 30, 15, -30, 15,QPen(Qt::blue,3))); // L4 + Lines.append(new qucs::Line(-30, 15, -30, -15,QPen(Qt::blue,3))); // L5 Lines.append(new qucs::Line(-25, -5, 25, -5,QPen(Qt::black,3))); // L7 Lines.append(new qucs::Line(-25, 0, 25, 0,QPen(Qt::black,3))); // L8 Lines.append(new qucs::Line(-25, 5, 25, 5,QPen(Qt::black,3))); // L9 - - Lines.append(new qucs::Line(40, 0, 30, 0,QPen(Qt::darkBlue,2))); // L16 - - + + Lines.append(new qucs::Line(40, 0, 30, 0,QPen(Qt::darkBlue,2))); // L16 + + Lines.append(new qucs::Line( -40, -30, -40, -20,QPen(Qt::red,3))); // + Lines.append(new qucs::Line( -45, -25, -35, -25,QPen(Qt::red,3))); - Lines.append(new qucs::Line( 45, -25, 35, -25,QPen(Qt::black,3))); // - - + Lines.append(new qucs::Line( 45, -25, 35, -25,QPen(Qt::black,3))); // - + Ports.append(new Port( -40, 0)); // Pin Ports.append(new Port( 40, 0)); // Pout @@ -55,7 +54,7 @@ core::core() Model = "core"; SpiceModel = "A"; Name = "CORE"; - + Props.append(new Property("A ", "", true,"Parameter list and\n .model spec.")); Props.append(new Property("A_Line 2", "", false,".model line")); Props.append(new Property("A_Line 3", "", false,".model line")); @@ -79,7 +78,7 @@ Component* core::newOne() Element* core::info(QString& Name, char* &BitmapFile, bool getNewOne) { Name = QObject::tr("core"); - BitmapFile = (char *) "core"; + BitmapFile = (char *) "core"; if(getNewOne) return new core(); return 0; @@ -90,23 +89,24 @@ QString core::netlist() return QString(); } -QString core::spice_netlist(bool) +QString core::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); QString P1 = Ports.at(0)->Connection->Name; QString P2 = Ports.at(1)->Connection->Name; - - s += " " + P1 + " " + P2 + " "; - + s += " " + P1 + " " + P2 + " "; + QString A= Props.at(0)->Value; QString A_Line_2= Props.at(1)->Value; - QString A_Line_3= Props.at(2)->Value; + QString A_Line_3= Props.at(2)->Value; QString A_Line_4= Props.at(3)->Value; - QString A_Line_5= Props.at(4)->Value; + QString A_Line_5= Props.at(4)->Value; QString A_Line_6= Props.at(5)->Value; - QString A_Line_7= Props.at(6)->Value; + QString A_Line_7= Props.at(6)->Value; + if( A.length() > 0) s += QStringLiteral("%1\n").arg(A); if( A_Line_2.length() > 0 ) s += QStringLiteral("%1\n").arg(A_Line_2); if( A_Line_3.length() > 0 ) s += QStringLiteral("%1\n").arg(A_Line_3); @@ -114,6 +114,6 @@ QString core::spice_netlist(bool) if( A_Line_5.length() > 0 ) s += QStringLiteral("%1\n").arg(A_Line_5); if( A_Line_6.length() > 0 ) s += QStringLiteral("%1\n").arg(A_Line_6); if( A_Line_7.length() > 0 ) s += QStringLiteral("%1\n").arg(A_Line_7); - + return s; } diff --git a/qucs/spicecomponents/core.h b/qucs/spicecomponents/core.h index 97ad0403..9a685cde 100644 --- a/qucs/spicecomponents/core.h +++ b/qucs/spicecomponents/core.h @@ -31,7 +31,7 @@ class core: public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // core_H diff --git a/qucs/spicecomponents/eNL.cpp b/qucs/spicecomponents/eNL.cpp index b4e20db5..d6066b04 100644 --- a/qucs/spicecomponents/eNL.cpp +++ b/qucs/spicecomponents/eNL.cpp @@ -36,7 +36,7 @@ eNL::eNL() Lines.append(new qucs::Line( 18, -5, 18, -11,QPen(Qt::red,2))); Lines.append(new qucs::Line( 21, -8, 15, -8,QPen(Qt::red,2))); // minus sign - Lines.append(new qucs::Line(-18, -5,-18, -11,QPen(Qt::black,2))); + Lines.append(new qucs::Line(-18, -5,-18, -11,QPen(Qt::black,2))); Ports.append(new Port( 30, 0)); Ports.append(new Port(-30, 0)); @@ -55,7 +55,7 @@ eNL::eNL() Props.append(new Property("Line_3", "", false,"+ continuation line 2")); Props.append(new Property("Line_4", "", false,"+ continuation line 3")); Props.append(new Property("Line_5", "", false,"+ continuation line 4")); - + rotate(); // fix historical flaw } @@ -71,7 +71,7 @@ Component* eNL::newOne() Element* eNL::info(QString& Name, char* &BitmapFile, bool getNewOne) { Name = QObject::tr("E"); - BitmapFile = (char *) "eNL"; + BitmapFile = (char *) "eNL"; if(getNewOne) return new eNL(); return 0; @@ -82,26 +82,30 @@ QString eNL::netlist() return QString(); } -QString eNL::spice_netlist(bool) +QString eNL::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam+" "; // node names } + QString E = Props.at(0)->Value; - QString Line_2 = Props.at(1)->Value; + QString Line_2 = Props.at(1)->Value; QString Line_3 = Props.at(2)->Value; QString Line_4 = Props.at(3)->Value; QString Line_5 = Props.at(4)->Value; - if( E.length() > 0) s += QStringLiteral("%1").arg(E); if( Line_2.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_2); if( Line_3.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_3); if( Line_4.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_4); if( Line_5.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_5); + s += "\n"; + return s; } diff --git a/qucs/spicecomponents/eNL.h b/qucs/spicecomponents/eNL.h index c5ec3659..3b759884 100644 --- a/qucs/spicecomponents/eNL.h +++ b/qucs/spicecomponents/eNL.h @@ -28,7 +28,7 @@ class eNL : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // ENL_H diff --git a/qucs/spicecomponents/gNL.cpp b/qucs/spicecomponents/gNL.cpp index 7e811945..e9ce407c 100644 --- a/qucs/spicecomponents/gNL.cpp +++ b/qucs/spicecomponents/gNL.cpp @@ -1,9 +1,9 @@ /*************************************************************************** gNL.cpp - description -------------------------------------- - begin : Tue. Mar 31 2015 - copyright : (C) by Mike Brinson (mbrin72043@yahoo.co.uk), - Vadim Kuznetsov (ra3xdh@gmail.com) + begin : Tue. Mar 31 2015 + copyright : (C) by Mike Brinson (mbrin72043@yahoo.co.uk), + : Vadim Kuznetsov (ra3xdh@gmail.com) ***************************************************************************/ @@ -36,7 +36,7 @@ gNL::gNL() Lines.append(new qucs::Line( -7, 0, 6, 0,QPen(Qt::blue,3, Qt::SolidLine, Qt::FlatCap))); Polylines.append(new qucs::Polyline( std::vector{{0, -4},{6, 0}, {0, 4}}, QPen(Qt::blue, 3, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin))); - + Ports.append(new Port( 30, 0)); Ports.append(new Port(-30, 0)); @@ -54,7 +54,7 @@ gNL::gNL() Props.append(new Property("Line_3", "", false,"+ continuation line 2")); Props.append(new Property("Line_4", "", false,"+ continuation line 3")); Props.append(new Property("Line_5", "", false,"+ continuation line 4")); - + rotate(); // fix historical flaw } @@ -81,24 +81,26 @@ QString gNL::netlist() return QString(); } -QString gNL::spice_netlist(bool) +QString gNL::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); s += " " + spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); s += " " + spicecompat::normalize_node_name(Ports.at(0)->Connection->Name); QString G= Props.at(0)->Value; - QString Line_2 = Props.at(1)->Value; + QString Line_2 = Props.at(1)->Value; QString Line_3 = Props.at(2)->Value; QString Line_4 = Props.at(3)->Value; QString Line_5 = Props.at(4)->Value; - - + if( G.length() > 0 ) s += QStringLiteral(" %1").arg(G); if( Line_2.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_2); if( Line_3.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_3); if( Line_4.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_4); if( Line_5.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_5); + s += "\n"; - return s; + return s; } diff --git a/qucs/spicecomponents/gNL.h b/qucs/spicecomponents/gNL.h index 1b8f2a79..805a4709 100644 --- a/qucs/spicecomponents/gNL.h +++ b/qucs/spicecomponents/gNL.h @@ -3,19 +3,19 @@ -------------------------------------- begin : Tue Mar 31 2015 copyright : (C) by Mike Brinson (mbrin72043@yahoo.co.uk), - Vadim Kuznetsov (ra3xdh@gmail.com) + Vadim Kuznetsov (ra3xdh@gmail.com) ***************************************************************************/ /*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * ***************************************************************************/ - #ifndef GNL_H +#ifndef GNL_H #define GNL_H #include "components/component.h" @@ -28,7 +28,7 @@ class gNL : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // GNL_H diff --git a/qucs/spicecomponents/iAmpMod.cpp b/qucs/spicecomponents/iAmpMod.cpp index 25b2d4a5..7672fba5 100644 --- a/qucs/spicecomponents/iAmpMod.cpp +++ b/qucs/spicecomponents/iAmpMod.cpp @@ -30,16 +30,15 @@ iAmpMod::iAmpMod() // normal current source symbol Ellipses.append(new qucs::Ellips(-12,-12, 24, 24, QPen(Qt::blue,3))); - Texts.append(new Text(26, 6,"AM",Qt::blue,12.0,0.0,-1.0)); + Texts.append(new Text(26, 6,"AM",Qt::blue,12.0,0.0,-1.0)); // pins Lines.append(new qucs::Line(-30, 0,-12, 0,QPen(Qt::darkBlue,2))); Lines.append(new qucs::Line( 30, 0, 12, 0,QPen(Qt::darkBlue,2))); - // arrow + // arrow Lines.append(new qucs::Line( -6, 0, 7, 0,QPen(Qt::blue,3, Qt::SolidLine, Qt::FlatCap))); Polylines.append(new qucs::Polyline( std::vector{{0, -4},{-6, 0}, {0, 4}}, QPen(Qt::blue, 3, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin))); - Ports.append(new Port( 30, 0)); Ports.append(new Port(-30, 0)); @@ -89,8 +88,10 @@ QString iAmpMod::netlist() return QString(); } -QString iAmpMod::spice_netlist(bool) +QString iAmpMod::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -98,12 +99,11 @@ QString iAmpMod::spice_netlist(bool) s += " "+ nam; // node names } - QString Va= spicecompat::normalize_value(Props.at(0)->Value); - QString Vo= spicecompat::normalize_value(Props.at(1)->Value); - QString Mf= spicecompat::normalize_value(Props.at(2)->Value); - QString Fc = spicecompat::normalize_value(Props.at(3)->Value); - QString Td = spicecompat::normalize_value(Props.at(4)->Value); - + QString Va = spicecompat::normalize_value(Props.at(0)->Value); + QString Vo = spicecompat::normalize_value(Props.at(1)->Value); + QString Mf = spicecompat::normalize_value(Props.at(2)->Value); + QString Fc = spicecompat::normalize_value(Props.at(3)->Value); + QString Td = spicecompat::normalize_value(Props.at(4)->Value); s += QStringLiteral(" DC 0 AM(%1 %2 %3 %4 %5 ) AC 0\n").arg(Va).arg(Vo).arg(Mf).arg(Fc).arg(Td); return s; diff --git a/qucs/spicecomponents/iAmpMod.h b/qucs/spicecomponents/iAmpMod.h index eb4b3864..34fcde13 100644 --- a/qucs/spicecomponents/iAmpMod.h +++ b/qucs/spicecomponents/iAmpMod.h @@ -31,7 +31,7 @@ class iAmpMod : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // IAMPMOD_H diff --git a/qucs/spicecomponents/iPWL.cpp b/qucs/spicecomponents/iPWL.cpp index a808c872..d67f0b54 100644 --- a/qucs/spicecomponents/iPWL.cpp +++ b/qucs/spicecomponents/iPWL.cpp @@ -38,7 +38,6 @@ iPWL::iPWL() Lines.append(new qucs::Line( -7, 0, 6, 0,QPen(Qt::darkRed,3, Qt::SolidLine, Qt::FlatCap))); Polylines.append(new qucs::Polyline( std::vector{{0, -4},{6, 0}, {0, 4}}, QPen(Qt::darkRed, 3, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin))); - Ports.append(new Port( 30, 0)); Ports.append(new Port(-30, 0)); @@ -62,8 +61,7 @@ iPWL::iPWL() Props.append(new Property("Line_8", "", false,"+ continuation line 7")); Props.append(new Property("Line_9", "", false,"+ continuation line 8")); Props.append(new Property("Line_10", "", false,"+ continuation line 9")); - - + rotate(); // fix historical flaw } @@ -90,8 +88,10 @@ QString iPWL::netlist() return QString(); } -QString iPWL::spice_netlist(bool) +QString iPWL::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); s += " " + spicecompat::normalize_node_name(Ports.at(1)->Connection->Name); diff --git a/qucs/spicecomponents/iPWL.h b/qucs/spicecomponents/iPWL.h index ba3b9a48..37a3c20f 100644 --- a/qucs/spicecomponents/iPWL.h +++ b/qucs/spicecomponents/iPWL.h @@ -31,7 +31,7 @@ class iPWL : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // IPWL_H diff --git a/qucs/spicecomponents/iTRNOISE.cpp b/qucs/spicecomponents/iTRNOISE.cpp index a56800ef..1c01cb6d 100644 --- a/qucs/spicecomponents/iTRNOISE.cpp +++ b/qucs/spicecomponents/iTRNOISE.cpp @@ -44,7 +44,6 @@ iTRNOISE::iTRNOISE() Polylines.append(new qucs::Polyline( std::vector{{0, -4},{6, 0}, {0, 4}}, QPen(Qt::blue, 3, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin))); - Ports.append(new Port( 30, 0)); Ports.append(new Port(-30, 0)); @@ -98,8 +97,10 @@ QString iTRNOISE::netlist() return QString(); } -QString iTRNOISE::spice_netlist(bool) +QString iTRNOISE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -107,14 +108,13 @@ QString iTRNOISE::spice_netlist(bool) s += " "+ nam; // node names } - QString Na= spicecompat::normalize_value(Props.at(0)->Value); - QString Nt= spicecompat::normalize_value(Props.at(1)->Value); - QString Nalpha= spicecompat::normalize_value(Props.at(2)->Value); - QString Namp = spicecompat::normalize_value(Props.at(3)->Value); - QString Rtsam = spicecompat::normalize_value(Props.at(4)->Value); - QString Rtscapt = spicecompat::normalize_value(Props.at(4)->Value); - QString Rtsemt = spicecompat::normalize_value(Props.at(4)->Value); - + QString Na= spicecompat::normalize_value(Props.at(0)->Value); + QString Nt= spicecompat::normalize_value(Props.at(1)->Value); + QString Nalpha= spicecompat::normalize_value(Props.at(2)->Value); + QString Namp = spicecompat::normalize_value(Props.at(3)->Value); + QString Rtsam = spicecompat::normalize_value(Props.at(4)->Value); + QString Rtscapt = spicecompat::normalize_value(Props.at(4)->Value); + QString Rtsemt = spicecompat::normalize_value(Props.at(4)->Value); s += QStringLiteral(" DC 0 AC 0 TRNOISE(%1 %2 %3 %4 %5 %6 %7) \n").arg(Na).arg(Nt).arg(Nalpha).arg(Namp). arg(Rtsam).arg(Rtscapt).arg(Rtsemt); diff --git a/qucs/spicecomponents/iTRNOISE.h b/qucs/spicecomponents/iTRNOISE.h index deb62f99..2a25dff9 100644 --- a/qucs/spicecomponents/iTRNOISE.h +++ b/qucs/spicecomponents/iTRNOISE.h @@ -31,7 +31,7 @@ class iTRNOISE : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // ITRNOISE_H diff --git a/qucs/spicecomponents/incl_script.cpp b/qucs/spicecomponents/incl_script.cpp index cc589deb..54f79dad 100644 --- a/qucs/spicecomponents/incl_script.cpp +++ b/qucs/spicecomponents/incl_script.cpp @@ -77,9 +77,9 @@ Element* InclScript::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString InclScript::getExpression(bool) +QString InclScript::getExpression(bool, bool isCdl /* = false */) { - if (isActive != COMP_IS_ACTIVE) + if (isActive != COMP_IS_ACTIVE || isCdl) return QString(); return Props.at(0)->Value+"\n"; } diff --git a/qucs/spicecomponents/incl_script.h b/qucs/spicecomponents/incl_script.h index 41748c07..51d9466a 100644 --- a/qucs/spicecomponents/incl_script.h +++ b/qucs/spicecomponents/incl_script.h @@ -27,7 +27,7 @@ class InclScript : public Component { ~InclScript(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString getExpression(bool isXyce); + QString getExpression(bool isXyce, bool isCdl = false); protected: QString vhdlCode(int) { return QString(); } diff --git a/qucs/spicecomponents/isffm.cpp b/qucs/spicecomponents/isffm.cpp index 6415d5ee..d636aabf 100644 --- a/qucs/spicecomponents/isffm.cpp +++ b/qucs/spicecomponents/isffm.cpp @@ -29,7 +29,7 @@ iSffm::iSffm() Simulator = spicecompat::simSpice; // normal current source symbol - + Ellipses.append(new qucs::Ellips(-12,-12, 24, 24,QPen(Qt::darkRed,3))); Texts.append(new Text(26, 6,"SFFM",Qt::darkRed,12.0,0.0,-1.0)); // pins @@ -38,8 +38,10 @@ iSffm::iSffm() // arrow Lines.append(new qucs::Line( -6, 0, 7, 0,QPen(Qt::darkRed,3, Qt::SolidLine, Qt::FlatCap))); Polylines.append(new qucs::Polyline( - - std::vector{{0, -4},{-6, 0}, {0, 4}}, QPen(Qt::darkRed, 3, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin))); + std::vector{{0, -4},{-6, 0}, {0, 4}}, + QPen(Qt::darkRed, 3, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin) + ) + ); Ports.append(new Port( 30, 0)); Ports.append(new Port(-30, 0)); @@ -89,8 +91,10 @@ QString iSffm::netlist() return QString(); } -QString iSffm::spice_netlist(bool) +QString iSffm::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -98,12 +102,11 @@ QString iSffm::spice_netlist(bool) s += " "+ nam; // node names } - QString I0 = spicecompat::normalize_value(Props.at(0)->Value); - QString Ia = spicecompat::normalize_value(Props.at(1)->Value); - QString Fc = spicecompat::normalize_value(Props.at(2)->Value); - QString Mdi = spicecompat::normalize_value(Props.at(3)->Value); - QString Fs = spicecompat::normalize_value(Props.at(4)->Value); - + QString I0 = spicecompat::normalize_value(Props.at(0)->Value); + QString Ia = spicecompat::normalize_value(Props.at(1)->Value); + QString Fc = spicecompat::normalize_value(Props.at(2)->Value); + QString Mdi = spicecompat::normalize_value(Props.at(3)->Value); + QString Fs = spicecompat::normalize_value(Props.at(4)->Value); s += QStringLiteral(" DC 0 SFFM(%1 %2 %3 %4 %5 ) AC 0\n").arg(I0).arg(Ia).arg(Fc).arg(Mdi).arg(Fs); return s; diff --git a/qucs/spicecomponents/isffm.h b/qucs/spicecomponents/isffm.h index 856f3a22..9de17235 100644 --- a/qucs/spicecomponents/isffm.h +++ b/qucs/spicecomponents/isffm.h @@ -25,7 +25,7 @@ class iSffm : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // ISFFM_H diff --git a/qucs/spicecomponents/sp_customsim.cpp b/qucs/spicecomponents/sp_customsim.cpp index 8599592d..1cbab0a3 100644 --- a/qucs/spicecomponents/sp_customsim.cpp +++ b/qucs/spicecomponents/sp_customsim.cpp @@ -66,10 +66,10 @@ Element* SpiceCustomSim::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceCustomSim::spice_netlist(bool isXyce) +QString SpiceCustomSim::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = ""; - if (isXyce) return s; + if (dialect == spicecompat::SPICEXyce) return s; s = Props.at(0)->Value+"\n"; return s; } diff --git a/qucs/spicecomponents/sp_customsim.h b/qucs/spicecomponents/sp_customsim.h index 90661dde..64dcfdc0 100644 --- a/qucs/spicecomponents/sp_customsim.h +++ b/qucs/spicecomponents/sp_customsim.h @@ -29,7 +29,7 @@ class SpiceCustomSim : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/sp_disto.cpp b/qucs/spicecomponents/sp_disto.cpp index e1047cce..88f456bb 100644 --- a/qucs/spicecomponents/sp_disto.cpp +++ b/qucs/spicecomponents/sp_disto.cpp @@ -61,10 +61,10 @@ Element* SpiceDisto::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceDisto::spice_netlist(bool isXyce) +QString SpiceDisto::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; - if (!isXyce) { + if (dialect != spicecompat::SPICEXyce) { QString fstart = spicecompat::normalize_value(Props.at(1)->Value); // Start freq. QString fstop = spicecompat::normalize_value(Props.at(2)->Value); // Stop freq. QString swp = spicecompat::convert_sweep_type(Props.at(0)->Value); // Sweep mode (lin,dec,etc.) diff --git a/qucs/spicecomponents/sp_disto.h b/qucs/spicecomponents/sp_disto.h index 7340d70f..b698aaab 100644 --- a/qucs/spicecomponents/sp_disto.h +++ b/qucs/spicecomponents/sp_disto.h @@ -29,7 +29,7 @@ class SpiceDisto : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/sp_fourier.cpp b/qucs/spicecomponents/sp_fourier.cpp index 52e5e323..e6d17cc8 100644 --- a/qucs/spicecomponents/sp_fourier.cpp +++ b/qucs/spicecomponents/sp_fourier.cpp @@ -54,12 +54,12 @@ Element* SpiceFourier::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceFourier::spice_netlist(bool isXyce) +QString SpiceFourier::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; QString f0 = spicecompat::normalize_value(Props.at(2)->Value); QString out = "spice4qucs." + Name.toLower() + ".four"; - if (!isXyce) { + if (dialect != spicecompat::SPICEXyce) { s = QStringLiteral("set nfreqs=%1\n").arg(Props.at(1)->Value); s += QStringLiteral("fourier %1 %2 > %3\n").arg(f0).arg(Props.at(3)->Value).arg(out); } else { diff --git a/qucs/spicecomponents/sp_fourier.h b/qucs/spicecomponents/sp_fourier.h index 39665200..0f0572ba 100644 --- a/qucs/spicecomponents/sp_fourier.h +++ b/qucs/spicecomponents/sp_fourier.h @@ -29,7 +29,7 @@ class SpiceFourier : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); Qt::GlobalColor color() const override { return Qt::darkRed; } }; diff --git a/qucs/spicecomponents/sp_func.cpp b/qucs/spicecomponents/sp_func.cpp index 24a58f8c..2fdb764d 100644 --- a/qucs/spicecomponents/sp_func.cpp +++ b/qucs/spicecomponents/sp_func.cpp @@ -70,9 +70,9 @@ Element* SpiceFunc::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceFunc::getExpression(bool) +QString SpiceFunc::getExpression(bool, bool isCdl /* = false */) { - if (isActive != COMP_IS_ACTIVE) return QString(); + if (isActive != COMP_IS_ACTIVE || isCdl) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_func.h b/qucs/spicecomponents/sp_func.h index f942921e..b4b3a5b1 100644 --- a/qucs/spicecomponents/sp_func.h +++ b/qucs/spicecomponents/sp_func.h @@ -28,7 +28,7 @@ class SpiceFunc : public Component { ~SpiceFunc(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString getExpression(bool isXyce); + QString getExpression(bool isXyce, bool isCdl = false); protected: QString vhdlCode(int) { return QString(); } diff --git a/qucs/spicecomponents/sp_globalpar.cpp b/qucs/spicecomponents/sp_globalpar.cpp index b83e7a83..efaadb88 100644 --- a/qucs/spicecomponents/sp_globalpar.cpp +++ b/qucs/spicecomponents/sp_globalpar.cpp @@ -70,14 +70,14 @@ Element* SpiceGlobalParam::info(QString& Name, char* &BitmapFile, bool getNewOne } -QString SpiceGlobalParam::getExpression(bool) +QString SpiceGlobalParam::getExpression(bool, bool isCdl /* = false */) { if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); for (Property *pp : Props) { - s += QStringLiteral(".GLOBAL_PARAM %1 = %2\n").arg(pp->Name).arg(pp->Value); + s += QStringLiteral(".%1PARAM %2 = %3\n").arg(isCdl ? "" : "GLOBAL_").arg(pp->Name).arg(pp->Value); } return s; } diff --git a/qucs/spicecomponents/sp_globalpar.h b/qucs/spicecomponents/sp_globalpar.h index aee5cbb1..f0e71c61 100644 --- a/qucs/spicecomponents/sp_globalpar.h +++ b/qucs/spicecomponents/sp_globalpar.h @@ -29,7 +29,7 @@ class SpiceGlobalParam : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); static void splitEqn(QString &eqn, QStringList &tokens); - QString getExpression(bool isXyce); + QString getExpression(bool isXyce, bool isCdl = false); protected: QString vhdlCode(int) { return QString(); } diff --git a/qucs/spicecomponents/sp_ic.cpp b/qucs/spicecomponents/sp_ic.cpp index a822ac15..7b28e43a 100644 --- a/qucs/spicecomponents/sp_ic.cpp +++ b/qucs/spicecomponents/sp_ic.cpp @@ -69,9 +69,9 @@ Element* SpiceIC::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceIC::getExpression(bool) +QString SpiceIC::getExpression(bool, bool isCdl /* = false */) { - if (isActive != COMP_IS_ACTIVE) return QString(); + if (isActive != COMP_IS_ACTIVE || isCdl) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_ic.h b/qucs/spicecomponents/sp_ic.h index a6b4b643..82db5a21 100644 --- a/qucs/spicecomponents/sp_ic.h +++ b/qucs/spicecomponents/sp_ic.h @@ -28,7 +28,7 @@ class SpiceIC : public Component { ~SpiceIC(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString getExpression(bool isXyce); + QString getExpression(bool isXyce, bool isCdl = false); protected: QString vhdlCode(int) { return QString(); } diff --git a/qucs/spicecomponents/sp_nodeset.cpp b/qucs/spicecomponents/sp_nodeset.cpp index 458cadd4..35da1101 100644 --- a/qucs/spicecomponents/sp_nodeset.cpp +++ b/qucs/spicecomponents/sp_nodeset.cpp @@ -69,9 +69,9 @@ Element* SpiceNodeset::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceNodeset::getExpression(bool) +QString SpiceNodeset::getExpression(bool, bool isCdl /* = false */) { - if (isActive != COMP_IS_ACTIVE) return QString(); + if (isActive != COMP_IS_ACTIVE || isCdl) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_nodeset.h b/qucs/spicecomponents/sp_nodeset.h index cadf0f45..aafa0b7f 100644 --- a/qucs/spicecomponents/sp_nodeset.h +++ b/qucs/spicecomponents/sp_nodeset.h @@ -28,7 +28,7 @@ class SpiceNodeset : public Component { ~SpiceNodeset(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); - QString getExpression(bool isXyce); + QString getExpression(bool isXyce, bool isCdl = false); protected: QString vhdlCode(int) { return QString(); } diff --git a/qucs/spicecomponents/sp_noise.cpp b/qucs/spicecomponents/sp_noise.cpp index 02a0f301..bfc38dd1 100644 --- a/qucs/spicecomponents/sp_noise.cpp +++ b/qucs/spicecomponents/sp_noise.cpp @@ -64,7 +64,7 @@ Element* SpiceNoise::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceNoise::spice_netlist(bool isXyce) +QString SpiceNoise::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; QString fstart = spicecompat::normalize_value(Props.at(1)->Value); // Start freq. @@ -91,7 +91,7 @@ QString SpiceNoise::spice_netlist(bool isXyce) s = QStringLiteral("noise %1 %2 %3 %4 %5 %6\n").arg(Props.at(4)->Value).arg(Props.at(5)->Value) .arg(swp).arg(points).arg(fstart).arg(fstop); QString out = "spice4qucs." + Name.toLower() + ".cir.noise"; - if (!isXyce) { + if (dialect != spicecompat::SPICEXyce) { s += QStringLiteral("print inoise_total onoise_total >> %1\n").arg(out); } else { s.insert(0,'.'); diff --git a/qucs/spicecomponents/sp_noise.h b/qucs/spicecomponents/sp_noise.h index 418221b0..4279323e 100644 --- a/qucs/spicecomponents/sp_noise.h +++ b/qucs/spicecomponents/sp_noise.h @@ -29,7 +29,7 @@ class SpiceNoise : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/sp_options.cpp b/qucs/spicecomponents/sp_options.cpp index 69a4b7a6..53371feb 100644 --- a/qucs/spicecomponents/sp_options.cpp +++ b/qucs/spicecomponents/sp_options.cpp @@ -71,9 +71,9 @@ Element* SpiceOptions::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceOptions::getExpression(bool isXyce) +QString SpiceOptions::getExpression(bool isXyce, bool isCdl /* = false */) { - if (isActive != COMP_IS_ACTIVE) return QString(); + if (isActive != COMP_IS_ACTIVE || isCdl) return QString(); QString s; s.clear(); diff --git a/qucs/spicecomponents/sp_options.h b/qucs/spicecomponents/sp_options.h index 05100a5f..6bccdd28 100644 --- a/qucs/spicecomponents/sp_options.h +++ b/qucs/spicecomponents/sp_options.h @@ -29,7 +29,7 @@ class SpiceOptions : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); static void splitEqn(QString &eqn, QStringList &tokens); - QString getExpression(bool isXyce); + QString getExpression(bool isXyce, bool isCdl = false); protected: QString vhdlCode(int) { return QString(); } diff --git a/qucs/spicecomponents/sp_parameter.cpp b/qucs/spicecomponents/sp_parameter.cpp index 0ce62464..5c290f7e 100644 --- a/qucs/spicecomponents/sp_parameter.cpp +++ b/qucs/spicecomponents/sp_parameter.cpp @@ -69,14 +69,21 @@ Element* SpiceParam::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceParam::getExpression(bool) +QString SpiceParam::getExpression(bool, bool isCdl /* = false */) { if (isActive != COMP_IS_ACTIVE) return QString(); QString s; s.clear(); for (Property *pp : Props) { - s += QStringLiteral(".PARAM %1 = %2\n").arg(pp->Name).arg(pp->Value); + if (isCdl) + { + s += QStringLiteral(".PARAM %1=%2\n").arg(pp->Name).arg(pp->Value); + } + else + { + s += QStringLiteral(".PARAM %1 = %2\n").arg(pp->Name).arg(pp->Value); + } } return s; } diff --git a/qucs/spicecomponents/sp_parameter.h b/qucs/spicecomponents/sp_parameter.h index 57161473..a3fba349 100644 --- a/qucs/spicecomponents/sp_parameter.h +++ b/qucs/spicecomponents/sp_parameter.h @@ -29,7 +29,7 @@ class SpiceParam : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); static void splitEqn(QString &eqn, QStringList &tokens); - QString getExpression(bool isXyce); + QString getExpression(bool isXyce, bool isCdl = false); protected: QString vhdlCode(int) { return QString(); } diff --git a/qucs/spicecomponents/sp_pz.cpp b/qucs/spicecomponents/sp_pz.cpp index b52d0774..6108381a 100644 --- a/qucs/spicecomponents/sp_pz.cpp +++ b/qucs/spicecomponents/sp_pz.cpp @@ -58,11 +58,11 @@ Element* SpicePZ::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpicePZ::spice_netlist(bool isXyce) +QString SpicePZ::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; QString out = "spice4qucs." + Name.toLower() + ".cir.pz"; - if (!isXyce) { + if (dialect != spicecompat::SPICEXyce) { s = QStringLiteral("pz %1 %2 %3 %4\n").arg(Props.at(0)->Value).arg(Props.at(1)->Value) .arg(Props.at(2)->Value).arg(Props.at(3)->Value); s += QStringLiteral("echo \"PZ analysis\" >> %1\n").arg(out); diff --git a/qucs/spicecomponents/sp_pz.h b/qucs/spicecomponents/sp_pz.h index 02bd643b..d2e94181 100644 --- a/qucs/spicecomponents/sp_pz.h +++ b/qucs/spicecomponents/sp_pz.h @@ -29,7 +29,7 @@ class SpicePZ : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/sp_sens.cpp b/qucs/spicecomponents/sp_sens.cpp index be044d81..3e7b68a9 100644 --- a/qucs/spicecomponents/sp_sens.cpp +++ b/qucs/spicecomponents/sp_sens.cpp @@ -59,11 +59,11 @@ Element* SpiceSENS::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceSENS::spice_netlist(bool isXyce) +QString SpiceSENS::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; s.clear(); - if (!isXyce) { + if (dialect != spicecompat::SPICEXyce) { QString sweepvar = Props.at(1)->Value; QString par = sweepvar; sweepvar.remove(' '); diff --git a/qucs/spicecomponents/sp_sens.h b/qucs/spicecomponents/sp_sens.h index a77f0504..fd6da452 100644 --- a/qucs/spicecomponents/sp_sens.h +++ b/qucs/spicecomponents/sp_sens.h @@ -29,7 +29,7 @@ class SpiceSENS : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/sp_sens_ac.cpp b/qucs/spicecomponents/sp_sens_ac.cpp index e6e77fb6..b70578a8 100644 --- a/qucs/spicecomponents/sp_sens_ac.cpp +++ b/qucs/spicecomponents/sp_sens_ac.cpp @@ -59,11 +59,11 @@ Element* SpiceSENS_AC::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceSENS_AC::spice_netlist(bool isXyce) +QString SpiceSENS_AC::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; s.clear(); - if (!isXyce) { + if (dialect != spicecompat::SPICEXyce) { QString fstart = spicecompat::normalize_value(Props.at(2)->Value); // Start freq. QString fstop = spicecompat::normalize_value(Props.at(3)->Value); // Stop freq. QString out = "spice4qucs." + Name.toLower() + ".sens.prn"; diff --git a/qucs/spicecomponents/sp_sens_ac.h b/qucs/spicecomponents/sp_sens_ac.h index beb3cd10..144a0b83 100644 --- a/qucs/spicecomponents/sp_sens_ac.h +++ b/qucs/spicecomponents/sp_sens_ac.h @@ -29,7 +29,7 @@ class SpiceSENS_AC : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/sp_sens_tr_xyce.cpp b/qucs/spicecomponents/sp_sens_tr_xyce.cpp index 35f489b4..82f3a80b 100644 --- a/qucs/spicecomponents/sp_sens_tr_xyce.cpp +++ b/qucs/spicecomponents/sp_sens_tr_xyce.cpp @@ -62,11 +62,11 @@ Element* SpiceSENS_TR_Xyce::info(QString& Name, char* &BitmapFile, bool getNewOn return 0; } -QString SpiceSENS_TR_Xyce::spice_netlist(bool isXyce) +QString SpiceSENS_TR_Xyce::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; s.clear(); - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { QString start = spicecompat::normalize_value(Props.at(3)->Value); QString stop = spicecompat::normalize_value(Props.at(4)->Value); QString step = spicecompat::normalize_value(Props.at(5)->Value); diff --git a/qucs/spicecomponents/sp_sens_tr_xyce.h b/qucs/spicecomponents/sp_sens_tr_xyce.h index d2d376c6..083afb0c 100644 --- a/qucs/spicecomponents/sp_sens_tr_xyce.h +++ b/qucs/spicecomponents/sp_sens_tr_xyce.h @@ -29,7 +29,7 @@ class SpiceSENS_TR_Xyce : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); Qt::GlobalColor color() const override { return Qt::darkGreen; } }; diff --git a/qucs/spicecomponents/sp_sens_xyce.cpp b/qucs/spicecomponents/sp_sens_xyce.cpp index 6759a6ea..293e0db7 100644 --- a/qucs/spicecomponents/sp_sens_xyce.cpp +++ b/qucs/spicecomponents/sp_sens_xyce.cpp @@ -60,11 +60,11 @@ Element* SpiceSENS_Xyce::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceSENS_Xyce::spice_netlist(bool isXyce) +QString SpiceSENS_Xyce::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s; s.clear(); - if (isXyce) { + if (dialect == spicecompat::SPICEXyce) { QString start = spicecompat::normalize_value(Props.at(3)->Value); QString stop = spicecompat::normalize_value(Props.at(4)->Value); QString step = spicecompat::normalize_value(Props.at(5)->Value); diff --git a/qucs/spicecomponents/sp_sens_xyce.h b/qucs/spicecomponents/sp_sens_xyce.h index b09f5b4a..625cde8c 100644 --- a/qucs/spicecomponents/sp_sens_xyce.h +++ b/qucs/spicecomponents/sp_sens_xyce.h @@ -29,7 +29,7 @@ class SpiceSENS_Xyce : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); Qt::GlobalColor color() const override { return Qt::darkGreen; } }; diff --git a/qucs/spicecomponents/sp_spectrum.cpp b/qucs/spicecomponents/sp_spectrum.cpp index 9afe1e4c..e2584e40 100644 --- a/qucs/spicecomponents/sp_spectrum.cpp +++ b/qucs/spicecomponents/sp_spectrum.cpp @@ -57,9 +57,9 @@ Element* SpiceFFT::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString SpiceFFT::spice_netlist(bool isXyce) +QString SpiceFFT::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { - Q_UNUSED(isXyce); + Q_UNUSED(dialect); QString s; QString unit; diff --git a/qucs/spicecomponents/sp_spectrum.h b/qucs/spicecomponents/sp_spectrum.h index 0a48f63e..f65cdf71 100644 --- a/qucs/spicecomponents/sp_spectrum.h +++ b/qucs/spicecomponents/sp_spectrum.h @@ -29,7 +29,7 @@ class SpiceFFT : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/spicegeneric.cpp b/qucs/spicecomponents/spicegeneric.cpp index 7de86261..6569bf93 100644 --- a/qucs/spicecomponents/spicegeneric.cpp +++ b/qucs/spicecomponents/spicegeneric.cpp @@ -134,8 +134,10 @@ QString SpiceGeneric::netlist() return QString(); } -QString SpiceGeneric::spice_netlist(bool) +QString SpiceGeneric::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + // form RefDes from unique device letter and device name QString s = Props.at(1)->Value + Name; for (Port *pp : Ports) { @@ -147,3 +149,8 @@ QString SpiceGeneric::spice_netlist(bool) return s; } + +QString SpiceGeneric::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} diff --git a/qucs/spicecomponents/spicegeneric.h b/qucs/spicecomponents/spicegeneric.h index 69e73418..cff19fa1 100644 --- a/qucs/spicecomponents/spicegeneric.h +++ b/qucs/spicecomponents/spicegeneric.h @@ -37,8 +37,8 @@ class SpiceGeneric : public MultiViewComponent { protected: QString netlist(); void createSymbol(); - QString spice_netlist(bool isXyce); - + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); }; #endif diff --git a/qucs/spicecomponents/spicelibcomp.cpp b/qucs/spicecomponents/spicelibcomp.cpp index 46e644bd..29a53f98 100644 --- a/qucs/spicecomponents/spicelibcomp.cpp +++ b/qucs/spicecomponents/spicelibcomp.cpp @@ -218,8 +218,10 @@ int SpiceLibComp::loadSymbol(const QString& DocName) return -8; // field not closed } -QString SpiceLibComp::spice_netlist(bool) +QString SpiceLibComp::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = QStringLiteral("X%1 ").arg(Name); QString pins = getProperty("PinAssign")->Value; QString sym = getProperty("SymPattern")->Value; @@ -239,6 +241,11 @@ QString SpiceLibComp::spice_netlist(bool) return s; } +QString SpiceLibComp::cdl_netlist() +{ + return spice_netlist(spicecompat::CDL); +} + QString SpiceLibComp::getSpiceLibrary() { if (isActive != COMP_IS_ACTIVE) return QString(); diff --git a/qucs/spicecomponents/spicelibcomp.h b/qucs/spicecomponents/spicelibcomp.h index f3bd932d..dc89997e 100644 --- a/qucs/spicecomponents/spicelibcomp.h +++ b/qucs/spicecomponents/spicelibcomp.h @@ -30,10 +30,12 @@ class SpiceLibComp : public MultiViewComponent { QString getSpiceLibrary(); protected: - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); + virtual QString cdl_netlist(); void createSymbol(); void remakeSymbol(int No, QStringList &pin_names); int loadSymbol(const QString&); + private: void removeUnusedPorts(); }; diff --git a/qucs/spicecomponents/src_eqndef.cpp b/qucs/spicecomponents/src_eqndef.cpp index e980dd2d..3f987a7c 100644 --- a/qucs/spicecomponents/src_eqndef.cpp +++ b/qucs/spicecomponents/src_eqndef.cpp @@ -30,7 +30,7 @@ Src_eqndef::Src_eqndef() Model = "src_eqndef"; SpiceModel = "B"; Name = "B"; - + Props.append(new Property("V", "", true,"B(V) specification")); Props.append(new Property("Line_2", "", false,"+ continuation line 1")); Props.append(new Property("Line_3", "", false,"+ continuation line 2")); @@ -67,15 +67,17 @@ QString Src_eqndef::netlist() return QString(); } -QString Src_eqndef::spice_netlist(bool) +QString Src_eqndef::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; if (nam=="gnd") nam = "0"; s += " "+ nam + " "; // node names } - + QString VI = Props.at(0)-> Name; QString VI2 = Props.at(0)->Value; QString Line_2 = Props.at(1)->Value; diff --git a/qucs/spicecomponents/src_eqndef.h b/qucs/spicecomponents/src_eqndef.h index 514554cd..15d53dfc 100644 --- a/qucs/spicecomponents/src_eqndef.h +++ b/qucs/spicecomponents/src_eqndef.h @@ -11,7 +11,7 @@ class Src_eqndef : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); QString va_code(); }; diff --git a/qucs/spicecomponents/vAmpMod.cpp b/qucs/spicecomponents/vAmpMod.cpp index 8bf3b6a4..768cc1c1 100644 --- a/qucs/spicecomponents/vAmpMod.cpp +++ b/qucs/spicecomponents/vAmpMod.cpp @@ -40,8 +40,6 @@ vAmpMod::vAmpMod() // minus sign Lines.append(new qucs::Line(-18, -5,-18, -11,QPen(Qt::black,2))); - - Ports.append(new Port( 30, 0)); Ports.append(new Port(-30, 0)); @@ -91,8 +89,10 @@ QString vAmpMod::netlist() return QString(); } -QString vAmpMod::spice_netlist(bool) +QString vAmpMod::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; diff --git a/qucs/spicecomponents/vAmpMod.h b/qucs/spicecomponents/vAmpMod.h index fa6472e5..024a3295 100644 --- a/qucs/spicecomponents/vAmpMod.h +++ b/qucs/spicecomponents/vAmpMod.h @@ -29,9 +29,10 @@ class vAmpMod : public Component { ~vAmpMod(); Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); + protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // VAMPMOD_H diff --git a/qucs/spicecomponents/vPWL.cpp b/qucs/spicecomponents/vPWL.cpp index 5cf66c9a..a73f93d5 100644 --- a/qucs/spicecomponents/vPWL.cpp +++ b/qucs/spicecomponents/vPWL.cpp @@ -52,17 +52,16 @@ vPWL::vPWL() Name = "V"; Props.append(new Property("PWL", "", true,"Piece-Wise Linear\nSpecification")); - Props.append(new Property("Line_2", "", false,"+ continuation line 1")); - Props.append(new Property("Line_3", "", false,"+ continuation line 2")); - Props.append(new Property("Line_4", "", false,"+ continuation line 3")); - Props.append(new Property("Line_5", "", false,"+ continuation line 4")); - Props.append(new Property("Line_6", "", false,"+ continuation line 5")); - Props.append(new Property("Line_7", "", false,"+ continuation line 6")); - Props.append(new Property("Line_8", "", false,"+ continuation line 7")); - Props.append(new Property("Line_9", "", false,"+ continuation line 8")); - Props.append(new Property("Line_10", "", false,"+ continuation line 9")); - - + Props.append(new Property("Line_2", "", false,"+ continuation line 1")); + Props.append(new Property("Line_3", "", false,"+ continuation line 2")); + Props.append(new Property("Line_4", "", false,"+ continuation line 3")); + Props.append(new Property("Line_5", "", false,"+ continuation line 4")); + Props.append(new Property("Line_6", "", false,"+ continuation line 5")); + Props.append(new Property("Line_7", "", false,"+ continuation line 6")); + Props.append(new Property("Line_8", "", false,"+ continuation line 7")); + Props.append(new Property("Line_9", "", false,"+ continuation line 8")); + Props.append(new Property("Line_10", "", false,"+ continuation line 9")); + rotate(); // fix historical flaw } @@ -89,8 +88,10 @@ QString vPWL::netlist() return QString(); } -QString vPWL::spice_netlist(bool) +QString vPWL::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -98,20 +99,19 @@ QString vPWL::spice_netlist(bool) s += " "+ nam+" "; // node names } - -QString PWL= Props.at(0)->Value; -QString Line_2= Props.at(1)->Value; -QString Line_3= Props.at(2)->Value; -QString Line_4= Props.at(3)->Value; -QString Line_5= Props.at(4)->Value; -QString Line_6= Props.at(5)->Value; -QString Line_7= Props.at(6)->Value; -QString Line_8= Props.at(7)->Value; -QString Line_9= Props.at(8)->Value; -QString Line_10= Props.at(9)->Value; + QString PWL= Props.at(0)->Value; + QString Line_2= Props.at(1)->Value; + QString Line_3= Props.at(2)->Value; + QString Line_4= Props.at(3)->Value; + QString Line_5= Props.at(4)->Value; + QString Line_6= Props.at(5)->Value; + QString Line_7= Props.at(6)->Value; + QString Line_8= Props.at(7)->Value; + QString Line_9= Props.at(8)->Value; + QString Line_10= Props.at(9)->Value; s += QString(); - + if( PWL.length() > 0) s += QStringLiteral("%1").arg(PWL); if( Line_2.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_2); if( Line_3.length() > 0 ) s += QStringLiteral("\n%1").arg(Line_3); diff --git a/qucs/spicecomponents/vPWL.h b/qucs/spicecomponents/vPWL.h index 710c9fd5..01d19eb9 100644 --- a/qucs/spicecomponents/vPWL.h +++ b/qucs/spicecomponents/vPWL.h @@ -31,7 +31,7 @@ class vPWL : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // VPWL_H diff --git a/qucs/spicecomponents/vTRNOISE.cpp b/qucs/spicecomponents/vTRNOISE.cpp index ed6f8442..34b11739 100644 --- a/qucs/spicecomponents/vTRNOISE.cpp +++ b/qucs/spicecomponents/vTRNOISE.cpp @@ -94,8 +94,10 @@ QString vTRNOISE::netlist() return QString(); } -QString vTRNOISE::spice_netlist(bool) +QString vTRNOISE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; diff --git a/qucs/spicecomponents/vTRNOISE.h b/qucs/spicecomponents/vTRNOISE.h index c8890794..c16c463d 100644 --- a/qucs/spicecomponents/vTRNOISE.h +++ b/qucs/spicecomponents/vTRNOISE.h @@ -31,7 +31,7 @@ class vTRNOISE : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // VTRNOISE_H diff --git a/qucs/spicecomponents/vTRRANDOM.cpp b/qucs/spicecomponents/vTRRANDOM.cpp index 28175706..14d6414c 100644 --- a/qucs/spicecomponents/vTRRANDOM.cpp +++ b/qucs/spicecomponents/vTRRANDOM.cpp @@ -96,8 +96,10 @@ QString vTRRANDOM::netlist() return QString(); } -QString vTRRANDOM::spice_netlist(bool) +QString vTRRANDOM::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -105,11 +107,11 @@ QString vTRRANDOM::spice_netlist(bool) s += " "+ nam; // node names } - QString Type= spicecompat::normalize_value(Props.at(0)->Value); - QString Ts= spicecompat::normalize_value(Props.at(1)->Value); - QString Td= spicecompat::normalize_value(Props.at(2)->Value); - QString Param1 = spicecompat::normalize_value(Props.at(3)->Value); - QString Param2 = spicecompat::normalize_value(Props.at(4)->Value); + QString Type= spicecompat::normalize_value(Props.at(0)->Value); + QString Ts= spicecompat::normalize_value(Props.at(1)->Value); + QString Td= spicecompat::normalize_value(Props.at(2)->Value); + QString Param1 = spicecompat::normalize_value(Props.at(3)->Value); + QString Param2 = spicecompat::normalize_value(Props.at(4)->Value); s += QStringLiteral(" DC 0 AC 0 TRRANDOM(%1 %2 %3 %4 %5 ) \n").arg(Type).arg(Ts).arg(Td).arg(Param1).arg(Param2); return s; diff --git a/qucs/spicecomponents/vTRRANDOM.h b/qucs/spicecomponents/vTRRANDOM.h index a89af0ef..b8de87a9 100644 --- a/qucs/spicecomponents/vTRRANDOM.h +++ b/qucs/spicecomponents/vTRRANDOM.h @@ -31,7 +31,7 @@ class vTRRANDOM : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // VTRRANDOM_H diff --git a/qucs/spicecomponents/volt_ac_SPICE.cpp b/qucs/spicecomponents/volt_ac_SPICE.cpp index 44d212bf..d14b1b6f 100644 --- a/qucs/spicecomponents/volt_ac_SPICE.cpp +++ b/qucs/spicecomponents/volt_ac_SPICE.cpp @@ -72,8 +72,10 @@ Element* Vac_SPICE::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString Vac_SPICE::spice_netlist(bool) +QString Vac_SPICE::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; diff --git a/qucs/spicecomponents/volt_ac_SPICE.h b/qucs/spicecomponents/volt_ac_SPICE.h index 048e6383..5419c078 100644 --- a/qucs/spicecomponents/volt_ac_SPICE.h +++ b/qucs/spicecomponents/volt_ac_SPICE.h @@ -28,7 +28,7 @@ class Vac_SPICE : public Component { Component* newOne(); static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif diff --git a/qucs/spicecomponents/vsffm.cpp b/qucs/spicecomponents/vsffm.cpp index e573637a..5816c93b 100644 --- a/qucs/spicecomponents/vsffm.cpp +++ b/qucs/spicecomponents/vsffm.cpp @@ -89,8 +89,10 @@ QString vSffm::netlist() return QString(); } -QString vSffm::spice_netlist(bool) +QString vSffm::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); for (Port *p1 : Ports) { QString nam = p1->Connection->Name; @@ -98,12 +100,11 @@ QString vSffm::spice_netlist(bool) s += " "+ nam; // node names } - QString Vo= spicecompat::normalize_value(Props.at(0)->Value); - QString Va= spicecompat::normalize_value(Props.at(1)->Value); - QString Fc= spicecompat::normalize_value(Props.at(2)->Value); - QString Mdi = spicecompat::normalize_value(Props.at(3)->Value); - QString Fs = spicecompat::normalize_value(Props.at(4)->Value); - + QString Vo= spicecompat::normalize_value(Props.at(0)->Value); + QString Va= spicecompat::normalize_value(Props.at(1)->Value); + QString Fc= spicecompat::normalize_value(Props.at(2)->Value); + QString Mdi = spicecompat::normalize_value(Props.at(3)->Value); + QString Fs = spicecompat::normalize_value(Props.at(4)->Value); s += QStringLiteral(" DC 0 SFFM(%1 %2 %3 %4 %5 ) AC 0\n").arg(Vo).arg(Va).arg(Fc).arg(Mdi).arg(Fs); return s; diff --git a/qucs/spicecomponents/vsffm.h b/qucs/spicecomponents/vsffm.h index de36a9f6..ae6a1ad8 100644 --- a/qucs/spicecomponents/vsffm.h +++ b/qucs/spicecomponents/vsffm.h @@ -31,7 +31,7 @@ class vSffm : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: QString netlist(); - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; #endif // VSFFM_H diff --git a/qucs/spicecomponents/xsp_cmlib.cpp b/qucs/spicecomponents/xsp_cmlib.cpp index cbef493e..77995c6a 100644 --- a/qucs/spicecomponents/xsp_cmlib.cpp +++ b/qucs/spicecomponents/xsp_cmlib.cpp @@ -86,8 +86,10 @@ QString XSP_CMlib::getSpiceInit() return s; } -QString XSP_CMlib::spice_netlist() +QString XSP_CMlib::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + return QString(); } diff --git a/qucs/spicecomponents/xsp_cmlib.h b/qucs/spicecomponents/xsp_cmlib.h index 6931305a..617c4395 100644 --- a/qucs/spicecomponents/xsp_cmlib.h +++ b/qucs/spicecomponents/xsp_cmlib.h @@ -32,7 +32,7 @@ class XSP_CMlib : public Component { QString getSpiceInit(); protected: - QString spice_netlist(); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; diff --git a/qucs/spicecomponents/xsp_codemodel.cpp b/qucs/spicecomponents/xsp_codemodel.cpp index c47dd34b..4b2f5ac1 100644 --- a/qucs/spicecomponents/xsp_codemodel.cpp +++ b/qucs/spicecomponents/xsp_codemodel.cpp @@ -69,8 +69,10 @@ Element* XSP_CodeModel::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString XSP_CodeModel::spice_netlist() +QString XSP_CodeModel::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + return QString(); } diff --git a/qucs/spicecomponents/xsp_codemodel.h b/qucs/spicecomponents/xsp_codemodel.h index df57ea70..819ccf40 100644 --- a/qucs/spicecomponents/xsp_codemodel.h +++ b/qucs/spicecomponents/xsp_codemodel.h @@ -30,7 +30,7 @@ class XSP_CodeModel : public Component { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; diff --git a/qucs/spicecomponents/xspicegeneric.cpp b/qucs/spicecomponents/xspicegeneric.cpp index a67c28c2..8a38f49e 100644 --- a/qucs/spicecomponents/xspicegeneric.cpp +++ b/qucs/spicecomponents/xspicegeneric.cpp @@ -91,7 +91,7 @@ void XspiceGeneric::createSymbol() int No = n_ports.count(); QString tmp; - + // draw symbol outline #define HALFWIDTH 27 int h = 30*((No-1)/2) + 15; @@ -145,8 +145,10 @@ QString XspiceGeneric::netlist() return QString(); } -QString XspiceGeneric::spice_netlist(bool) +QString XspiceGeneric::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { + Q_UNUSED(dialect); + QString s = spicecompat::check_refdes(Name,SpiceModel); QStringList t_ports = Props.at(0)->Value.split(','); diff --git a/qucs/spicecomponents/xspicegeneric.h b/qucs/spicecomponents/xspicegeneric.h index 100987a4..8171df1f 100644 --- a/qucs/spicecomponents/xspicegeneric.h +++ b/qucs/spicecomponents/xspicegeneric.h @@ -37,7 +37,7 @@ class XspiceGeneric : public MultiViewComponent { protected: QString netlist(); void createSymbol(); - QString spice_netlist(bool isXyce); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); }; diff --git a/qucs/spicecomponents/xyce_script.cpp b/qucs/spicecomponents/xyce_script.cpp index 3e84e569..71280380 100644 --- a/qucs/spicecomponents/xyce_script.cpp +++ b/qucs/spicecomponents/xyce_script.cpp @@ -55,10 +55,10 @@ Element* XyceScript::info(QString& Name, char* &BitmapFile, bool getNewOne) return 0; } -QString XyceScript::spice_netlist(bool isXyce) +QString XyceScript::spice_netlist(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */) { QString s = ""; - if (!isXyce) return s; + if (dialect != spicecompat::SPICEXyce) return s; s = Props.at(0)->Value+"\n"; return s; } diff --git a/qucs/spicecomponents/xyce_script.h b/qucs/spicecomponents/xyce_script.h index 52a27345..239b3338 100644 --- a/qucs/spicecomponents/xyce_script.h +++ b/qucs/spicecomponents/xyce_script.h @@ -29,7 +29,7 @@ class XyceScript : public qucs::component::SimulationComponent { static Element* info(QString&, char* &, bool getNewOne=false); protected: - QString spice_netlist(bool isXyce = false); + QString spice_netlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault); Qt::GlobalColor color() const override { return Qt::darkGreen; } };