From f9c05885fa8c5dae497e2d4f95a2387b57e93663 Mon Sep 17 00:00:00 2001 From: dwarning Date: Wed, 30 Oct 2013 20:14:22 +0100 Subject: [PATCH] devices/bsim3v32, implement BSIM3v32soaCheck() --- src/spicelib/devices/bsim3v32/Makefile.am | 1 + src/spicelib/devices/bsim3v32/b3v32.c | 7 ++ src/spicelib/devices/bsim3v32/b3v32mask.c | 20 ++++ src/spicelib/devices/bsim3v32/b3v32mpar.c | 26 +++++ src/spicelib/devices/bsim3v32/b3v32set.c | 14 +++ src/spicelib/devices/bsim3v32/b3v32soachk.c | 110 +++++++++++++++++++ src/spicelib/devices/bsim3v32/bsim3v32def.h | 20 ++++ src/spicelib/devices/bsim3v32/bsim3v32ext.h | 1 + src/spicelib/devices/bsim3v32/bsim3v32init.c | 2 +- visualc/vngspice.vcproj | 4 + 10 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/spicelib/devices/bsim3v32/b3v32soachk.c diff --git a/src/spicelib/devices/bsim3v32/Makefile.am b/src/spicelib/devices/bsim3v32/Makefile.am index 37674d382..8c5bb529a 100644 --- a/src/spicelib/devices/bsim3v32/Makefile.am +++ b/src/spicelib/devices/bsim3v32/Makefile.am @@ -19,6 +19,7 @@ libbsim3v32_la_SOURCES = \ b3v32par.c \ b3v32pzld.c \ b3v32set.c \ + b3v32soachk.c \ b3v32temp.c \ b3v32trunc.c \ bsim3v32def.h \ diff --git a/src/spicelib/devices/bsim3v32/b3v32.c b/src/spicelib/devices/bsim3v32/b3v32.c index b2d17ba94..0e026cd56 100644 --- a/src/spicelib/devices/bsim3v32/b3v32.c +++ b/src/spicelib/devices/bsim3v32/b3v32.c @@ -498,6 +498,13 @@ IOP( "ef", BSIM3v32_MOD_EF, IF_REAL, "Flicker noise frequency exponent"), IOP( "af", BSIM3v32_MOD_AF, IF_REAL, "Flicker noise exponent"), IOP( "kf", BSIM3v32_MOD_KF, IF_REAL, "Flicker noise coefficient"), +IOP("vgs_max", BSIM3v32_MOD_VGS_MAX, IF_REAL, "maximum voltage G-S branch"), +IOP("vgd_max", BSIM3v32_MOD_VGD_MAX, IF_REAL, "maximum voltage G-D branch"), +IOP("vgb_max", BSIM3v32_MOD_VGB_MAX, IF_REAL, "maximum voltage G-B branch"), +IOP("vds_max", BSIM3v32_MOD_VDS_MAX, IF_REAL, "maximum voltage D-S branch"), +IOP("vbs_max", BSIM3v32_MOD_VBS_MAX, IF_REAL, "maximum voltage B-S branch"), +IOP("vbd_max", BSIM3v32_MOD_VBD_MAX, IF_REAL, "maximum voltage B-D branch"), + IP( "nmos", BSIM3v32_MOD_NMOS, IF_FLAG, "Flag to indicate NMOS"), IP( "pmos", BSIM3v32_MOD_PMOS, IF_FLAG, "Flag to indicate PMOS"), }; diff --git a/src/spicelib/devices/bsim3v32/b3v32mask.c b/src/spicelib/devices/bsim3v32/b3v32mask.c index d54ee9558..729801ada 100644 --- a/src/spicelib/devices/bsim3v32/b3v32mask.c +++ b/src/spicelib/devices/bsim3v32/b3v32mask.c @@ -1274,6 +1274,26 @@ BSIM3v32mAsk (CKTcircuit *ckt, GENmodel *inst, int which, IFvalue *value) case BSIM3v32_MOD_KF: value->rValue = model->BSIM3v32kf; return(OK); + + case BSIM3v32_MOD_VGS_MAX: + value->rValue = model->BSIM3v32vgsMax; + return(OK); + case BSIM3v32_MOD_VGD_MAX: + value->rValue = model->BSIM3v32vgdMax; + return(OK); + case BSIM3v32_MOD_VGB_MAX: + value->rValue = model->BSIM3v32vgbMax; + return(OK); + case BSIM3v32_MOD_VDS_MAX: + value->rValue = model->BSIM3v32vdsMax; + return(OK); + case BSIM3v32_MOD_VBS_MAX: + value->rValue = model->BSIM3v32vbsMax; + return(OK); + case BSIM3v32_MOD_VBD_MAX: + value->rValue = model->BSIM3v32vbdMax; + return(OK); + default: return(E_BADPARM); } diff --git a/src/spicelib/devices/bsim3v32/b3v32mpar.c b/src/spicelib/devices/bsim3v32/b3v32mpar.c index 353f6320d..ed5442cf7 100644 --- a/src/spicelib/devices/bsim3v32/b3v32mpar.c +++ b/src/spicelib/devices/bsim3v32/b3v32mpar.c @@ -1709,6 +1709,32 @@ BSIM3v32mParam(int param, IFvalue *value, GENmodel *inMod) mod->BSIM3v32kf = value->rValue; mod->BSIM3v32kfGiven = TRUE; break; + + case BSIM3v32_MOD_VGS_MAX: + mod->BSIM3v32vgsMax = value->rValue; + mod->BSIM3v32vgsMaxGiven = TRUE; + break; + case BSIM3v32_MOD_VGD_MAX: + mod->BSIM3v32vgdMax = value->rValue; + mod->BSIM3v32vgdMaxGiven = TRUE; + break; + case BSIM3v32_MOD_VGB_MAX: + mod->BSIM3v32vgbMax = value->rValue; + mod->BSIM3v32vgbMaxGiven = TRUE; + break; + case BSIM3v32_MOD_VDS_MAX: + mod->BSIM3v32vdsMax = value->rValue; + mod->BSIM3v32vdsMaxGiven = TRUE; + break; + case BSIM3v32_MOD_VBS_MAX: + mod->BSIM3v32vbsMax = value->rValue; + mod->BSIM3v32vbsMaxGiven = TRUE; + break; + case BSIM3v32_MOD_VBD_MAX: + mod->BSIM3v32vbdMax = value->rValue; + mod->BSIM3v32vbdMaxGiven = TRUE; + break; + case BSIM3v32_MOD_NMOS : if(value->iValue) { mod->BSIM3v32type = 1; diff --git a/src/spicelib/devices/bsim3v32/b3v32set.c b/src/spicelib/devices/bsim3v32/b3v32set.c index 8d18aeb57..5f9d90e23 100644 --- a/src/spicelib/devices/bsim3v32/b3v32set.c +++ b/src/spicelib/devices/bsim3v32/b3v32set.c @@ -902,6 +902,20 @@ IFuid tmpName; model->BSIM3v32af = 1.0; if (!model->BSIM3v32kfGiven) model->BSIM3v32kf = 0.0; + + if (!model->BSIM3v32vgsMaxGiven) + model->BSIM3v32vgsMax = 1e99; + if (!model->BSIM3v32vgdMaxGiven) + model->BSIM3v32vgdMax = 1e99; + if (!model->BSIM3v32vgbMaxGiven) + model->BSIM3v32vgbMax = 1e99; + if (!model->BSIM3v32vdsMaxGiven) + model->BSIM3v32vdsMax = 1e99; + if (!model->BSIM3v32vbsMaxGiven) + model->BSIM3v32vbsMax = 1e99; + if (!model->BSIM3v32vbdMaxGiven) + model->BSIM3v32vbdMax = 1e99; + /* loop through all the instances of the model */ for (here = model->BSIM3v32instances; here != NULL ; here=here->BSIM3v32nextInstance) diff --git a/src/spicelib/devices/bsim3v32/b3v32soachk.c b/src/spicelib/devices/bsim3v32/b3v32soachk.c new file mode 100644 index 000000000..e60ce1bd0 --- /dev/null +++ b/src/spicelib/devices/bsim3v32/b3v32soachk.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 "bsim3v32def.h" +#include "ngspice/trandefs.h" +#include "ngspice/sperror.h" +#include "ngspice/suffix.h" +#include "ngspice/cpdefs.h" + + +int +BSIM3v32soaCheck(CKTcircuit *ckt, GENmodel *inModel) +{ + BSIM3v32model *model = (BSIM3v32model *) inModel; + BSIM3v32instance *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->BSIM3v32nextModel) { + + for (here = model->BSIM3v32instances; here; here = here->BSIM3v32nextInstance) { + + vgs = fabs(ckt->CKTrhsOld [here->BSIM3v32gNode] - + ckt->CKTrhsOld [here->BSIM3v32sNodePrime]); + + vgd = fabs(ckt->CKTrhsOld [here->BSIM3v32gNode] - + ckt->CKTrhsOld [here->BSIM3v32dNodePrime]); + + vgb = fabs(ckt->CKTrhsOld [here->BSIM3v32gNode] - + ckt->CKTrhsOld [here->BSIM3v32bNode]); + + vds = fabs(ckt->CKTrhsOld [here->BSIM3v32dNodePrime] - + ckt->CKTrhsOld [here->BSIM3v32sNodePrime]); + + vbs = fabs(ckt->CKTrhsOld [here->BSIM3v32bNode] - + ckt->CKTrhsOld [here->BSIM3v32sNodePrime]); + + vbd = fabs(ckt->CKTrhsOld [here->BSIM3v32bNode] - + ckt->CKTrhsOld [here->BSIM3v32dNodePrime]); + + if (vgs > model->BSIM3v32vgsMax) + if (warns_vgs < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vgs|=%g has exceeded Vgs_max=%g\n", + vgs, model->BSIM3v32vgsMax); + warns_vgs++; + } + + if (vgd > model->BSIM3v32vgdMax) + if (warns_vgd < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vgd|=%g has exceeded Vgd_max=%g\n", + vgd, model->BSIM3v32vgdMax); + warns_vgd++; + } + + if (vgb > model->BSIM3v32vgbMax) + if (warns_vgb < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vgb|=%g has exceeded Vgb_max=%g\n", + vgb, model->BSIM3v32vgbMax); + warns_vgb++; + } + + if (vds > model->BSIM3v32vdsMax) + if (warns_vds < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vds|=%g has exceeded Vds_max=%g\n", + vds, model->BSIM3v32vdsMax); + warns_vds++; + } + + if (vbs > model->BSIM3v32vbsMax) + if (warns_vbs < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vbs|=%g has exceeded Vbs_max=%g\n", + vbs, model->BSIM3v32vbsMax); + warns_vbs++; + } + + if (vbd > model->BSIM3v32vbdMax) + if (warns_vbd < maxwarns) { + soa_printf(ckt, (GENinstance*) here, + "|Vbd|=%g has exceeded Vbd_max=%g\n", + vbd, model->BSIM3v32vbdMax); + warns_vbd++; + } + + } + } + + return OK; +} diff --git a/src/spicelib/devices/bsim3v32/bsim3v32def.h b/src/spicelib/devices/bsim3v32/bsim3v32def.h index a98f2b59f..1962c5493 100644 --- a/src/spicelib/devices/bsim3v32/bsim3v32def.h +++ b/src/spicelib/devices/bsim3v32/bsim3v32def.h @@ -822,6 +822,13 @@ typedef struct sBSIM3v32model double BSIM3v32af; double BSIM3v32kf; + double BSIM3v32vgsMax; + double BSIM3v32vgdMax; + double BSIM3v32vgbMax; + double BSIM3v32vdsMax; + double BSIM3v32vbsMax; + double BSIM3v32vbdMax; + struct bsim3v32SizeDependParam *pSizeDependParamKnot; /* Flags */ @@ -1259,6 +1266,13 @@ typedef struct sBSIM3v32model unsigned BSIM3v32WminGiven :1; unsigned BSIM3v32WmaxGiven :1; + unsigned BSIM3v32vgsMaxGiven :1; + unsigned BSIM3v32vgdMaxGiven :1; + unsigned BSIM3v32vgbMaxGiven :1; + unsigned BSIM3v32vdsMaxGiven :1; + unsigned BSIM3v32vbsMaxGiven :1; + unsigned BSIM3v32vbdMaxGiven :1; + } BSIM3v32model; @@ -1814,6 +1828,12 @@ typedef struct sBSIM3v32model #define BSIM3v32_CBDB 792 #define BSIM3v32_CBSB 793 +#define BSIM3v32_MOD_VGS_MAX 801 +#define BSIM3v32_MOD_VGD_MAX 802 +#define BSIM3v32_MOD_VGB_MAX 803 +#define BSIM3v32_MOD_VDS_MAX 804 +#define BSIM3v32_MOD_VBS_MAX 805 +#define BSIM3v32_MOD_VBD_MAX 806 #include "bsim3v32ext.h" diff --git a/src/spicelib/devices/bsim3v32/bsim3v32ext.h b/src/spicelib/devices/bsim3v32/bsim3v32ext.h index b64496f6d..64ff43ccf 100644 --- a/src/spicelib/devices/bsim3v32/bsim3v32ext.h +++ b/src/spicelib/devices/bsim3v32/bsim3v32ext.h @@ -29,3 +29,4 @@ extern int BSIM3v32temp(GENmodel*,CKTcircuit*); extern int BSIM3v32trunc(GENmodel*,CKTcircuit*,double*); extern int BSIM3v32noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int BSIM3v32unsetup(GENmodel*,CKTcircuit*); +extern int BSIM3v32soaCheck(CKTcircuit *, GENmodel *); diff --git a/src/spicelib/devices/bsim3v32/bsim3v32init.c b/src/spicelib/devices/bsim3v32/bsim3v32init.c index 52f52726a..e109cf654 100644 --- a/src/spicelib/devices/bsim3v32/bsim3v32init.c +++ b/src/spicelib/devices/bsim3v32/bsim3v32init.c @@ -66,7 +66,7 @@ SPICEdev BSIM3v32info = { /* DEVsenTrunc */ NULL, /* DEVdisto */ NULL, /* DEVnoise */ BSIM3v32noise, - /* DEVsoaCheck */ NULL, + /* DEVsoaCheck */ BSIM3v32soaCheck, #ifdef CIDER /* DEVdump */ NULL, /* DEVacct */ NULL, diff --git a/visualc/vngspice.vcproj b/visualc/vngspice.vcproj index d7677e2c8..7b5f89e95 100644 --- a/visualc/vngspice.vcproj +++ b/visualc/vngspice.vcproj @@ -3904,6 +3904,10 @@ RelativePath="..\src\spicelib\devices\bsim3v32\b3v32set.c" > + +