Check LEVEL when importing SPICE model

This commit is contained in:
Vadim Kuznetsov 2024-07-18 12:08:03 +03:00
parent edd4be1826
commit f1807463ff
2 changed files with 19 additions and 1 deletions

View File

@ -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<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()) {
@ -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;
}

View File

@ -19,9 +19,10 @@ private:
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;