From 7fae91cd5fcd18eb86ada0fc7d777a3d7da54f87 Mon Sep 17 00:00:00 2001 From: pnenzi Date: Mon, 26 Nov 2001 16:17:31 +0000 Subject: [PATCH] Some code cleanups and conformed to ngspice device interface. --- DEVICES | 3 +- src/spicelib/devices/bsim4/b4acld.c | 11 ++-- src/spicelib/devices/bsim4/b4ask.c | 2 +- src/spicelib/devices/bsim4/b4check.c | 5 +- src/spicelib/devices/bsim4/b4cvtest.c | 13 +++-- src/spicelib/devices/bsim4/b4del.c | 1 - src/spicelib/devices/bsim4/b4dest.c | 1 - src/spicelib/devices/bsim4/b4getic.c | 4 +- src/spicelib/devices/bsim4/b4ld.c | 44 +-------------- src/spicelib/devices/bsim4/b4mask.c | 2 +- src/spicelib/devices/bsim4/b4mdel.c | 2 +- src/spicelib/devices/bsim4/b4mpar.c | 1 - src/spicelib/devices/bsim4/b4noi.c | 7 ++- src/spicelib/devices/bsim4/b4par.c | 1 - src/spicelib/devices/bsim4/b4pzld.c | 12 ++--- src/spicelib/devices/bsim4/b4set.c | 26 ++++----- src/spicelib/devices/bsim4/b4temp.c | 8 +-- src/spicelib/devices/bsim4/b4trunc.c | 8 +-- src/spicelib/devices/bsim4/bsim4def.h | 1 + src/spicelib/devices/bsim4/bsim4itf.h | 78 +-------------------------- 20 files changed, 58 insertions(+), 172 deletions(-) diff --git a/DEVICES b/DEVICES index 305664c74..f3320bef4 100644 --- a/DEVICES +++ b/DEVICES @@ -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. \ No newline at end of file + *) rework-14: removed #ifndef NEWCONV code. diff --git a/src/spicelib/devices/bsim4/b4acld.c b/src/spicelib/devices/bsim4/b4acld.c index 86e4d38b3..28dc21b8a 100644 --- a/src/spicelib/devices/bsim4/b4acld.c +++ b/src/spicelib/devices/bsim4/b4acld.c @@ -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; diff --git a/src/spicelib/devices/bsim4/b4ask.c b/src/spicelib/devices/bsim4/b4ask.c index 449861231..e3353cb57 100644 --- a/src/spicelib/devices/bsim4/b4ask.c +++ b/src/spicelib/devices/bsim4/b4ask.c @@ -18,7 +18,7 @@ #include "devdefs.h" #include "bsim4def.h" #include "sperror.h" -#include "suffix.h" + int BSIM4ask(ckt,inst,which,value,select) diff --git a/src/spicelib/devices/bsim4/b4check.c b/src/spicelib/devices/bsim4/b4check.c index 820c4091b..50fb00be1 100644 --- a/src/spicelib/devices/bsim4/b4check.c +++ b/src/spicelib/devices/bsim4/b4check.c @@ -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; diff --git a/src/spicelib/devices/bsim4/b4cvtest.c b/src/spicelib/devices/bsim4/b4cvtest.c index 861b6b32a..2626b5a5f 100644 --- a/src/spicelib/devices/bsim4/b4cvtest.c +++ b/src/spicelib/devices/bsim4/b4cvtest.c @@ -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 diff --git a/src/spicelib/devices/bsim4/b4del.c b/src/spicelib/devices/bsim4/b4del.c index ecae506d0..fde0870bc 100644 --- a/src/spicelib/devices/bsim4/b4del.c +++ b/src/spicelib/devices/bsim4/b4del.c @@ -13,7 +13,6 @@ #include "bsim4def.h" #include "sperror.h" #include "gendefs.h" -#include "suffix.h" int diff --git a/src/spicelib/devices/bsim4/b4dest.c b/src/spicelib/devices/bsim4/b4dest.c index 7dbc1d5d4..d1c5f2bd4 100644 --- a/src/spicelib/devices/bsim4/b4dest.c +++ b/src/spicelib/devices/bsim4/b4dest.c @@ -11,7 +11,6 @@ #include "ngspice.h" #include #include "bsim4def.h" -#include "suffix.h" void BSIM4destroy(inModel) diff --git a/src/spicelib/devices/bsim4/b4getic.c b/src/spicelib/devices/bsim4/b4getic.c index 6deff2424..0c1550e04 100644 --- a/src/spicelib/devices/bsim4/b4getic.c +++ b/src/spicelib/devices/bsim4/b4getic.c @@ -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); } diff --git a/src/spicelib/devices/bsim4/b4ld.c b/src/spicelib/devices/bsim4/b4ld.c index 37564b454..e89ad662e 100644 --- a/src/spicelib/devices/bsim4/b4ld.c +++ b/src/spicelib/devices/bsim4/b4ld.c @@ -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; diff --git a/src/spicelib/devices/bsim4/b4mask.c b/src/spicelib/devices/bsim4/b4mask.c index 6dd16ddc8..7ee477130 100644 --- a/src/spicelib/devices/bsim4/b4mask.c +++ b/src/spicelib/devices/bsim4/b4mask.c @@ -16,7 +16,7 @@ #include "devdefs.h" #include "bsim4def.h" #include "sperror.h" -#include "suffix.h" + int BSIM4mAsk(ckt,inst,which,value) diff --git a/src/spicelib/devices/bsim4/b4mdel.c b/src/spicelib/devices/bsim4/b4mdel.c index d133c0e81..c472a97be 100644 --- a/src/spicelib/devices/bsim4/b4mdel.c +++ b/src/spicelib/devices/bsim4/b4mdel.c @@ -12,7 +12,7 @@ #include #include "bsim4def.h" #include "sperror.h" -#include "suffix.h" + int BSIM4mDelete(inModel,modname,kill) diff --git a/src/spicelib/devices/bsim4/b4mpar.c b/src/spicelib/devices/bsim4/b4mpar.c index 679e20843..a4606612e 100644 --- a/src/spicelib/devices/bsim4/b4mpar.c +++ b/src/spicelib/devices/bsim4/b4mpar.c @@ -15,7 +15,6 @@ #include "bsim4def.h" #include "ifsim.h" #include "sperror.h" -#include "suffix.h" #include "const.h" int diff --git a/src/spicelib/devices/bsim4/b4noi.c b/src/spicelib/devices/bsim4/b4noi.c index f5663d2e6..434d01713 100644 --- a/src/spicelib/devices/bsim4/b4noi.c +++ b/src/spicelib/devices/bsim4/b4noi.c @@ -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; diff --git a/src/spicelib/devices/bsim4/b4par.c b/src/spicelib/devices/bsim4/b4par.c index 6fde48085..aa4b450e9 100644 --- a/src/spicelib/devices/bsim4/b4par.c +++ b/src/spicelib/devices/bsim4/b4par.c @@ -13,7 +13,6 @@ #include "ifsim.h" #include "bsim4def.h" #include "sperror.h" -#include "suffix.h" int BSIM4param(param,value,inst,select) diff --git a/src/spicelib/devices/bsim4/b4pzld.c b/src/spicelib/devices/bsim4/b4pzld.c index d75087cd7..7d07f2da1 100644 --- a/src/spicelib/devices/bsim4/b4pzld.c +++ b/src/spicelib/devices/bsim4/b4pzld.c @@ -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; diff --git a/src/spicelib/devices/bsim4/b4set.c b/src/spicelib/devices/bsim4/b4set.c index ffe5bbf6f..e15e88214 100644 --- a/src/spicelib/devices/bsim4/b4set.c +++ b/src/spicelib/devices/bsim4/b4set.c @@ -13,14 +13,14 @@ #include "ngspice.h" #include #include -#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; } diff --git a/src/spicelib/devices/bsim4/b4temp.c b/src/spicelib/devices/bsim4/b4temp.c index 06237253f..c84334d3f 100644 --- a/src/spicelib/devices/bsim4/b4temp.c +++ b/src/spicelib/devices/bsim4/b4temp.c @@ -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) diff --git a/src/spicelib/devices/bsim4/b4trunc.c b/src/spicelib/devices/bsim4/b4trunc.c index 8d1cb3b53..d6e881e65 100644 --- a/src/spicelib/devices/bsim4/b4trunc.c +++ b/src/spicelib/devices/bsim4/b4trunc.c @@ -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 */ diff --git a/src/spicelib/devices/bsim4/bsim4def.h b/src/spicelib/devices/bsim4/bsim4def.h index cd4d6cb1b..b46a09273 100644 --- a/src/spicelib/devices/bsim4/bsim4def.h +++ b/src/spicelib/devices/bsim4/bsim4def.h @@ -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; diff --git a/src/spicelib/devices/bsim4/bsim4itf.h b/src/spicelib/devices/bsim4/bsim4itf.h index 911050479..08c4ec852 100644 --- a/src/spicelib/devices/bsim4/bsim4itf.h +++ b/src/spicelib/devices/bsim4/bsim4itf.h @@ -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