Some code cleanups and conformed to ngspice device interface.

This commit is contained in:
pnenzi 2001-11-26 16:17:31 +00:00
parent 402eff28a2
commit 7fae91cd5f
20 changed files with 58 additions and 172 deletions

View File

@ -154,6 +154,7 @@ BSIM3v2 - BSIM model level 3
BSIM4 - BSIM model level 4 (0.18 um)
Initial Release. TO BE TESTED.
Updated to 4.21 YET UNTESTED.
**************************************
@ -191,4 +192,4 @@ BSIM3SOI_DD - SOI Model (dynamic depletion model)
web site at:
http://www-device.eecs.berkeley.edu/~bsimsoi
*) rework-14: removed #ifndef NEWCONV code.
*) rework-14: removed #ifndef NEWCONV code.

View File

@ -15,16 +15,16 @@
#include "cktdefs.h"
#include "bsim4def.h"
#include "sperror.h"
#include "suffix.h"
int
BSIM4acLoad(inModel,ckt)
GENmodel *inModel;
register CKTcircuit *ckt;
CKTcircuit *ckt;
{
register BSIM4model *model = (BSIM4model*)inModel;
register BSIM4instance *here;
BSIM4model *model = (BSIM4model*)inModel;
BSIM4instance *here;
double gjbd, gjbs, geltd, gcrg, gcrgg, gcrgd, gcrgs, gcrgb;
double xcbgb, xcbdb, xcbsb, xcbbb;
@ -58,7 +58,8 @@ double ggidld, ggidlg, ggidlb,ggisld, ggislg, ggislb, ggisls;
for (; model != NULL; model = model->BSIM4nextModel)
{ for (here = model->BSIM4instances; here!= NULL;
here = here->BSIM4nextInstance)
{ pParam = here->pParam;
{ if (here->BSIM4owner != ARCHme) continue;
pParam = here->pParam;
capbd = here->BSIM4capbd;
capbs = here->BSIM4capbs;
cgso = here->BSIM4cgso;

View File

@ -18,7 +18,7 @@
#include "devdefs.h"
#include "bsim4def.h"
#include "sperror.h"
#include "suffix.h"
int
BSIM4ask(ckt,inst,which,value,select)

View File

@ -19,12 +19,11 @@
#include "const.h"
#include "sperror.h"
#include "devdefs.h"
#include "suffix.h"
int
BSIM4checkModel(model, here, ckt)
register BSIM4model *model;
register BSIM4instance *here;
BSIM4model *model;
BSIM4instance *here;
CKTcircuit *ckt;
{
struct bsim4SizeDependParam *pParam;

View File

@ -19,16 +19,16 @@
#include "const.h"
#include "devdefs.h"
#include "sperror.h"
#include "suffix.h"
int
BSIM4convTest(inModel,ckt)
GENmodel *inModel;
register CKTcircuit *ckt;
CKTcircuit *ckt;
{
register BSIM4model *model = (BSIM4model*)inModel;
register BSIM4instance *here;
BSIM4model *model = (BSIM4model*)inModel;
BSIM4instance *here;
double delvbd, delvbs, delvds, delvgd, delvgs;
double delvdbd, delvsbs;
double delvbd_jct, delvbs_jct;
@ -43,7 +43,10 @@ double tol0, tol1, tol2, tol3, tol4, tol5, tol6;
for (; model != NULL; model = model->BSIM4nextModel)
{ for (here = model->BSIM4instances; here != NULL ;
here=here->BSIM4nextInstance)
{ vds = model->BSIM4type
{
if (here->BSIM4owner != ARCHme) continue;
vds = model->BSIM4type
* (*(ckt->CKTrhsOld + here->BSIM4dNodePrime)
- *(ckt->CKTrhsOld + here->BSIM4sNodePrime));
vgs = model->BSIM4type

View File

@ -13,7 +13,6 @@
#include "bsim4def.h"
#include "sperror.h"
#include "gendefs.h"
#include "suffix.h"
int

View File

@ -11,7 +11,6 @@
#include "ngspice.h"
#include <stdio.h>
#include "bsim4def.h"
#include "suffix.h"
void
BSIM4destroy(inModel)

View File

@ -13,7 +13,6 @@
#include "cktdefs.h"
#include "bsim4def.h"
#include "sperror.h"
#include "suffix.h"
int
@ -26,7 +25,8 @@ BSIM4instance *here;
for (; model ; model = model->BSIM4nextModel)
{ for (here = model->BSIM4instances; here; here = here->BSIM4nextInstance)
{ if (!here->BSIM4icVDSGiven)
{ if (here->BSIM4owner != ARCHme) continue;
if (!here->BSIM4icVDSGiven)
{ here->BSIM4icVDS = *(ckt->CKTrhs + here->BSIM4dNode)
- *(ckt->CKTrhs + here->BSIM4sNode);
}

View File

@ -19,7 +19,6 @@
#include "const.h"
#include "sperror.h"
#include "devdefs.h"
#include "suffix.h"
#define MAX_EXP 5.834617425e14
#define MIN_EXP 1.713908431e-15
@ -184,7 +183,8 @@ ChargeComputationNeeded =
for (; model != NULL; model = model->BSIM4nextModel)
{ for (here = model->BSIM4instances; here != NULL;
here = here->BSIM4nextInstance)
{ Check = Check1 = Check2 = 1;
{ if (here->BSIM4owner != ARCHme) continue;
Check = Check1 = Check2 = 1;
ByPass = 0;
pParam = here->pParam;
@ -3376,46 +3376,6 @@ finished:
if ((here->BSIM4off == 0) || (!(ckt->CKTmode & MODEINITFIX)))
{ if (Check == 1)
{ ckt->CKTnoncon++;
#ifndef NEWCONV
}
else
{ if (here->BSIM4mode >= 0)
{ Idtot = here->BSIM4cd + here->BSIM4csub
+ here->BSIM4Igidl - here->BSIM4cbd;
}
else
{ Idtot = here->BSIM4cd + here->BSIM4cbd;
}
tol0 = ckt->CKTreltol * MAX(fabs(cdhat), fabs(Idtot))
+ ckt->CKTabstol;
tol1 = ckt->CKTreltol * MAX(fabs(cseshat), fabs(Isestot))
+ ckt->CKTabstol;
tol2 = ckt->CKTreltol * MAX(fabs(cdedhat), fabs(Idedtot))
+ ckt->CKTabstol;
tol3 = ckt->CKTreltol * MAX(fabs(cgshat), fabs(Igstot))
+ ckt->CKTabstol;
tol4 = ckt->CKTreltol * MAX(fabs(cgdhat), fabs(Igdtot))
+ ckt->CKTabstol;
tol5 = ckt->CKTreltol * MAX(fabs(cgbhat), fabs(Igbtot))
+ ckt->CKTabstol;
if ((fabs(cdhat - Idtot) >= tol0) || (fabs(cseshat - Isestot) >= tol1)
|| (fabs(cdedhat - Idedtot) >= tol2))
{ ckt->CKTnoncon++;
}
else if ((fabs(cgshat - Igstot) >= tol3) || (fabs(cgdhat - Igdtot) >= tol4)
|| (fabs(cgbhat - Igbtot) >= tol5))
{ ckt->CKTnoncon++;
}
else
{ Ibtot = here->BSIM4cbs + here->BSIM4cbd
- here->BSIM4Igidl - here->BSIM4Igisl - here->BSIM4csub;
tol6 = ckt->CKTreltol * MAX(fabs(cbhat), fabs(Ibtot))
+ ckt->CKTabstol;
if (fabs(cbhat - Ibtot) > tol6)
{ ckt->CKTnoncon++;
}
}
#endif /* NEWCONV */
}
}
*(ckt->CKTstate0 + here->BSIM4vds) = vds;

View File

@ -16,7 +16,7 @@
#include "devdefs.h"
#include "bsim4def.h"
#include "sperror.h"
#include "suffix.h"
int
BSIM4mAsk(ckt,inst,which,value)

View File

@ -12,7 +12,7 @@
#include <stdio.h>
#include "bsim4def.h"
#include "sperror.h"
#include "suffix.h"
int
BSIM4mDelete(inModel,modname,kill)

View File

@ -15,7 +15,6 @@
#include "bsim4def.h"
#include "ifsim.h"
#include "sperror.h"
#include "suffix.h"
#include "const.h"
int

View File

@ -17,7 +17,6 @@
#include "cktdefs.h"
#include "iferrmsg.h"
#include "noisedef.h"
#include "suffix.h"
#include "const.h"
@ -78,11 +77,11 @@ BSIM4noise (mode, operation, inModel, ckt, data, OnDens)
int mode, operation;
GENmodel *inModel;
CKTcircuit *ckt;
register Ndata *data;
Ndata *data;
double *OnDens;
{
register BSIM4model *model = (BSIM4model *)inModel;
register BSIM4instance *here;
BSIM4model *model = (BSIM4model *)inModel;
BSIM4instance *here;
struct bsim4SizeDependParam *pParam;
char name[N_MXVLNTH];
double tempOnoise;

View File

@ -13,7 +13,6 @@
#include "ifsim.h"
#include "bsim4def.h"
#include "sperror.h"
#include "suffix.h"
int
BSIM4param(param,value,inst,select)

View File

@ -16,16 +16,15 @@
#include "complex.h"
#include "sperror.h"
#include "bsim4def.h"
#include "suffix.h"
int
BSIM4pzLoad(inModel,ckt,s)
GENmodel *inModel;
register CKTcircuit *ckt;
register SPcomplex *s;
CKTcircuit *ckt;
SPcomplex *s;
{
register BSIM4model *model = (BSIM4model*)inModel;
register BSIM4instance *here;
BSIM4model *model = (BSIM4model*)inModel;
BSIM4instance *here;
double gjbd, gjbs, geltd, gcrg, gcrgg, gcrgd, gcrgs, gcrgb;
double xcggb, xcgdb, xcgsb, xcgbb, xcbgb, xcbdb, xcbsb, xcbbb;
@ -54,7 +53,8 @@ double ggidld, ggidlg, ggidlb,ggisld, ggislg, ggislb, ggisls;
for (; model != NULL; model = model->BSIM4nextModel)
{ for (here = model->BSIM4instances; here!= NULL;
here = here->BSIM4nextInstance)
{ pParam = here->pParam;
{ if (here->BSIM4owner != ARCHme) continue;
pParam = here->pParam;
capbd = here->BSIM4capbd;
capbs = here->BSIM4capbs;
cgso = here->BSIM4cgso;

View File

@ -13,14 +13,14 @@
#include "ngspice.h"
#include <stdio.h>
#include <math.h>
#include "jobdefs.h"
#include "ftedefs.h"
#include "jobdefs.h" /* Needed because the model searches for noise Analysis */
#include "ftedefs.h" /* " " */
#include "smpdefs.h"
#include "cktdefs.h"
#include "bsim4def.h"
#include "const.h"
#include "sperror.h"
#include "suffix.h"
#define MAX_EXP 5.834617425e14
#define MIN_EXP 1.713908431e-15
@ -32,13 +32,13 @@
int
BSIM4setup(matrix,inModel,ckt,states)
register SMPmatrix *matrix;
register GENmodel *inModel;
register CKTcircuit *ckt;
SMPmatrix *matrix;
GENmodel *inModel;
CKTcircuit *ckt;
int *states;
{
register BSIM4model *model = (BSIM4model*)inModel;
register BSIM4instance *here;
BSIM4model *model = (BSIM4model*)inModel;
BSIM4instance *here;
int error;
CKTnode *tmp;
double tmp1, tmp2;
@ -1335,10 +1335,13 @@ JOB *job;
*/
for (here = model->BSIM4instances; here != NULL ;
here=here->BSIM4nextInstance)
{ /* allocate a chunk of the state vector */
here=here->BSIM4nextInstance)
{
if (here->BSIM4owner == ARCHme) {
/* allocate a chunk of the state vector */
here->BSIM4states = *states;
*states += BSIM4numStates;
}
/* perform the parameter defaulting */
if (!here->BSIM4lGiven)
here->BSIM4l = 5.0e-6;
@ -1648,7 +1651,7 @@ BSIM4unsetup(inModel,ckt)
GENmodel *inModel;
CKTcircuit *ckt;
{
#ifndef HAS_BATCHSIM
BSIM4model *model;
BSIM4instance *here;
@ -1672,6 +1675,5 @@ BSIM4unsetup(inModel,ckt)
}
}
}
#endif
return OK;
}

View File

@ -18,7 +18,6 @@
#include "bsim4def.h"
#include "const.h"
#include "sperror.h"
#include "suffix.h"
#define Kb 1.3806226e-23
#define KboQ 8.617087e-5
@ -51,8 +50,8 @@ BSIM4temp(inModel,ckt)
GENmodel *inModel;
CKTcircuit *ckt;
{
register BSIM4model *model = (BSIM4model*) inModel;
register BSIM4instance *here;
BSIM4model *model = (BSIM4model*) inModel;
BSIM4instance *here;
struct bsim4SizeDependParam *pSizeDependParamKnot, *pLastKnot, *pParam;
double tmp, tmp1, tmp2, tmp3, Eg, Eg0, ni;
double T0, T1, T2, T3, T4, T5, T8, T9, Lnew, Wnew;
@ -321,7 +320,8 @@ int Size_Not_Found;
/* loop through all the instances of the model */
for (here = model->BSIM4instances; here != NULL;
here = here->BSIM4nextInstance)
{ pSizeDependParamKnot = model->pSizeDependParamKnot;
{ if (here->BSIM4owner != ARCHme) continue;
pSizeDependParamKnot = model->pSizeDependParamKnot;
Size_Not_Found = 1;
while ((pSizeDependParamKnot != NULL) && Size_Not_Found)
{ if ((here->BSIM4l == pSizeDependParamKnot->Length)

View File

@ -14,17 +14,16 @@
#include "cktdefs.h"
#include "bsim4def.h"
#include "sperror.h"
#include "suffix.h"
int
BSIM4trunc(inModel,ckt,timeStep)
GENmodel *inModel;
register CKTcircuit *ckt;
CKTcircuit *ckt;
double *timeStep;
{
register BSIM4model *model = (BSIM4model*)inModel;
register BSIM4instance *here;
BSIM4model *model = (BSIM4model*)inModel;
BSIM4instance *here;
#ifdef STEPDEBUG
double debugtemp;
@ -34,6 +33,7 @@ register BSIM4instance *here;
{ for (here = model->BSIM4instances; here != NULL;
here = here->BSIM4nextInstance)
{
if (here->BSIM4owner != ARCHme) continue;
#ifdef STEPDEBUG
debugtemp = *timeStep;
#endif /* STEPDEBUG */

View File

@ -19,6 +19,7 @@ typedef struct sBSIM4instance
struct sBSIM4model *BSIM4modPtr;
struct sBSIM4instance *BSIM4nextInstance;
IFuid BSIM4name;
int BSIM4owner; /* Number of owner process */
int BSIM4states; /* index into state table for this device */
int BSIM4dNode;
int BSIM4gNodeExt;

View File

@ -4,86 +4,10 @@ Author: 2000 Weidong Liu.
Author: 2001 Xuemei Xi
File: bsim4itf.h
**********/
#ifdef DEV_bsim4
#ifndef DEV_BSIM4
#define DEV_BSIM4
#include "bsim4ext.h"
extern IFparm BSIM4pTable[ ];
extern IFparm BSIM4mPTable[ ];
extern char *BSIM4names[ ];
extern int BSIM4pTSize;
extern int BSIM4mPTSize;
extern int BSIM4nSize;
extern int BSIM4iSize;
extern int BSIM4mSize;
SPICEdev B4info = {
{ "BSIM4",
"Berkeley Short Channel IGFET Model-4",
&BSIM4nSize,
&BSIM4nSize,
BSIM4names,
&BSIM4pTSize,
BSIM4pTable,
&BSIM4mPTSize,
BSIM4mPTable,
DEV_DEFAULT
},
BSIM4param,
BSIM4mParam,
BSIM4load,
BSIM4setup,
BSIM4unsetup,
BSIM4setup,
BSIM4temp,
BSIM4trunc,
NULL,
BSIM4acLoad,
NULL,
BSIM4destroy,
#ifdef DELETES
BSIM4mDelete,
BSIM4delete,
#else /* DELETES */
NULL,
NULL,
#endif /* DELETES */
BSIM4getic,
BSIM4ask,
BSIM4mAsk,
#ifdef AN_pz
BSIM4pzLoad,
#else /* AN_pz */
NULL,
#endif /* AN_pz */
#ifdef NEWCONV
BSIM4convTest,
#else /* NEWCONV */
NULL,
#endif /* NEWCONV */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
#ifdef AN_noise
BSIM4noise,
#else /* AN_noise */
NULL,
#endif /* AN_noise */
&BSIM4iSize,
&BSIM4mSize
};
SPICEdev *get_bsim4_info(void);
#endif
#endif