From 868235b3b296c482e8cc8141e0be27e97de31cc2 Mon Sep 17 00:00:00 2001 From: dwarning Date: Tue, 25 Jun 2013 22:03:32 +0200 Subject: [PATCH] prevent NaN in sqrt for negative value of model parameter PHI --- src/spicelib/devices/mos1/mos1temp.c | 6 +++++- src/spicelib/devices/mos2/mos2temp.c | 6 +++++- src/spicelib/devices/mos3/mos3temp.c | 5 +++++ src/spicelib/devices/mos6/mos6temp.c | 6 +++++- src/spicelib/devices/mos9/mos9temp.c | 6 +++++- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/spicelib/devices/mos1/mos1temp.c b/src/spicelib/devices/mos1/mos1temp.c index 3764bc96a..e73b6dada 100644 --- a/src/spicelib/devices/mos1/mos1temp.c +++ b/src/spicelib/devices/mos1/mos1temp.c @@ -51,7 +51,11 @@ MOS1temp(GENmodel *inModel, CKTcircuit *ckt) pbfact1 = -2*vtnom *(1.5*log(fact1)+CHARGE*arg1); /* now model parameter preprocessing */ - + if (model->MOS1phi <= 0.0) { + SPfrontEnd->IFerror (ERR_FATAL, + "%s: Phi is not positive.",&model->MOS1modName); + return(E_BADPARM); + } if(!model->MOS1oxideThicknessGiven || model->MOS1oxideThickness == 0) { model->MOS1oxideCapFactor = 0; } else { diff --git a/src/spicelib/devices/mos2/mos2temp.c b/src/spicelib/devices/mos2/mos2temp.c index 982c784dd..9f8b19a7e 100644 --- a/src/spicelib/devices/mos2/mos2temp.c +++ b/src/spicelib/devices/mos2/mos2temp.c @@ -53,7 +53,11 @@ MOS2temp(GENmodel *inModel, CKTcircuit *ckt) arg1 = -egfet1/(kt1+kt1)+1.1150877/(CONSTboltz*(REFTEMP+REFTEMP)); pbfact1 = -2*vtnom *(1.5*log(fact1)+CHARGE*arg1); - + if (model->MOS2phi <= 0.0) { + SPfrontEnd->IFerror (ERR_FATAL, + "%s: Phi is not positive.",&model->MOS2modName); + return(E_BADPARM); + } if(!model->MOS2oxideThicknessGiven) { model->MOS2oxideThickness = 1e-7; } diff --git a/src/spicelib/devices/mos3/mos3temp.c b/src/spicelib/devices/mos3/mos3temp.c index 7357b47ae..e91523431 100644 --- a/src/spicelib/devices/mos3/mos3temp.c +++ b/src/spicelib/devices/mos3/mos3temp.c @@ -53,6 +53,11 @@ MOS3temp(GENmodel *inModel, CKTcircuit *ckt) CONSTKoverQ); ni_temp=1.45e16*nifact; + if (model->MOS3phi <= 0.0) { + SPfrontEnd->IFerror (ERR_FATAL, + "%s: Phi is not positive.",&model->MOS3modName); + return(E_BADPARM); + } model->MOS3oxideCapFactor = 3.9 * 8.854214871e-12/ model->MOS3oxideThickness; if(!model->MOS3surfaceMobilityGiven) model->MOS3surfaceMobility=600; diff --git a/src/spicelib/devices/mos6/mos6temp.c b/src/spicelib/devices/mos6/mos6temp.c index 046f62c79..a896700e1 100644 --- a/src/spicelib/devices/mos6/mos6temp.c +++ b/src/spicelib/devices/mos6/mos6temp.c @@ -50,7 +50,11 @@ MOS6temp(GENmodel *inModel, CKTcircuit *ckt) pbfact1 = -2*vtnom *(1.5*log(fact1)+CHARGE*arg1); /* now model parameter preprocessing */ - + if (model->MOS6phi <= 0.0) { + SPfrontEnd->IFerror (ERR_FATAL, + "%s: Phi is not positive.",&model->MOS6modName); + return(E_BADPARM); + } if(!model->MOS6oxideThicknessGiven || model->MOS6oxideThickness == 0) { model->MOS6oxideCapFactor = 0; } else { diff --git a/src/spicelib/devices/mos9/mos9temp.c b/src/spicelib/devices/mos9/mos9temp.c index 0ffcd11df..f71aa6648 100644 --- a/src/spicelib/devices/mos9/mos9temp.c +++ b/src/spicelib/devices/mos9/mos9temp.c @@ -54,7 +54,11 @@ MOS9temp(GENmodel *inModel, CKTcircuit *ckt) CONSTKoverQ); ni_temp=1.45e16*nifact; - + if (model->MOS9phi <= 0.0) { + SPfrontEnd->IFerror (ERR_FATAL, + "%s: Phi is not positive.",&model->MOS9modName); + return(E_BADPARM); + } model->MOS9oxideCapFactor = 3.9 * 8.854214871e-12/ model->MOS9oxideThickness; if(!model->MOS9surfaceMobilityGiven) model->MOS9surfaceMobility=600;