Skip to content

Commit

Permalink
Introduce optional netlisting to console
Browse files Browse the repository at this point in the history
-Replaced Component::getExpression(bool isXyce, bool isCdl) with
 Component::getExpression(spicecompat::SpiceDialect dialect)

Signed-off-by: ThomasZecha <[email protected]>
  • Loading branch information
ThomasZecha committed Jan 19, 2025
1 parent b79d94e commit 63d6d07
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion qucs/components/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ QString Component::getVerilogACode() {
}
}

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

Expand Down
2 changes: 1 addition & 1 deletion qucs/components/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Component : public Element {
QString getNetlist();
QString getSpiceNetlist(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
QString getVerilogACode();
virtual QString getExpression(bool isXyce = false, bool isCdl = false);
virtual QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
virtual QString getEquations(QString sim, QStringList &dep_vars);
virtual QStringList getExtraVariables();
virtual QString getProbeVariable(bool isXyce = false);
Expand Down
11 changes: 4 additions & 7 deletions qucs/components/equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,11 @@ 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.
* \param dialect Which spice-dialect is used.
* \return .PARAM section of spice netlist as a single string.
*/
QString Equation::getExpression(bool isXyce, bool isCdl /* = false */)
QString Equation::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
{
Q_UNUSED(isCdl);

if (isActive != COMP_IS_ACTIVE) return QString();

QStringList ng_vars,ngsims;
Expand All @@ -145,9 +142,9 @@ QString Equation::getExpression(bool isXyce, bool isCdl /* = false */)
QStringList tokens;
QString eqn = Props.at(i)->Value;
spicecompat::splitEqn(eqn,tokens);
spicecompat::convert_functions(tokens,isXyce);
spicecompat::convert_functions(tokens, dialect == spicecompat::SPICEXyce);
eqn = tokens.join("");
if (isXyce) {
if (dialect == spicecompat::SPICEXyce) {
eqn.replace("^","**");

if (!(fp_pattern.match(eqn).hasMatch()||
Expand Down
2 changes: 1 addition & 1 deletion qucs/components/equation.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Equation : public Component {
~Equation();
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
QString getExpression(bool isXyce, bool isCdl = false);
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);
QString getEquations(QString sim, QStringList &dep_vars);
QString getVAvariables();
QString getVAExpressions();
Expand Down
2 changes: 1 addition & 1 deletion qucs/components/iprobe.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class iProbe : public Component {
~iProbe();
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
QString getExpression(bool, bool) { return "";}
QString getExpression(spicecompat::SpiceDialect) { return "";}
QString getProbeVariable(bool isXyce = false);

protected:
Expand Down
2 changes: 1 addition & 1 deletion qucs/extsimkernels/CdlNetlistWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void CdlNetlistWriter::startNetlist()
{
if (pc->isEquation)
{
s = pc->getExpression(false, true);
s = pc->getExpression(spicecompat::CDL);
a_netlistStream << s;
}
}
Expand Down
4 changes: 2 additions & 2 deletions qucs/spicecomponents/incl_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ Element* InclScript::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString InclScript::getExpression(bool, bool isCdl /* = false */)
QString InclScript::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
{
if (isActive != COMP_IS_ACTIVE || isCdl)
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL)
return QString();
return Props.at(0)->Value+"\n";
}
2 changes: 1 addition & 1 deletion qucs/spicecomponents/incl_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class InclScript : public Component {
~InclScript();
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
QString getExpression(bool isXyce, bool isCdl = false);
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);

protected:
QString vhdlCode(int) { return QString(); }
Expand Down
4 changes: 3 additions & 1 deletion qucs/spicecomponents/sp_csparameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ Element* SpiceCSParam::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString SpiceCSParam::getExpression(bool)
QString SpiceCSParam::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
{
Q_UNUSED(dialect);

if (isActive != COMP_IS_ACTIVE) return QString();

QString s;
Expand Down
2 changes: 1 addition & 1 deletion qucs/spicecomponents/sp_csparameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SpiceCSParam : public Component {
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
static void splitEqn(QString &eqn, QStringList &tokens);
QString getExpression(bool isXyce = false);
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);

protected:
QString netlist() { return QString(); }
Expand Down
4 changes: 2 additions & 2 deletions qucs/spicecomponents/sp_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ Element* SpiceFunc::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString SpiceFunc::getExpression(bool, bool isCdl /* = false */)
QString SpiceFunc::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
{
if (isActive != COMP_IS_ACTIVE || isCdl) return QString();
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL) return QString();

QString s;
s.clear();
Expand Down
2 changes: 1 addition & 1 deletion qucs/spicecomponents/sp_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SpiceFunc : public Component {
~SpiceFunc();
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
QString getExpression(bool isXyce, bool isCdl = false);
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);

protected:
QString vhdlCode(int) { return QString(); }
Expand Down
5 changes: 3 additions & 2 deletions qucs/spicecomponents/sp_globalpar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ Element* SpiceGlobalParam::info(QString& Name, char* &BitmapFile, bool getNewOne
}


QString SpiceGlobalParam::getExpression(bool, bool isCdl /* = false */)
QString SpiceGlobalParam::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
{
if (isActive != COMP_IS_ACTIVE) return QString();

QString s;
s.clear();
for (Property *pp : Props) {
s += QStringLiteral(".%1PARAM %2 = %3\n").arg(isCdl ? "" : "GLOBAL_").arg(pp->Name).arg(pp->Value);
s += QStringLiteral(".%1PARAM %2 = %3\n")
.arg(dialect == spicecompat::CDL ? "" : "GLOBAL_").arg(pp->Name).arg(pp->Value);
}
return s;
}
Expand Down
2 changes: 1 addition & 1 deletion qucs/spicecomponents/sp_globalpar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, bool isCdl = false);
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);

protected:
QString vhdlCode(int) { return QString(); }
Expand Down
4 changes: 2 additions & 2 deletions qucs/spicecomponents/sp_ic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ Element* SpiceIC::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString SpiceIC::getExpression(bool, bool isCdl /* = false */)
QString SpiceIC::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
{
if (isActive != COMP_IS_ACTIVE || isCdl) return QString();
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL) return QString();

QString s;
s.clear();
Expand Down
2 changes: 1 addition & 1 deletion qucs/spicecomponents/sp_ic.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SpiceIC : public Component {
~SpiceIC();
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
QString getExpression(bool isXyce, bool isCdl = false);
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);

protected:
QString vhdlCode(int) { return QString(); }
Expand Down
4 changes: 2 additions & 2 deletions qucs/spicecomponents/sp_nodeset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ Element* SpiceNodeset::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString SpiceNodeset::getExpression(bool, bool isCdl /* = false */)
QString SpiceNodeset::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
{
if (isActive != COMP_IS_ACTIVE || isCdl) return QString();
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL) return QString();

QString s;
s.clear();
Expand Down
2 changes: 1 addition & 1 deletion qucs/spicecomponents/sp_nodeset.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SpiceNodeset : public Component {
~SpiceNodeset();
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
QString getExpression(bool isXyce, bool isCdl = false);
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);

protected:
QString vhdlCode(int) { return QString(); }
Expand Down
6 changes: 3 additions & 3 deletions qucs/spicecomponents/sp_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ Element* SpiceOptions::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString SpiceOptions::getExpression(bool isXyce, bool isCdl /* = false */)
QString SpiceOptions::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
{
if (isActive != COMP_IS_ACTIVE || isCdl) return QString();
if (isActive != COMP_IS_ACTIVE || dialect == spicecompat::CDL) return QString();

QString s;
s.clear();
if (isXyce) {
if (dialect == spicecompat::SPICEXyce) {
s += QStringLiteral(".OPTIONS %1 ").arg(Props.at(0)->Value);
for (int i=1;i<Props.count();i++) {
s += QStringLiteral(" %1 = %2 ").arg(Props.at(i)->Name).arg(Props.at(i)->Value);
Expand Down
2 changes: 1 addition & 1 deletion qucs/spicecomponents/sp_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, bool isCdl = false);
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);

protected:
QString vhdlCode(int) { return QString(); }
Expand Down
4 changes: 2 additions & 2 deletions qucs/spicecomponents/sp_parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ Element* SpiceParam::info(QString& Name, char* &BitmapFile, bool getNewOne)
return 0;
}

QString SpiceParam::getExpression(bool, bool isCdl /* = false */)
QString SpiceParam::getExpression(spicecompat::SpiceDialect dialect /* = spicecompat::SPICEDefault */)
{
if (isActive != COMP_IS_ACTIVE) return QString();

QString s;
s.clear();
for (Property *pp : Props) {
if (isCdl)
if (dialect == spicecompat::CDL)
{
s += QStringLiteral(".PARAM %1=%2\n").arg(pp->Name).arg(pp->Value);
}
Expand Down
2 changes: 1 addition & 1 deletion qucs/spicecomponents/sp_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, bool isCdl = false);
QString getExpression(spicecompat::SpiceDialect dialect = spicecompat::SPICEDefault);

protected:
QString vhdlCode(int) { return QString(); }
Expand Down

0 comments on commit 63d6d07

Please sign in to comment.