Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/tze/feature export cdl netlist #1154

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qucs/components/ac_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void AC_Sim::recreate(Schematic*)
}
}

QString AC_Sim::spice_netlist(bool isXyce)
QString AC_Sim::spice_netlist(bool isXyce, bool)
{
QString s = SpiceModel + " ";
QString unit;
Expand Down
2 changes: 1 addition & 1 deletion qucs/components/ac_sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(bool isXyce=false, bool isCdl = false);
};

#endif
2 changes: 1 addition & 1 deletion qucs/components/ampere_ac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Element* Ampere_ac::info(QString& Name, char* &BitmapFile, bool getNewOne)
}


QString Ampere_ac::spice_netlist(bool)
QString Ampere_ac::spice_netlist(bool, bool)
{
QString s = spicecompat::check_refdes(Name,SpiceModel);

Expand Down
2 changes: 1 addition & 1 deletion qucs/components/ampere_ac.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(bool isXyce = false, bool isCdl = false);
};

#endif
10 changes: 8 additions & 2 deletions qucs/components/ampere_dc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -56,7 +56,7 @@ Ampere_dc::~Ampere_dc()
{
}

QString Ampere_dc::spice_netlist(bool)
QString Ampere_dc::spice_netlist(bool, bool)
{
QString s = spicecompat::check_refdes(Name,SpiceModel);

Expand All @@ -68,6 +68,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(false, true);
}

Component* Ampere_dc::newOne()
{
return new Ampere_dc();
Expand Down
3 changes: 2 additions & 1 deletion qucs/components/ampere_dc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(bool isXyce = false, bool isCdl = false);
virtual QString cdl_netlist();
};

#endif
2 changes: 1 addition & 1 deletion qucs/components/biast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Element* BiasT::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString BiasT::spice_netlist(bool isXyce)
QString BiasT::spice_netlist(bool isXyce, bool)
{
Q_UNUSED(isXyce);
QString s;
Expand Down
2 changes: 1 addition & 1 deletion qucs/components/biast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(bool isXyce = false, bool isCdl = false);
};

#endif
21 changes: 15 additions & 6 deletions qucs/components/bjt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Component* BJT::newOne()
return p;
}

QString BJT::spice_netlist(bool)
QString BJT::spice_netlist(bool, bool isCdl /* = false */)
{
QString s = spicecompat::check_refdes(Name,SpiceModel);
QList<int> pin_seq;
Expand All @@ -60,17 +60,26 @@ 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);
if (getProperty("UseGlobTemp")->Value == "yes" || isCdl) {
s += QStringLiteral(" QMOD_%1 %2=%3\n").arg(Name).arg(isCdl ? "$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 (!isCdl)
{
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(false, true);
}

// -------------------------------------------------------
Element* BJT::info(QString& Name, char* &BitmapFile, bool getNewOne)
{
Expand Down
3 changes: 2 additions & 1 deletion qucs/components/bjt.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class BJT : public Basic_BJT {
protected:
void createSymbol();
QString netlist();
QString spice_netlist(bool isXyce = false);
QString spice_netlist(bool isXyce = false, bool isCdl = false);
virtual QString cdl_netlist();
};

#endif
20 changes: 14 additions & 6 deletions qucs/components/bjtsub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void BJTsub::createSymbol()
x2 = 30; y2 = 30;
}

QString BJTsub::spice_netlist(bool)
QString BJTsub::spice_netlist(bool, bool isCdl /* = false */)
{
QString s = spicecompat::check_refdes(Name,SpiceModel);
QList<int> pin_seq;
Expand All @@ -219,14 +219,22 @@ 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);
if (getProperty("UseGlobTemp")->Value == "yes" || isCdl) {
s += QStringLiteral(" QMOD_%1 %2=%3\n").arg(Name).arg(isCdl ? "$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 (!isCdl)
{
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(false, true);
}
3 changes: 2 additions & 1 deletion qucs/components/bjtsub.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(bool isXyce, bool isCdl = false);
virtual QString cdl_netlist();
void createSymbol();
};

Expand Down
21 changes: 13 additions & 8 deletions qucs/components/capacitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -53,7 +53,7 @@ Element* Capacitor::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString Capacitor::spice_netlist(bool)
QString Capacitor::spice_netlist(bool, bool isCdl /*= false */)
{
QString s = spicecompat::check_refdes(Name,SpiceModel);

Expand All @@ -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() && !isCdl) {
s += " IC=" + val;
}

return s+'\n';
}

QString Capacitor::cdl_netlist()
{
return spice_netlist(false, true);
}

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;
}

Expand Down
3 changes: 2 additions & 1 deletion qucs/components/capacitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class Capacitor : public MultiViewComponent {

protected:
void createSymbol();
QString spice_netlist(bool isXyce = false);
QString spice_netlist(bool isXyce = false, bool isCdl = false);
virtual QString cdl_netlist();
QString va_code();
};

Expand Down
3 changes: 2 additions & 1 deletion qucs/components/capq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Element* CapQ::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString CapQ::spice_netlist(bool isXyce)
QString CapQ::spice_netlist(bool isXyce, bool)
{
Q_UNUSED(isXyce);
QString s;
Expand Down Expand Up @@ -124,3 +124,4 @@ QString CapQ::spice_netlist(bool isXyce)

return s;
}

2 changes: 1 addition & 1 deletion qucs/components/capq.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(bool isXyce = false, bool isCdl = false);
};

