Skip to content

Commit

Permalink
Check LEVEL when importing SPICE model
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3xdh committed Jul 18, 2024
1 parent edd4be1 commit f180746
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions qucs/dialogs/fillfromspicedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fillFromSpiceDialog::fillFromSpiceDialog(Component *pc, QWidget *w)
: QDialog(w)
{
Comp = pc;
ModelLevel = 1;

edtModel = new QPlainTextEdit;
QLabel *lblModel = new QLabel(tr("Insert .MODEL text here"));
Expand Down Expand Up @@ -127,6 +128,17 @@ int fillFromSpiceDialog::parseModelcard()
value += "M";
}

if (ModelType == "nmos" || ModelType == "pmos") { // check MOS level
if (name == "level") {
ModelLevel = value.toInt();
QList<int> allowed_levels;
allowed_levels<<1<<2<<3<<4<<5<<6<<7<<9;
if (!allowed_levels.contains(ModelLevel)) {
return wrongLevel;
}
}
}

if (value.size() >=2) {
// Ngspice doesn't accept numbers without leading zero
if (value.at(0) == '.' && value.at(1).isDigit()) {
Expand Down Expand Up @@ -187,6 +199,11 @@ void fillFromSpiceDialog::showErrorMsg(int code)
msg = tr("Subcircuit model (.SUBCKT) found\n"
"Modelcard (.MODEL) expected");
break;
case wrongLevel:
msg = QString(tr("Model LEVEL=%1 is not allowed for unified MOS device\n"
"Use red SPICE device from Microelectronics group\n"
"Allowed LEVELS are: 1,2,3,4,5,6,9")).arg(ModelLevel);
break;
default:
break;
}
Expand Down
3 changes: 2 additions & 1 deletion qucs/dialogs/fillfromspicedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class fillFromSpiceDialog : public QDialog {
QMap<QString,QString> parsedProps;
QString ModelName;
QString ModelType;
int ModelLevel;

enum errorCode { noError = 0, noModel = 1, modelMismatch = 2, wrongModel = 3, subcirFound = 4,
numberError = 5 };
numberError = 5, wrongLevel = 6 };

QPlainTextEdit *edtModel;
QPushButton *btnOK, *btnCancel;
Expand Down

0 comments on commit f180746

Please sign in to comment.