From 4b643d6b3f06b23345d3a901fc9fdd47e2f9bdae Mon Sep 17 00:00:00 2001 From: dwarning Date: Wed, 30 Oct 2013 20:16:30 +0100 Subject: [PATCH] devices/bsim4v5, implement BSIM4v5soaCheck() --- src/spicelib/devices/bsim4v5/Makefile.am | 1 + src/spicelib/devices/bsim4v5/b4v5.c | 7 ++ src/spicelib/devices/bsim4v5/b4v5mask.c | 20 ++++ src/spicelib/devices/bsim4v5/b4v5mpar.c | 26 +++++ src/spicelib/devices/bsim4v5/b4v5set.c | 13 +++ src/spicelib/devices/bsim4v5/b4v5soachk.c | 110 +++++++++++++++++++++ src/spicelib/devices/bsim4v5/bsim4v5def.h | 21 ++++ src/spicelib/devices/bsim4v5/bsim4v5ext.h | 1 + src/spicelib/devices/bsim4v5/bsim4v5init.c | 2 +- visualc/vngspice.vcproj | 4 + 10 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/spicelib/devices/bsim4v5/b4v5soachk.c diff --git a/src/spicelib/devices/bsim4v5/Makefile.am b/src/spicelib/devices/bsim4v5/Makefile.am index a7ab65505..4438ce323 100644 --- a/src/spicelib/devices/bsim4v5/Makefile.am +++ b/src/spicelib/devices/bsim4v5/Makefile.am @@ -20,6 +20,7 @@ libbsim4v5_la_SOURCES = \ b4v5par.c \ b4v5pzld.c \ b4v5set.c \ + b4v5soachk.c \ b4v5temp.c \ b4v5trunc.c \ bsim4v5def.h \ diff --git a/src/spicelib/devices/bsim4v5/b4v5.c b/src/spicelib/devices/bsim4v5/b4v5.c index 2f6ecea14..983f8fe2b 100644 --- a/src/spicelib/devices/bsim4v5/b4v5.c +++ b/src/spicelib/devices/bsim4v5/b4v5.c @@ -890,6 +890,13 @@ IOP( "ef", BSIM4v5_MOD_EF, IF_REAL, "Flicker noise frequency exponent"), IOP( "af", BSIM4v5_MOD_AF, IF_REAL, "Flicker noise exponent"), IOP( "kf", BSIM4v5_MOD_KF, IF_REAL, "Flicker noise coefficient"), +IOP("vgs_max", BSIM4v5_MOD_VGS_MAX, IF_REAL, "maximum voltage G-S branch"), +IOP("vgd_max", BSIM4v5_MOD_VGD_MAX, IF_REAL, "maximum voltage G-D branch"), +IOP("vgb_max", BSIM4v5_MOD_VGB_MAX, IF_REAL, "maximum voltage G-B branch"), +IOP("vds_max", BSIM4v5_MOD_VDS_MAX, IF_REAL, "maximum voltage D-S branch"), +IOP("vbs_max", BSIM4v5_MOD_VBS_MAX, IF_REAL, "maximum voltage B-S branch"), +IOP("vbd_max", BSIM4v5_MOD_VBD_MAX, IF_REAL, "maximum voltage B-D branch"), + IP( "nmos", BSIM4v5_MOD_NMOS, IF_FLAG, "Flag to indicate NMOS"), IP( "pmos", BSIM4v5_MOD_PMOS, IF_FLAG, "Flag to indicate PMOS"), }; diff --git a/src/spicelib/devices/bsim4v5/b4v5mask.c b/src/spicelib/devices/bsim4v5/b4v5mask.c index 909f2fa14..8fc0273ec 100644 --- a/src/spicelib/devices/bsim4v5/b4v5mask.c +++ b/src/spicelib/devices/bsim4v5/b4v5mask.c @@ -2253,6 +2253,26 @@ IFvalue *value) case BSIM4v5_MOD_KF: value->rValue = model->BSIM4v5kf; return(OK); + + case BSIM4v5_MOD_VGS_MAX: + value->rValue = model->BSIM4v5vgsMax; + return(OK); + case BSIM4v5_MOD_VGD_MAX: + value->rValue = model->BSIM4v5vgdMax; + return(OK); + case BSIM4v5_MOD_VGB_MAX: + value->rValue = model->BSIM4v5vgbMax; + return(OK); + case BSIM4v5_MOD_VDS_MAX: + value->rValue = model->BSIM4v5vdsMax; + return(OK); + case BSIM4v5_MOD_VBS_MAX: + value->rValue = model->BSIM4v5vbsMax; + return(OK); + case BSIM4v5_MOD_VBD_MAX: + value->rValue = model->BSIM4v5vbdMax; + return(OK); + default: return(E_BADPARM); } diff --git a/src/spicelib/devices/bsim4v5/b4v5mpar.c b/src/spicelib/devices/bsim4v5/b4v5mpar.c index 7b138f18d..eb31e0f94 100644 --- a/src/spicelib/devices/bsim4v5/b4v5mpar.c +++ b/src/spicelib/devices/bsim4v5/b4v5mpar.c @@ -3060,6 +3060,32 @@ GENmodel *inMod) mod->BSIM4v5kf = value->rValue; mod->BSIM4v5kfGiven = TRUE; break; + + case BSIM4v5_MOD_VGS_MAX: + mod->BSIM4v5vgsMax = value->rValue; + mod->BSIM4v5vgsMaxGiven = TRUE; + break; + case BSIM4v5_MOD_VGD_MAX: + mod->BSIM4v5vgdMax = value->rValue; + mod->BSIM4v5vgdMaxGiven = TRUE; + break; + case BSIM4v5_MOD_VGB_MAX: + mod->BSIM4v5vgbMax = value->rValue; + mod->BSIM4v5vgbMaxGiven = TRUE; + break; + case BSIM4v5_MOD_VDS_MAX: + mod->BSIM4v5vdsMax = value->rValue; + mod->BSIM4v5vdsMaxGiven = TRUE; + break; + case BSIM4v5_MOD_VBS_MAX: + mod->BSIM4v5vbsMax = value->rValue; + mod->BSIM4v5vbsMaxGiven = TRUE; + break; + case BSIM4v5_MOD_VBD_MAX: + mod->BSIM4v5vbdMax = value->rValue; + mod->BSIM4v5vbdMaxGiven = TRUE; + break; + case BSIM4v5_MOD_NMOS : if(value->iValue) { mod->BSIM4v5type = 1; diff --git a/src/spicelib/devices/bsim4v5/b4v5set.c b/src/spicelib/devices/bsim4v5/b4v5set.c index 667a86c7c..bb3df430e 100644 --- a/src/spicelib/devices/bsim4v5/b4v5set.c +++ b/src/spicelib/devices/bsim4v5/b4v5set.c @@ -1567,6 +1567,19 @@ JOB *job; if (!model->BSIM4v5kfGiven) model->BSIM4v5kf = 0.0; + if (!model->BSIM4v5vgsMaxGiven) + model->BSIM4v5vgsMax = 1e99; + if (!model->BSIM4v5vgdMaxGiven) + model->BSIM4v5vgdMax = 1e99; + if (!model->BSIM4v5vgbMaxGiven) + model->BSIM4v5vgbMax = 1e99; + if (!model->BSIM4v5vdsMaxGiven) + model->BSIM4v5vdsMax = 1e99; + if (!model->BSIM4v5vbsMaxGiven) + model->BSIM4v5vbsMax = 1e99; + if (!model->BSIM4v5vbdMaxGiven) + model->BSIM4v5vbdMax = 1e99; + /* stress effect */ if (!model->BSIM4v5sarefGiven) model->BSIM4v5saref = 1e-6; /* m */ diff --git a/src/spicelib/devices/bsim4v5/b4v5soachk.c b/src/spicelib/devices/bsim4v5/b4v5soachk.c new file mode 100644 index 000000000..0fdda87fd --- /dev/null +++ b/src/spicelib/devices/bsim4v5/b4v5soachk.c @@ -0,0 +1,110 @@ +/********** +Copyright 2013 Dietmar Warning. All rights reserved. +Author: 2013 Dietmar Warning +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bsim4v5def.h" +#include "ngspice/trandefs.h" +#include "ngspice/sperror.h" +#include "ngspice/suffix.h" +#include "ngspice/cpdefs.h" + + +int +BSIM4v5soaCheck(CKTcircuit *ckt, GENmodel *inModel) +{ + BSIM4v5model *model = (BSIM4v5model *) inModel; + BSIM4v5instance *here; + double vgs, vgd, vgb, vds, vbs, vbd; /* actual mos voltages */ + int maxwarns; + static int warns_vgs = 0, warns_vgd = 0, warns_vgb = 0, warns_vds = 0, warns_vbs = 0, warns_vbd = 0; + + if (!ckt) { + warns_vgs = 0; + warns_vgd = 0; + warns_vgb = 0; + warns_vds = 0; + warns_vbs = 0; + warns_vbd = 0; + return OK; + } + + maxwarns = ckt->CKTsoaMaxWarns; + + for (; model; model = model->BSIM4v5nextModel) { + + for (here = model->BSIM4v5instances; here; here = here->BSIM4v5nextInstance) { + + vgs = fabs(ckt->CKTrhsOld [here->BSIM4v5gNodePrime] - + ckt->CKTrhsOld [here->BSIM4v5sNodePrime]); + + vgd = fabs(ckt->CKTrhsOld [here->BSIM4v5gNodePrime] - + ckt->CKTrhsOld [here->BSIM4v5dNodePrime]); + + vgb = fabs(ckt->CKTrhsOld [here->BSIM4v5gNodePrime] - + ckt->CKTrhsOld [here->BSIM4v5bNodePrime]); + + vds = fabs(ckt->CKTrhsOld [here->BSIM4v5dNodePrime] - + ckt->CKTrhsOld [here->BSIM4v5sNodePrime]); + + vbs = fabs(ckt->CKTrhsOld [here->BSIM4v5bNodePrime] - + ckt->CKTrhsOld [here->BSIM4v5sNodePrime]); + + vbd = fabs(ckt->CKTrhsOld [here->BSIM4v5bNodePrime] - + ckt->CKTrhsOld [here->BSIM4v5dNodePrime]); + + if (vgs > model->BSIM4v5vgsMax) + if (warns_vgs < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vgs|=%g has exceeded Vgs_max=%g\n", + vgs, model->BSIM4v5vgsMax); + warns_vgs++; + } + + if (vgd > model->BSIM4v5vgdMax) + if (warns_vgd < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vgd|=%g has exceeded Vgd_max=%g\n", + vgd, model->BSIM4v5vgdMax); + warns_vgd++; + } + + if (vgb > model->BSIM4v5vgbMax) + if (warns_vgb < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vgb|=%g has exceeded Vgb_max=%g\n", + vgb, model->BSIM4v5vgbMax); + warns_vgb++; + } + + if (vds > model->BSIM4v5vdsMax) + if (warns_vds < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vds|=%g has exceeded Vds_max=%g\n", + vds, model->BSIM4v5vdsMax); + warns_vds++; + } + + if (vbs > model->BSIM4v5vbsMax) + if (warns_vbs < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vbs|=%g has exceeded Vbs_max=%g\n", + vbs, model->BSIM4v5vbsMax); + warns_vbs++; + } + + if (vbd > model->BSIM4v5vbdMax) + if (warns_vbd < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vbd|=%g has exceeded Vbd_max=%g\n", + vbd, model->BSIM4v5vbdMax); + warns_vbd++; + } + + } + } + + return OK; +} diff --git a/src/spicelib/devices/bsim4v5/bsim4v5def.h b/src/spicelib/devices/bsim4v5/bsim4v5def.h index 3a7a59855..3cef6e15b 100644 --- a/src/spicelib/devices/bsim4v5/bsim4v5def.h +++ b/src/spicelib/devices/bsim4v5/bsim4v5def.h @@ -1470,6 +1470,13 @@ typedef struct sBSIM4v5model double BSIM4v5af; double BSIM4v5kf; + double BSIM4v5vgsMax; + double BSIM4v5vgdMax; + double BSIM4v5vgbMax; + double BSIM4v5vdsMax; + double BSIM4v5vbsMax; + double BSIM4v5vbdMax; + struct bsim4v5SizeDependParam *pSizeDependParamKnot; /* Flags */ @@ -2192,6 +2199,13 @@ typedef struct sBSIM4v5model unsigned BSIM4v5afGiven :1; unsigned BSIM4v5kfGiven :1; + unsigned BSIM4v5vgsMaxGiven :1; + unsigned BSIM4v5vgdMaxGiven :1; + unsigned BSIM4v5vgbMaxGiven :1; + unsigned BSIM4v5vdsMaxGiven :1; + unsigned BSIM4v5vbsMaxGiven :1; + unsigned BSIM4v5vbdMaxGiven :1; + unsigned BSIM4v5LintGiven :1; unsigned BSIM4v5LlGiven :1; unsigned BSIM4v5LlcGiven :1; @@ -3164,6 +3178,13 @@ typedef struct sBSIM4v5model #define BSIM4v5_MOD_RBSDBYW 1125 #define BSIM4v5_MOD_RBSDBYNF 1126 +#define BSIM4v5_MOD_VGS_MAX 1201 +#define BSIM4v5_MOD_VGD_MAX 1202 +#define BSIM4v5_MOD_VGB_MAX 1203 +#define BSIM4v5_MOD_VDS_MAX 1204 +#define BSIM4v5_MOD_VBS_MAX 1205 +#define BSIM4v5_MOD_VBD_MAX 1206 + #include "bsim4v5ext.h" extern void BSIM4v5evaluate(double,double,double,BSIM4v5instance*,BSIM4v5model*, diff --git a/src/spicelib/devices/bsim4v5/bsim4v5ext.h b/src/spicelib/devices/bsim4v5/bsim4v5ext.h index 511969bfb..d4b72da68 100644 --- a/src/spicelib/devices/bsim4v5/bsim4v5ext.h +++ b/src/spicelib/devices/bsim4v5/bsim4v5ext.h @@ -28,3 +28,4 @@ extern int BSIM4v5temp(GENmodel*,CKTcircuit*); extern int BSIM4v5trunc(GENmodel*,CKTcircuit*,double*); extern int BSIM4v5noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int BSIM4v5unsetup(GENmodel*,CKTcircuit*); +extern int BSIM4v5soaCheck(CKTcircuit *, GENmodel *); diff --git a/src/spicelib/devices/bsim4v5/bsim4v5init.c b/src/spicelib/devices/bsim4v5/bsim4v5init.c index e0280b3ee..ba6aca999 100644 --- a/src/spicelib/devices/bsim4v5/bsim4v5init.c +++ b/src/spicelib/devices/bsim4v5/bsim4v5init.c @@ -67,7 +67,7 @@ SPICEdev BSIM4v5info = { NULL, /* DEVsenTrunc */ NULL, /* DEVdisto */ BSIM4v5noise, /* DEVnoise */ - NULL, /* DEVsoaCheck */ + BSIM4v5soaCheck, /* DEVsoaCheck */ #ifdef CIDER NULL, /* DEVdump */ NULL, /* DEVacct */ diff --git a/visualc/vngspice.vcproj b/visualc/vngspice.vcproj index 4fa4eb9f5..8b79e4940 100644 --- a/visualc/vngspice.vcproj +++ b/visualc/vngspice.vcproj @@ -4216,6 +4216,10 @@ RelativePath="..\src\spicelib\devices\bsim4v5\b4v5set.c" > + +