#endif
2 changes: 1 addition & 1 deletion qucs/components/cccs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ QString CCCS::va_code()

return s;
}
QString CCCS::spice_netlist(bool)
QString CCCS::spice_netlist(bool, bool)
{
QString s = spicecompat::check_refdes(Name,SpiceModel); // spice CCCS consists two sources: output source
// and zero value controlling source
Expand Down
2 changes: 1 addition & 1 deletion qucs/components/cccs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(bool isXyce = false, bool isCdl = false);
QString va_code();
};

Expand Down
2 changes: 1 addition & 1 deletion qucs/components/ccvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ QString CCVS::va_code()
}

// -------------------------------------------------------
QString CCVS::spice_netlist(bool)
QString CCVS::spice_netlist(bool, bool)
{
QString s = spicecompat::check_refdes(Name,SpiceModel); // spice CCVS consists two sources: output source
// and zero value controlling source
Expand Down
2 changes: 1 addition & 1 deletion qucs/components/ccvs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(bool isXyce = false, bool isCdl = false);
QString va_code();
};

Expand Down
14 changes: 9 additions & 5 deletions qucs/components/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(bool, bool) {
return QStringLiteral("\n"); // ignore if not implemented
}

QString Component::cdl_netlist() {
return QStringLiteral("\n"); // ignore if not implemented
}

Expand Down Expand Up @@ -787,11 +791,11 @@ QString Component::getNetlist() {
return s;
}

QString Component::getSpiceNetlist(bool isXyce) {
QString Component::getSpiceNetlist(bool isXyce /* = false */, bool isCdl /* = false */) {
QString s;
switch (isActive) {
case COMP_IS_ACTIVE:
s = spice_netlist(isXyce);
s = isCdl ? cdl_netlist() : spice_netlist(isXyce, false);
s.replace(" gnd ", " 0 ");
return s;
case COMP_IS_OPEN:
Expand Down Expand Up @@ -824,7 +828,7 @@ QString Component::getVerilogACode() {
}
}

QString Component::getExpression(bool) {
QString Component::getExpression(bool, bool) {
return QString();
}

Expand Down Expand Up @@ -1537,7 +1541,7 @@ QString GateComponent::netlist() {
return s;
}

QString GateComponent::spice_netlist(bool isXyce) {
QString GateComponent::spice_netlist(bool isXyce, bool) {
if (isXyce) return {""};

QString s = SpiceModel + Name;
Expand Down
9 changes: 5 additions & 4 deletions qucs/components/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class Component : public Element {
virtual Component* newOne();
virtual void recreate(Schematic*) {};
QString getNetlist();
QString getSpiceNetlist(bool isXyce = false);
QString getSpiceNetlist(bool isXyce = false, bool isCdl = false);
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);
Expand Down Expand Up @@ -114,7 +114,8 @@ class Component : public Element {

protected:
virtual QString netlist();
virtual QString spice_netlist(bool isXyce = false);
virtual QString spice_netlist(bool isXyce = false, bool isCdl = false);
virtual QString cdl_netlist();
virtual QString va_code();
virtual QString vhdlCode(int);
virtual QString verilogCode(int);
Expand Down Expand Up @@ -149,7 +150,7 @@ class GateComponent : public MultiViewComponent {
public:
GateComponent();
QString netlist();
QString spice_netlist(bool isXyce);
QString spice_netlist(bool isXyce, bool isCdl = false);
QString vhdlCode(int);
QString verilogCode(int);

Expand Down
Loading
Loading