diff --git a/qucs/dialogs/fillfromspicedialog.cpp b/qucs/dialogs/fillfromspicedialog.cpp index 5cad117be..dacfdf487 100644 --- a/qucs/dialogs/fillfromspicedialog.cpp +++ b/qucs/dialogs/fillfromspicedialog.cpp @@ -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")); @@ -127,6 +128,17 @@ int fillFromSpiceDialog::parseModelcard() value += "M"; } + if (ModelType == "nmos" || ModelType == "pmos") { // check MOS level + if (name == "level") { + ModelLevel = value.toInt(); + QList 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()) { @@ -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; } diff --git a/qucs/dialogs/fillfromspicedialog.h b/qucs/dialogs/fillfromspicedialog.h index 9542e3b87..ebadf5ff7 100644 --- a/qucs/dialogs/fillfromspicedialog.h +++ b/qucs/dialogs/fillfromspicedialog.h @@ -19,9 +19,10 @@ class fillFromSpiceDialog : public QDialog { QMap 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;