diff --git a/src/spicelib/devices/asrc/asrcinit.c b/src/spicelib/devices/asrc/asrcinit.c index 8360f5418..89518c8ce 100644 --- a/src/spicelib/devices/asrc/asrcinit.c +++ b/src/spicelib/devices/asrc/asrcinit.c @@ -74,7 +74,14 @@ SPICEdev ASRCinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &ASRCiSize, - /* DEVmodSize */ &ASRCmSize + /* DEVmodSize */ &ASRCmSize, + +#ifdef KLU + /* DEVbindCSC */ NULL, + /* DEVbindCSCComplex */ NULL, + /* DEVbindCSCComplexToReal */ NULL, +#endif + }; diff --git a/src/spicelib/devices/bjt/Makefile.am b/src/spicelib/devices/bjt/Makefile.am index 47aa59d69..e1ddb2a9d 100644 --- a/src/spicelib/devices/bjt/Makefile.am +++ b/src/spicelib/devices/bjt/Makefile.am @@ -36,6 +36,9 @@ libbjt_la_SOURCES = \ bjttrunc.c +if KLU_WANTED +libbjt_la_SOURCES += bjtbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bjt/bjtbindCSC.c b/src/spicelib/devices/bjt/bjtbindCSC.c new file mode 100644 index 000000000..409f27f60 --- /dev/null +++ b/src/spicelib/devices/bjt/bjtbindCSC.c @@ -0,0 +1,407 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bjtdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +BJTbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + BJTmodel *model = (BJTmodel *)inModel ; + BJTinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the BJT models */ + for ( ; model != NULL ; model = model->BJTnextModel) + { + /* loop through all the instances of the model */ + for (here = model->BJTinstances ; here != NULL ; here = here->BJTnextInstance) + { + if ((here->BJTcolNode != 0) && (here->BJTcolPrimeNode != 0)) + { + i = here->BJTcolColPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTcolColPrimeStructPtr = matched ; + here->BJTcolColPrimePtr = matched->CSC ; + } + + if ((here->BJTbaseNode != 0) && (here->BJTbasePrimeNode != 0)) + { + i = here->BJTbaseBasePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTbaseBasePrimeStructPtr = matched ; + here->BJTbaseBasePrimePtr = matched->CSC ; + } + + if ((here->BJTemitNode != 0) && (here->BJTemitPrimeNode != 0)) + { + i = here->BJTemitEmitPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTemitEmitPrimeStructPtr = matched ; + here->BJTemitEmitPrimePtr = matched->CSC ; + } + + if ((here->BJTcolPrimeNode != 0) && (here->BJTcolNode != 0)) + { + i = here->BJTcolPrimeColPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTcolPrimeColStructPtr = matched ; + here->BJTcolPrimeColPtr = matched->CSC ; + } + + if ((here->BJTcolPrimeNode != 0) && (here->BJTbasePrimeNode != 0)) + { + i = here->BJTcolPrimeBasePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTcolPrimeBasePrimeStructPtr = matched ; + here->BJTcolPrimeBasePrimePtr = matched->CSC ; + } + + if ((here->BJTcolPrimeNode != 0) && (here->BJTemitPrimeNode != 0)) + { + i = here->BJTcolPrimeEmitPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTcolPrimeEmitPrimeStructPtr = matched ; + here->BJTcolPrimeEmitPrimePtr = matched->CSC ; + } + + if ((here->BJTbasePrimeNode != 0) && (here->BJTbaseNode != 0)) + { + i = here->BJTbasePrimeBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTbasePrimeBaseStructPtr = matched ; + here->BJTbasePrimeBasePtr = matched->CSC ; + } + + if ((here->BJTbasePrimeNode != 0) && (here->BJTcolPrimeNode != 0)) + { + i = here->BJTbasePrimeColPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTbasePrimeColPrimeStructPtr = matched ; + here->BJTbasePrimeColPrimePtr = matched->CSC ; + } + + if ((here->BJTbasePrimeNode != 0) && (here->BJTemitPrimeNode != 0)) + { + i = here->BJTbasePrimeEmitPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTbasePrimeEmitPrimeStructPtr = matched ; + here->BJTbasePrimeEmitPrimePtr = matched->CSC ; + } + + if ((here->BJTemitPrimeNode != 0) && (here->BJTemitNode != 0)) + { + i = here->BJTemitPrimeEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTemitPrimeEmitStructPtr = matched ; + here->BJTemitPrimeEmitPtr = matched->CSC ; + } + + if ((here->BJTemitPrimeNode != 0) && (here->BJTcolPrimeNode != 0)) + { + i = here->BJTemitPrimeColPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTemitPrimeColPrimeStructPtr = matched ; + here->BJTemitPrimeColPrimePtr = matched->CSC ; + } + + if ((here->BJTemitPrimeNode != 0) && (here->BJTbasePrimeNode != 0)) + { + i = here->BJTemitPrimeBasePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTemitPrimeBasePrimeStructPtr = matched ; + here->BJTemitPrimeBasePrimePtr = matched->CSC ; + } + + if ((here->BJTcolNode != 0) && (here->BJTcolNode != 0)) + { + i = here->BJTcolColPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTcolColStructPtr = matched ; + here->BJTcolColPtr = matched->CSC ; + } + + if ((here->BJTbaseNode != 0) && (here->BJTbaseNode != 0)) + { + i = here->BJTbaseBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTbaseBaseStructPtr = matched ; + here->BJTbaseBasePtr = matched->CSC ; + } + + if ((here->BJTemitNode != 0) && (here->BJTemitNode != 0)) + { + i = here->BJTemitEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTemitEmitStructPtr = matched ; + here->BJTemitEmitPtr = matched->CSC ; + } + + if ((here->BJTcolPrimeNode != 0) && (here->BJTcolPrimeNode != 0)) + { + i = here->BJTcolPrimeColPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTcolPrimeColPrimeStructPtr = matched ; + here->BJTcolPrimeColPrimePtr = matched->CSC ; + } + + if ((here->BJTbasePrimeNode != 0) && (here->BJTbasePrimeNode != 0)) + { + i = here->BJTbasePrimeBasePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTbasePrimeBasePrimeStructPtr = matched ; + here->BJTbasePrimeBasePrimePtr = matched->CSC ; + } + + if ((here->BJTemitPrimeNode != 0) && (here->BJTemitPrimeNode != 0)) + { + i = here->BJTemitPrimeEmitPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTemitPrimeEmitPrimeStructPtr = matched ; + here->BJTemitPrimeEmitPrimePtr = matched->CSC ; + } + + if ((here->BJTsubstNode != 0) && (here->BJTsubstNode != 0)) + { + i = here->BJTsubstSubstPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTsubstSubstStructPtr = matched ; + here->BJTsubstSubstPtr = matched->CSC ; + } + + if ((here->BJTsubstConNode != 0) && (here->BJTsubstNode != 0)) + { + i = here->BJTsubstConSubstPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTsubstConSubstStructPtr = matched ; + here->BJTsubstConSubstPtr = matched->CSC ; + } + + if ((here->BJTsubstNode != 0) && (here->BJTsubstConNode != 0)) + { + i = here->BJTsubstSubstConPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTsubstSubstConStructPtr = matched ; + here->BJTsubstSubstConPtr = matched->CSC ; + } + + if ((here->BJTbaseNode != 0) && (here->BJTcolPrimeNode != 0)) + { + i = here->BJTbaseColPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTbaseColPrimeStructPtr = matched ; + here->BJTbaseColPrimePtr = matched->CSC ; + } + + if ((here->BJTcolPrimeNode != 0) && (here->BJTbaseNode != 0)) + { + i = here->BJTcolPrimeBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BJTcolPrimeBaseStructPtr = matched ; + here->BJTcolPrimeBasePtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +BJTbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + BJTmodel *model = (BJTmodel *)inModel ; + BJTinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BJT models */ + for ( ; model != NULL ; model = model->BJTnextModel) + { + /* loop through all the instances of the model */ + for (here = model->BJTinstances ; here != NULL ; here = here->BJTnextInstance) + { + if ((here->BJTcolNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTcolColPrimePtr = here->BJTcolColPrimeStructPtr->CSC_Complex ; + + if ((here->BJTbaseNode != 0) && (here->BJTbasePrimeNode != 0)) + here->BJTbaseBasePrimePtr = here->BJTbaseBasePrimeStructPtr->CSC_Complex ; + + if ((here->BJTemitNode != 0) && (here->BJTemitPrimeNode != 0)) + here->BJTemitEmitPrimePtr = here->BJTemitEmitPrimeStructPtr->CSC_Complex ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTcolNode != 0)) + here->BJTcolPrimeColPtr = here->BJTcolPrimeColStructPtr->CSC_Complex ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTbasePrimeNode != 0)) + here->BJTcolPrimeBasePrimePtr = here->BJTcolPrimeBasePrimeStructPtr->CSC_Complex ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTemitPrimeNode != 0)) + here->BJTcolPrimeEmitPrimePtr = here->BJTcolPrimeEmitPrimeStructPtr->CSC_Complex ; + + if ((here->BJTbasePrimeNode != 0) && (here->BJTbaseNode != 0)) + here->BJTbasePrimeBasePtr = here->BJTbasePrimeBaseStructPtr->CSC_Complex ; + + if ((here->BJTbasePrimeNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTbasePrimeColPrimePtr = here->BJTbasePrimeColPrimeStructPtr->CSC_Complex ; + + if ((here->BJTbasePrimeNode != 0) && (here->BJTemitPrimeNode != 0)) + here->BJTbasePrimeEmitPrimePtr = here->BJTbasePrimeEmitPrimeStructPtr->CSC_Complex ; + + if ((here->BJTemitPrimeNode != 0) && (here->BJTemitNode != 0)) + here->BJTemitPrimeEmitPtr = here->BJTemitPrimeEmitStructPtr->CSC_Complex ; + + if ((here->BJTemitPrimeNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTemitPrimeColPrimePtr = here->BJTemitPrimeColPrimeStructPtr->CSC_Complex ; + + if ((here->BJTemitPrimeNode != 0) && (here->BJTbasePrimeNode != 0)) + here->BJTemitPrimeBasePrimePtr = here->BJTemitPrimeBasePrimeStructPtr->CSC_Complex ; + + if ((here->BJTcolNode != 0) && (here->BJTcolNode != 0)) + here->BJTcolColPtr = here->BJTcolColStructPtr->CSC_Complex ; + + if ((here->BJTbaseNode != 0) && (here->BJTbaseNode != 0)) + here->BJTbaseBasePtr = here->BJTbaseBaseStructPtr->CSC_Complex ; + + if ((here->BJTemitNode != 0) && (here->BJTemitNode != 0)) + here->BJTemitEmitPtr = here->BJTemitEmitStructPtr->CSC_Complex ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTcolPrimeColPrimePtr = here->BJTcolPrimeColPrimeStructPtr->CSC_Complex ; + + if ((here->BJTbasePrimeNode != 0) && (here->BJTbasePrimeNode != 0)) + here->BJTbasePrimeBasePrimePtr = here->BJTbasePrimeBasePrimeStructPtr->CSC_Complex ; + + if ((here->BJTemitPrimeNode != 0) && (here->BJTemitPrimeNode != 0)) + here->BJTemitPrimeEmitPrimePtr = here->BJTemitPrimeEmitPrimeStructPtr->CSC_Complex ; + + if ((here->BJTsubstNode != 0) && (here->BJTsubstNode != 0)) + here->BJTsubstSubstPtr = here->BJTsubstSubstStructPtr->CSC_Complex ; + + if ((here->BJTsubstConNode != 0) && (here->BJTsubstNode != 0)) + here->BJTsubstConSubstPtr = here->BJTsubstConSubstStructPtr->CSC_Complex ; + + if ((here->BJTsubstNode != 0) && (here->BJTsubstConNode != 0)) + here->BJTsubstSubstConPtr = here->BJTsubstSubstConStructPtr->CSC_Complex ; + + if ((here->BJTbaseNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTbaseColPrimePtr = here->BJTbaseColPrimeStructPtr->CSC_Complex ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTbaseNode != 0)) + here->BJTcolPrimeBasePtr = here->BJTcolPrimeBaseStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +BJTbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + BJTmodel *model = (BJTmodel *)inModel ; + BJTinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BJT models */ + for ( ; model != NULL ; model = model->BJTnextModel) + { + /* loop through all the instances of the model */ + for (here = model->BJTinstances ; here != NULL ; here = here->BJTnextInstance) + { + if ((here->BJTcolNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTcolColPrimePtr = here->BJTcolColPrimeStructPtr->CSC ; + + if ((here->BJTbaseNode != 0) && (here->BJTbasePrimeNode != 0)) + here->BJTbaseBasePrimePtr = here->BJTbaseBasePrimeStructPtr->CSC ; + + if ((here->BJTemitNode != 0) && (here->BJTemitPrimeNode != 0)) + here->BJTemitEmitPrimePtr = here->BJTemitEmitPrimeStructPtr->CSC ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTcolNode != 0)) + here->BJTcolPrimeColPtr = here->BJTcolPrimeColStructPtr->CSC ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTbasePrimeNode != 0)) + here->BJTcolPrimeBasePrimePtr = here->BJTcolPrimeBasePrimeStructPtr->CSC ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTemitPrimeNode != 0)) + here->BJTcolPrimeEmitPrimePtr = here->BJTcolPrimeEmitPrimeStructPtr->CSC ; + + if ((here->BJTbasePrimeNode != 0) && (here->BJTbaseNode != 0)) + here->BJTbasePrimeBasePtr = here->BJTbasePrimeBaseStructPtr->CSC ; + + if ((here->BJTbasePrimeNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTbasePrimeColPrimePtr = here->BJTbasePrimeColPrimeStructPtr->CSC ; + + if ((here->BJTbasePrimeNode != 0) && (here->BJTemitPrimeNode != 0)) + here->BJTbasePrimeEmitPrimePtr = here->BJTbasePrimeEmitPrimeStructPtr->CSC ; + + if ((here->BJTemitPrimeNode != 0) && (here->BJTemitNode != 0)) + here->BJTemitPrimeEmitPtr = here->BJTemitPrimeEmitStructPtr->CSC ; + + if ((here->BJTemitPrimeNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTemitPrimeColPrimePtr = here->BJTemitPrimeColPrimeStructPtr->CSC ; + + if ((here->BJTemitPrimeNode != 0) && (here->BJTbasePrimeNode != 0)) + here->BJTemitPrimeBasePrimePtr = here->BJTemitPrimeBasePrimeStructPtr->CSC ; + + if ((here->BJTcolNode != 0) && (here->BJTcolNode != 0)) + here->BJTcolColPtr = here->BJTcolColStructPtr->CSC ; + + if ((here->BJTbaseNode != 0) && (here->BJTbaseNode != 0)) + here->BJTbaseBasePtr = here->BJTbaseBaseStructPtr->CSC ; + + if ((here->BJTemitNode != 0) && (here->BJTemitNode != 0)) + here->BJTemitEmitPtr = here->BJTemitEmitStructPtr->CSC ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTcolPrimeColPrimePtr = here->BJTcolPrimeColPrimeStructPtr->CSC ; + + if ((here->BJTbasePrimeNode != 0) && (here->BJTbasePrimeNode != 0)) + here->BJTbasePrimeBasePrimePtr = here->BJTbasePrimeBasePrimeStructPtr->CSC ; + + if ((here->BJTemitPrimeNode != 0) && (here->BJTemitPrimeNode != 0)) + here->BJTemitPrimeEmitPrimePtr = here->BJTemitPrimeEmitPrimeStructPtr->CSC ; + + if ((here->BJTsubstNode != 0) && (here->BJTsubstNode != 0)) + here->BJTsubstSubstPtr = here->BJTsubstSubstStructPtr->CSC ; + + if ((here->BJTsubstConNode != 0) && (here->BJTsubstNode != 0)) + here->BJTsubstConSubstPtr = here->BJTsubstConSubstStructPtr->CSC ; + + if ((here->BJTsubstNode != 0) && (here->BJTsubstConNode != 0)) + here->BJTsubstSubstConPtr = here->BJTsubstSubstConStructPtr->CSC ; + + if ((here->BJTbaseNode != 0) && (here->BJTcolPrimeNode != 0)) + here->BJTbaseColPrimePtr = here->BJTbaseColPrimeStructPtr->CSC ; + + if ((here->BJTcolPrimeNode != 0) && (here->BJTbaseNode != 0)) + here->BJTcolPrimeBasePtr = here->BJTcolPrimeBaseStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bjt/bjtdefs.h b/src/spicelib/devices/bjt/bjtdefs.h index 000919e3f..9519dfdbe 100644 --- a/src/spicelib/devices/bjt/bjtdefs.h +++ b/src/spicelib/devices/bjt/bjtdefs.h @@ -283,6 +283,33 @@ typedef struct sBJTinstance { #endif /*NONOISE*/ /* the above to avoid allocating memory when it is not needed */ +#ifdef KLU + BindElement *BJTcolColPrimeStructPtr ; + BindElement *BJTbaseBasePrimeStructPtr ; + BindElement *BJTemitEmitPrimeStructPtr ; + BindElement *BJTcolPrimeColStructPtr ; + BindElement *BJTcolPrimeBasePrimeStructPtr ; + BindElement *BJTcolPrimeEmitPrimeStructPtr ; + BindElement *BJTbasePrimeBaseStructPtr ; + BindElement *BJTbasePrimeColPrimeStructPtr ; + BindElement *BJTbasePrimeEmitPrimeStructPtr ; + BindElement *BJTemitPrimeEmitStructPtr ; + BindElement *BJTemitPrimeColPrimeStructPtr ; + BindElement *BJTemitPrimeBasePrimeStructPtr ; + BindElement *BJTcolColStructPtr ; + BindElement *BJTbaseBaseStructPtr ; + BindElement *BJTemitEmitStructPtr ; + BindElement *BJTcolPrimeColPrimeStructPtr ; + BindElement *BJTbasePrimeBasePrimeStructPtr ; + BindElement *BJTemitPrimeEmitPrimeStructPtr ; + BindElement *BJTsubstSubstStructPtr ; + BindElement *BJTsubstConSubstStructPtr ; + BindElement *BJTsubstSubstConStructPtr ; + BindElement *BJTsubstConSubstConStructPtr ; + BindElement *BJTbaseColPrimeStructPtr ; + BindElement *BJTcolPrimeBaseStructPtr ; +#endif + } BJTinstance ; /* entries in the state vector for bjt: */ diff --git a/src/spicelib/devices/bjt/bjtext.h b/src/spicelib/devices/bjt/bjtext.h index 16655610f..c5f50ea43 100644 --- a/src/spicelib/devices/bjt/bjtext.h +++ b/src/spicelib/devices/bjt/bjtext.h @@ -34,3 +34,9 @@ extern int BJTdSetup(GENmodel*, register CKTcircuit*); extern int BJTsoaCheck(CKTcircuit *, GENmodel *); #endif + +#ifdef KLU +extern int BJTbindCSC (GENmodel*, CKTcircuit*) ; +extern int BJTbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int BJTbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bjt/bjtinit.c b/src/spicelib/devices/bjt/bjtinit.c index dc5e025b1..e7a07b816 100644 --- a/src/spicelib/devices/bjt/bjtinit.c +++ b/src/spicelib/devices/bjt/bjtinit.c @@ -73,7 +73,13 @@ SPICEdev BJTinfo = { /* description from struct IFdevice */ /* DEVacct */ NULL, #endif /* DEVinstSize */ &BJTiSize, - /* DEVmodSize */ &BJTmSize + /* DEVmodSize */ &BJTmSize, + +#ifdef KLU + /* DEVbindCSC */ BJTbindCSC, + /* DEVbindCSCComplex */ BJTbindCSCComplex, + /* DEVbindCSCComplexToReal */ BJTbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/bsim1/Makefile.am b/src/spicelib/devices/bsim1/Makefile.am index da088cf5b..d08915b4c 100644 --- a/src/spicelib/devices/bsim1/Makefile.am +++ b/src/spicelib/devices/bsim1/Makefile.am @@ -31,7 +31,11 @@ libbsim1_la_SOURCES = \ bsim1itf.h +if KLU_WANTED +libbsim1_la_SOURCES += b1bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/bsim1/b1bindCSC.c b/src/spicelib/devices/bsim1/b1bindCSC.c new file mode 100644 index 000000000..ea2ac11ed --- /dev/null +++ b/src/spicelib/devices/bsim1/b1bindCSC.c @@ -0,0 +1,393 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bsim1def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +B1bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + B1model *model = (B1model *)inModel ; + B1instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the B1 models */ + for ( ; model != NULL ; model = model->B1nextModel) + { + /* loop through all the instances of the model */ + for (here = model->B1instances ; here != NULL ; here = here->B1nextInstance) + { + if ((here-> B1dNode != 0) && (here-> B1dNode != 0)) + { + i = here->B1DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1DdStructPtr = matched ; + here->B1DdPtr = matched->CSC ; + } + + if ((here-> B1gNode != 0) && (here-> B1gNode != 0)) + { + i = here->B1GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1GgStructPtr = matched ; + here->B1GgPtr = matched->CSC ; + } + + if ((here-> B1sNode != 0) && (here-> B1sNode != 0)) + { + i = here->B1SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1SsStructPtr = matched ; + here->B1SsPtr = matched->CSC ; + } + + if ((here-> B1bNode != 0) && (here-> B1bNode != 0)) + { + i = here->B1BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1BbStructPtr = matched ; + here->B1BbPtr = matched->CSC ; + } + + if ((here-> B1dNodePrime != 0) && (here-> B1dNodePrime != 0)) + { + i = here->B1DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1DPdpStructPtr = matched ; + here->B1DPdpPtr = matched->CSC ; + } + + if ((here-> B1sNodePrime != 0) && (here-> B1sNodePrime != 0)) + { + i = here->B1SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1SPspStructPtr = matched ; + here->B1SPspPtr = matched->CSC ; + } + + if ((here-> B1dNode != 0) && (here-> B1dNodePrime != 0)) + { + i = here->B1DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1DdpStructPtr = matched ; + here->B1DdpPtr = matched->CSC ; + } + + if ((here-> B1gNode != 0) && (here-> B1bNode != 0)) + { + i = here->B1GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1GbStructPtr = matched ; + here->B1GbPtr = matched->CSC ; + } + + if ((here-> B1gNode != 0) && (here-> B1dNodePrime != 0)) + { + i = here->B1GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1GdpStructPtr = matched ; + here->B1GdpPtr = matched->CSC ; + } + + if ((here-> B1gNode != 0) && (here-> B1sNodePrime != 0)) + { + i = here->B1GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1GspStructPtr = matched ; + here->B1GspPtr = matched->CSC ; + } + + if ((here-> B1sNode != 0) && (here-> B1sNodePrime != 0)) + { + i = here->B1SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1SspStructPtr = matched ; + here->B1SspPtr = matched->CSC ; + } + + if ((here-> B1bNode != 0) && (here-> B1dNodePrime != 0)) + { + i = here->B1BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1BdpStructPtr = matched ; + here->B1BdpPtr = matched->CSC ; + } + + if ((here-> B1bNode != 0) && (here-> B1sNodePrime != 0)) + { + i = here->B1BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1BspStructPtr = matched ; + here->B1BspPtr = matched->CSC ; + } + + if ((here-> B1dNodePrime != 0) && (here-> B1sNodePrime != 0)) + { + i = here->B1DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1DPspStructPtr = matched ; + here->B1DPspPtr = matched->CSC ; + } + + if ((here-> B1dNodePrime != 0) && (here-> B1dNode != 0)) + { + i = here->B1DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1DPdStructPtr = matched ; + here->B1DPdPtr = matched->CSC ; + } + + if ((here-> B1bNode != 0) && (here-> B1gNode != 0)) + { + i = here->B1BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1BgStructPtr = matched ; + here->B1BgPtr = matched->CSC ; + } + + if ((here-> B1dNodePrime != 0) && (here-> B1gNode != 0)) + { + i = here->B1DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1DPgStructPtr = matched ; + here->B1DPgPtr = matched->CSC ; + } + + if ((here-> B1sNodePrime != 0) && (here-> B1gNode != 0)) + { + i = here->B1SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1SPgStructPtr = matched ; + here->B1SPgPtr = matched->CSC ; + } + + if ((here-> B1sNodePrime != 0) && (here-> B1sNode != 0)) + { + i = here->B1SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1SPsStructPtr = matched ; + here->B1SPsPtr = matched->CSC ; + } + + if ((here-> B1dNodePrime != 0) && (here-> B1bNode != 0)) + { + i = here->B1DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1DPbStructPtr = matched ; + here->B1DPbPtr = matched->CSC ; + } + + if ((here-> B1sNodePrime != 0) && (here-> B1bNode != 0)) + { + i = here->B1SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1SPbStructPtr = matched ; + here->B1SPbPtr = matched->CSC ; + } + + if ((here-> B1sNodePrime != 0) && (here-> B1dNodePrime != 0)) + { + i = here->B1SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B1SPdpStructPtr = matched ; + here->B1SPdpPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +B1bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + B1model *model = (B1model *)inModel ; + B1instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B1 models */ + for ( ; model != NULL ; model = model->B1nextModel) + { + /* loop through all the instances of the model */ + for (here = model->B1instances ; here != NULL ; here = here->B1nextInstance) + { + if ((here-> B1dNode != 0) && (here-> B1dNode != 0)) + here->B1DdPtr = here->B1DdStructPtr->CSC_Complex ; + + if ((here-> B1gNode != 0) && (here-> B1gNode != 0)) + here->B1GgPtr = here->B1GgStructPtr->CSC_Complex ; + + if ((here-> B1sNode != 0) && (here-> B1sNode != 0)) + here->B1SsPtr = here->B1SsStructPtr->CSC_Complex ; + + if ((here-> B1bNode != 0) && (here-> B1bNode != 0)) + here->B1BbPtr = here->B1BbStructPtr->CSC_Complex ; + + if ((here-> B1dNodePrime != 0) && (here-> B1dNodePrime != 0)) + here->B1DPdpPtr = here->B1DPdpStructPtr->CSC_Complex ; + + if ((here-> B1sNodePrime != 0) && (here-> B1sNodePrime != 0)) + here->B1SPspPtr = here->B1SPspStructPtr->CSC_Complex ; + + if ((here-> B1dNode != 0) && (here-> B1dNodePrime != 0)) + here->B1DdpPtr = here->B1DdpStructPtr->CSC_Complex ; + + if ((here-> B1gNode != 0) && (here-> B1bNode != 0)) + here->B1GbPtr = here->B1GbStructPtr->CSC_Complex ; + + if ((here-> B1gNode != 0) && (here-> B1dNodePrime != 0)) + here->B1GdpPtr = here->B1GdpStructPtr->CSC_Complex ; + + if ((here-> B1gNode != 0) && (here-> B1sNodePrime != 0)) + here->B1GspPtr = here->B1GspStructPtr->CSC_Complex ; + + if ((here-> B1sNode != 0) && (here-> B1sNodePrime != 0)) + here->B1SspPtr = here->B1SspStructPtr->CSC_Complex ; + + if ((here-> B1bNode != 0) && (here-> B1dNodePrime != 0)) + here->B1BdpPtr = here->B1BdpStructPtr->CSC_Complex ; + + if ((here-> B1bNode != 0) && (here-> B1sNodePrime != 0)) + here->B1BspPtr = here->B1BspStructPtr->CSC_Complex ; + + if ((here-> B1dNodePrime != 0) && (here-> B1sNodePrime != 0)) + here->B1DPspPtr = here->B1DPspStructPtr->CSC_Complex ; + + if ((here-> B1dNodePrime != 0) && (here-> B1dNode != 0)) + here->B1DPdPtr = here->B1DPdStructPtr->CSC_Complex ; + + if ((here-> B1bNode != 0) && (here-> B1gNode != 0)) + here->B1BgPtr = here->B1BgStructPtr->CSC_Complex ; + + if ((here-> B1dNodePrime != 0) && (here-> B1gNode != 0)) + here->B1DPgPtr = here->B1DPgStructPtr->CSC_Complex ; + + if ((here-> B1sNodePrime != 0) && (here-> B1gNode != 0)) + here->B1SPgPtr = here->B1SPgStructPtr->CSC_Complex ; + + if ((here-> B1sNodePrime != 0) && (here-> B1sNode != 0)) + here->B1SPsPtr = here->B1SPsStructPtr->CSC_Complex ; + + if ((here-> B1dNodePrime != 0) && (here-> B1bNode != 0)) + here->B1DPbPtr = here->B1DPbStructPtr->CSC_Complex ; + + if ((here-> B1sNodePrime != 0) && (here-> B1bNode != 0)) + here->B1SPbPtr = here->B1SPbStructPtr->CSC_Complex ; + + if ((here-> B1sNodePrime != 0) && (here-> B1dNodePrime != 0)) + here->B1SPdpPtr = here->B1SPdpStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +B1bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + B1model *model = (B1model *)inModel ; + B1instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B1 models */ + for ( ; model != NULL ; model = model->B1nextModel) + { + /* loop through all the instances of the model */ + for (here = model->B1instances ; here != NULL ; here = here->B1nextInstance) + { + if ((here-> B1dNode != 0) && (here-> B1dNode != 0)) + here->B1DdPtr = here->B1DdStructPtr->CSC ; + + if ((here-> B1gNode != 0) && (here-> B1gNode != 0)) + here->B1GgPtr = here->B1GgStructPtr->CSC ; + + if ((here-> B1sNode != 0) && (here-> B1sNode != 0)) + here->B1SsPtr = here->B1SsStructPtr->CSC ; + + if ((here-> B1bNode != 0) && (here-> B1bNode != 0)) + here->B1BbPtr = here->B1BbStructPtr->CSC ; + + if ((here-> B1dNodePrime != 0) && (here-> B1dNodePrime != 0)) + here->B1DPdpPtr = here->B1DPdpStructPtr->CSC ; + + if ((here-> B1sNodePrime != 0) && (here-> B1sNodePrime != 0)) + here->B1SPspPtr = here->B1SPspStructPtr->CSC ; + + if ((here-> B1dNode != 0) && (here-> B1dNodePrime != 0)) + here->B1DdpPtr = here->B1DdpStructPtr->CSC ; + + if ((here-> B1gNode != 0) && (here-> B1bNode != 0)) + here->B1GbPtr = here->B1GbStructPtr->CSC ; + + if ((here-> B1gNode != 0) && (here-> B1dNodePrime != 0)) + here->B1GdpPtr = here->B1GdpStructPtr->CSC ; + + if ((here-> B1gNode != 0) && (here-> B1sNodePrime != 0)) + here->B1GspPtr = here->B1GspStructPtr->CSC ; + + if ((here-> B1sNode != 0) && (here-> B1sNodePrime != 0)) + here->B1SspPtr = here->B1SspStructPtr->CSC ; + + if ((here-> B1bNode != 0) && (here-> B1dNodePrime != 0)) + here->B1BdpPtr = here->B1BdpStructPtr->CSC ; + + if ((here-> B1bNode != 0) && (here-> B1sNodePrime != 0)) + here->B1BspPtr = here->B1BspStructPtr->CSC ; + + if ((here-> B1dNodePrime != 0) && (here-> B1sNodePrime != 0)) + here->B1DPspPtr = here->B1DPspStructPtr->CSC ; + + if ((here-> B1dNodePrime != 0) && (here-> B1dNode != 0)) + here->B1DPdPtr = here->B1DPdStructPtr->CSC ; + + if ((here-> B1bNode != 0) && (here-> B1gNode != 0)) + here->B1BgPtr = here->B1BgStructPtr->CSC ; + + if ((here-> B1dNodePrime != 0) && (here-> B1gNode != 0)) + here->B1DPgPtr = here->B1DPgStructPtr->CSC ; + + if ((here-> B1sNodePrime != 0) && (here-> B1gNode != 0)) + here->B1SPgPtr = here->B1SPgStructPtr->CSC ; + + if ((here-> B1sNodePrime != 0) && (here-> B1sNode != 0)) + here->B1SPsPtr = here->B1SPsStructPtr->CSC ; + + if ((here-> B1dNodePrime != 0) && (here-> B1bNode != 0)) + here->B1DPbPtr = here->B1DPbStructPtr->CSC ; + + if ((here-> B1sNodePrime != 0) && (here-> B1bNode != 0)) + here->B1SPbPtr = here->B1SPbStructPtr->CSC ; + + if ((here-> B1sNodePrime != 0) && (here-> B1dNodePrime != 0)) + here->B1SPdpPtr = here->B1SPdpStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim1/bsim1def.h b/src/spicelib/devices/bsim1/bsim1def.h index 7e8188499..f96311121 100644 --- a/src/spicelib/devices/bsim1/bsim1def.h +++ b/src/spicelib/devices/bsim1/bsim1def.h @@ -166,6 +166,30 @@ typedef struct sBSIM1instance { double **B1nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *B1DdStructPtr ; + BindElement *B1GgStructPtr ; + BindElement *B1SsStructPtr ; + BindElement *B1BbStructPtr ; + BindElement *B1DPdpStructPtr ; + BindElement *B1SPspStructPtr ; + BindElement *B1DdpStructPtr ; + BindElement *B1GbStructPtr ; + BindElement *B1GdpStructPtr ; + BindElement *B1GspStructPtr ; + BindElement *B1SspStructPtr ; + BindElement *B1BdpStructPtr ; + BindElement *B1BspStructPtr ; + BindElement *B1DPspStructPtr ; + BindElement *B1DPdStructPtr ; + BindElement *B1BgStructPtr ; + BindElement *B1DPgStructPtr ; + BindElement *B1SPgStructPtr ; + BindElement *B1SPsStructPtr ; + BindElement *B1DPbStructPtr ; + BindElement *B1SPbStructPtr ; + BindElement *B1SPdpStructPtr ; +#endif } B1instance ; diff --git a/src/spicelib/devices/bsim1/bsim1ext.h b/src/spicelib/devices/bsim1/bsim1ext.h index e859e3009..9b1588a42 100644 --- a/src/spicelib/devices/bsim1/bsim1ext.h +++ b/src/spicelib/devices/bsim1/bsim1ext.h @@ -29,3 +29,9 @@ extern int B1temp(GENmodel*,CKTcircuit*); extern int B1trunc(GENmodel*,CKTcircuit*,double*); extern int B1disto(int,GENmodel*,CKTcircuit*); extern int B1dSetup(GENmodel*, register CKTcircuit*); + +#ifdef KLU +extern int B1bindCSC (GENmodel*, CKTcircuit*) ; +extern int B1bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int B1bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim1/bsim1init.c b/src/spicelib/devices/bsim1/bsim1init.c index 16d4e9ef7..88de3b5f2 100644 --- a/src/spicelib/devices/bsim1/bsim1init.c +++ b/src/spicelib/devices/bsim1/bsim1init.c @@ -73,7 +73,13 @@ SPICEdev B1info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &B1iSize, - /* DEVmodSize */ &B1mSize + /* DEVmodSize */ &B1mSize, + +#ifdef KLU + /* DEVbindCSC */ B1bindCSC, + /* DEVbindCSCComplex */ B1bindCSCComplex, + /* DEVbindCSCComplexToReal */ B1bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/bsim2/Makefile.am b/src/spicelib/devices/bsim2/Makefile.am index ea8ae9855..97597da11 100644 --- a/src/spicelib/devices/bsim2/Makefile.am +++ b/src/spicelib/devices/bsim2/Makefile.am @@ -29,6 +29,9 @@ libbsim2_la_SOURCES = \ bsim2itf.h +if KLU_WANTED +libbsim2_la_SOURCES += b2bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim2/b2bindCSC.c b/src/spicelib/devices/bsim2/b2bindCSC.c new file mode 100644 index 000000000..791ea5943 --- /dev/null +++ b/src/spicelib/devices/bsim2/b2bindCSC.c @@ -0,0 +1,393 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bsim2def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +B2bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + B2model *model = (B2model *)inModel ; + B2instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the B2 models */ + for ( ; model != NULL ; model = model->B2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->B2instances ; here != NULL ; here = here->B2nextInstance) + { + if ((here-> B2dNode != 0) && (here-> B2dNode != 0)) + { + i = here->B2DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2DdStructPtr = matched ; + here->B2DdPtr = matched->CSC ; + } + + if ((here-> B2gNode != 0) && (here-> B2gNode != 0)) + { + i = here->B2GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2GgStructPtr = matched ; + here->B2GgPtr = matched->CSC ; + } + + if ((here-> B2sNode != 0) && (here-> B2sNode != 0)) + { + i = here->B2SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2SsStructPtr = matched ; + here->B2SsPtr = matched->CSC ; + } + + if ((here-> B2bNode != 0) && (here-> B2bNode != 0)) + { + i = here->B2BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2BbStructPtr = matched ; + here->B2BbPtr = matched->CSC ; + } + + if ((here-> B2dNodePrime != 0) && (here-> B2dNodePrime != 0)) + { + i = here->B2DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2DPdpStructPtr = matched ; + here->B2DPdpPtr = matched->CSC ; + } + + if ((here-> B2sNodePrime != 0) && (here-> B2sNodePrime != 0)) + { + i = here->B2SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2SPspStructPtr = matched ; + here->B2SPspPtr = matched->CSC ; + } + + if ((here-> B2dNode != 0) && (here-> B2dNodePrime != 0)) + { + i = here->B2DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2DdpStructPtr = matched ; + here->B2DdpPtr = matched->CSC ; + } + + if ((here-> B2gNode != 0) && (here-> B2bNode != 0)) + { + i = here->B2GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2GbStructPtr = matched ; + here->B2GbPtr = matched->CSC ; + } + + if ((here-> B2gNode != 0) && (here-> B2dNodePrime != 0)) + { + i = here->B2GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2GdpStructPtr = matched ; + here->B2GdpPtr = matched->CSC ; + } + + if ((here-> B2gNode != 0) && (here-> B2sNodePrime != 0)) + { + i = here->B2GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2GspStructPtr = matched ; + here->B2GspPtr = matched->CSC ; + } + + if ((here-> B2sNode != 0) && (here-> B2sNodePrime != 0)) + { + i = here->B2SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2SspStructPtr = matched ; + here->B2SspPtr = matched->CSC ; + } + + if ((here-> B2bNode != 0) && (here-> B2dNodePrime != 0)) + { + i = here->B2BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2BdpStructPtr = matched ; + here->B2BdpPtr = matched->CSC ; + } + + if ((here-> B2bNode != 0) && (here-> B2sNodePrime != 0)) + { + i = here->B2BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2BspStructPtr = matched ; + here->B2BspPtr = matched->CSC ; + } + + if ((here-> B2dNodePrime != 0) && (here-> B2sNodePrime != 0)) + { + i = here->B2DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2DPspStructPtr = matched ; + here->B2DPspPtr = matched->CSC ; + } + + if ((here-> B2dNodePrime != 0) && (here-> B2dNode != 0)) + { + i = here->B2DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2DPdStructPtr = matched ; + here->B2DPdPtr = matched->CSC ; + } + + if ((here-> B2bNode != 0) && (here-> B2gNode != 0)) + { + i = here->B2BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2BgStructPtr = matched ; + here->B2BgPtr = matched->CSC ; + } + + if ((here-> B2dNodePrime != 0) && (here-> B2gNode != 0)) + { + i = here->B2DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2DPgStructPtr = matched ; + here->B2DPgPtr = matched->CSC ; + } + + if ((here-> B2sNodePrime != 0) && (here-> B2gNode != 0)) + { + i = here->B2SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2SPgStructPtr = matched ; + here->B2SPgPtr = matched->CSC ; + } + + if ((here-> B2sNodePrime != 0) && (here-> B2sNode != 0)) + { + i = here->B2SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2SPsStructPtr = matched ; + here->B2SPsPtr = matched->CSC ; + } + + if ((here-> B2dNodePrime != 0) && (here-> B2bNode != 0)) + { + i = here->B2DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2DPbStructPtr = matched ; + here->B2DPbPtr = matched->CSC ; + } + + if ((here-> B2sNodePrime != 0) && (here-> B2bNode != 0)) + { + i = here->B2SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2SPbStructPtr = matched ; + here->B2SPbPtr = matched->CSC ; + } + + if ((here-> B2sNodePrime != 0) && (here-> B2dNodePrime != 0)) + { + i = here->B2SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B2SPdpStructPtr = matched ; + here->B2SPdpPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +B2bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + B2model *model = (B2model *)inModel ; + B2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B2 models */ + for ( ; model != NULL ; model = model->B2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->B2instances ; here != NULL ; here = here->B2nextInstance) + { + if ((here-> B2dNode != 0) && (here-> B2dNode != 0)) + here->B2DdPtr = here->B2DdStructPtr->CSC_Complex ; + + if ((here-> B2gNode != 0) && (here-> B2gNode != 0)) + here->B2GgPtr = here->B2GgStructPtr->CSC_Complex ; + + if ((here-> B2sNode != 0) && (here-> B2sNode != 0)) + here->B2SsPtr = here->B2SsStructPtr->CSC_Complex ; + + if ((here-> B2bNode != 0) && (here-> B2bNode != 0)) + here->B2BbPtr = here->B2BbStructPtr->CSC_Complex ; + + if ((here-> B2dNodePrime != 0) && (here-> B2dNodePrime != 0)) + here->B2DPdpPtr = here->B2DPdpStructPtr->CSC_Complex ; + + if ((here-> B2sNodePrime != 0) && (here-> B2sNodePrime != 0)) + here->B2SPspPtr = here->B2SPspStructPtr->CSC_Complex ; + + if ((here-> B2dNode != 0) && (here-> B2dNodePrime != 0)) + here->B2DdpPtr = here->B2DdpStructPtr->CSC_Complex ; + + if ((here-> B2gNode != 0) && (here-> B2bNode != 0)) + here->B2GbPtr = here->B2GbStructPtr->CSC_Complex ; + + if ((here-> B2gNode != 0) && (here-> B2dNodePrime != 0)) + here->B2GdpPtr = here->B2GdpStructPtr->CSC_Complex ; + + if ((here-> B2gNode != 0) && (here-> B2sNodePrime != 0)) + here->B2GspPtr = here->B2GspStructPtr->CSC_Complex ; + + if ((here-> B2sNode != 0) && (here-> B2sNodePrime != 0)) + here->B2SspPtr = here->B2SspStructPtr->CSC_Complex ; + + if ((here-> B2bNode != 0) && (here-> B2dNodePrime != 0)) + here->B2BdpPtr = here->B2BdpStructPtr->CSC_Complex ; + + if ((here-> B2bNode != 0) && (here-> B2sNodePrime != 0)) + here->B2BspPtr = here->B2BspStructPtr->CSC_Complex ; + + if ((here-> B2dNodePrime != 0) && (here-> B2sNodePrime != 0)) + here->B2DPspPtr = here->B2DPspStructPtr->CSC_Complex ; + + if ((here-> B2dNodePrime != 0) && (here-> B2dNode != 0)) + here->B2DPdPtr = here->B2DPdStructPtr->CSC_Complex ; + + if ((here-> B2bNode != 0) && (here-> B2gNode != 0)) + here->B2BgPtr = here->B2BgStructPtr->CSC_Complex ; + + if ((here-> B2dNodePrime != 0) && (here-> B2gNode != 0)) + here->B2DPgPtr = here->B2DPgStructPtr->CSC_Complex ; + + if ((here-> B2sNodePrime != 0) && (here-> B2gNode != 0)) + here->B2SPgPtr = here->B2SPgStructPtr->CSC_Complex ; + + if ((here-> B2sNodePrime != 0) && (here-> B2sNode != 0)) + here->B2SPsPtr = here->B2SPsStructPtr->CSC_Complex ; + + if ((here-> B2dNodePrime != 0) && (here-> B2bNode != 0)) + here->B2DPbPtr = here->B2DPbStructPtr->CSC_Complex ; + + if ((here-> B2sNodePrime != 0) && (here-> B2bNode != 0)) + here->B2SPbPtr = here->B2SPbStructPtr->CSC_Complex ; + + if ((here-> B2sNodePrime != 0) && (here-> B2dNodePrime != 0)) + here->B2SPdpPtr = here->B2SPdpStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +B2bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + B2model *model = (B2model *)inModel ; + B2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B2 models */ + for ( ; model != NULL ; model = model->B2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->B2instances ; here != NULL ; here = here->B2nextInstance) + { + if ((here-> B2dNode != 0) && (here-> B2dNode != 0)) + here->B2DdPtr = here->B2DdStructPtr->CSC ; + + if ((here-> B2gNode != 0) && (here-> B2gNode != 0)) + here->B2GgPtr = here->B2GgStructPtr->CSC ; + + if ((here-> B2sNode != 0) && (here-> B2sNode != 0)) + here->B2SsPtr = here->B2SsStructPtr->CSC ; + + if ((here-> B2bNode != 0) && (here-> B2bNode != 0)) + here->B2BbPtr = here->B2BbStructPtr->CSC ; + + if ((here-> B2dNodePrime != 0) && (here-> B2dNodePrime != 0)) + here->B2DPdpPtr = here->B2DPdpStructPtr->CSC ; + + if ((here-> B2sNodePrime != 0) && (here-> B2sNodePrime != 0)) + here->B2SPspPtr = here->B2SPspStructPtr->CSC ; + + if ((here-> B2dNode != 0) && (here-> B2dNodePrime != 0)) + here->B2DdpPtr = here->B2DdpStructPtr->CSC ; + + if ((here-> B2gNode != 0) && (here-> B2bNode != 0)) + here->B2GbPtr = here->B2GbStructPtr->CSC ; + + if ((here-> B2gNode != 0) && (here-> B2dNodePrime != 0)) + here->B2GdpPtr = here->B2GdpStructPtr->CSC ; + + if ((here-> B2gNode != 0) && (here-> B2sNodePrime != 0)) + here->B2GspPtr = here->B2GspStructPtr->CSC ; + + if ((here-> B2sNode != 0) && (here-> B2sNodePrime != 0)) + here->B2SspPtr = here->B2SspStructPtr->CSC ; + + if ((here-> B2bNode != 0) && (here-> B2dNodePrime != 0)) + here->B2BdpPtr = here->B2BdpStructPtr->CSC ; + + if ((here-> B2bNode != 0) && (here-> B2sNodePrime != 0)) + here->B2BspPtr = here->B2BspStructPtr->CSC ; + + if ((here-> B2dNodePrime != 0) && (here-> B2sNodePrime != 0)) + here->B2DPspPtr = here->B2DPspStructPtr->CSC ; + + if ((here-> B2dNodePrime != 0) && (here-> B2dNode != 0)) + here->B2DPdPtr = here->B2DPdStructPtr->CSC ; + + if ((here-> B2bNode != 0) && (here-> B2gNode != 0)) + here->B2BgPtr = here->B2BgStructPtr->CSC ; + + if ((here-> B2dNodePrime != 0) && (here-> B2gNode != 0)) + here->B2DPgPtr = here->B2DPgStructPtr->CSC ; + + if ((here-> B2sNodePrime != 0) && (here-> B2gNode != 0)) + here->B2SPgPtr = here->B2SPgStructPtr->CSC ; + + if ((here-> B2sNodePrime != 0) && (here-> B2sNode != 0)) + here->B2SPsPtr = here->B2SPsStructPtr->CSC ; + + if ((here-> B2dNodePrime != 0) && (here-> B2bNode != 0)) + here->B2DPbPtr = here->B2DPbStructPtr->CSC ; + + if ((here-> B2sNodePrime != 0) && (here-> B2bNode != 0)) + here->B2SPbPtr = here->B2SPbStructPtr->CSC ; + + if ((here-> B2sNodePrime != 0) && (here-> B2dNodePrime != 0)) + here->B2SPdpPtr = here->B2SPdpStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim2/bsim2def.h b/src/spicelib/devices/bsim2/bsim2def.h index d60d268c8..1bc6ece6a 100644 --- a/src/spicelib/devices/bsim2/bsim2def.h +++ b/src/spicelib/devices/bsim2/bsim2def.h @@ -176,6 +176,31 @@ typedef struct sBSIM2instance { #define B2numStates 35 +#ifdef KLU + BindElement *B2DdStructPtr ; + BindElement *B2GgStructPtr ; + BindElement *B2SsStructPtr ; + BindElement *B2BbStructPtr ; + BindElement *B2DPdpStructPtr ; + BindElement *B2SPspStructPtr ; + BindElement *B2DdpStructPtr ; + BindElement *B2GbStructPtr ; + BindElement *B2GdpStructPtr ; + BindElement *B2GspStructPtr ; + BindElement *B2SspStructPtr ; + BindElement *B2BdpStructPtr ; + BindElement *B2BspStructPtr ; + BindElement *B2DPspStructPtr ; + BindElement *B2DPdStructPtr ; + BindElement *B2BgStructPtr ; + BindElement *B2DPgStructPtr ; + BindElement *B2SPgStructPtr ; + BindElement *B2SPsStructPtr ; + BindElement *B2DPbStructPtr ; + BindElement *B2SPbStructPtr ; + BindElement *B2SPdpStructPtr ; +#endif + } B2instance ; struct bsim2SizeDependParam diff --git a/src/spicelib/devices/bsim2/bsim2ext.h b/src/spicelib/devices/bsim2/bsim2ext.h index ab7b800da..4141e2f86 100644 --- a/src/spicelib/devices/bsim2/bsim2ext.h +++ b/src/spicelib/devices/bsim2/bsim2ext.h @@ -25,3 +25,9 @@ extern int B2setup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int B2unsetup(GENmodel*,CKTcircuit*); extern int B2temp(GENmodel*,CKTcircuit*); extern int B2trunc(GENmodel*,CKTcircuit*,double*); + +#ifdef KLU +extern int B2bindCSC (GENmodel*, CKTcircuit*) ; +extern int B2bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int B2bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim2/bsim2init.c b/src/spicelib/devices/bsim2/bsim2init.c index 6a4294505..f95f31ce9 100644 --- a/src/spicelib/devices/bsim2/bsim2init.c +++ b/src/spicelib/devices/bsim2/bsim2init.c @@ -73,7 +73,13 @@ SPICEdev B2info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &B2iSize, - /* DEVmodSize */ &B2mSize + /* DEVmodSize */ &B2mSize, + +#ifdef KLU + /* DEVbindCSC */ B2bindCSC, + /* DEVbindCSCComplex */ B2bindCSCComplex, + /* DEVbindCSCComplexToReal */ B2bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/bsim3/Makefile.am b/src/spicelib/devices/bsim3/Makefile.am index 2489d1e5a..397e19595 100644 --- a/src/spicelib/devices/bsim3/Makefile.am +++ b/src/spicelib/devices/bsim3/Makefile.am @@ -29,6 +29,9 @@ libbsim3_la_SOURCES = \ bsim3itf.h +if KLU_WANTED +libbsim3_la_SOURCES += b3bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim3/b3bindCSC.c b/src/spicelib/devices/bsim3/b3bindCSC.c new file mode 100644 index 000000000..95fe83357 --- /dev/null +++ b/src/spicelib/devices/bsim3/b3bindCSC.c @@ -0,0 +1,519 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bsim3def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +BSIM3bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3model *model = (BSIM3model *)inModel ; + BSIM3instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the BSIM3 models */ + for ( ; model != NULL ; model = model->BSIM3nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3instances ; here != NULL ; here = here->BSIM3nextInstance) + { + if ((here-> BSIM3dNode != 0) && (here-> BSIM3dNode != 0)) + { + i = here->BSIM3DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3DdStructPtr = matched ; + here->BSIM3DdPtr = matched->CSC ; + } + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3gNode != 0)) + { + i = here->BSIM3GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3GgStructPtr = matched ; + here->BSIM3GgPtr = matched->CSC ; + } + + if ((here-> BSIM3sNode != 0) && (here-> BSIM3sNode != 0)) + { + i = here->BSIM3SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3SsStructPtr = matched ; + here->BSIM3SsPtr = matched->CSC ; + } + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3bNode != 0)) + { + i = here->BSIM3BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3BbStructPtr = matched ; + here->BSIM3BbPtr = matched->CSC ; + } + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3dNodePrime != 0)) + { + i = here->BSIM3DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3DPdpStructPtr = matched ; + here->BSIM3DPdpPtr = matched->CSC ; + } + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3sNodePrime != 0)) + { + i = here->BSIM3SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3SPspStructPtr = matched ; + here->BSIM3SPspPtr = matched->CSC ; + } + + if ((here-> BSIM3dNode != 0) && (here-> BSIM3dNodePrime != 0)) + { + i = here->BSIM3DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3DdpStructPtr = matched ; + here->BSIM3DdpPtr = matched->CSC ; + } + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3bNode != 0)) + { + i = here->BSIM3GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3GbStructPtr = matched ; + here->BSIM3GbPtr = matched->CSC ; + } + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3dNodePrime != 0)) + { + i = here->BSIM3GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3GdpStructPtr = matched ; + here->BSIM3GdpPtr = matched->CSC ; + } + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3sNodePrime != 0)) + { + i = here->BSIM3GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3GspStructPtr = matched ; + here->BSIM3GspPtr = matched->CSC ; + } + + if ((here-> BSIM3sNode != 0) && (here-> BSIM3sNodePrime != 0)) + { + i = here->BSIM3SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3SspStructPtr = matched ; + here->BSIM3SspPtr = matched->CSC ; + } + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3dNodePrime != 0)) + { + i = here->BSIM3BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3BdpStructPtr = matched ; + here->BSIM3BdpPtr = matched->CSC ; + } + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3sNodePrime != 0)) + { + i = here->BSIM3BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3BspStructPtr = matched ; + here->BSIM3BspPtr = matched->CSC ; + } + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3sNodePrime != 0)) + { + i = here->BSIM3DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3DPspStructPtr = matched ; + here->BSIM3DPspPtr = matched->CSC ; + } + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3dNode != 0)) + { + i = here->BSIM3DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3DPdStructPtr = matched ; + here->BSIM3DPdPtr = matched->CSC ; + } + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3gNode != 0)) + { + i = here->BSIM3BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3BgStructPtr = matched ; + here->BSIM3BgPtr = matched->CSC ; + } + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3gNode != 0)) + { + i = here->BSIM3DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3DPgStructPtr = matched ; + here->BSIM3DPgPtr = matched->CSC ; + } + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3gNode != 0)) + { + i = here->BSIM3SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3SPgStructPtr = matched ; + here->BSIM3SPgPtr = matched->CSC ; + } + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3sNode != 0)) + { + i = here->BSIM3SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3SPsStructPtr = matched ; + here->BSIM3SPsPtr = matched->CSC ; + } + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3bNode != 0)) + { + i = here->BSIM3DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3DPbStructPtr = matched ; + here->BSIM3DPbPtr = matched->CSC ; + } + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3bNode != 0)) + { + i = here->BSIM3SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3SPbStructPtr = matched ; + here->BSIM3SPbPtr = matched->CSC ; + } + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3dNodePrime != 0)) + { + i = here->BSIM3SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3SPdpStructPtr = matched ; + here->BSIM3SPdpPtr = matched->CSC ; + } + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3qNode != 0)) + { + i = here->BSIM3QqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3QqStructPtr = matched ; + here->BSIM3QqPtr = matched->CSC ; + } + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3dNodePrime != 0)) + { + i = here->BSIM3QdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3QdpStructPtr = matched ; + here->BSIM3QdpPtr = matched->CSC ; + } + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3gNode != 0)) + { + i = here->BSIM3QgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3QgStructPtr = matched ; + here->BSIM3QgPtr = matched->CSC ; + } + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3sNodePrime != 0)) + { + i = here->BSIM3QspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3QspStructPtr = matched ; + here->BSIM3QspPtr = matched->CSC ; + } + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3bNode != 0)) + { + i = here->BSIM3QbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3QbStructPtr = matched ; + here->BSIM3QbPtr = matched->CSC ; + } + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3qNode != 0)) + { + i = here->BSIM3DPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3DPqStructPtr = matched ; + here->BSIM3DPqPtr = matched->CSC ; + } + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3qNode != 0)) + { + i = here->BSIM3GqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3GqStructPtr = matched ; + here->BSIM3GqPtr = matched->CSC ; + } + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3qNode != 0)) + { + i = here->BSIM3SPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3SPqStructPtr = matched ; + here->BSIM3SPqPtr = matched->CSC ; + } + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3qNode != 0)) + { + i = here->BSIM3BqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3BqStructPtr = matched ; + here->BSIM3BqPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +BSIM3bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3model *model = (BSIM3model *)inModel ; + BSIM3instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM3 models */ + for ( ; model != NULL ; model = model->BSIM3nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3instances ; here != NULL ; here = here->BSIM3nextInstance) + { + if ((here-> BSIM3dNode != 0) && (here-> BSIM3dNode != 0)) + here->BSIM3DdPtr = here->BSIM3DdStructPtr->CSC_Complex ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3GgPtr = here->BSIM3GgStructPtr->CSC_Complex ; + + if ((here-> BSIM3sNode != 0) && (here-> BSIM3sNode != 0)) + here->BSIM3SsPtr = here->BSIM3SsStructPtr->CSC_Complex ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3BbPtr = here->BSIM3BbStructPtr->CSC_Complex ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3DPdpPtr = here->BSIM3DPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3SPspPtr = here->BSIM3SPspStructPtr->CSC_Complex ; + + if ((here-> BSIM3dNode != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3DdpPtr = here->BSIM3DdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3GbPtr = here->BSIM3GbStructPtr->CSC_Complex ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3GdpPtr = here->BSIM3GdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3GspPtr = here->BSIM3GspStructPtr->CSC_Complex ; + + if ((here-> BSIM3sNode != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3SspPtr = here->BSIM3SspStructPtr->CSC_Complex ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3BdpPtr = here->BSIM3BdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3BspPtr = here->BSIM3BspStructPtr->CSC_Complex ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3DPspPtr = here->BSIM3DPspStructPtr->CSC_Complex ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3dNode != 0)) + here->BSIM3DPdPtr = here->BSIM3DPdStructPtr->CSC_Complex ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3BgPtr = here->BSIM3BgStructPtr->CSC_Complex ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3DPgPtr = here->BSIM3DPgStructPtr->CSC_Complex ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3SPgPtr = here->BSIM3SPgStructPtr->CSC_Complex ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3sNode != 0)) + here->BSIM3SPsPtr = here->BSIM3SPsStructPtr->CSC_Complex ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3DPbPtr = here->BSIM3DPbStructPtr->CSC_Complex ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3SPbPtr = here->BSIM3SPbStructPtr->CSC_Complex ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3SPdpPtr = here->BSIM3SPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3QqPtr = here->BSIM3QqStructPtr->CSC_Complex ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3QdpPtr = here->BSIM3QdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3QgPtr = here->BSIM3QgStructPtr->CSC_Complex ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3QspPtr = here->BSIM3QspStructPtr->CSC_Complex ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3QbPtr = here->BSIM3QbStructPtr->CSC_Complex ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3DPqPtr = here->BSIM3DPqStructPtr->CSC_Complex ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3GqPtr = here->BSIM3GqStructPtr->CSC_Complex ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3SPqPtr = here->BSIM3SPqStructPtr->CSC_Complex ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3BqPtr = here->BSIM3BqStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +BSIM3bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3model *model = (BSIM3model *)inModel ; + BSIM3instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM3 models */ + for ( ; model != NULL ; model = model->BSIM3nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3instances ; here != NULL ; here = here->BSIM3nextInstance) + { + if ((here-> BSIM3dNode != 0) && (here-> BSIM3dNode != 0)) + here->BSIM3DdPtr = here->BSIM3DdStructPtr->CSC ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3GgPtr = here->BSIM3GgStructPtr->CSC ; + + if ((here-> BSIM3sNode != 0) && (here-> BSIM3sNode != 0)) + here->BSIM3SsPtr = here->BSIM3SsStructPtr->CSC ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3BbPtr = here->BSIM3BbStructPtr->CSC ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3DPdpPtr = here->BSIM3DPdpStructPtr->CSC ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3SPspPtr = here->BSIM3SPspStructPtr->CSC ; + + if ((here-> BSIM3dNode != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3DdpPtr = here->BSIM3DdpStructPtr->CSC ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3GbPtr = here->BSIM3GbStructPtr->CSC ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3GdpPtr = here->BSIM3GdpStructPtr->CSC ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3GspPtr = here->BSIM3GspStructPtr->CSC ; + + if ((here-> BSIM3sNode != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3SspPtr = here->BSIM3SspStructPtr->CSC ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3BdpPtr = here->BSIM3BdpStructPtr->CSC ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3BspPtr = here->BSIM3BspStructPtr->CSC ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3DPspPtr = here->BSIM3DPspStructPtr->CSC ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3dNode != 0)) + here->BSIM3DPdPtr = here->BSIM3DPdStructPtr->CSC ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3BgPtr = here->BSIM3BgStructPtr->CSC ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3DPgPtr = here->BSIM3DPgStructPtr->CSC ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3SPgPtr = here->BSIM3SPgStructPtr->CSC ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3sNode != 0)) + here->BSIM3SPsPtr = here->BSIM3SPsStructPtr->CSC ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3DPbPtr = here->BSIM3DPbStructPtr->CSC ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3SPbPtr = here->BSIM3SPbStructPtr->CSC ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3SPdpPtr = here->BSIM3SPdpStructPtr->CSC ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3QqPtr = here->BSIM3QqStructPtr->CSC ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3dNodePrime != 0)) + here->BSIM3QdpPtr = here->BSIM3QdpStructPtr->CSC ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3gNode != 0)) + here->BSIM3QgPtr = here->BSIM3QgStructPtr->CSC ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3sNodePrime != 0)) + here->BSIM3QspPtr = here->BSIM3QspStructPtr->CSC ; + + if ((here-> BSIM3qNode != 0) && (here-> BSIM3bNode != 0)) + here->BSIM3QbPtr = here->BSIM3QbStructPtr->CSC ; + + if ((here-> BSIM3dNodePrime != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3DPqPtr = here->BSIM3DPqStructPtr->CSC ; + + if ((here-> BSIM3gNode != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3GqPtr = here->BSIM3GqStructPtr->CSC ; + + if ((here-> BSIM3sNodePrime != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3SPqPtr = here->BSIM3SPqStructPtr->CSC ; + + if ((here-> BSIM3bNode != 0) && (here-> BSIM3qNode != 0)) + here->BSIM3BqPtr = here->BSIM3BqStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim3/bsim3def.h b/src/spicelib/devices/bsim3/bsim3def.h index 9b1b9503d..79a1ae497 100644 --- a/src/spicelib/devices/bsim3/bsim3def.h +++ b/src/spicelib/devices/bsim3/bsim3def.h @@ -257,6 +257,40 @@ typedef struct sBSIM3instance double **BSIM3nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *BSIM3DdStructPtr ; + BindElement *BSIM3GgStructPtr ; + BindElement *BSIM3SsStructPtr ; + BindElement *BSIM3BbStructPtr ; + BindElement *BSIM3DPdpStructPtr ; + BindElement *BSIM3SPspStructPtr ; + BindElement *BSIM3DdpStructPtr ; + BindElement *BSIM3GbStructPtr ; + BindElement *BSIM3GdpStructPtr ; + BindElement *BSIM3GspStructPtr ; + BindElement *BSIM3SspStructPtr ; + BindElement *BSIM3BdpStructPtr ; + BindElement *BSIM3BspStructPtr ; + BindElement *BSIM3DPspStructPtr ; + BindElement *BSIM3DPdStructPtr ; + BindElement *BSIM3BgStructPtr ; + BindElement *BSIM3DPgStructPtr ; + BindElement *BSIM3SPgStructPtr ; + BindElement *BSIM3SPsStructPtr ; + BindElement *BSIM3DPbStructPtr ; + BindElement *BSIM3SPbStructPtr ; + BindElement *BSIM3SPdpStructPtr ; + BindElement *BSIM3QqStructPtr ; + BindElement *BSIM3QdpStructPtr ; + BindElement *BSIM3QgStructPtr ; + BindElement *BSIM3QspStructPtr ; + BindElement *BSIM3QbStructPtr ; + BindElement *BSIM3DPqStructPtr ; + BindElement *BSIM3GqStructPtr ; + BindElement *BSIM3SPqStructPtr ; + BindElement *BSIM3BqStructPtr ; +#endif + } BSIM3instance ; struct bsim3SizeDependParam diff --git a/src/spicelib/devices/bsim3/bsim3ext.h b/src/spicelib/devices/bsim3/bsim3ext.h index 2282a6d37..ba915f85b 100644 --- a/src/spicelib/devices/bsim3/bsim3ext.h +++ b/src/spicelib/devices/bsim3/bsim3ext.h @@ -29,3 +29,9 @@ extern int BSIM3trunc(GENmodel*,CKTcircuit*,double*); extern int BSIM3noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int BSIM3unsetup(GENmodel*,CKTcircuit*); extern int BSIM3soaCheck(CKTcircuit *, GENmodel *); + +#ifdef KLU +extern int BSIM3bindCSC (GENmodel*, CKTcircuit*) ; +extern int BSIM3bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int BSIM3bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim3/bsim3init.c b/src/spicelib/devices/bsim3/bsim3init.c index e27f3925b..8b4870b83 100644 --- a/src/spicelib/devices/bsim3/bsim3init.c +++ b/src/spicelib/devices/bsim3/bsim3init.c @@ -72,7 +72,13 @@ SPICEdev BSIM3info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &BSIM3iSize, - /* DEVmodSize */ &BSIM3mSize + /* DEVmodSize */ &BSIM3mSize, + +#ifdef KLU + /* DEVbindCSC */ BSIM3bindCSC, + /* DEVbindCSCComplex */ BSIM3bindCSCComplex, + /* DEVbindCSCComplexToReal */ BSIM3bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/bsim3soi_dd/Makefile.am b/src/spicelib/devices/bsim3soi_dd/Makefile.am index 5187d67e3..df3b14beb 100644 --- a/src/spicelib/devices/bsim3soi_dd/Makefile.am +++ b/src/spicelib/devices/bsim3soi_dd/Makefile.am @@ -28,6 +28,9 @@ libbsim3soidd_la_SOURCES = \ b3soidditf.h +if KLU_WANTED +libbsim3soidd_la_SOURCES += b3soiddbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim3soi_dd/b3soiddbindCSC.c b/src/spicelib/devices/bsim3soi_dd/b3soiddbindCSC.c new file mode 100644 index 000000000..927451757 --- /dev/null +++ b/src/spicelib/devices/bsim3soi_dd/b3soiddbindCSC.c @@ -0,0 +1,1432 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "b3soidddef.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +B3SOIDDbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + B3SOIDDmodel *model = (B3SOIDDmodel *)inModel ; + B3SOIDDinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the B3SOIDD models */ + for ( ; model != NULL ; model = model->B3SOIDDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->B3SOIDDinstances ; here != NULL ; here = here->B3SOIDDnextInstance) + { + if ((model->B3SOIDDshMod == 1) && (here->B3SOIDDrth0!=0.0)) + { + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDtempNode != 0)) + { + i = here->B3SOIDDTemptempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDTemptempStructPtr = matched ; + here->B3SOIDDTemptempPtr = matched->CSC ; + } + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + { + i = here->B3SOIDDTempdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDTempdpStructPtr = matched ; + here->B3SOIDDTempdpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + { + i = here->B3SOIDDTempspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDTempspStructPtr = matched ; + here->B3SOIDDTempspPtr = matched->CSC ; + } + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDgNode != 0)) + { + i = here->B3SOIDDTempgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDTempgStructPtr = matched ; + here->B3SOIDDTempgPtr = matched->CSC ; + } + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDbNode != 0)) + { + i = here->B3SOIDDTempbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDTempbStructPtr = matched ; + here->B3SOIDDTempbPtr = matched->CSC ; + } + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDeNode != 0)) + { + i = here->B3SOIDDTempePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDTempeStructPtr = matched ; + here->B3SOIDDTempePtr = matched->CSC ; + } + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDtempNode != 0)) + { + i = here->B3SOIDDGtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGtempStructPtr = matched ; + here->B3SOIDDGtempPtr = matched->CSC ; + } + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDtempNode != 0)) + { + i = here->B3SOIDDDPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDPtempStructPtr = matched ; + here->B3SOIDDDPtempPtr = matched->CSC ; + } + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDtempNode != 0)) + { + i = here->B3SOIDDSPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDSPtempStructPtr = matched ; + here->B3SOIDDSPtempPtr = matched->CSC ; + } + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDtempNode != 0)) + { + i = here->B3SOIDDEtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDEtempStructPtr = matched ; + here->B3SOIDDEtempPtr = matched->CSC ; + } + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDtempNode != 0)) + { + i = here->B3SOIDDBtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDBtempStructPtr = matched ; + here->B3SOIDDBtempPtr = matched->CSC ; + } + + if (here->B3SOIDDbodyMod == 1) + { + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDtempNode != 0)) + { + i = here->B3SOIDDPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDPtempStructPtr = matched ; + here->B3SOIDDPtempPtr = matched->CSC ; + } + + } + } + if (here->B3SOIDDbodyMod == 2) + { + } + else if (here->B3SOIDDbodyMod == 1) + { + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDpNode != 0)) + { + i = here->B3SOIDDBpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDBpStructPtr = matched ; + here->B3SOIDDBpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDbNode != 0)) + { + i = here->B3SOIDDPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDPbStructPtr = matched ; + here->B3SOIDDPbPtr = matched->CSC ; + } + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDpNode != 0)) + { + i = here->B3SOIDDPpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDPpStructPtr = matched ; + here->B3SOIDDPpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDgNode != 0)) + { + i = here->B3SOIDDPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDPgStructPtr = matched ; + here->B3SOIDDPgPtr = matched->CSC ; + } + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + { + i = here->B3SOIDDPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDPdpStructPtr = matched ; + here->B3SOIDDPdpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + { + i = here->B3SOIDDPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDPspStructPtr = matched ; + here->B3SOIDDPspPtr = matched->CSC ; + } + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDeNode != 0)) + { + i = here->B3SOIDDPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDPeStructPtr = matched ; + here->B3SOIDDPePtr = matched->CSC ; + } + + } + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDgNode != 0)) + { + i = here->B3SOIDDEgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDEgStructPtr = matched ; + here->B3SOIDDEgPtr = matched->CSC ; + } + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + { + i = here->B3SOIDDEdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDEdpStructPtr = matched ; + here->B3SOIDDEdpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + { + i = here->B3SOIDDEspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDEspStructPtr = matched ; + here->B3SOIDDEspPtr = matched->CSC ; + } + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDeNode != 0)) + { + i = here->B3SOIDDGePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGeStructPtr = matched ; + here->B3SOIDDGePtr = matched->CSC ; + } + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDeNode != 0)) + { + i = here->B3SOIDDDPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDPeStructPtr = matched ; + here->B3SOIDDDPePtr = matched->CSC ; + } + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDeNode != 0)) + { + i = here->B3SOIDDSPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDSPeStructPtr = matched ; + here->B3SOIDDSPePtr = matched->CSC ; + } + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDbNode != 0)) + { + i = here->B3SOIDDEbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDEbStructPtr = matched ; + here->B3SOIDDEbPtr = matched->CSC ; + } + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDbNode != 0)) + { + i = here->B3SOIDDGbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGbStructPtr = matched ; + here->B3SOIDDGbPtr = matched->CSC ; + } + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDbNode != 0)) + { + i = here->B3SOIDDDPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDPbStructPtr = matched ; + here->B3SOIDDDPbPtr = matched->CSC ; + } + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDbNode != 0)) + { + i = here->B3SOIDDSPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDSPbStructPtr = matched ; + here->B3SOIDDSPbPtr = matched->CSC ; + } + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDeNode != 0)) + { + i = here->B3SOIDDBePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDBeStructPtr = matched ; + here->B3SOIDDBePtr = matched->CSC ; + } + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDgNode != 0)) + { + i = here->B3SOIDDBgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDBgStructPtr = matched ; + here->B3SOIDDBgPtr = matched->CSC ; + } + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + { + i = here->B3SOIDDBdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDBdpStructPtr = matched ; + here->B3SOIDDBdpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + { + i = here->B3SOIDDBspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDBspStructPtr = matched ; + here->B3SOIDDBspPtr = matched->CSC ; + } + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDbNode != 0)) + { + i = here->B3SOIDDBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDBbStructPtr = matched ; + here->B3SOIDDBbPtr = matched->CSC ; + } + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDeNode != 0)) + { + i = here->B3SOIDDEePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDEeStructPtr = matched ; + here->B3SOIDDEePtr = matched->CSC ; + } + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDgNode != 0)) + { + i = here->B3SOIDDGgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGgStructPtr = matched ; + here->B3SOIDDGgPtr = matched->CSC ; + } + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + { + i = here->B3SOIDDGdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGdpStructPtr = matched ; + here->B3SOIDDGdpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + { + i = here->B3SOIDDGspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGspStructPtr = matched ; + here->B3SOIDDGspPtr = matched->CSC ; + } + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDgNode != 0)) + { + i = here->B3SOIDDDPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDPgStructPtr = matched ; + here->B3SOIDDDPgPtr = matched->CSC ; + } + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDdNodePrime != 0)) + { + i = here->B3SOIDDDPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDPdpStructPtr = matched ; + here->B3SOIDDDPdpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDsNodePrime != 0)) + { + i = here->B3SOIDDDPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDPspStructPtr = matched ; + here->B3SOIDDDPspPtr = matched->CSC ; + } + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDdNode != 0)) + { + i = here->B3SOIDDDPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDPdStructPtr = matched ; + here->B3SOIDDDPdPtr = matched->CSC ; + } + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDgNode != 0)) + { + i = here->B3SOIDDSPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDSPgStructPtr = matched ; + here->B3SOIDDSPgPtr = matched->CSC ; + } + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDdNodePrime != 0)) + { + i = here->B3SOIDDSPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDSPdpStructPtr = matched ; + here->B3SOIDDSPdpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDsNodePrime != 0)) + { + i = here->B3SOIDDSPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDSPspStructPtr = matched ; + here->B3SOIDDSPspPtr = matched->CSC ; + } + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDsNode != 0)) + { + i = here->B3SOIDDSPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDSPsStructPtr = matched ; + here->B3SOIDDSPsPtr = matched->CSC ; + } + + if ((here-> B3SOIDDdNode != 0) && (here-> B3SOIDDdNode != 0)) + { + i = here->B3SOIDDDdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDdStructPtr = matched ; + here->B3SOIDDDdPtr = matched->CSC ; + } + + if ((here-> B3SOIDDdNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + { + i = here->B3SOIDDDdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDdpStructPtr = matched ; + here->B3SOIDDDdpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDsNode != 0) && (here-> B3SOIDDsNode != 0)) + { + i = here->B3SOIDDSsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDSsStructPtr = matched ; + here->B3SOIDDSsPtr = matched->CSC ; + } + + if ((here-> B3SOIDDsNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + { + i = here->B3SOIDDSspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDSspStructPtr = matched ; + here->B3SOIDDSspPtr = matched->CSC ; + } + + if ((here->B3SOIDDdebugMod > 1) || (here->B3SOIDDdebugMod == -1)) + { + if ((here-> B3SOIDDvbsNode != 0) && (here-> B3SOIDDvbsNode != 0)) + { + i = here->B3SOIDDVbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDVbsStructPtr = matched ; + here->B3SOIDDVbsPtr = matched->CSC ; + } + + if ((here-> B3SOIDDidsNode != 0) && (here-> B3SOIDDidsNode != 0)) + { + i = here->B3SOIDDIdsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDIdsStructPtr = matched ; + here->B3SOIDDIdsPtr = matched->CSC ; + } + + if ((here-> B3SOIDDicNode != 0) && (here-> B3SOIDDicNode != 0)) + { + i = here->B3SOIDDIcPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDIcStructPtr = matched ; + here->B3SOIDDIcPtr = matched->CSC ; + } + + if ((here-> B3SOIDDibsNode != 0) && (here-> B3SOIDDibsNode != 0)) + { + i = here->B3SOIDDIbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDIbsStructPtr = matched ; + here->B3SOIDDIbsPtr = matched->CSC ; + } + + if ((here-> B3SOIDDibdNode != 0) && (here-> B3SOIDDibdNode != 0)) + { + i = here->B3SOIDDIbdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDIbdStructPtr = matched ; + here->B3SOIDDIbdPtr = matched->CSC ; + } + + if ((here-> B3SOIDDiiiNode != 0) && (here-> B3SOIDDiiiNode != 0)) + { + i = here->B3SOIDDIiiPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDIiiStructPtr = matched ; + here->B3SOIDDIiiPtr = matched->CSC ; + } + + if ((here-> B3SOIDDigidlNode != 0) && (here-> B3SOIDDigidlNode != 0)) + { + i = here->B3SOIDDIgidlPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDIgidlStructPtr = matched ; + here->B3SOIDDIgidlPtr = matched->CSC ; + } + + if ((here-> B3SOIDDitunNode != 0) && (here-> B3SOIDDitunNode != 0)) + { + i = here->B3SOIDDItunPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDItunStructPtr = matched ; + here->B3SOIDDItunPtr = matched->CSC ; + } + + if ((here-> B3SOIDDibpNode != 0) && (here-> B3SOIDDibpNode != 0)) + { + i = here->B3SOIDDIbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDIbpStructPtr = matched ; + here->B3SOIDDIbpPtr = matched->CSC ; + } + + if ((here-> B3SOIDDabeffNode != 0) && (here-> B3SOIDDabeffNode != 0)) + { + i = here->B3SOIDDAbeffPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDAbeffStructPtr = matched ; + here->B3SOIDDAbeffPtr = matched->CSC ; + } + + if ((here-> B3SOIDDvbs0effNode != 0) && (here-> B3SOIDDvbs0effNode != 0)) + { + i = here->B3SOIDDVbs0effPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDVbs0effStructPtr = matched ; + here->B3SOIDDVbs0effPtr = matched->CSC ; + } + + if ((here-> B3SOIDDvbseffNode != 0) && (here-> B3SOIDDvbseffNode != 0)) + { + i = here->B3SOIDDVbseffPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDVbseffStructPtr = matched ; + here->B3SOIDDVbseffPtr = matched->CSC ; + } + + if ((here-> B3SOIDDxcNode != 0) && (here-> B3SOIDDxcNode != 0)) + { + i = here->B3SOIDDXcPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDXcStructPtr = matched ; + here->B3SOIDDXcPtr = matched->CSC ; + } + + if ((here-> B3SOIDDcbbNode != 0) && (here-> B3SOIDDcbbNode != 0)) + { + i = here->B3SOIDDCbbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDCbbStructPtr = matched ; + here->B3SOIDDCbbPtr = matched->CSC ; + } + + if ((here-> B3SOIDDcbdNode != 0) && (here-> B3SOIDDcbdNode != 0)) + { + i = here->B3SOIDDCbdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDCbdStructPtr = matched ; + here->B3SOIDDCbdPtr = matched->CSC ; + } + + if ((here-> B3SOIDDcbgNode != 0) && (here-> B3SOIDDcbgNode != 0)) + { + i = here->B3SOIDDCbgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDCbgStructPtr = matched ; + here->B3SOIDDCbgPtr = matched->CSC ; + } + + if ((here-> B3SOIDDqbNode != 0) && (here-> B3SOIDDqbNode != 0)) + { + i = here->B3SOIDDqbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDqbStructPtr = matched ; + here->B3SOIDDqbPtr = matched->CSC ; + } + + if ((here-> B3SOIDDqbfNode != 0) && (here-> B3SOIDDqbfNode != 0)) + { + i = here->B3SOIDDQbfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDQbfStructPtr = matched ; + here->B3SOIDDQbfPtr = matched->CSC ; + } + + if ((here-> B3SOIDDqjsNode != 0) && (here-> B3SOIDDqjsNode != 0)) + { + i = here->B3SOIDDQjsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDQjsStructPtr = matched ; + here->B3SOIDDQjsPtr = matched->CSC ; + } + + if ((here-> B3SOIDDqjdNode != 0) && (here-> B3SOIDDqjdNode != 0)) + { + i = here->B3SOIDDQjdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDQjdStructPtr = matched ; + here->B3SOIDDQjdPtr = matched->CSC ; + } + + if ((here-> B3SOIDDgmNode != 0) && (here-> B3SOIDDgmNode != 0)) + { + i = here->B3SOIDDGmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGmStructPtr = matched ; + here->B3SOIDDGmPtr = matched->CSC ; + } + + if ((here-> B3SOIDDgmbsNode != 0) && (here-> B3SOIDDgmbsNode != 0)) + { + i = here->B3SOIDDGmbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGmbsStructPtr = matched ; + here->B3SOIDDGmbsPtr = matched->CSC ; + } + + if ((here-> B3SOIDDgdsNode != 0) && (here-> B3SOIDDgdsNode != 0)) + { + i = here->B3SOIDDGdsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGdsStructPtr = matched ; + here->B3SOIDDGdsPtr = matched->CSC ; + } + + if ((here-> B3SOIDDgmeNode != 0) && (here-> B3SOIDDgmeNode != 0)) + { + i = here->B3SOIDDGmePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDGmeStructPtr = matched ; + here->B3SOIDDGmePtr = matched->CSC ; + } + + if ((here-> B3SOIDDvbs0teffNode != 0) && (here-> B3SOIDDvbs0teffNode != 0)) + { + i = here->B3SOIDDVbs0teffPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDVbs0teffStructPtr = matched ; + here->B3SOIDDVbs0teffPtr = matched->CSC ; + } + + if ((here-> B3SOIDDvthNode != 0) && (here-> B3SOIDDvthNode != 0)) + { + i = here->B3SOIDDVthPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDVthStructPtr = matched ; + here->B3SOIDDVthPtr = matched->CSC ; + } + + if ((here-> B3SOIDDvgsteffNode != 0) && (here-> B3SOIDDvgsteffNode != 0)) + { + i = here->B3SOIDDVgsteffPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDVgsteffStructPtr = matched ; + here->B3SOIDDVgsteffPtr = matched->CSC ; + } + + if ((here-> B3SOIDDxcsatNode != 0) && (here-> B3SOIDDxcsatNode != 0)) + { + i = here->B3SOIDDXcsatPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDXcsatStructPtr = matched ; + here->B3SOIDDXcsatPtr = matched->CSC ; + } + + if ((here-> B3SOIDDvcscvNode != 0) && (here-> B3SOIDDvcscvNode != 0)) + { + i = here->B3SOIDDVcscvPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDVcscvStructPtr = matched ; + here->B3SOIDDVcscvPtr = matched->CSC ; + } + + if ((here-> B3SOIDDvdscvNode != 0) && (here-> B3SOIDDvdscvNode != 0)) + { + i = here->B3SOIDDVdscvPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDVdscvStructPtr = matched ; + here->B3SOIDDVdscvPtr = matched->CSC ; + } + + if ((here-> B3SOIDDcbeNode != 0) && (here-> B3SOIDDcbeNode != 0)) + { + i = here->B3SOIDDCbePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDCbeStructPtr = matched ; + here->B3SOIDDCbePtr = matched->CSC ; + } + + if ((here-> B3SOIDDdum1Node != 0) && (here-> B3SOIDDdum1Node != 0)) + { + i = here->B3SOIDDDum1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDum1StructPtr = matched ; + here->B3SOIDDDum1Ptr = matched->CSC ; + } + + if ((here-> B3SOIDDdum2Node != 0) && (here-> B3SOIDDdum2Node != 0)) + { + i = here->B3SOIDDDum2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDum2StructPtr = matched ; + here->B3SOIDDDum2Ptr = matched->CSC ; + } + + if ((here-> B3SOIDDdum3Node != 0) && (here-> B3SOIDDdum3Node != 0)) + { + i = here->B3SOIDDDum3Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDum3StructPtr = matched ; + here->B3SOIDDDum3Ptr = matched->CSC ; + } + + if ((here-> B3SOIDDdum4Node != 0) && (here-> B3SOIDDdum4Node != 0)) + { + i = here->B3SOIDDDum4Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDum4StructPtr = matched ; + here->B3SOIDDDum4Ptr = matched->CSC ; + } + + if ((here-> B3SOIDDdum5Node != 0) && (here-> B3SOIDDdum5Node != 0)) + { + i = here->B3SOIDDDum5Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDDum5StructPtr = matched ; + here->B3SOIDDDum5Ptr = matched->CSC ; + } + + if ((here-> B3SOIDDqaccNode != 0) && (here-> B3SOIDDqaccNode != 0)) + { + i = here->B3SOIDDQaccPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDQaccStructPtr = matched ; + here->B3SOIDDQaccPtr = matched->CSC ; + } + + if ((here-> B3SOIDDqsub0Node != 0) && (here-> B3SOIDDqsub0Node != 0)) + { + i = here->B3SOIDDQsub0Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDQsub0StructPtr = matched ; + here->B3SOIDDQsub0Ptr = matched->CSC ; + } + + if ((here-> B3SOIDDqsubs1Node != 0) && (here-> B3SOIDDqsubs1Node != 0)) + { + i = here->B3SOIDDQsubs1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDQsubs1StructPtr = matched ; + here->B3SOIDDQsubs1Ptr = matched->CSC ; + } + + if ((here-> B3SOIDDqsubs2Node != 0) && (here-> B3SOIDDqsubs2Node != 0)) + { + i = here->B3SOIDDQsubs2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDQsubs2StructPtr = matched ; + here->B3SOIDDQsubs2Ptr = matched->CSC ; + } + + if ((here-> B3SOIDDqeNode != 0) && (here-> B3SOIDDqeNode != 0)) + { + i = here->B3SOIDDqePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDqeStructPtr = matched ; + here->B3SOIDDqePtr = matched->CSC ; + } + + if ((here-> B3SOIDDqdNode != 0) && (here-> B3SOIDDqdNode != 0)) + { + i = here->B3SOIDDqdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDqdStructPtr = matched ; + here->B3SOIDDqdPtr = matched->CSC ; + } + + if ((here-> B3SOIDDqgNode != 0) && (here-> B3SOIDDqgNode != 0)) + { + i = here->B3SOIDDqgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIDDqgStructPtr = matched ; + here->B3SOIDDqgPtr = matched->CSC ; + } + + } + } + } + + return (OK) ; +} + +int +B3SOIDDbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + B3SOIDDmodel *model = (B3SOIDDmodel *)inModel ; + B3SOIDDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B3SOIDD models */ + for ( ; model != NULL ; model = model->B3SOIDDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->B3SOIDDinstances ; here != NULL ; here = here->B3SOIDDnextInstance) + { + if ((model->B3SOIDDshMod == 1) && (here->B3SOIDDrth0!=0.0)) + { + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDTemptempPtr = here->B3SOIDDTemptempStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDTempdpPtr = here->B3SOIDDTempdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDTempspPtr = here->B3SOIDDTempspStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDTempgPtr = here->B3SOIDDTempgStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDTempbPtr = here->B3SOIDDTempbStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDTempePtr = here->B3SOIDDTempeStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDGtempPtr = here->B3SOIDDGtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDDPtempPtr = here->B3SOIDDDPtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDSPtempPtr = here->B3SOIDDSPtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDEtempPtr = here->B3SOIDDEtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDBtempPtr = here->B3SOIDDBtempStructPtr->CSC_Complex ; + + if (here->B3SOIDDbodyMod == 1) + { + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDPtempPtr = here->B3SOIDDPtempStructPtr->CSC_Complex ; + + } + } + if (here->B3SOIDDbodyMod == 2) + { + } + else if (here->B3SOIDDbodyMod == 1) + { + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDpNode != 0)) + here->B3SOIDDBpPtr = here->B3SOIDDBpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDPbPtr = here->B3SOIDDPbStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDpNode != 0)) + here->B3SOIDDPpPtr = here->B3SOIDDPpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDPgPtr = here->B3SOIDDPgStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDPdpPtr = here->B3SOIDDPdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDPspPtr = here->B3SOIDDPspStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDPePtr = here->B3SOIDDPeStructPtr->CSC_Complex ; + + } + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDEgPtr = here->B3SOIDDEgStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDEdpPtr = here->B3SOIDDEdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDEspPtr = here->B3SOIDDEspStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDGePtr = here->B3SOIDDGeStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDDPePtr = here->B3SOIDDDPeStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDSPePtr = here->B3SOIDDSPeStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDEbPtr = here->B3SOIDDEbStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDGbPtr = here->B3SOIDDGbStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDDPbPtr = here->B3SOIDDDPbStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDSPbPtr = here->B3SOIDDSPbStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDBePtr = here->B3SOIDDBeStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDBgPtr = here->B3SOIDDBgStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDBdpPtr = here->B3SOIDDBdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDBspPtr = here->B3SOIDDBspStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDBbPtr = here->B3SOIDDBbStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDEePtr = here->B3SOIDDEeStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDGgPtr = here->B3SOIDDGgStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDGdpPtr = here->B3SOIDDGdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDGspPtr = here->B3SOIDDGspStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDDPgPtr = here->B3SOIDDDPgStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDDPdpPtr = here->B3SOIDDDPdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDDPspPtr = here->B3SOIDDDPspStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDdNode != 0)) + here->B3SOIDDDPdPtr = here->B3SOIDDDPdStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDSPgPtr = here->B3SOIDDSPgStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDSPdpPtr = here->B3SOIDDSPdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDSPspPtr = here->B3SOIDDSPspStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDsNode != 0)) + here->B3SOIDDSPsPtr = here->B3SOIDDSPsStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdNode != 0) && (here-> B3SOIDDdNode != 0)) + here->B3SOIDDDdPtr = here->B3SOIDDDdStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDDdpPtr = here->B3SOIDDDdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDsNode != 0) && (here-> B3SOIDDsNode != 0)) + here->B3SOIDDSsPtr = here->B3SOIDDSsStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDsNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDSspPtr = here->B3SOIDDSspStructPtr->CSC_Complex ; + + if ((here->B3SOIDDdebugMod > 1) || (here->B3SOIDDdebugMod == -1)) + { + if ((here-> B3SOIDDvbsNode != 0) && (here-> B3SOIDDvbsNode != 0)) + here->B3SOIDDVbsPtr = here->B3SOIDDVbsStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDidsNode != 0) && (here-> B3SOIDDidsNode != 0)) + here->B3SOIDDIdsPtr = here->B3SOIDDIdsStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDicNode != 0) && (here-> B3SOIDDicNode != 0)) + here->B3SOIDDIcPtr = here->B3SOIDDIcStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDibsNode != 0) && (here-> B3SOIDDibsNode != 0)) + here->B3SOIDDIbsPtr = here->B3SOIDDIbsStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDibdNode != 0) && (here-> B3SOIDDibdNode != 0)) + here->B3SOIDDIbdPtr = here->B3SOIDDIbdStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDiiiNode != 0) && (here-> B3SOIDDiiiNode != 0)) + here->B3SOIDDIiiPtr = here->B3SOIDDIiiStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDigidlNode != 0) && (here-> B3SOIDDigidlNode != 0)) + here->B3SOIDDIgidlPtr = here->B3SOIDDIgidlStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDitunNode != 0) && (here-> B3SOIDDitunNode != 0)) + here->B3SOIDDItunPtr = here->B3SOIDDItunStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDibpNode != 0) && (here-> B3SOIDDibpNode != 0)) + here->B3SOIDDIbpPtr = here->B3SOIDDIbpStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDabeffNode != 0) && (here-> B3SOIDDabeffNode != 0)) + here->B3SOIDDAbeffPtr = here->B3SOIDDAbeffStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDvbs0effNode != 0) && (here-> B3SOIDDvbs0effNode != 0)) + here->B3SOIDDVbs0effPtr = here->B3SOIDDVbs0effStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDvbseffNode != 0) && (here-> B3SOIDDvbseffNode != 0)) + here->B3SOIDDVbseffPtr = here->B3SOIDDVbseffStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDxcNode != 0) && (here-> B3SOIDDxcNode != 0)) + here->B3SOIDDXcPtr = here->B3SOIDDXcStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDcbbNode != 0) && (here-> B3SOIDDcbbNode != 0)) + here->B3SOIDDCbbPtr = here->B3SOIDDCbbStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDcbdNode != 0) && (here-> B3SOIDDcbdNode != 0)) + here->B3SOIDDCbdPtr = here->B3SOIDDCbdStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDcbgNode != 0) && (here-> B3SOIDDcbgNode != 0)) + here->B3SOIDDCbgPtr = here->B3SOIDDCbgStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqbNode != 0) && (here-> B3SOIDDqbNode != 0)) + here->B3SOIDDqbPtr = here->B3SOIDDqbStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqbfNode != 0) && (here-> B3SOIDDqbfNode != 0)) + here->B3SOIDDQbfPtr = here->B3SOIDDQbfStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqjsNode != 0) && (here-> B3SOIDDqjsNode != 0)) + here->B3SOIDDQjsPtr = here->B3SOIDDQjsStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqjdNode != 0) && (here-> B3SOIDDqjdNode != 0)) + here->B3SOIDDQjdPtr = here->B3SOIDDQjdStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgmNode != 0) && (here-> B3SOIDDgmNode != 0)) + here->B3SOIDDGmPtr = here->B3SOIDDGmStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgmbsNode != 0) && (here-> B3SOIDDgmbsNode != 0)) + here->B3SOIDDGmbsPtr = here->B3SOIDDGmbsStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgdsNode != 0) && (here-> B3SOIDDgdsNode != 0)) + here->B3SOIDDGdsPtr = here->B3SOIDDGdsStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDgmeNode != 0) && (here-> B3SOIDDgmeNode != 0)) + here->B3SOIDDGmePtr = here->B3SOIDDGmeStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDvbs0teffNode != 0) && (here-> B3SOIDDvbs0teffNode != 0)) + here->B3SOIDDVbs0teffPtr = here->B3SOIDDVbs0teffStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDvthNode != 0) && (here-> B3SOIDDvthNode != 0)) + here->B3SOIDDVthPtr = here->B3SOIDDVthStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDvgsteffNode != 0) && (here-> B3SOIDDvgsteffNode != 0)) + here->B3SOIDDVgsteffPtr = here->B3SOIDDVgsteffStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDxcsatNode != 0) && (here-> B3SOIDDxcsatNode != 0)) + here->B3SOIDDXcsatPtr = here->B3SOIDDXcsatStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDvcscvNode != 0) && (here-> B3SOIDDvcscvNode != 0)) + here->B3SOIDDVcscvPtr = here->B3SOIDDVcscvStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDvdscvNode != 0) && (here-> B3SOIDDvdscvNode != 0)) + here->B3SOIDDVdscvPtr = here->B3SOIDDVdscvStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDcbeNode != 0) && (here-> B3SOIDDcbeNode != 0)) + here->B3SOIDDCbePtr = here->B3SOIDDCbeStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdum1Node != 0) && (here-> B3SOIDDdum1Node != 0)) + here->B3SOIDDDum1Ptr = here->B3SOIDDDum1StructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdum2Node != 0) && (here-> B3SOIDDdum2Node != 0)) + here->B3SOIDDDum2Ptr = here->B3SOIDDDum2StructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdum3Node != 0) && (here-> B3SOIDDdum3Node != 0)) + here->B3SOIDDDum3Ptr = here->B3SOIDDDum3StructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdum4Node != 0) && (here-> B3SOIDDdum4Node != 0)) + here->B3SOIDDDum4Ptr = here->B3SOIDDDum4StructPtr->CSC_Complex ; + + if ((here-> B3SOIDDdum5Node != 0) && (here-> B3SOIDDdum5Node != 0)) + here->B3SOIDDDum5Ptr = here->B3SOIDDDum5StructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqaccNode != 0) && (here-> B3SOIDDqaccNode != 0)) + here->B3SOIDDQaccPtr = here->B3SOIDDQaccStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqsub0Node != 0) && (here-> B3SOIDDqsub0Node != 0)) + here->B3SOIDDQsub0Ptr = here->B3SOIDDQsub0StructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqsubs1Node != 0) && (here-> B3SOIDDqsubs1Node != 0)) + here->B3SOIDDQsubs1Ptr = here->B3SOIDDQsubs1StructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqsubs2Node != 0) && (here-> B3SOIDDqsubs2Node != 0)) + here->B3SOIDDQsubs2Ptr = here->B3SOIDDQsubs2StructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqeNode != 0) && (here-> B3SOIDDqeNode != 0)) + here->B3SOIDDqePtr = here->B3SOIDDqeStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqdNode != 0) && (here-> B3SOIDDqdNode != 0)) + here->B3SOIDDqdPtr = here->B3SOIDDqdStructPtr->CSC_Complex ; + + if ((here-> B3SOIDDqgNode != 0) && (here-> B3SOIDDqgNode != 0)) + here->B3SOIDDqgPtr = here->B3SOIDDqgStructPtr->CSC_Complex ; + + } + } + } + + return (OK) ; +} + +int +B3SOIDDbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + B3SOIDDmodel *model = (B3SOIDDmodel *)inModel ; + B3SOIDDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B3SOIDD models */ + for ( ; model != NULL ; model = model->B3SOIDDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->B3SOIDDinstances ; here != NULL ; here = here->B3SOIDDnextInstance) + { + if ((model->B3SOIDDshMod == 1) && (here->B3SOIDDrth0!=0.0)) + { + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDTemptempPtr = here->B3SOIDDTemptempStructPtr->CSC ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDTempdpPtr = here->B3SOIDDTempdpStructPtr->CSC ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDTempspPtr = here->B3SOIDDTempspStructPtr->CSC ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDTempgPtr = here->B3SOIDDTempgStructPtr->CSC ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDTempbPtr = here->B3SOIDDTempbStructPtr->CSC ; + + if ((here-> B3SOIDDtempNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDTempePtr = here->B3SOIDDTempeStructPtr->CSC ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDGtempPtr = here->B3SOIDDGtempStructPtr->CSC ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDDPtempPtr = here->B3SOIDDDPtempStructPtr->CSC ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDSPtempPtr = here->B3SOIDDSPtempStructPtr->CSC ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDEtempPtr = here->B3SOIDDEtempStructPtr->CSC ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDBtempPtr = here->B3SOIDDBtempStructPtr->CSC ; + + if (here->B3SOIDDbodyMod == 1) + { + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDtempNode != 0)) + here->B3SOIDDPtempPtr = here->B3SOIDDPtempStructPtr->CSC ; + + } + } + if (here->B3SOIDDbodyMod == 2) + { + } + else if (here->B3SOIDDbodyMod == 1) + { + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDpNode != 0)) + here->B3SOIDDBpPtr = here->B3SOIDDBpStructPtr->CSC ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDPbPtr = here->B3SOIDDPbStructPtr->CSC ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDpNode != 0)) + here->B3SOIDDPpPtr = here->B3SOIDDPpStructPtr->CSC ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDPgPtr = here->B3SOIDDPgStructPtr->CSC ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDPdpPtr = here->B3SOIDDPdpStructPtr->CSC ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDPspPtr = here->B3SOIDDPspStructPtr->CSC ; + + if ((here-> B3SOIDDpNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDPePtr = here->B3SOIDDPeStructPtr->CSC ; + + } + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDEgPtr = here->B3SOIDDEgStructPtr->CSC ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDEdpPtr = here->B3SOIDDEdpStructPtr->CSC ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDEspPtr = here->B3SOIDDEspStructPtr->CSC ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDGePtr = here->B3SOIDDGeStructPtr->CSC ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDDPePtr = here->B3SOIDDDPeStructPtr->CSC ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDSPePtr = here->B3SOIDDSPeStructPtr->CSC ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDEbPtr = here->B3SOIDDEbStructPtr->CSC ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDGbPtr = here->B3SOIDDGbStructPtr->CSC ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDDPbPtr = here->B3SOIDDDPbStructPtr->CSC ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDSPbPtr = here->B3SOIDDSPbStructPtr->CSC ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDBePtr = here->B3SOIDDBeStructPtr->CSC ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDBgPtr = here->B3SOIDDBgStructPtr->CSC ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDBdpPtr = here->B3SOIDDBdpStructPtr->CSC ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDBspPtr = here->B3SOIDDBspStructPtr->CSC ; + + if ((here-> B3SOIDDbNode != 0) && (here-> B3SOIDDbNode != 0)) + here->B3SOIDDBbPtr = here->B3SOIDDBbStructPtr->CSC ; + + if ((here-> B3SOIDDeNode != 0) && (here-> B3SOIDDeNode != 0)) + here->B3SOIDDEePtr = here->B3SOIDDEeStructPtr->CSC ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDGgPtr = here->B3SOIDDGgStructPtr->CSC ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDGdpPtr = here->B3SOIDDGdpStructPtr->CSC ; + + if ((here-> B3SOIDDgNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDGspPtr = here->B3SOIDDGspStructPtr->CSC ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDDPgPtr = here->B3SOIDDDPgStructPtr->CSC ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDDPdpPtr = here->B3SOIDDDPdpStructPtr->CSC ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDDPspPtr = here->B3SOIDDDPspStructPtr->CSC ; + + if ((here-> B3SOIDDdNodePrime != 0) && (here-> B3SOIDDdNode != 0)) + here->B3SOIDDDPdPtr = here->B3SOIDDDPdStructPtr->CSC ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDgNode != 0)) + here->B3SOIDDSPgPtr = here->B3SOIDDSPgStructPtr->CSC ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDSPdpPtr = here->B3SOIDDSPdpStructPtr->CSC ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDSPspPtr = here->B3SOIDDSPspStructPtr->CSC ; + + if ((here-> B3SOIDDsNodePrime != 0) && (here-> B3SOIDDsNode != 0)) + here->B3SOIDDSPsPtr = here->B3SOIDDSPsStructPtr->CSC ; + + if ((here-> B3SOIDDdNode != 0) && (here-> B3SOIDDdNode != 0)) + here->B3SOIDDDdPtr = here->B3SOIDDDdStructPtr->CSC ; + + if ((here-> B3SOIDDdNode != 0) && (here-> B3SOIDDdNodePrime != 0)) + here->B3SOIDDDdpPtr = here->B3SOIDDDdpStructPtr->CSC ; + + if ((here-> B3SOIDDsNode != 0) && (here-> B3SOIDDsNode != 0)) + here->B3SOIDDSsPtr = here->B3SOIDDSsStructPtr->CSC ; + + if ((here-> B3SOIDDsNode != 0) && (here-> B3SOIDDsNodePrime != 0)) + here->B3SOIDDSspPtr = here->B3SOIDDSspStructPtr->CSC ; + + if ((here->B3SOIDDdebugMod > 1) || (here->B3SOIDDdebugMod == -1)) + { + if ((here-> B3SOIDDvbsNode != 0) && (here-> B3SOIDDvbsNode != 0)) + here->B3SOIDDVbsPtr = here->B3SOIDDVbsStructPtr->CSC ; + + if ((here-> B3SOIDDidsNode != 0) && (here-> B3SOIDDidsNode != 0)) + here->B3SOIDDIdsPtr = here->B3SOIDDIdsStructPtr->CSC ; + + if ((here-> B3SOIDDicNode != 0) && (here-> B3SOIDDicNode != 0)) + here->B3SOIDDIcPtr = here->B3SOIDDIcStructPtr->CSC ; + + if ((here-> B3SOIDDibsNode != 0) && (here-> B3SOIDDibsNode != 0)) + here->B3SOIDDIbsPtr = here->B3SOIDDIbsStructPtr->CSC ; + + if ((here-> B3SOIDDibdNode != 0) && (here-> B3SOIDDibdNode != 0)) + here->B3SOIDDIbdPtr = here->B3SOIDDIbdStructPtr->CSC ; + + if ((here-> B3SOIDDiiiNode != 0) && (here-> B3SOIDDiiiNode != 0)) + here->B3SOIDDIiiPtr = here->B3SOIDDIiiStructPtr->CSC ; + + if ((here-> B3SOIDDigidlNode != 0) && (here-> B3SOIDDigidlNode != 0)) + here->B3SOIDDIgidlPtr = here->B3SOIDDIgidlStructPtr->CSC ; + + if ((here-> B3SOIDDitunNode != 0) && (here-> B3SOIDDitunNode != 0)) + here->B3SOIDDItunPtr = here->B3SOIDDItunStructPtr->CSC ; + + if ((here-> B3SOIDDibpNode != 0) && (here-> B3SOIDDibpNode != 0)) + here->B3SOIDDIbpPtr = here->B3SOIDDIbpStructPtr->CSC ; + + if ((here-> B3SOIDDabeffNode != 0) && (here-> B3SOIDDabeffNode != 0)) + here->B3SOIDDAbeffPtr = here->B3SOIDDAbeffStructPtr->CSC ; + + if ((here-> B3SOIDDvbs0effNode != 0) && (here-> B3SOIDDvbs0effNode != 0)) + here->B3SOIDDVbs0effPtr = here->B3SOIDDVbs0effStructPtr->CSC ; + + if ((here-> B3SOIDDvbseffNode != 0) && (here-> B3SOIDDvbseffNode != 0)) + here->B3SOIDDVbseffPtr = here->B3SOIDDVbseffStructPtr->CSC ; + + if ((here-> B3SOIDDxcNode != 0) && (here-> B3SOIDDxcNode != 0)) + here->B3SOIDDXcPtr = here->B3SOIDDXcStructPtr->CSC ; + + if ((here-> B3SOIDDcbbNode != 0) && (here-> B3SOIDDcbbNode != 0)) + here->B3SOIDDCbbPtr = here->B3SOIDDCbbStructPtr->CSC ; + + if ((here-> B3SOIDDcbdNode != 0) && (here-> B3SOIDDcbdNode != 0)) + here->B3SOIDDCbdPtr = here->B3SOIDDCbdStructPtr->CSC ; + + if ((here-> B3SOIDDcbgNode != 0) && (here-> B3SOIDDcbgNode != 0)) + here->B3SOIDDCbgPtr = here->B3SOIDDCbgStructPtr->CSC ; + + if ((here-> B3SOIDDqbNode != 0) && (here-> B3SOIDDqbNode != 0)) + here->B3SOIDDqbPtr = here->B3SOIDDqbStructPtr->CSC ; + + if ((here-> B3SOIDDqbfNode != 0) && (here-> B3SOIDDqbfNode != 0)) + here->B3SOIDDQbfPtr = here->B3SOIDDQbfStructPtr->CSC ; + + if ((here-> B3SOIDDqjsNode != 0) && (here-> B3SOIDDqjsNode != 0)) + here->B3SOIDDQjsPtr = here->B3SOIDDQjsStructPtr->CSC ; + + if ((here-> B3SOIDDqjdNode != 0) && (here-> B3SOIDDqjdNode != 0)) + here->B3SOIDDQjdPtr = here->B3SOIDDQjdStructPtr->CSC ; + + if ((here-> B3SOIDDgmNode != 0) && (here-> B3SOIDDgmNode != 0)) + here->B3SOIDDGmPtr = here->B3SOIDDGmStructPtr->CSC ; + + if ((here-> B3SOIDDgmbsNode != 0) && (here-> B3SOIDDgmbsNode != 0)) + here->B3SOIDDGmbsPtr = here->B3SOIDDGmbsStructPtr->CSC ; + + if ((here-> B3SOIDDgdsNode != 0) && (here-> B3SOIDDgdsNode != 0)) + here->B3SOIDDGdsPtr = here->B3SOIDDGdsStructPtr->CSC ; + + if ((here-> B3SOIDDgmeNode != 0) && (here-> B3SOIDDgmeNode != 0)) + here->B3SOIDDGmePtr = here->B3SOIDDGmeStructPtr->CSC ; + + if ((here-> B3SOIDDvbs0teffNode != 0) && (here-> B3SOIDDvbs0teffNode != 0)) + here->B3SOIDDVbs0teffPtr = here->B3SOIDDVbs0teffStructPtr->CSC ; + + if ((here-> B3SOIDDvthNode != 0) && (here-> B3SOIDDvthNode != 0)) + here->B3SOIDDVthPtr = here->B3SOIDDVthStructPtr->CSC ; + + if ((here-> B3SOIDDvgsteffNode != 0) && (here-> B3SOIDDvgsteffNode != 0)) + here->B3SOIDDVgsteffPtr = here->B3SOIDDVgsteffStructPtr->CSC ; + + if ((here-> B3SOIDDxcsatNode != 0) && (here-> B3SOIDDxcsatNode != 0)) + here->B3SOIDDXcsatPtr = here->B3SOIDDXcsatStructPtr->CSC ; + + if ((here-> B3SOIDDvcscvNode != 0) && (here-> B3SOIDDvcscvNode != 0)) + here->B3SOIDDVcscvPtr = here->B3SOIDDVcscvStructPtr->CSC ; + + if ((here-> B3SOIDDvdscvNode != 0) && (here-> B3SOIDDvdscvNode != 0)) + here->B3SOIDDVdscvPtr = here->B3SOIDDVdscvStructPtr->CSC ; + + if ((here-> B3SOIDDcbeNode != 0) && (here-> B3SOIDDcbeNode != 0)) + here->B3SOIDDCbePtr = here->B3SOIDDCbeStructPtr->CSC ; + + if ((here-> B3SOIDDdum1Node != 0) && (here-> B3SOIDDdum1Node != 0)) + here->B3SOIDDDum1Ptr = here->B3SOIDDDum1StructPtr->CSC ; + + if ((here-> B3SOIDDdum2Node != 0) && (here-> B3SOIDDdum2Node != 0)) + here->B3SOIDDDum2Ptr = here->B3SOIDDDum2StructPtr->CSC ; + + if ((here-> B3SOIDDdum3Node != 0) && (here-> B3SOIDDdum3Node != 0)) + here->B3SOIDDDum3Ptr = here->B3SOIDDDum3StructPtr->CSC ; + + if ((here-> B3SOIDDdum4Node != 0) && (here-> B3SOIDDdum4Node != 0)) + here->B3SOIDDDum4Ptr = here->B3SOIDDDum4StructPtr->CSC ; + + if ((here-> B3SOIDDdum5Node != 0) && (here-> B3SOIDDdum5Node != 0)) + here->B3SOIDDDum5Ptr = here->B3SOIDDDum5StructPtr->CSC ; + + if ((here-> B3SOIDDqaccNode != 0) && (here-> B3SOIDDqaccNode != 0)) + here->B3SOIDDQaccPtr = here->B3SOIDDQaccStructPtr->CSC ; + + if ((here-> B3SOIDDqsub0Node != 0) && (here-> B3SOIDDqsub0Node != 0)) + here->B3SOIDDQsub0Ptr = here->B3SOIDDQsub0StructPtr->CSC ; + + if ((here-> B3SOIDDqsubs1Node != 0) && (here-> B3SOIDDqsubs1Node != 0)) + here->B3SOIDDQsubs1Ptr = here->B3SOIDDQsubs1StructPtr->CSC ; + + if ((here-> B3SOIDDqsubs2Node != 0) && (here-> B3SOIDDqsubs2Node != 0)) + here->B3SOIDDQsubs2Ptr = here->B3SOIDDQsubs2StructPtr->CSC ; + + if ((here-> B3SOIDDqeNode != 0) && (here-> B3SOIDDqeNode != 0)) + here->B3SOIDDqePtr = here->B3SOIDDqeStructPtr->CSC ; + + if ((here-> B3SOIDDqdNode != 0) && (here-> B3SOIDDqdNode != 0)) + here->B3SOIDDqdPtr = here->B3SOIDDqdStructPtr->CSC ; + + if ((here-> B3SOIDDqgNode != 0) && (here-> B3SOIDDqgNode != 0)) + here->B3SOIDDqgPtr = here->B3SOIDDqgStructPtr->CSC ; + + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim3soi_dd/b3soidddef.h b/src/spicelib/devices/bsim3soi_dd/b3soidddef.h index 01fb81667..c07a62d7a 100644 --- a/src/spicelib/devices/bsim3soi_dd/b3soidddef.h +++ b/src/spicelib/devices/bsim3soi_dd/b3soidddef.h @@ -414,6 +414,102 @@ typedef struct sB3SOIDDinstance double **B3SOIDDnVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *B3SOIDDTemptempStructPtr ; + BindElement *B3SOIDDTempdpStructPtr ; + BindElement *B3SOIDDTempspStructPtr ; + BindElement *B3SOIDDTempgStructPtr ; + BindElement *B3SOIDDTempbStructPtr ; + BindElement *B3SOIDDTempeStructPtr ; + BindElement *B3SOIDDGtempStructPtr ; + BindElement *B3SOIDDDPtempStructPtr ; + BindElement *B3SOIDDSPtempStructPtr ; + BindElement *B3SOIDDEtempStructPtr ; + BindElement *B3SOIDDBtempStructPtr ; + BindElement *B3SOIDDPtempStructPtr ; + BindElement *B3SOIDDBpStructPtr ; + BindElement *B3SOIDDPbStructPtr ; + BindElement *B3SOIDDPpStructPtr ; + BindElement *B3SOIDDPgStructPtr ; + BindElement *B3SOIDDPdpStructPtr ; + BindElement *B3SOIDDPspStructPtr ; + BindElement *B3SOIDDPeStructPtr ; + BindElement *B3SOIDDEgStructPtr ; + BindElement *B3SOIDDEdpStructPtr ; + BindElement *B3SOIDDEspStructPtr ; + BindElement *B3SOIDDGeStructPtr ; + BindElement *B3SOIDDDPeStructPtr ; + BindElement *B3SOIDDSPeStructPtr ; + BindElement *B3SOIDDEbStructPtr ; + BindElement *B3SOIDDGbStructPtr ; + BindElement *B3SOIDDDPbStructPtr ; + BindElement *B3SOIDDSPbStructPtr ; + BindElement *B3SOIDDBeStructPtr ; + BindElement *B3SOIDDBgStructPtr ; + BindElement *B3SOIDDBdpStructPtr ; + BindElement *B3SOIDDBspStructPtr ; + BindElement *B3SOIDDBbStructPtr ; + BindElement *B3SOIDDEeStructPtr ; + BindElement *B3SOIDDGgStructPtr ; + BindElement *B3SOIDDGdpStructPtr ; + BindElement *B3SOIDDGspStructPtr ; + BindElement *B3SOIDDDPgStructPtr ; + BindElement *B3SOIDDDPdpStructPtr ; + BindElement *B3SOIDDDPspStructPtr ; + BindElement *B3SOIDDDPdStructPtr ; + BindElement *B3SOIDDSPgStructPtr ; + BindElement *B3SOIDDSPdpStructPtr ; + BindElement *B3SOIDDSPspStructPtr ; + BindElement *B3SOIDDSPsStructPtr ; + BindElement *B3SOIDDDdStructPtr ; + BindElement *B3SOIDDDdpStructPtr ; + BindElement *B3SOIDDSsStructPtr ; + BindElement *B3SOIDDSspStructPtr ; + BindElement *B3SOIDDVbsStructPtr ; + BindElement *B3SOIDDIdsStructPtr ; + BindElement *B3SOIDDIcStructPtr ; + BindElement *B3SOIDDIbsStructPtr ; + BindElement *B3SOIDDIbdStructPtr ; + BindElement *B3SOIDDIiiStructPtr ; + BindElement *B3SOIDDIgidlStructPtr ; + BindElement *B3SOIDDItunStructPtr ; + BindElement *B3SOIDDIbpStructPtr ; + BindElement *B3SOIDDAbeffStructPtr ; + BindElement *B3SOIDDVbs0effStructPtr ; + BindElement *B3SOIDDVbseffStructPtr ; + BindElement *B3SOIDDXcStructPtr ; + BindElement *B3SOIDDCbbStructPtr ; + BindElement *B3SOIDDCbdStructPtr ; + BindElement *B3SOIDDCbgStructPtr ; + BindElement *B3SOIDDqbStructPtr ; + BindElement *B3SOIDDQbfStructPtr ; + BindElement *B3SOIDDQjsStructPtr ; + BindElement *B3SOIDDQjdStructPtr ; + BindElement *B3SOIDDGmStructPtr ; + BindElement *B3SOIDDGmbsStructPtr ; + BindElement *B3SOIDDGdsStructPtr ; + BindElement *B3SOIDDGmeStructPtr ; + BindElement *B3SOIDDVbs0teffStructPtr ; + BindElement *B3SOIDDVthStructPtr ; + BindElement *B3SOIDDVgsteffStructPtr ; + BindElement *B3SOIDDXcsatStructPtr ; + BindElement *B3SOIDDVcscvStructPtr ; + BindElement *B3SOIDDVdscvStructPtr ; + BindElement *B3SOIDDCbeStructPtr ; + BindElement *B3SOIDDDum1StructPtr ; + BindElement *B3SOIDDDum2StructPtr ; + BindElement *B3SOIDDDum3StructPtr ; + BindElement *B3SOIDDDum4StructPtr ; + BindElement *B3SOIDDDum5StructPtr ; + BindElement *B3SOIDDQaccStructPtr ; + BindElement *B3SOIDDQsub0StructPtr ; + BindElement *B3SOIDDQsubs1StructPtr ; + BindElement *B3SOIDDQsubs2StructPtr ; + BindElement *B3SOIDDqeStructPtr ; + BindElement *B3SOIDDqdStructPtr ; + BindElement *B3SOIDDqgStructPtr ; +#endif + } B3SOIDDinstance ; struct b3soiddSizeDependParam diff --git a/src/spicelib/devices/bsim3soi_dd/b3soiddext.h b/src/spicelib/devices/bsim3soi_dd/b3soiddext.h index 1d5d90695..37b0d6fab 100644 --- a/src/spicelib/devices/bsim3soi_dd/b3soiddext.h +++ b/src/spicelib/devices/bsim3soi_dd/b3soiddext.h @@ -28,3 +28,9 @@ extern int B3SOIDDtemp(GENmodel*,CKTcircuit*); extern int B3SOIDDtrunc(GENmodel*,CKTcircuit*,double*); extern int B3SOIDDnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int B3SOIDDunsetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int B3SOIDDbindCSC (GENmodel*, CKTcircuit*) ; +extern int B3SOIDDbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int B3SOIDDbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim3soi_dd/b3soiddinit.c b/src/spicelib/devices/bsim3soi_dd/b3soiddinit.c index 12b98c75f..418aaa89b 100644 --- a/src/spicelib/devices/bsim3soi_dd/b3soiddinit.c +++ b/src/spicelib/devices/bsim3soi_dd/b3soiddinit.c @@ -70,7 +70,14 @@ SPICEdev B3SOIDDinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &B3SOIDDiSize, - /* DEVmodSize */ &B3SOIDDmSize + /* DEVmodSize */ &B3SOIDDmSize, + +#ifdef KLU + /* DEVbindCSC */ B3SOIDDbindCSC, + /* DEVbindCSCComplex */ B3SOIDDbindCSCComplex, + /* DEVbindCSCComplexToReal */ B3SOIDDbindCSCComplexToReal, +#endif + }; SPICEdev * diff --git a/src/spicelib/devices/bsim3soi_fd/Makefile.am b/src/spicelib/devices/bsim3soi_fd/Makefile.am index aac0e863a..dad13649e 100644 --- a/src/spicelib/devices/bsim3soi_fd/Makefile.am +++ b/src/spicelib/devices/bsim3soi_fd/Makefile.am @@ -28,6 +28,9 @@ libbsim3soifd_la_SOURCES = \ b3soifditf.h +if KLU_WANTED +libbsim3soifd_la_SOURCES += b3soifdbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim3soi_fd/b3soifdbindCSC.c b/src/spicelib/devices/bsim3soi_fd/b3soifdbindCSC.c new file mode 100644 index 000000000..dcdb964da --- /dev/null +++ b/src/spicelib/devices/bsim3soi_fd/b3soifdbindCSC.c @@ -0,0 +1,1320 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "b3soifddef.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +B3SOIFDbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + B3SOIFDmodel *model = (B3SOIFDmodel *)inModel ; + B3SOIFDinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the B3SOIFD models */ + for ( ; model != NULL ; model = model->B3SOIFDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->B3SOIFDinstances ; here != NULL ; here = here->B3SOIFDnextInstance) + { + if ((model->B3SOIFDshMod == 1) && (here->B3SOIFDrth0!=0.0)) + { + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDtempNode != 0)) + { + i = here->B3SOIFDTemptempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDTemptempStructPtr = matched ; + here->B3SOIFDTemptempPtr = matched->CSC ; + } + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + { + i = here->B3SOIFDTempdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDTempdpStructPtr = matched ; + here->B3SOIFDTempdpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + { + i = here->B3SOIFDTempspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDTempspStructPtr = matched ; + here->B3SOIFDTempspPtr = matched->CSC ; + } + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDgNode != 0)) + { + i = here->B3SOIFDTempgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDTempgStructPtr = matched ; + here->B3SOIFDTempgPtr = matched->CSC ; + } + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDbNode != 0)) + { + i = here->B3SOIFDTempbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDTempbStructPtr = matched ; + here->B3SOIFDTempbPtr = matched->CSC ; + } + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDeNode != 0)) + { + i = here->B3SOIFDTempePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDTempeStructPtr = matched ; + here->B3SOIFDTempePtr = matched->CSC ; + } + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDtempNode != 0)) + { + i = here->B3SOIFDGtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDGtempStructPtr = matched ; + here->B3SOIFDGtempPtr = matched->CSC ; + } + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDtempNode != 0)) + { + i = here->B3SOIFDDPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDPtempStructPtr = matched ; + here->B3SOIFDDPtempPtr = matched->CSC ; + } + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDtempNode != 0)) + { + i = here->B3SOIFDSPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDSPtempStructPtr = matched ; + here->B3SOIFDSPtempPtr = matched->CSC ; + } + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDtempNode != 0)) + { + i = here->B3SOIFDEtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDEtempStructPtr = matched ; + here->B3SOIFDEtempPtr = matched->CSC ; + } + + if ((here-> B3SOIFDbNode != 0) && (here-> B3SOIFDtempNode != 0)) + { + i = here->B3SOIFDBtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDBtempStructPtr = matched ; + here->B3SOIFDBtempPtr = matched->CSC ; + } + + if (here->B3SOIFDbodyMod == 1) + { + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDtempNode != 0)) + { + i = here->B3SOIFDPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDPtempStructPtr = matched ; + here->B3SOIFDPtempPtr = matched->CSC ; + } + + } + } + if (here->B3SOIFDbodyMod == 2) + { + } + else if (here->B3SOIFDbodyMod == 1) + { + if ((here-> B3SOIFDbNode != 0) && (here-> B3SOIFDpNode != 0)) + { + i = here->B3SOIFDBpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDBpStructPtr = matched ; + here->B3SOIFDBpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDbNode != 0)) + { + i = here->B3SOIFDPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDPbStructPtr = matched ; + here->B3SOIFDPbPtr = matched->CSC ; + } + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDpNode != 0)) + { + i = here->B3SOIFDPpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDPpStructPtr = matched ; + here->B3SOIFDPpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDgNode != 0)) + { + i = here->B3SOIFDPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDPgStructPtr = matched ; + here->B3SOIFDPgPtr = matched->CSC ; + } + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + { + i = here->B3SOIFDPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDPdpStructPtr = matched ; + here->B3SOIFDPdpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + { + i = here->B3SOIFDPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDPspStructPtr = matched ; + here->B3SOIFDPspPtr = matched->CSC ; + } + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDeNode != 0)) + { + i = here->B3SOIFDPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDPeStructPtr = matched ; + here->B3SOIFDPePtr = matched->CSC ; + } + + } + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDgNode != 0)) + { + i = here->B3SOIFDEgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDEgStructPtr = matched ; + here->B3SOIFDEgPtr = matched->CSC ; + } + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + { + i = here->B3SOIFDEdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDEdpStructPtr = matched ; + here->B3SOIFDEdpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + { + i = here->B3SOIFDEspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDEspStructPtr = matched ; + here->B3SOIFDEspPtr = matched->CSC ; + } + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDeNode != 0)) + { + i = here->B3SOIFDGePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDGeStructPtr = matched ; + here->B3SOIFDGePtr = matched->CSC ; + } + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDeNode != 0)) + { + i = here->B3SOIFDDPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDPeStructPtr = matched ; + here->B3SOIFDDPePtr = matched->CSC ; + } + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDeNode != 0)) + { + i = here->B3SOIFDSPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDSPeStructPtr = matched ; + here->B3SOIFDSPePtr = matched->CSC ; + } + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDbNode != 0)) + { + i = here->B3SOIFDEbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDEbStructPtr = matched ; + here->B3SOIFDEbPtr = matched->CSC ; + } + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDeNode != 0)) + { + i = here->B3SOIFDEePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDEeStructPtr = matched ; + here->B3SOIFDEePtr = matched->CSC ; + } + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDgNode != 0)) + { + i = here->B3SOIFDGgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDGgStructPtr = matched ; + here->B3SOIFDGgPtr = matched->CSC ; + } + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + { + i = here->B3SOIFDGdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDGdpStructPtr = matched ; + here->B3SOIFDGdpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + { + i = here->B3SOIFDGspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDGspStructPtr = matched ; + here->B3SOIFDGspPtr = matched->CSC ; + } + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDgNode != 0)) + { + i = here->B3SOIFDDPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDPgStructPtr = matched ; + here->B3SOIFDDPgPtr = matched->CSC ; + } + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDdNodePrime != 0)) + { + i = here->B3SOIFDDPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDPdpStructPtr = matched ; + here->B3SOIFDDPdpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDsNodePrime != 0)) + { + i = here->B3SOIFDDPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDPspStructPtr = matched ; + here->B3SOIFDDPspPtr = matched->CSC ; + } + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDdNode != 0)) + { + i = here->B3SOIFDDPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDPdStructPtr = matched ; + here->B3SOIFDDPdPtr = matched->CSC ; + } + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDgNode != 0)) + { + i = here->B3SOIFDSPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDSPgStructPtr = matched ; + here->B3SOIFDSPgPtr = matched->CSC ; + } + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDdNodePrime != 0)) + { + i = here->B3SOIFDSPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDSPdpStructPtr = matched ; + here->B3SOIFDSPdpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDsNodePrime != 0)) + { + i = here->B3SOIFDSPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDSPspStructPtr = matched ; + here->B3SOIFDSPspPtr = matched->CSC ; + } + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDsNode != 0)) + { + i = here->B3SOIFDSPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDSPsStructPtr = matched ; + here->B3SOIFDSPsPtr = matched->CSC ; + } + + if ((here-> B3SOIFDdNode != 0) && (here-> B3SOIFDdNode != 0)) + { + i = here->B3SOIFDDdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDdStructPtr = matched ; + here->B3SOIFDDdPtr = matched->CSC ; + } + + if ((here-> B3SOIFDdNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + { + i = here->B3SOIFDDdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDdpStructPtr = matched ; + here->B3SOIFDDdpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDsNode != 0) && (here-> B3SOIFDsNode != 0)) + { + i = here->B3SOIFDSsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDSsStructPtr = matched ; + here->B3SOIFDSsPtr = matched->CSC ; + } + + if ((here-> B3SOIFDsNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + { + i = here->B3SOIFDSspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDSspStructPtr = matched ; + here->B3SOIFDSspPtr = matched->CSC ; + } + + if ((here->B3SOIFDdebugMod > 1) || (here->B3SOIFDdebugMod == -1)) + { + if ((here-> B3SOIFDvbsNode != 0) && (here-> B3SOIFDvbsNode != 0)) + { + i = here->B3SOIFDVbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDVbsStructPtr = matched ; + here->B3SOIFDVbsPtr = matched->CSC ; + } + + if ((here-> B3SOIFDidsNode != 0) && (here-> B3SOIFDidsNode != 0)) + { + i = here->B3SOIFDIdsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDIdsStructPtr = matched ; + here->B3SOIFDIdsPtr = matched->CSC ; + } + + if ((here-> B3SOIFDicNode != 0) && (here-> B3SOIFDicNode != 0)) + { + i = here->B3SOIFDIcPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDIcStructPtr = matched ; + here->B3SOIFDIcPtr = matched->CSC ; + } + + if ((here-> B3SOIFDibsNode != 0) && (here-> B3SOIFDibsNode != 0)) + { + i = here->B3SOIFDIbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDIbsStructPtr = matched ; + here->B3SOIFDIbsPtr = matched->CSC ; + } + + if ((here-> B3SOIFDibdNode != 0) && (here-> B3SOIFDibdNode != 0)) + { + i = here->B3SOIFDIbdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDIbdStructPtr = matched ; + here->B3SOIFDIbdPtr = matched->CSC ; + } + + if ((here-> B3SOIFDiiiNode != 0) && (here-> B3SOIFDiiiNode != 0)) + { + i = here->B3SOIFDIiiPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDIiiStructPtr = matched ; + here->B3SOIFDIiiPtr = matched->CSC ; + } + + if ((here-> B3SOIFDigidlNode != 0) && (here-> B3SOIFDigidlNode != 0)) + { + i = here->B3SOIFDIgidlPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDIgidlStructPtr = matched ; + here->B3SOIFDIgidlPtr = matched->CSC ; + } + + if ((here-> B3SOIFDitunNode != 0) && (here-> B3SOIFDitunNode != 0)) + { + i = here->B3SOIFDItunPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDItunStructPtr = matched ; + here->B3SOIFDItunPtr = matched->CSC ; + } + + if ((here-> B3SOIFDibpNode != 0) && (here-> B3SOIFDibpNode != 0)) + { + i = here->B3SOIFDIbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDIbpStructPtr = matched ; + here->B3SOIFDIbpPtr = matched->CSC ; + } + + if ((here-> B3SOIFDabeffNode != 0) && (here-> B3SOIFDabeffNode != 0)) + { + i = here->B3SOIFDAbeffPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDAbeffStructPtr = matched ; + here->B3SOIFDAbeffPtr = matched->CSC ; + } + + if ((here-> B3SOIFDvbs0effNode != 0) && (here-> B3SOIFDvbs0effNode != 0)) + { + i = here->B3SOIFDVbs0effPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDVbs0effStructPtr = matched ; + here->B3SOIFDVbs0effPtr = matched->CSC ; + } + + if ((here-> B3SOIFDvbseffNode != 0) && (here-> B3SOIFDvbseffNode != 0)) + { + i = here->B3SOIFDVbseffPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDVbseffStructPtr = matched ; + here->B3SOIFDVbseffPtr = matched->CSC ; + } + + if ((here-> B3SOIFDxcNode != 0) && (here-> B3SOIFDxcNode != 0)) + { + i = here->B3SOIFDXcPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDXcStructPtr = matched ; + here->B3SOIFDXcPtr = matched->CSC ; + } + + if ((here-> B3SOIFDcbbNode != 0) && (here-> B3SOIFDcbbNode != 0)) + { + i = here->B3SOIFDCbbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDCbbStructPtr = matched ; + here->B3SOIFDCbbPtr = matched->CSC ; + } + + if ((here-> B3SOIFDcbdNode != 0) && (here-> B3SOIFDcbdNode != 0)) + { + i = here->B3SOIFDCbdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDCbdStructPtr = matched ; + here->B3SOIFDCbdPtr = matched->CSC ; + } + + if ((here-> B3SOIFDcbgNode != 0) && (here-> B3SOIFDcbgNode != 0)) + { + i = here->B3SOIFDCbgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDCbgStructPtr = matched ; + here->B3SOIFDCbgPtr = matched->CSC ; + } + + if ((here-> B3SOIFDqbNode != 0) && (here-> B3SOIFDqbNode != 0)) + { + i = here->B3SOIFDqbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDqbStructPtr = matched ; + here->B3SOIFDqbPtr = matched->CSC ; + } + + if ((here-> B3SOIFDqbfNode != 0) && (here-> B3SOIFDqbfNode != 0)) + { + i = here->B3SOIFDQbfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDQbfStructPtr = matched ; + here->B3SOIFDQbfPtr = matched->CSC ; + } + + if ((here-> B3SOIFDqjsNode != 0) && (here-> B3SOIFDqjsNode != 0)) + { + i = here->B3SOIFDQjsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDQjsStructPtr = matched ; + here->B3SOIFDQjsPtr = matched->CSC ; + } + + if ((here-> B3SOIFDqjdNode != 0) && (here-> B3SOIFDqjdNode != 0)) + { + i = here->B3SOIFDQjdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDQjdStructPtr = matched ; + here->B3SOIFDQjdPtr = matched->CSC ; + } + + if ((here-> B3SOIFDgmNode != 0) && (here-> B3SOIFDgmNode != 0)) + { + i = here->B3SOIFDGmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDGmStructPtr = matched ; + here->B3SOIFDGmPtr = matched->CSC ; + } + + if ((here-> B3SOIFDgmbsNode != 0) && (here-> B3SOIFDgmbsNode != 0)) + { + i = here->B3SOIFDGmbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDGmbsStructPtr = matched ; + here->B3SOIFDGmbsPtr = matched->CSC ; + } + + if ((here-> B3SOIFDgdsNode != 0) && (here-> B3SOIFDgdsNode != 0)) + { + i = here->B3SOIFDGdsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDGdsStructPtr = matched ; + here->B3SOIFDGdsPtr = matched->CSC ; + } + + if ((here-> B3SOIFDgmeNode != 0) && (here-> B3SOIFDgmeNode != 0)) + { + i = here->B3SOIFDGmePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDGmeStructPtr = matched ; + here->B3SOIFDGmePtr = matched->CSC ; + } + + if ((here-> B3SOIFDvbs0teffNode != 0) && (here-> B3SOIFDvbs0teffNode != 0)) + { + i = here->B3SOIFDVbs0teffPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDVbs0teffStructPtr = matched ; + here->B3SOIFDVbs0teffPtr = matched->CSC ; + } + + if ((here-> B3SOIFDvthNode != 0) && (here-> B3SOIFDvthNode != 0)) + { + i = here->B3SOIFDVthPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDVthStructPtr = matched ; + here->B3SOIFDVthPtr = matched->CSC ; + } + + if ((here-> B3SOIFDvgsteffNode != 0) && (here-> B3SOIFDvgsteffNode != 0)) + { + i = here->B3SOIFDVgsteffPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDVgsteffStructPtr = matched ; + here->B3SOIFDVgsteffPtr = matched->CSC ; + } + + if ((here-> B3SOIFDxcsatNode != 0) && (here-> B3SOIFDxcsatNode != 0)) + { + i = here->B3SOIFDXcsatPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDXcsatStructPtr = matched ; + here->B3SOIFDXcsatPtr = matched->CSC ; + } + + if ((here-> B3SOIFDvcscvNode != 0) && (here-> B3SOIFDvcscvNode != 0)) + { + i = here->B3SOIFDVcscvPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDVcscvStructPtr = matched ; + here->B3SOIFDVcscvPtr = matched->CSC ; + } + + if ((here-> B3SOIFDvdscvNode != 0) && (here-> B3SOIFDvdscvNode != 0)) + { + i = here->B3SOIFDVdscvPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDVdscvStructPtr = matched ; + here->B3SOIFDVdscvPtr = matched->CSC ; + } + + if ((here-> B3SOIFDcbeNode != 0) && (here-> B3SOIFDcbeNode != 0)) + { + i = here->B3SOIFDCbePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDCbeStructPtr = matched ; + here->B3SOIFDCbePtr = matched->CSC ; + } + + if ((here-> B3SOIFDdum1Node != 0) && (here-> B3SOIFDdum1Node != 0)) + { + i = here->B3SOIFDDum1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDum1StructPtr = matched ; + here->B3SOIFDDum1Ptr = matched->CSC ; + } + + if ((here-> B3SOIFDdum2Node != 0) && (here-> B3SOIFDdum2Node != 0)) + { + i = here->B3SOIFDDum2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDum2StructPtr = matched ; + here->B3SOIFDDum2Ptr = matched->CSC ; + } + + if ((here-> B3SOIFDdum3Node != 0) && (here-> B3SOIFDdum3Node != 0)) + { + i = here->B3SOIFDDum3Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDum3StructPtr = matched ; + here->B3SOIFDDum3Ptr = matched->CSC ; + } + + if ((here-> B3SOIFDdum4Node != 0) && (here-> B3SOIFDdum4Node != 0)) + { + i = here->B3SOIFDDum4Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDum4StructPtr = matched ; + here->B3SOIFDDum4Ptr = matched->CSC ; + } + + if ((here-> B3SOIFDdum5Node != 0) && (here-> B3SOIFDdum5Node != 0)) + { + i = here->B3SOIFDDum5Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDDum5StructPtr = matched ; + here->B3SOIFDDum5Ptr = matched->CSC ; + } + + if ((here-> B3SOIFDqaccNode != 0) && (here-> B3SOIFDqaccNode != 0)) + { + i = here->B3SOIFDQaccPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDQaccStructPtr = matched ; + here->B3SOIFDQaccPtr = matched->CSC ; + } + + if ((here-> B3SOIFDqsub0Node != 0) && (here-> B3SOIFDqsub0Node != 0)) + { + i = here->B3SOIFDQsub0Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDQsub0StructPtr = matched ; + here->B3SOIFDQsub0Ptr = matched->CSC ; + } + + if ((here-> B3SOIFDqsubs1Node != 0) && (here-> B3SOIFDqsubs1Node != 0)) + { + i = here->B3SOIFDQsubs1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDQsubs1StructPtr = matched ; + here->B3SOIFDQsubs1Ptr = matched->CSC ; + } + + if ((here-> B3SOIFDqsubs2Node != 0) && (here-> B3SOIFDqsubs2Node != 0)) + { + i = here->B3SOIFDQsubs2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDQsubs2StructPtr = matched ; + here->B3SOIFDQsubs2Ptr = matched->CSC ; + } + + if ((here-> B3SOIFDqeNode != 0) && (here-> B3SOIFDqeNode != 0)) + { + i = here->B3SOIFDqePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDqeStructPtr = matched ; + here->B3SOIFDqePtr = matched->CSC ; + } + + if ((here-> B3SOIFDqdNode != 0) && (here-> B3SOIFDqdNode != 0)) + { + i = here->B3SOIFDqdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDqdStructPtr = matched ; + here->B3SOIFDqdPtr = matched->CSC ; + } + + if ((here-> B3SOIFDqgNode != 0) && (here-> B3SOIFDqgNode != 0)) + { + i = here->B3SOIFDqgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIFDqgStructPtr = matched ; + here->B3SOIFDqgPtr = matched->CSC ; + } + + } + } + } + + return (OK) ; +} + +int +B3SOIFDbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + B3SOIFDmodel *model = (B3SOIFDmodel *)inModel ; + B3SOIFDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B3SOIFD models */ + for ( ; model != NULL ; model = model->B3SOIFDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->B3SOIFDinstances ; here != NULL ; here = here->B3SOIFDnextInstance) + { + if ((model->B3SOIFDshMod == 1) && (here->B3SOIFDrth0!=0.0)) + { + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDTemptempPtr = here->B3SOIFDTemptempStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDTempdpPtr = here->B3SOIFDTempdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDTempspPtr = here->B3SOIFDTempspStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDTempgPtr = here->B3SOIFDTempgStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDbNode != 0)) + here->B3SOIFDTempbPtr = here->B3SOIFDTempbStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDTempePtr = here->B3SOIFDTempeStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDGtempPtr = here->B3SOIFDGtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDDPtempPtr = here->B3SOIFDDPtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDSPtempPtr = here->B3SOIFDSPtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDEtempPtr = here->B3SOIFDEtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDbNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDBtempPtr = here->B3SOIFDBtempStructPtr->CSC_Complex ; + + if (here->B3SOIFDbodyMod == 1) + { + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDPtempPtr = here->B3SOIFDPtempStructPtr->CSC_Complex ; + + } + } + if (here->B3SOIFDbodyMod == 2) + { + } + else if (here->B3SOIFDbodyMod == 1) + { + if ((here-> B3SOIFDbNode != 0) && (here-> B3SOIFDpNode != 0)) + here->B3SOIFDBpPtr = here->B3SOIFDBpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDbNode != 0)) + here->B3SOIFDPbPtr = here->B3SOIFDPbStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDpNode != 0)) + here->B3SOIFDPpPtr = here->B3SOIFDPpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDPgPtr = here->B3SOIFDPgStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDPdpPtr = here->B3SOIFDPdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDPspPtr = here->B3SOIFDPspStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDPePtr = here->B3SOIFDPeStructPtr->CSC_Complex ; + + } + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDEgPtr = here->B3SOIFDEgStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDEdpPtr = here->B3SOIFDEdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDEspPtr = here->B3SOIFDEspStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDGePtr = here->B3SOIFDGeStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDDPePtr = here->B3SOIFDDPeStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDSPePtr = here->B3SOIFDSPeStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDbNode != 0)) + here->B3SOIFDEbPtr = here->B3SOIFDEbStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDEePtr = here->B3SOIFDEeStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDGgPtr = here->B3SOIFDGgStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDGdpPtr = here->B3SOIFDGdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDGspPtr = here->B3SOIFDGspStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDDPgPtr = here->B3SOIFDDPgStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDDPdpPtr = here->B3SOIFDDPdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDDPspPtr = here->B3SOIFDDPspStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDdNode != 0)) + here->B3SOIFDDPdPtr = here->B3SOIFDDPdStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDSPgPtr = here->B3SOIFDSPgStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDSPdpPtr = here->B3SOIFDSPdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDSPspPtr = here->B3SOIFDSPspStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDsNode != 0)) + here->B3SOIFDSPsPtr = here->B3SOIFDSPsStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdNode != 0) && (here-> B3SOIFDdNode != 0)) + here->B3SOIFDDdPtr = here->B3SOIFDDdStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDDdpPtr = here->B3SOIFDDdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDsNode != 0) && (here-> B3SOIFDsNode != 0)) + here->B3SOIFDSsPtr = here->B3SOIFDSsStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDsNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDSspPtr = here->B3SOIFDSspStructPtr->CSC_Complex ; + + if ((here->B3SOIFDdebugMod > 1) || (here->B3SOIFDdebugMod == -1)) + { + if ((here-> B3SOIFDvbsNode != 0) && (here-> B3SOIFDvbsNode != 0)) + here->B3SOIFDVbsPtr = here->B3SOIFDVbsStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDidsNode != 0) && (here-> B3SOIFDidsNode != 0)) + here->B3SOIFDIdsPtr = here->B3SOIFDIdsStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDicNode != 0) && (here-> B3SOIFDicNode != 0)) + here->B3SOIFDIcPtr = here->B3SOIFDIcStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDibsNode != 0) && (here-> B3SOIFDibsNode != 0)) + here->B3SOIFDIbsPtr = here->B3SOIFDIbsStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDibdNode != 0) && (here-> B3SOIFDibdNode != 0)) + here->B3SOIFDIbdPtr = here->B3SOIFDIbdStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDiiiNode != 0) && (here-> B3SOIFDiiiNode != 0)) + here->B3SOIFDIiiPtr = here->B3SOIFDIiiStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDigidlNode != 0) && (here-> B3SOIFDigidlNode != 0)) + here->B3SOIFDIgidlPtr = here->B3SOIFDIgidlStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDitunNode != 0) && (here-> B3SOIFDitunNode != 0)) + here->B3SOIFDItunPtr = here->B3SOIFDItunStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDibpNode != 0) && (here-> B3SOIFDibpNode != 0)) + here->B3SOIFDIbpPtr = here->B3SOIFDIbpStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDabeffNode != 0) && (here-> B3SOIFDabeffNode != 0)) + here->B3SOIFDAbeffPtr = here->B3SOIFDAbeffStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDvbs0effNode != 0) && (here-> B3SOIFDvbs0effNode != 0)) + here->B3SOIFDVbs0effPtr = here->B3SOIFDVbs0effStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDvbseffNode != 0) && (here-> B3SOIFDvbseffNode != 0)) + here->B3SOIFDVbseffPtr = here->B3SOIFDVbseffStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDxcNode != 0) && (here-> B3SOIFDxcNode != 0)) + here->B3SOIFDXcPtr = here->B3SOIFDXcStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDcbbNode != 0) && (here-> B3SOIFDcbbNode != 0)) + here->B3SOIFDCbbPtr = here->B3SOIFDCbbStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDcbdNode != 0) && (here-> B3SOIFDcbdNode != 0)) + here->B3SOIFDCbdPtr = here->B3SOIFDCbdStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDcbgNode != 0) && (here-> B3SOIFDcbgNode != 0)) + here->B3SOIFDCbgPtr = here->B3SOIFDCbgStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqbNode != 0) && (here-> B3SOIFDqbNode != 0)) + here->B3SOIFDqbPtr = here->B3SOIFDqbStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqbfNode != 0) && (here-> B3SOIFDqbfNode != 0)) + here->B3SOIFDQbfPtr = here->B3SOIFDQbfStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqjsNode != 0) && (here-> B3SOIFDqjsNode != 0)) + here->B3SOIFDQjsPtr = here->B3SOIFDQjsStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqjdNode != 0) && (here-> B3SOIFDqjdNode != 0)) + here->B3SOIFDQjdPtr = here->B3SOIFDQjdStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDgmNode != 0) && (here-> B3SOIFDgmNode != 0)) + here->B3SOIFDGmPtr = here->B3SOIFDGmStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDgmbsNode != 0) && (here-> B3SOIFDgmbsNode != 0)) + here->B3SOIFDGmbsPtr = here->B3SOIFDGmbsStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDgdsNode != 0) && (here-> B3SOIFDgdsNode != 0)) + here->B3SOIFDGdsPtr = here->B3SOIFDGdsStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDgmeNode != 0) && (here-> B3SOIFDgmeNode != 0)) + here->B3SOIFDGmePtr = here->B3SOIFDGmeStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDvbs0teffNode != 0) && (here-> B3SOIFDvbs0teffNode != 0)) + here->B3SOIFDVbs0teffPtr = here->B3SOIFDVbs0teffStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDvthNode != 0) && (here-> B3SOIFDvthNode != 0)) + here->B3SOIFDVthPtr = here->B3SOIFDVthStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDvgsteffNode != 0) && (here-> B3SOIFDvgsteffNode != 0)) + here->B3SOIFDVgsteffPtr = here->B3SOIFDVgsteffStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDxcsatNode != 0) && (here-> B3SOIFDxcsatNode != 0)) + here->B3SOIFDXcsatPtr = here->B3SOIFDXcsatStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDvcscvNode != 0) && (here-> B3SOIFDvcscvNode != 0)) + here->B3SOIFDVcscvPtr = here->B3SOIFDVcscvStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDvdscvNode != 0) && (here-> B3SOIFDvdscvNode != 0)) + here->B3SOIFDVdscvPtr = here->B3SOIFDVdscvStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDcbeNode != 0) && (here-> B3SOIFDcbeNode != 0)) + here->B3SOIFDCbePtr = here->B3SOIFDCbeStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdum1Node != 0) && (here-> B3SOIFDdum1Node != 0)) + here->B3SOIFDDum1Ptr = here->B3SOIFDDum1StructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdum2Node != 0) && (here-> B3SOIFDdum2Node != 0)) + here->B3SOIFDDum2Ptr = here->B3SOIFDDum2StructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdum3Node != 0) && (here-> B3SOIFDdum3Node != 0)) + here->B3SOIFDDum3Ptr = here->B3SOIFDDum3StructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdum4Node != 0) && (here-> B3SOIFDdum4Node != 0)) + here->B3SOIFDDum4Ptr = here->B3SOIFDDum4StructPtr->CSC_Complex ; + + if ((here-> B3SOIFDdum5Node != 0) && (here-> B3SOIFDdum5Node != 0)) + here->B3SOIFDDum5Ptr = here->B3SOIFDDum5StructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqaccNode != 0) && (here-> B3SOIFDqaccNode != 0)) + here->B3SOIFDQaccPtr = here->B3SOIFDQaccStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqsub0Node != 0) && (here-> B3SOIFDqsub0Node != 0)) + here->B3SOIFDQsub0Ptr = here->B3SOIFDQsub0StructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqsubs1Node != 0) && (here-> B3SOIFDqsubs1Node != 0)) + here->B3SOIFDQsubs1Ptr = here->B3SOIFDQsubs1StructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqsubs2Node != 0) && (here-> B3SOIFDqsubs2Node != 0)) + here->B3SOIFDQsubs2Ptr = here->B3SOIFDQsubs2StructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqeNode != 0) && (here-> B3SOIFDqeNode != 0)) + here->B3SOIFDqePtr = here->B3SOIFDqeStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqdNode != 0) && (here-> B3SOIFDqdNode != 0)) + here->B3SOIFDqdPtr = here->B3SOIFDqdStructPtr->CSC_Complex ; + + if ((here-> B3SOIFDqgNode != 0) && (here-> B3SOIFDqgNode != 0)) + here->B3SOIFDqgPtr = here->B3SOIFDqgStructPtr->CSC_Complex ; + + } + } + } + + return (OK) ; +} + +int +B3SOIFDbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + B3SOIFDmodel *model = (B3SOIFDmodel *)inModel ; + B3SOIFDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B3SOIFD models */ + for ( ; model != NULL ; model = model->B3SOIFDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->B3SOIFDinstances ; here != NULL ; here = here->B3SOIFDnextInstance) + { + if ((model->B3SOIFDshMod == 1) && (here->B3SOIFDrth0!=0.0)) + { + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDTemptempPtr = here->B3SOIFDTemptempStructPtr->CSC ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDTempdpPtr = here->B3SOIFDTempdpStructPtr->CSC ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDTempspPtr = here->B3SOIFDTempspStructPtr->CSC ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDTempgPtr = here->B3SOIFDTempgStructPtr->CSC ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDbNode != 0)) + here->B3SOIFDTempbPtr = here->B3SOIFDTempbStructPtr->CSC ; + + if ((here-> B3SOIFDtempNode != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDTempePtr = here->B3SOIFDTempeStructPtr->CSC ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDGtempPtr = here->B3SOIFDGtempStructPtr->CSC ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDDPtempPtr = here->B3SOIFDDPtempStructPtr->CSC ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDSPtempPtr = here->B3SOIFDSPtempStructPtr->CSC ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDEtempPtr = here->B3SOIFDEtempStructPtr->CSC ; + + if ((here-> B3SOIFDbNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDBtempPtr = here->B3SOIFDBtempStructPtr->CSC ; + + if (here->B3SOIFDbodyMod == 1) + { + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDtempNode != 0)) + here->B3SOIFDPtempPtr = here->B3SOIFDPtempStructPtr->CSC ; + + } + } + if (here->B3SOIFDbodyMod == 2) + { + } + else if (here->B3SOIFDbodyMod == 1) + { + if ((here-> B3SOIFDbNode != 0) && (here-> B3SOIFDpNode != 0)) + here->B3SOIFDBpPtr = here->B3SOIFDBpStructPtr->CSC ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDbNode != 0)) + here->B3SOIFDPbPtr = here->B3SOIFDPbStructPtr->CSC ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDpNode != 0)) + here->B3SOIFDPpPtr = here->B3SOIFDPpStructPtr->CSC ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDPgPtr = here->B3SOIFDPgStructPtr->CSC ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDPdpPtr = here->B3SOIFDPdpStructPtr->CSC ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDPspPtr = here->B3SOIFDPspStructPtr->CSC ; + + if ((here-> B3SOIFDpNode != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDPePtr = here->B3SOIFDPeStructPtr->CSC ; + + } + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDEgPtr = here->B3SOIFDEgStructPtr->CSC ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDEdpPtr = here->B3SOIFDEdpStructPtr->CSC ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDEspPtr = here->B3SOIFDEspStructPtr->CSC ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDGePtr = here->B3SOIFDGeStructPtr->CSC ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDDPePtr = here->B3SOIFDDPeStructPtr->CSC ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDSPePtr = here->B3SOIFDSPeStructPtr->CSC ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDbNode != 0)) + here->B3SOIFDEbPtr = here->B3SOIFDEbStructPtr->CSC ; + + if ((here-> B3SOIFDeNode != 0) && (here-> B3SOIFDeNode != 0)) + here->B3SOIFDEePtr = here->B3SOIFDEeStructPtr->CSC ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDGgPtr = here->B3SOIFDGgStructPtr->CSC ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDGdpPtr = here->B3SOIFDGdpStructPtr->CSC ; + + if ((here-> B3SOIFDgNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDGspPtr = here->B3SOIFDGspStructPtr->CSC ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDDPgPtr = here->B3SOIFDDPgStructPtr->CSC ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDDPdpPtr = here->B3SOIFDDPdpStructPtr->CSC ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDDPspPtr = here->B3SOIFDDPspStructPtr->CSC ; + + if ((here-> B3SOIFDdNodePrime != 0) && (here-> B3SOIFDdNode != 0)) + here->B3SOIFDDPdPtr = here->B3SOIFDDPdStructPtr->CSC ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDgNode != 0)) + here->B3SOIFDSPgPtr = here->B3SOIFDSPgStructPtr->CSC ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDSPdpPtr = here->B3SOIFDSPdpStructPtr->CSC ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDSPspPtr = here->B3SOIFDSPspStructPtr->CSC ; + + if ((here-> B3SOIFDsNodePrime != 0) && (here-> B3SOIFDsNode != 0)) + here->B3SOIFDSPsPtr = here->B3SOIFDSPsStructPtr->CSC ; + + if ((here-> B3SOIFDdNode != 0) && (here-> B3SOIFDdNode != 0)) + here->B3SOIFDDdPtr = here->B3SOIFDDdStructPtr->CSC ; + + if ((here-> B3SOIFDdNode != 0) && (here-> B3SOIFDdNodePrime != 0)) + here->B3SOIFDDdpPtr = here->B3SOIFDDdpStructPtr->CSC ; + + if ((here-> B3SOIFDsNode != 0) && (here-> B3SOIFDsNode != 0)) + here->B3SOIFDSsPtr = here->B3SOIFDSsStructPtr->CSC ; + + if ((here-> B3SOIFDsNode != 0) && (here-> B3SOIFDsNodePrime != 0)) + here->B3SOIFDSspPtr = here->B3SOIFDSspStructPtr->CSC ; + + if ((here->B3SOIFDdebugMod > 1) || (here->B3SOIFDdebugMod == -1)) + { + if ((here-> B3SOIFDvbsNode != 0) && (here-> B3SOIFDvbsNode != 0)) + here->B3SOIFDVbsPtr = here->B3SOIFDVbsStructPtr->CSC ; + + if ((here-> B3SOIFDidsNode != 0) && (here-> B3SOIFDidsNode != 0)) + here->B3SOIFDIdsPtr = here->B3SOIFDIdsStructPtr->CSC ; + + if ((here-> B3SOIFDicNode != 0) && (here-> B3SOIFDicNode != 0)) + here->B3SOIFDIcPtr = here->B3SOIFDIcStructPtr->CSC ; + + if ((here-> B3SOIFDibsNode != 0) && (here-> B3SOIFDibsNode != 0)) + here->B3SOIFDIbsPtr = here->B3SOIFDIbsStructPtr->CSC ; + + if ((here-> B3SOIFDibdNode != 0) && (here-> B3SOIFDibdNode != 0)) + here->B3SOIFDIbdPtr = here->B3SOIFDIbdStructPtr->CSC ; + + if ((here-> B3SOIFDiiiNode != 0) && (here-> B3SOIFDiiiNode != 0)) + here->B3SOIFDIiiPtr = here->B3SOIFDIiiStructPtr->CSC ; + + if ((here-> B3SOIFDigidlNode != 0) && (here-> B3SOIFDigidlNode != 0)) + here->B3SOIFDIgidlPtr = here->B3SOIFDIgidlStructPtr->CSC ; + + if ((here-> B3SOIFDitunNode != 0) && (here-> B3SOIFDitunNode != 0)) + here->B3SOIFDItunPtr = here->B3SOIFDItunStructPtr->CSC ; + + if ((here-> B3SOIFDibpNode != 0) && (here-> B3SOIFDibpNode != 0)) + here->B3SOIFDIbpPtr = here->B3SOIFDIbpStructPtr->CSC ; + + if ((here-> B3SOIFDabeffNode != 0) && (here-> B3SOIFDabeffNode != 0)) + here->B3SOIFDAbeffPtr = here->B3SOIFDAbeffStructPtr->CSC ; + + if ((here-> B3SOIFDvbs0effNode != 0) && (here-> B3SOIFDvbs0effNode != 0)) + here->B3SOIFDVbs0effPtr = here->B3SOIFDVbs0effStructPtr->CSC ; + + if ((here-> B3SOIFDvbseffNode != 0) && (here-> B3SOIFDvbseffNode != 0)) + here->B3SOIFDVbseffPtr = here->B3SOIFDVbseffStructPtr->CSC ; + + if ((here-> B3SOIFDxcNode != 0) && (here-> B3SOIFDxcNode != 0)) + here->B3SOIFDXcPtr = here->B3SOIFDXcStructPtr->CSC ; + + if ((here-> B3SOIFDcbbNode != 0) && (here-> B3SOIFDcbbNode != 0)) + here->B3SOIFDCbbPtr = here->B3SOIFDCbbStructPtr->CSC ; + + if ((here-> B3SOIFDcbdNode != 0) && (here-> B3SOIFDcbdNode != 0)) + here->B3SOIFDCbdPtr = here->B3SOIFDCbdStructPtr->CSC ; + + if ((here-> B3SOIFDcbgNode != 0) && (here-> B3SOIFDcbgNode != 0)) + here->B3SOIFDCbgPtr = here->B3SOIFDCbgStructPtr->CSC ; + + if ((here-> B3SOIFDqbNode != 0) && (here-> B3SOIFDqbNode != 0)) + here->B3SOIFDqbPtr = here->B3SOIFDqbStructPtr->CSC ; + + if ((here-> B3SOIFDqbfNode != 0) && (here-> B3SOIFDqbfNode != 0)) + here->B3SOIFDQbfPtr = here->B3SOIFDQbfStructPtr->CSC ; + + if ((here-> B3SOIFDqjsNode != 0) && (here-> B3SOIFDqjsNode != 0)) + here->B3SOIFDQjsPtr = here->B3SOIFDQjsStructPtr->CSC ; + + if ((here-> B3SOIFDqjdNode != 0) && (here-> B3SOIFDqjdNode != 0)) + here->B3SOIFDQjdPtr = here->B3SOIFDQjdStructPtr->CSC ; + + if ((here-> B3SOIFDgmNode != 0) && (here-> B3SOIFDgmNode != 0)) + here->B3SOIFDGmPtr = here->B3SOIFDGmStructPtr->CSC ; + + if ((here-> B3SOIFDgmbsNode != 0) && (here-> B3SOIFDgmbsNode != 0)) + here->B3SOIFDGmbsPtr = here->B3SOIFDGmbsStructPtr->CSC ; + + if ((here-> B3SOIFDgdsNode != 0) && (here-> B3SOIFDgdsNode != 0)) + here->B3SOIFDGdsPtr = here->B3SOIFDGdsStructPtr->CSC ; + + if ((here-> B3SOIFDgmeNode != 0) && (here-> B3SOIFDgmeNode != 0)) + here->B3SOIFDGmePtr = here->B3SOIFDGmeStructPtr->CSC ; + + if ((here-> B3SOIFDvbs0teffNode != 0) && (here-> B3SOIFDvbs0teffNode != 0)) + here->B3SOIFDVbs0teffPtr = here->B3SOIFDVbs0teffStructPtr->CSC ; + + if ((here-> B3SOIFDvthNode != 0) && (here-> B3SOIFDvthNode != 0)) + here->B3SOIFDVthPtr = here->B3SOIFDVthStructPtr->CSC ; + + if ((here-> B3SOIFDvgsteffNode != 0) && (here-> B3SOIFDvgsteffNode != 0)) + here->B3SOIFDVgsteffPtr = here->B3SOIFDVgsteffStructPtr->CSC ; + + if ((here-> B3SOIFDxcsatNode != 0) && (here-> B3SOIFDxcsatNode != 0)) + here->B3SOIFDXcsatPtr = here->B3SOIFDXcsatStructPtr->CSC ; + + if ((here-> B3SOIFDvcscvNode != 0) && (here-> B3SOIFDvcscvNode != 0)) + here->B3SOIFDVcscvPtr = here->B3SOIFDVcscvStructPtr->CSC ; + + if ((here-> B3SOIFDvdscvNode != 0) && (here-> B3SOIFDvdscvNode != 0)) + here->B3SOIFDVdscvPtr = here->B3SOIFDVdscvStructPtr->CSC ; + + if ((here-> B3SOIFDcbeNode != 0) && (here-> B3SOIFDcbeNode != 0)) + here->B3SOIFDCbePtr = here->B3SOIFDCbeStructPtr->CSC ; + + if ((here-> B3SOIFDdum1Node != 0) && (here-> B3SOIFDdum1Node != 0)) + here->B3SOIFDDum1Ptr = here->B3SOIFDDum1StructPtr->CSC ; + + if ((here-> B3SOIFDdum2Node != 0) && (here-> B3SOIFDdum2Node != 0)) + here->B3SOIFDDum2Ptr = here->B3SOIFDDum2StructPtr->CSC ; + + if ((here-> B3SOIFDdum3Node != 0) && (here-> B3SOIFDdum3Node != 0)) + here->B3SOIFDDum3Ptr = here->B3SOIFDDum3StructPtr->CSC ; + + if ((here-> B3SOIFDdum4Node != 0) && (here-> B3SOIFDdum4Node != 0)) + here->B3SOIFDDum4Ptr = here->B3SOIFDDum4StructPtr->CSC ; + + if ((here-> B3SOIFDdum5Node != 0) && (here-> B3SOIFDdum5Node != 0)) + here->B3SOIFDDum5Ptr = here->B3SOIFDDum5StructPtr->CSC ; + + if ((here-> B3SOIFDqaccNode != 0) && (here-> B3SOIFDqaccNode != 0)) + here->B3SOIFDQaccPtr = here->B3SOIFDQaccStructPtr->CSC ; + + if ((here-> B3SOIFDqsub0Node != 0) && (here-> B3SOIFDqsub0Node != 0)) + here->B3SOIFDQsub0Ptr = here->B3SOIFDQsub0StructPtr->CSC ; + + if ((here-> B3SOIFDqsubs1Node != 0) && (here-> B3SOIFDqsubs1Node != 0)) + here->B3SOIFDQsubs1Ptr = here->B3SOIFDQsubs1StructPtr->CSC ; + + if ((here-> B3SOIFDqsubs2Node != 0) && (here-> B3SOIFDqsubs2Node != 0)) + here->B3SOIFDQsubs2Ptr = here->B3SOIFDQsubs2StructPtr->CSC ; + + if ((here-> B3SOIFDqeNode != 0) && (here-> B3SOIFDqeNode != 0)) + here->B3SOIFDqePtr = here->B3SOIFDqeStructPtr->CSC ; + + if ((here-> B3SOIFDqdNode != 0) && (here-> B3SOIFDqdNode != 0)) + here->B3SOIFDqdPtr = here->B3SOIFDqdStructPtr->CSC ; + + if ((here-> B3SOIFDqgNode != 0) && (here-> B3SOIFDqgNode != 0)) + here->B3SOIFDqgPtr = here->B3SOIFDqgStructPtr->CSC ; + + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim3soi_fd/b3soifddef.h b/src/spicelib/devices/bsim3soi_fd/b3soifddef.h index f3c0a1007..2efc2b723 100644 --- a/src/spicelib/devices/bsim3soi_fd/b3soifddef.h +++ b/src/spicelib/devices/bsim3soi_fd/b3soifddef.h @@ -414,6 +414,94 @@ typedef struct sB3SOIFDinstance double **B3SOIFDnVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *B3SOIFDTemptempStructPtr ; + BindElement *B3SOIFDTempdpStructPtr ; + BindElement *B3SOIFDTempspStructPtr ; + BindElement *B3SOIFDTempgStructPtr ; + BindElement *B3SOIFDTempbStructPtr ; + BindElement *B3SOIFDTempeStructPtr ; + BindElement *B3SOIFDGtempStructPtr ; + BindElement *B3SOIFDDPtempStructPtr ; + BindElement *B3SOIFDSPtempStructPtr ; + BindElement *B3SOIFDEtempStructPtr ; + BindElement *B3SOIFDBtempStructPtr ; + BindElement *B3SOIFDPtempStructPtr ; + BindElement *B3SOIFDBpStructPtr ; + BindElement *B3SOIFDPbStructPtr ; + BindElement *B3SOIFDPpStructPtr ; + BindElement *B3SOIFDPgStructPtr ; + BindElement *B3SOIFDPdpStructPtr ; + BindElement *B3SOIFDPspStructPtr ; + BindElement *B3SOIFDPeStructPtr ; + BindElement *B3SOIFDEgStructPtr ; + BindElement *B3SOIFDEdpStructPtr ; + BindElement *B3SOIFDEspStructPtr ; + BindElement *B3SOIFDGeStructPtr ; + BindElement *B3SOIFDDPeStructPtr ; + BindElement *B3SOIFDSPeStructPtr ; + BindElement *B3SOIFDEbStructPtr ; + BindElement *B3SOIFDEeStructPtr ; + BindElement *B3SOIFDGgStructPtr ; + BindElement *B3SOIFDGdpStructPtr ; + BindElement *B3SOIFDGspStructPtr ; + BindElement *B3SOIFDDPgStructPtr ; + BindElement *B3SOIFDDPdpStructPtr ; + BindElement *B3SOIFDDPspStructPtr ; + BindElement *B3SOIFDDPdStructPtr ; + BindElement *B3SOIFDSPgStructPtr ; + BindElement *B3SOIFDSPdpStructPtr ; + BindElement *B3SOIFDSPspStructPtr ; + BindElement *B3SOIFDSPsStructPtr ; + BindElement *B3SOIFDDdStructPtr ; + BindElement *B3SOIFDDdpStructPtr ; + BindElement *B3SOIFDSsStructPtr ; + BindElement *B3SOIFDSspStructPtr ; + BindElement *B3SOIFDVbsStructPtr ; + BindElement *B3SOIFDIdsStructPtr ; + BindElement *B3SOIFDIcStructPtr ; + BindElement *B3SOIFDIbsStructPtr ; + BindElement *B3SOIFDIbdStructPtr ; + BindElement *B3SOIFDIiiStructPtr ; + BindElement *B3SOIFDIgidlStructPtr ; + BindElement *B3SOIFDItunStructPtr ; + BindElement *B3SOIFDIbpStructPtr ; + BindElement *B3SOIFDAbeffStructPtr ; + BindElement *B3SOIFDVbs0effStructPtr ; + BindElement *B3SOIFDVbseffStructPtr ; + BindElement *B3SOIFDXcStructPtr ; + BindElement *B3SOIFDCbbStructPtr ; + BindElement *B3SOIFDCbdStructPtr ; + BindElement *B3SOIFDCbgStructPtr ; + BindElement *B3SOIFDqbStructPtr ; + BindElement *B3SOIFDQbfStructPtr ; + BindElement *B3SOIFDQjsStructPtr ; + BindElement *B3SOIFDQjdStructPtr ; + BindElement *B3SOIFDGmStructPtr ; + BindElement *B3SOIFDGmbsStructPtr ; + BindElement *B3SOIFDGdsStructPtr ; + BindElement *B3SOIFDGmeStructPtr ; + BindElement *B3SOIFDVbs0teffStructPtr ; + BindElement *B3SOIFDVthStructPtr ; + BindElement *B3SOIFDVgsteffStructPtr ; + BindElement *B3SOIFDXcsatStructPtr ; + BindElement *B3SOIFDVcscvStructPtr ; + BindElement *B3SOIFDVdscvStructPtr ; + BindElement *B3SOIFDCbeStructPtr ; + BindElement *B3SOIFDDum1StructPtr ; + BindElement *B3SOIFDDum2StructPtr ; + BindElement *B3SOIFDDum3StructPtr ; + BindElement *B3SOIFDDum4StructPtr ; + BindElement *B3SOIFDDum5StructPtr ; + BindElement *B3SOIFDQaccStructPtr ; + BindElement *B3SOIFDQsub0StructPtr ; + BindElement *B3SOIFDQsubs1StructPtr ; + BindElement *B3SOIFDQsubs2StructPtr ; + BindElement *B3SOIFDqeStructPtr ; + BindElement *B3SOIFDqdStructPtr ; + BindElement *B3SOIFDqgStructPtr ; +#endif + } B3SOIFDinstance ; struct b3soifdSizeDependParam diff --git a/src/spicelib/devices/bsim3soi_fd/b3soifdext.h b/src/spicelib/devices/bsim3soi_fd/b3soifdext.h index 1c6ed33dd..6f2b0fded 100644 --- a/src/spicelib/devices/bsim3soi_fd/b3soifdext.h +++ b/src/spicelib/devices/bsim3soi_fd/b3soifdext.h @@ -29,3 +29,8 @@ extern int B3SOIFDtrunc(GENmodel*,CKTcircuit*,double*); extern int B3SOIFDnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int B3SOIFDunsetup(GENmodel*,CKTcircuit*); +#ifdef KLU +extern int B3SOIFDbindCSC (GENmodel*, CKTcircuit*) ; +extern int B3SOIFDbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int B3SOIFDbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim3soi_fd/b3soifdinit.c b/src/spicelib/devices/bsim3soi_fd/b3soifdinit.c index d5213e623..9ba3af873 100644 --- a/src/spicelib/devices/bsim3soi_fd/b3soifdinit.c +++ b/src/spicelib/devices/bsim3soi_fd/b3soifdinit.c @@ -71,7 +71,14 @@ SPICEdev B3SOIFDinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize*/ &B3SOIFDiSize, - /* DEVmodSize*/ &B3SOIFDmSize + /* DEVmodSize*/ &B3SOIFDmSize, + +#ifdef KLU + /* DEVbindCSC */ B3SOIFDbindCSC, + /* DEVbindCSCComplex */ B3SOIFDbindCSCComplex, + /* DEVbindCSCComplexToReal */ B3SOIFDbindCSCComplexToReal, +#endif + }; diff --git a/src/spicelib/devices/bsim3soi_pd/Makefile.am b/src/spicelib/devices/bsim3soi_pd/Makefile.am index f363b1d0e..5c426c521 100644 --- a/src/spicelib/devices/bsim3soi_pd/Makefile.am +++ b/src/spicelib/devices/bsim3soi_pd/Makefile.am @@ -28,6 +28,9 @@ libbsim3soipd_la_SOURCES = \ b3soipditf.h +if KLU_WANTED +libbsim3soipd_la_SOURCES += b3soipdbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim3soi_pd/b3soipdbindCSC.c b/src/spicelib/devices/bsim3soi_pd/b3soipdbindCSC.c new file mode 100644 index 000000000..4c728375f --- /dev/null +++ b/src/spicelib/devices/bsim3soi_pd/b3soipdbindCSC.c @@ -0,0 +1,1026 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "b3soipddef.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +B3SOIPDbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + B3SOIPDmodel *model = (B3SOIPDmodel *)inModel ; + B3SOIPDinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the B3SOIPD models */ + for ( ; model != NULL ; model = model->B3SOIPDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->B3SOIPDinstances ; here != NULL ; here = here->B3SOIPDnextInstance) + { + if ((model->B3SOIPDshMod == 1) && (here->B3SOIPDrth0!=0.0)) + { + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDtempNode != 0)) + { + i = here->B3SOIPDTemptempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDTemptempStructPtr = matched ; + here->B3SOIPDTemptempPtr = matched->CSC ; + } + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + { + i = here->B3SOIPDTempdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDTempdpStructPtr = matched ; + here->B3SOIPDTempdpPtr = matched->CSC ; + } + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + { + i = here->B3SOIPDTempspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDTempspStructPtr = matched ; + here->B3SOIPDTempspPtr = matched->CSC ; + } + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDgNode != 0)) + { + i = here->B3SOIPDTempgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDTempgStructPtr = matched ; + here->B3SOIPDTempgPtr = matched->CSC ; + } + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDbNode != 0)) + { + i = here->B3SOIPDTempbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDTempbStructPtr = matched ; + here->B3SOIPDTempbPtr = matched->CSC ; + } + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDtempNode != 0)) + { + i = here->B3SOIPDGtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDGtempStructPtr = matched ; + here->B3SOIPDGtempPtr = matched->CSC ; + } + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDtempNode != 0)) + { + i = here->B3SOIPDDPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDDPtempStructPtr = matched ; + here->B3SOIPDDPtempPtr = matched->CSC ; + } + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDtempNode != 0)) + { + i = here->B3SOIPDSPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDSPtempStructPtr = matched ; + here->B3SOIPDSPtempPtr = matched->CSC ; + } + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDtempNode != 0)) + { + i = here->B3SOIPDEtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDEtempStructPtr = matched ; + here->B3SOIPDEtempPtr = matched->CSC ; + } + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDtempNode != 0)) + { + i = here->B3SOIPDBtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDBtempStructPtr = matched ; + here->B3SOIPDBtempPtr = matched->CSC ; + } + + if (here->B3SOIPDbodyMod == 1) + { + if ((here-> B3SOIPDpNode != 0) && (here-> B3SOIPDtempNode != 0)) + { + i = here->B3SOIPDPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDPtempStructPtr = matched ; + here->B3SOIPDPtempPtr = matched->CSC ; + } + + } + } + if (here->B3SOIPDbodyMod == 2) + { + } + else if (here->B3SOIPDbodyMod == 1) + { + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDpNode != 0)) + { + i = here->B3SOIPDBpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDBpStructPtr = matched ; + here->B3SOIPDBpPtr = matched->CSC ; + } + + if ((here-> B3SOIPDpNode != 0) && (here-> B3SOIPDbNode != 0)) + { + i = here->B3SOIPDPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDPbStructPtr = matched ; + here->B3SOIPDPbPtr = matched->CSC ; + } + + if ((here-> B3SOIPDpNode != 0) && (here-> B3SOIPDpNode != 0)) + { + i = here->B3SOIPDPpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDPpStructPtr = matched ; + here->B3SOIPDPpPtr = matched->CSC ; + } + + } + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDbNode != 0)) + { + i = here->B3SOIPDEbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDEbStructPtr = matched ; + here->B3SOIPDEbPtr = matched->CSC ; + } + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDbNode != 0)) + { + i = here->B3SOIPDGbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDGbStructPtr = matched ; + here->B3SOIPDGbPtr = matched->CSC ; + } + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDbNode != 0)) + { + i = here->B3SOIPDDPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDDPbStructPtr = matched ; + here->B3SOIPDDPbPtr = matched->CSC ; + } + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDbNode != 0)) + { + i = here->B3SOIPDSPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDSPbStructPtr = matched ; + here->B3SOIPDSPbPtr = matched->CSC ; + } + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDeNode != 0)) + { + i = here->B3SOIPDBePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDBeStructPtr = matched ; + here->B3SOIPDBePtr = matched->CSC ; + } + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDgNode != 0)) + { + i = here->B3SOIPDBgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDBgStructPtr = matched ; + here->B3SOIPDBgPtr = matched->CSC ; + } + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + { + i = here->B3SOIPDBdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDBdpStructPtr = matched ; + here->B3SOIPDBdpPtr = matched->CSC ; + } + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + { + i = here->B3SOIPDBspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDBspStructPtr = matched ; + here->B3SOIPDBspPtr = matched->CSC ; + } + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDbNode != 0)) + { + i = here->B3SOIPDBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDBbStructPtr = matched ; + here->B3SOIPDBbPtr = matched->CSC ; + } + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDgNode != 0)) + { + i = here->B3SOIPDEgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDEgStructPtr = matched ; + here->B3SOIPDEgPtr = matched->CSC ; + } + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + { + i = here->B3SOIPDEdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDEdpStructPtr = matched ; + here->B3SOIPDEdpPtr = matched->CSC ; + } + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + { + i = here->B3SOIPDEspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDEspStructPtr = matched ; + here->B3SOIPDEspPtr = matched->CSC ; + } + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDeNode != 0)) + { + i = here->B3SOIPDGePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDGeStructPtr = matched ; + here->B3SOIPDGePtr = matched->CSC ; + } + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDeNode != 0)) + { + i = here->B3SOIPDDPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDDPeStructPtr = matched ; + here->B3SOIPDDPePtr = matched->CSC ; + } + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDeNode != 0)) + { + i = here->B3SOIPDSPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDSPeStructPtr = matched ; + here->B3SOIPDSPePtr = matched->CSC ; + } + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDeNode != 0)) + { + i = here->B3SOIPDEePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDEeStructPtr = matched ; + here->B3SOIPDEePtr = matched->CSC ; + } + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDgNode != 0)) + { + i = here->B3SOIPDGgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDGgStructPtr = matched ; + here->B3SOIPDGgPtr = matched->CSC ; + } + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + { + i = here->B3SOIPDGdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDGdpStructPtr = matched ; + here->B3SOIPDGdpPtr = matched->CSC ; + } + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + { + i = here->B3SOIPDGspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDGspStructPtr = matched ; + here->B3SOIPDGspPtr = matched->CSC ; + } + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDgNode != 0)) + { + i = here->B3SOIPDDPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDDPgStructPtr = matched ; + here->B3SOIPDDPgPtr = matched->CSC ; + } + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDdNodePrime != 0)) + { + i = here->B3SOIPDDPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDDPdpStructPtr = matched ; + here->B3SOIPDDPdpPtr = matched->CSC ; + } + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDsNodePrime != 0)) + { + i = here->B3SOIPDDPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDDPspStructPtr = matched ; + here->B3SOIPDDPspPtr = matched->CSC ; + } + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDdNode != 0)) + { + i = here->B3SOIPDDPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDDPdStructPtr = matched ; + here->B3SOIPDDPdPtr = matched->CSC ; + } + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDgNode != 0)) + { + i = here->B3SOIPDSPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDSPgStructPtr = matched ; + here->B3SOIPDSPgPtr = matched->CSC ; + } + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDdNodePrime != 0)) + { + i = here->B3SOIPDSPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDSPdpStructPtr = matched ; + here->B3SOIPDSPdpPtr = matched->CSC ; + } + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDsNodePrime != 0)) + { + i = here->B3SOIPDSPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDSPspStructPtr = matched ; + here->B3SOIPDSPspPtr = matched->CSC ; + } + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDsNode != 0)) + { + i = here->B3SOIPDSPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDSPsStructPtr = matched ; + here->B3SOIPDSPsPtr = matched->CSC ; + } + + if ((here-> B3SOIPDdNode != 0) && (here-> B3SOIPDdNode != 0)) + { + i = here->B3SOIPDDdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDDdStructPtr = matched ; + here->B3SOIPDDdPtr = matched->CSC ; + } + + if ((here-> B3SOIPDdNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + { + i = here->B3SOIPDDdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDDdpStructPtr = matched ; + here->B3SOIPDDdpPtr = matched->CSC ; + } + + if ((here-> B3SOIPDsNode != 0) && (here-> B3SOIPDsNode != 0)) + { + i = here->B3SOIPDSsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDSsStructPtr = matched ; + here->B3SOIPDSsPtr = matched->CSC ; + } + + if ((here-> B3SOIPDsNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + { + i = here->B3SOIPDSspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDSspStructPtr = matched ; + here->B3SOIPDSspPtr = matched->CSC ; + } + + if (here->B3SOIPDdebugMod != 0) + { + if ((here-> B3SOIPDvbsNode != 0) && (here-> B3SOIPDvbsNode != 0)) + { + i = here->B3SOIPDVbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDVbsStructPtr = matched ; + here->B3SOIPDVbsPtr = matched->CSC ; + } + + if ((here-> B3SOIPDidsNode != 0) && (here-> B3SOIPDidsNode != 0)) + { + i = here->B3SOIPDIdsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDIdsStructPtr = matched ; + here->B3SOIPDIdsPtr = matched->CSC ; + } + + if ((here-> B3SOIPDicNode != 0) && (here-> B3SOIPDicNode != 0)) + { + i = here->B3SOIPDIcPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDIcStructPtr = matched ; + here->B3SOIPDIcPtr = matched->CSC ; + } + + if ((here-> B3SOIPDibsNode != 0) && (here-> B3SOIPDibsNode != 0)) + { + i = here->B3SOIPDIbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDIbsStructPtr = matched ; + here->B3SOIPDIbsPtr = matched->CSC ; + } + + if ((here-> B3SOIPDibdNode != 0) && (here-> B3SOIPDibdNode != 0)) + { + i = here->B3SOIPDIbdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDIbdStructPtr = matched ; + here->B3SOIPDIbdPtr = matched->CSC ; + } + + if ((here-> B3SOIPDiiiNode != 0) && (here-> B3SOIPDiiiNode != 0)) + { + i = here->B3SOIPDIiiPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDIiiStructPtr = matched ; + here->B3SOIPDIiiPtr = matched->CSC ; + } + + if ((here-> B3SOIPDigNode != 0) && (here-> B3SOIPDigNode != 0)) + { + i = here->B3SOIPDIgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDIgStructPtr = matched ; + here->B3SOIPDIgPtr = matched->CSC ; + } + + if ((here-> B3SOIPDgiggNode != 0) && (here-> B3SOIPDgiggNode != 0)) + { + i = here->B3SOIPDGiggPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDGiggStructPtr = matched ; + here->B3SOIPDGiggPtr = matched->CSC ; + } + + if ((here-> B3SOIPDgigdNode != 0) && (here-> B3SOIPDgigdNode != 0)) + { + i = here->B3SOIPDGigdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDGigdStructPtr = matched ; + here->B3SOIPDGigdPtr = matched->CSC ; + } + + if ((here-> B3SOIPDgigbNode != 0) && (here-> B3SOIPDgigbNode != 0)) + { + i = here->B3SOIPDGigbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDGigbStructPtr = matched ; + here->B3SOIPDGigbPtr = matched->CSC ; + } + + if ((here-> B3SOIPDigidlNode != 0) && (here-> B3SOIPDigidlNode != 0)) + { + i = here->B3SOIPDIgidlPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDIgidlStructPtr = matched ; + here->B3SOIPDIgidlPtr = matched->CSC ; + } + + if ((here-> B3SOIPDitunNode != 0) && (here-> B3SOIPDitunNode != 0)) + { + i = here->B3SOIPDItunPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDItunStructPtr = matched ; + here->B3SOIPDItunPtr = matched->CSC ; + } + + if ((here-> B3SOIPDibpNode != 0) && (here-> B3SOIPDibpNode != 0)) + { + i = here->B3SOIPDIbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDIbpStructPtr = matched ; + here->B3SOIPDIbpPtr = matched->CSC ; + } + + if ((here-> B3SOIPDcbbNode != 0) && (here-> B3SOIPDcbbNode != 0)) + { + i = here->B3SOIPDCbbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDCbbStructPtr = matched ; + here->B3SOIPDCbbPtr = matched->CSC ; + } + + if ((here-> B3SOIPDcbdNode != 0) && (here-> B3SOIPDcbdNode != 0)) + { + i = here->B3SOIPDCbdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDCbdStructPtr = matched ; + here->B3SOIPDCbdPtr = matched->CSC ; + } + + if ((here-> B3SOIPDcbgNode != 0) && (here-> B3SOIPDcbgNode != 0)) + { + i = here->B3SOIPDCbgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDCbgStructPtr = matched ; + here->B3SOIPDCbgPtr = matched->CSC ; + } + + if ((here-> B3SOIPDqbfNode != 0) && (here-> B3SOIPDqbfNode != 0)) + { + i = here->B3SOIPDQbfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDQbfStructPtr = matched ; + here->B3SOIPDQbfPtr = matched->CSC ; + } + + if ((here-> B3SOIPDqjsNode != 0) && (here-> B3SOIPDqjsNode != 0)) + { + i = here->B3SOIPDQjsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDQjsStructPtr = matched ; + here->B3SOIPDQjsPtr = matched->CSC ; + } + + if ((here-> B3SOIPDqjdNode != 0) && (here-> B3SOIPDqjdNode != 0)) + { + i = here->B3SOIPDQjdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B3SOIPDQjdStructPtr = matched ; + here->B3SOIPDQjdPtr = matched->CSC ; + } + + } + } + } + + return (OK) ; +} + +int +B3SOIPDbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + B3SOIPDmodel *model = (B3SOIPDmodel *)inModel ; + B3SOIPDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B3SOIPD models */ + for ( ; model != NULL ; model = model->B3SOIPDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->B3SOIPDinstances ; here != NULL ; here = here->B3SOIPDnextInstance) + { + if ((model->B3SOIPDshMod == 1) && (here->B3SOIPDrth0!=0.0)) + { + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDTemptempPtr = here->B3SOIPDTemptempStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDTempdpPtr = here->B3SOIPDTempdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDTempspPtr = here->B3SOIPDTempspStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDTempgPtr = here->B3SOIPDTempgStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDTempbPtr = here->B3SOIPDTempbStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDGtempPtr = here->B3SOIPDGtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDDPtempPtr = here->B3SOIPDDPtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDSPtempPtr = here->B3SOIPDSPtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDEtempPtr = here->B3SOIPDEtempStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDBtempPtr = here->B3SOIPDBtempStructPtr->CSC_Complex ; + + if (here->B3SOIPDbodyMod == 1) + { + if ((here-> B3SOIPDpNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDPtempPtr = here->B3SOIPDPtempStructPtr->CSC_Complex ; + + } + } + if (here->B3SOIPDbodyMod == 2) + { + } + else if (here->B3SOIPDbodyMod == 1) + { + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDpNode != 0)) + here->B3SOIPDBpPtr = here->B3SOIPDBpStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDpNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDPbPtr = here->B3SOIPDPbStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDpNode != 0) && (here-> B3SOIPDpNode != 0)) + here->B3SOIPDPpPtr = here->B3SOIPDPpStructPtr->CSC_Complex ; + + } + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDEbPtr = here->B3SOIPDEbStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDGbPtr = here->B3SOIPDGbStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDDPbPtr = here->B3SOIPDDPbStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDSPbPtr = here->B3SOIPDSPbStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDBePtr = here->B3SOIPDBeStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDBgPtr = here->B3SOIPDBgStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDBdpPtr = here->B3SOIPDBdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDBspPtr = here->B3SOIPDBspStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDBbPtr = here->B3SOIPDBbStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDEgPtr = here->B3SOIPDEgStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDEdpPtr = here->B3SOIPDEdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDEspPtr = here->B3SOIPDEspStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDGePtr = here->B3SOIPDGeStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDDPePtr = here->B3SOIPDDPeStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDSPePtr = here->B3SOIPDSPeStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDEePtr = here->B3SOIPDEeStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDGgPtr = here->B3SOIPDGgStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDGdpPtr = here->B3SOIPDGdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDGspPtr = here->B3SOIPDGspStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDDPgPtr = here->B3SOIPDDPgStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDDPdpPtr = here->B3SOIPDDPdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDDPspPtr = here->B3SOIPDDPspStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDdNode != 0)) + here->B3SOIPDDPdPtr = here->B3SOIPDDPdStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDSPgPtr = here->B3SOIPDSPgStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDSPdpPtr = here->B3SOIPDSPdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDSPspPtr = here->B3SOIPDSPspStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDsNode != 0)) + here->B3SOIPDSPsPtr = here->B3SOIPDSPsStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDdNode != 0) && (here-> B3SOIPDdNode != 0)) + here->B3SOIPDDdPtr = here->B3SOIPDDdStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDdNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDDdpPtr = here->B3SOIPDDdpStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDsNode != 0) && (here-> B3SOIPDsNode != 0)) + here->B3SOIPDSsPtr = here->B3SOIPDSsStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDsNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDSspPtr = here->B3SOIPDSspStructPtr->CSC_Complex ; + + if (here->B3SOIPDdebugMod != 0) + { + if ((here-> B3SOIPDvbsNode != 0) && (here-> B3SOIPDvbsNode != 0)) + here->B3SOIPDVbsPtr = here->B3SOIPDVbsStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDidsNode != 0) && (here-> B3SOIPDidsNode != 0)) + here->B3SOIPDIdsPtr = here->B3SOIPDIdsStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDicNode != 0) && (here-> B3SOIPDicNode != 0)) + here->B3SOIPDIcPtr = here->B3SOIPDIcStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDibsNode != 0) && (here-> B3SOIPDibsNode != 0)) + here->B3SOIPDIbsPtr = here->B3SOIPDIbsStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDibdNode != 0) && (here-> B3SOIPDibdNode != 0)) + here->B3SOIPDIbdPtr = here->B3SOIPDIbdStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDiiiNode != 0) && (here-> B3SOIPDiiiNode != 0)) + here->B3SOIPDIiiPtr = here->B3SOIPDIiiStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDigNode != 0) && (here-> B3SOIPDigNode != 0)) + here->B3SOIPDIgPtr = here->B3SOIPDIgStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDgiggNode != 0) && (here-> B3SOIPDgiggNode != 0)) + here->B3SOIPDGiggPtr = here->B3SOIPDGiggStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDgigdNode != 0) && (here-> B3SOIPDgigdNode != 0)) + here->B3SOIPDGigdPtr = here->B3SOIPDGigdStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDgigbNode != 0) && (here-> B3SOIPDgigbNode != 0)) + here->B3SOIPDGigbPtr = here->B3SOIPDGigbStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDigidlNode != 0) && (here-> B3SOIPDigidlNode != 0)) + here->B3SOIPDIgidlPtr = here->B3SOIPDIgidlStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDitunNode != 0) && (here-> B3SOIPDitunNode != 0)) + here->B3SOIPDItunPtr = here->B3SOIPDItunStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDibpNode != 0) && (here-> B3SOIPDibpNode != 0)) + here->B3SOIPDIbpPtr = here->B3SOIPDIbpStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDcbbNode != 0) && (here-> B3SOIPDcbbNode != 0)) + here->B3SOIPDCbbPtr = here->B3SOIPDCbbStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDcbdNode != 0) && (here-> B3SOIPDcbdNode != 0)) + here->B3SOIPDCbdPtr = here->B3SOIPDCbdStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDcbgNode != 0) && (here-> B3SOIPDcbgNode != 0)) + here->B3SOIPDCbgPtr = here->B3SOIPDCbgStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDqbfNode != 0) && (here-> B3SOIPDqbfNode != 0)) + here->B3SOIPDQbfPtr = here->B3SOIPDQbfStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDqjsNode != 0) && (here-> B3SOIPDqjsNode != 0)) + here->B3SOIPDQjsPtr = here->B3SOIPDQjsStructPtr->CSC_Complex ; + + if ((here-> B3SOIPDqjdNode != 0) && (here-> B3SOIPDqjdNode != 0)) + here->B3SOIPDQjdPtr = here->B3SOIPDQjdStructPtr->CSC_Complex ; + + } + } + } + + return (OK) ; +} + +int +B3SOIPDbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + B3SOIPDmodel *model = (B3SOIPDmodel *)inModel ; + B3SOIPDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B3SOIPD models */ + for ( ; model != NULL ; model = model->B3SOIPDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->B3SOIPDinstances ; here != NULL ; here = here->B3SOIPDnextInstance) + { + if ((model->B3SOIPDshMod == 1) && (here->B3SOIPDrth0!=0.0)) + { + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDTemptempPtr = here->B3SOIPDTemptempStructPtr->CSC ; + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDTempdpPtr = here->B3SOIPDTempdpStructPtr->CSC ; + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDTempspPtr = here->B3SOIPDTempspStructPtr->CSC ; + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDTempgPtr = here->B3SOIPDTempgStructPtr->CSC ; + + if ((here-> B3SOIPDtempNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDTempbPtr = here->B3SOIPDTempbStructPtr->CSC ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDGtempPtr = here->B3SOIPDGtempStructPtr->CSC ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDDPtempPtr = here->B3SOIPDDPtempStructPtr->CSC ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDSPtempPtr = here->B3SOIPDSPtempStructPtr->CSC ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDEtempPtr = here->B3SOIPDEtempStructPtr->CSC ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDBtempPtr = here->B3SOIPDBtempStructPtr->CSC ; + + if (here->B3SOIPDbodyMod == 1) + { + if ((here-> B3SOIPDpNode != 0) && (here-> B3SOIPDtempNode != 0)) + here->B3SOIPDPtempPtr = here->B3SOIPDPtempStructPtr->CSC ; + + } + } + if (here->B3SOIPDbodyMod == 2) + { + } + else if (here->B3SOIPDbodyMod == 1) + { + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDpNode != 0)) + here->B3SOIPDBpPtr = here->B3SOIPDBpStructPtr->CSC ; + + if ((here-> B3SOIPDpNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDPbPtr = here->B3SOIPDPbStructPtr->CSC ; + + if ((here-> B3SOIPDpNode != 0) && (here-> B3SOIPDpNode != 0)) + here->B3SOIPDPpPtr = here->B3SOIPDPpStructPtr->CSC ; + + } + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDEbPtr = here->B3SOIPDEbStructPtr->CSC ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDGbPtr = here->B3SOIPDGbStructPtr->CSC ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDDPbPtr = here->B3SOIPDDPbStructPtr->CSC ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDSPbPtr = here->B3SOIPDSPbStructPtr->CSC ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDBePtr = here->B3SOIPDBeStructPtr->CSC ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDBgPtr = here->B3SOIPDBgStructPtr->CSC ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDBdpPtr = here->B3SOIPDBdpStructPtr->CSC ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDBspPtr = here->B3SOIPDBspStructPtr->CSC ; + + if ((here-> B3SOIPDbNode != 0) && (here-> B3SOIPDbNode != 0)) + here->B3SOIPDBbPtr = here->B3SOIPDBbStructPtr->CSC ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDEgPtr = here->B3SOIPDEgStructPtr->CSC ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDEdpPtr = here->B3SOIPDEdpStructPtr->CSC ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDEspPtr = here->B3SOIPDEspStructPtr->CSC ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDGePtr = here->B3SOIPDGeStructPtr->CSC ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDDPePtr = here->B3SOIPDDPeStructPtr->CSC ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDSPePtr = here->B3SOIPDSPeStructPtr->CSC ; + + if ((here-> B3SOIPDeNode != 0) && (here-> B3SOIPDeNode != 0)) + here->B3SOIPDEePtr = here->B3SOIPDEeStructPtr->CSC ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDGgPtr = here->B3SOIPDGgStructPtr->CSC ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDGdpPtr = here->B3SOIPDGdpStructPtr->CSC ; + + if ((here-> B3SOIPDgNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDGspPtr = here->B3SOIPDGspStructPtr->CSC ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDDPgPtr = here->B3SOIPDDPgStructPtr->CSC ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDDPdpPtr = here->B3SOIPDDPdpStructPtr->CSC ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDDPspPtr = here->B3SOIPDDPspStructPtr->CSC ; + + if ((here-> B3SOIPDdNodePrime != 0) && (here-> B3SOIPDdNode != 0)) + here->B3SOIPDDPdPtr = here->B3SOIPDDPdStructPtr->CSC ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDgNode != 0)) + here->B3SOIPDSPgPtr = here->B3SOIPDSPgStructPtr->CSC ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDSPdpPtr = here->B3SOIPDSPdpStructPtr->CSC ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDSPspPtr = here->B3SOIPDSPspStructPtr->CSC ; + + if ((here-> B3SOIPDsNodePrime != 0) && (here-> B3SOIPDsNode != 0)) + here->B3SOIPDSPsPtr = here->B3SOIPDSPsStructPtr->CSC ; + + if ((here-> B3SOIPDdNode != 0) && (here-> B3SOIPDdNode != 0)) + here->B3SOIPDDdPtr = here->B3SOIPDDdStructPtr->CSC ; + + if ((here-> B3SOIPDdNode != 0) && (here-> B3SOIPDdNodePrime != 0)) + here->B3SOIPDDdpPtr = here->B3SOIPDDdpStructPtr->CSC ; + + if ((here-> B3SOIPDsNode != 0) && (here-> B3SOIPDsNode != 0)) + here->B3SOIPDSsPtr = here->B3SOIPDSsStructPtr->CSC ; + + if ((here-> B3SOIPDsNode != 0) && (here-> B3SOIPDsNodePrime != 0)) + here->B3SOIPDSspPtr = here->B3SOIPDSspStructPtr->CSC ; + + if (here->B3SOIPDdebugMod != 0) + { + if ((here-> B3SOIPDvbsNode != 0) && (here-> B3SOIPDvbsNode != 0)) + here->B3SOIPDVbsPtr = here->B3SOIPDVbsStructPtr->CSC ; + + if ((here-> B3SOIPDidsNode != 0) && (here-> B3SOIPDidsNode != 0)) + here->B3SOIPDIdsPtr = here->B3SOIPDIdsStructPtr->CSC ; + + if ((here-> B3SOIPDicNode != 0) && (here-> B3SOIPDicNode != 0)) + here->B3SOIPDIcPtr = here->B3SOIPDIcStructPtr->CSC ; + + if ((here-> B3SOIPDibsNode != 0) && (here-> B3SOIPDibsNode != 0)) + here->B3SOIPDIbsPtr = here->B3SOIPDIbsStructPtr->CSC ; + + if ((here-> B3SOIPDibdNode != 0) && (here-> B3SOIPDibdNode != 0)) + here->B3SOIPDIbdPtr = here->B3SOIPDIbdStructPtr->CSC ; + + if ((here-> B3SOIPDiiiNode != 0) && (here-> B3SOIPDiiiNode != 0)) + here->B3SOIPDIiiPtr = here->B3SOIPDIiiStructPtr->CSC ; + + if ((here-> B3SOIPDigNode != 0) && (here-> B3SOIPDigNode != 0)) + here->B3SOIPDIgPtr = here->B3SOIPDIgStructPtr->CSC ; + + if ((here-> B3SOIPDgiggNode != 0) && (here-> B3SOIPDgiggNode != 0)) + here->B3SOIPDGiggPtr = here->B3SOIPDGiggStructPtr->CSC ; + + if ((here-> B3SOIPDgigdNode != 0) && (here-> B3SOIPDgigdNode != 0)) + here->B3SOIPDGigdPtr = here->B3SOIPDGigdStructPtr->CSC ; + + if ((here-> B3SOIPDgigbNode != 0) && (here-> B3SOIPDgigbNode != 0)) + here->B3SOIPDGigbPtr = here->B3SOIPDGigbStructPtr->CSC ; + + if ((here-> B3SOIPDigidlNode != 0) && (here-> B3SOIPDigidlNode != 0)) + here->B3SOIPDIgidlPtr = here->B3SOIPDIgidlStructPtr->CSC ; + + if ((here-> B3SOIPDitunNode != 0) && (here-> B3SOIPDitunNode != 0)) + here->B3SOIPDItunPtr = here->B3SOIPDItunStructPtr->CSC ; + + if ((here-> B3SOIPDibpNode != 0) && (here-> B3SOIPDibpNode != 0)) + here->B3SOIPDIbpPtr = here->B3SOIPDIbpStructPtr->CSC ; + + if ((here-> B3SOIPDcbbNode != 0) && (here-> B3SOIPDcbbNode != 0)) + here->B3SOIPDCbbPtr = here->B3SOIPDCbbStructPtr->CSC ; + + if ((here-> B3SOIPDcbdNode != 0) && (here-> B3SOIPDcbdNode != 0)) + here->B3SOIPDCbdPtr = here->B3SOIPDCbdStructPtr->CSC ; + + if ((here-> B3SOIPDcbgNode != 0) && (here-> B3SOIPDcbgNode != 0)) + here->B3SOIPDCbgPtr = here->B3SOIPDCbgStructPtr->CSC ; + + if ((here-> B3SOIPDqbfNode != 0) && (here-> B3SOIPDqbfNode != 0)) + here->B3SOIPDQbfPtr = here->B3SOIPDQbfStructPtr->CSC ; + + if ((here-> B3SOIPDqjsNode != 0) && (here-> B3SOIPDqjsNode != 0)) + here->B3SOIPDQjsPtr = here->B3SOIPDQjsStructPtr->CSC ; + + if ((here-> B3SOIPDqjdNode != 0) && (here-> B3SOIPDqjdNode != 0)) + here->B3SOIPDQjdPtr = here->B3SOIPDQjdStructPtr->CSC ; + + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim3soi_pd/b3soipddef.h b/src/spicelib/devices/bsim3soi_pd/b3soipddef.h index ceddbe2f8..3b46ba44f 100644 --- a/src/spicelib/devices/bsim3soi_pd/b3soipddef.h +++ b/src/spicelib/devices/bsim3soi_pd/b3soipddef.h @@ -379,6 +379,73 @@ typedef struct sB3SOIPDinstance double **B3SOIPDnVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *B3SOIPDTemptempStructPtr ; + BindElement *B3SOIPDTempdpStructPtr ; + BindElement *B3SOIPDTempspStructPtr ; + BindElement *B3SOIPDTempgStructPtr ; + BindElement *B3SOIPDTempbStructPtr ; + BindElement *B3SOIPDGtempStructPtr ; + BindElement *B3SOIPDDPtempStructPtr ; + BindElement *B3SOIPDSPtempStructPtr ; + BindElement *B3SOIPDEtempStructPtr ; + BindElement *B3SOIPDBtempStructPtr ; + BindElement *B3SOIPDPtempStructPtr ; + BindElement *B3SOIPDBpStructPtr ; + BindElement *B3SOIPDPbStructPtr ; + BindElement *B3SOIPDPpStructPtr ; + BindElement *B3SOIPDEbStructPtr ; + BindElement *B3SOIPDGbStructPtr ; + BindElement *B3SOIPDDPbStructPtr ; + BindElement *B3SOIPDSPbStructPtr ; + BindElement *B3SOIPDBeStructPtr ; + BindElement *B3SOIPDBgStructPtr ; + BindElement *B3SOIPDBdpStructPtr ; + BindElement *B3SOIPDBspStructPtr ; + BindElement *B3SOIPDBbStructPtr ; + BindElement *B3SOIPDEgStructPtr ; + BindElement *B3SOIPDEdpStructPtr ; + BindElement *B3SOIPDEspStructPtr ; + BindElement *B3SOIPDGeStructPtr ; + BindElement *B3SOIPDDPeStructPtr ; + BindElement *B3SOIPDSPeStructPtr ; + BindElement *B3SOIPDEeStructPtr ; + BindElement *B3SOIPDGgStructPtr ; + BindElement *B3SOIPDGdpStructPtr ; + BindElement *B3SOIPDGspStructPtr ; + BindElement *B3SOIPDDPgStructPtr ; + BindElement *B3SOIPDDPdpStructPtr ; + BindElement *B3SOIPDDPspStructPtr ; + BindElement *B3SOIPDDPdStructPtr ; + BindElement *B3SOIPDSPgStructPtr ; + BindElement *B3SOIPDSPdpStructPtr ; + BindElement *B3SOIPDSPspStructPtr ; + BindElement *B3SOIPDSPsStructPtr ; + BindElement *B3SOIPDDdStructPtr ; + BindElement *B3SOIPDDdpStructPtr ; + BindElement *B3SOIPDSsStructPtr ; + BindElement *B3SOIPDSspStructPtr ; + BindElement *B3SOIPDVbsStructPtr ; + BindElement *B3SOIPDIdsStructPtr ; + BindElement *B3SOIPDIcStructPtr ; + BindElement *B3SOIPDIbsStructPtr ; + BindElement *B3SOIPDIbdStructPtr ; + BindElement *B3SOIPDIiiStructPtr ; + BindElement *B3SOIPDIgStructPtr ; + BindElement *B3SOIPDGiggStructPtr ; + BindElement *B3SOIPDGigdStructPtr ; + BindElement *B3SOIPDGigbStructPtr ; + BindElement *B3SOIPDIgidlStructPtr ; + BindElement *B3SOIPDItunStructPtr ; + BindElement *B3SOIPDIbpStructPtr ; + BindElement *B3SOIPDCbbStructPtr ; + BindElement *B3SOIPDCbdStructPtr ; + BindElement *B3SOIPDCbgStructPtr ; + BindElement *B3SOIPDQbfStructPtr ; + BindElement *B3SOIPDQjsStructPtr ; + BindElement *B3SOIPDQjdStructPtr ; +#endif + } B3SOIPDinstance ; struct b3soipdSizeDependParam diff --git a/src/spicelib/devices/bsim3soi_pd/b3soipdext.h b/src/spicelib/devices/bsim3soi_pd/b3soipdext.h index ea2951794..e2f8629d9 100644 --- a/src/spicelib/devices/bsim3soi_pd/b3soipdext.h +++ b/src/spicelib/devices/bsim3soi_pd/b3soipdext.h @@ -28,3 +28,9 @@ extern int B3SOIPDtemp(GENmodel*,CKTcircuit*); extern int B3SOIPDtrunc(GENmodel*,CKTcircuit*,double*); extern int B3SOIPDnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int B3SOIPDunsetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int B3SOIPDbindCSC (GENmodel*, CKTcircuit*) ; +extern int B3SOIPDbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int B3SOIPDbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim3soi_pd/b3soipdinit.c b/src/spicelib/devices/bsim3soi_pd/b3soipdinit.c index 60c8a0033..f735d5f21 100644 --- a/src/spicelib/devices/bsim3soi_pd/b3soipdinit.c +++ b/src/spicelib/devices/bsim3soi_pd/b3soipdinit.c @@ -72,7 +72,14 @@ SPICEdev B3SOIPDinfo = { /* DEVacct*/ NULL, #endif /* DEVinstSize*/ &B3SOIPDiSize, - /* DEVmodSize*/ &B3SOIPDmSize + /* DEVmodSize*/ &B3SOIPDmSize, + +#ifdef KLU + /* DEVbindCSC */ B3SOIPDbindCSC, + /* DEVbindCSCComplex */ B3SOIPDbindCSCComplex, + /* DEVbindCSCComplexToReal */ B3SOIPDbindCSCComplexToReal, +#endif + }; SPICEdev * diff --git a/src/spicelib/devices/bsim3v0/Makefile.am b/src/spicelib/devices/bsim3v0/Makefile.am index 4db27a86d..8273566bf 100644 --- a/src/spicelib/devices/bsim3v0/Makefile.am +++ b/src/spicelib/devices/bsim3v0/Makefile.am @@ -27,6 +27,9 @@ libbsim3v0_la_SOURCES = \ bsim3v0itf.h +if KLU_WANTED +libbsim3v0_la_SOURCES += b3v0bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim3v0/b3v0bindCSC.c b/src/spicelib/devices/bsim3v0/b3v0bindCSC.c new file mode 100644 index 000000000..e422e3648 --- /dev/null +++ b/src/spicelib/devices/bsim3v0/b3v0bindCSC.c @@ -0,0 +1,519 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bsim3v0def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +BSIM3v0bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3v0model *model = (BSIM3v0model *)inModel ; + BSIM3v0instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the BSIM3v0 models */ + for ( ; model != NULL ; model = model->BSIM3v0nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3v0instances ; here != NULL ; here = here->BSIM3v0nextInstance) + { + if ((here-> BSIM3v0dNode != 0) && (here-> BSIM3v0dNode != 0)) + { + i = here->BSIM3v0DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0DdStructPtr = matched ; + here->BSIM3v0DdPtr = matched->CSC ; + } + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0gNode != 0)) + { + i = here->BSIM3v0GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0GgStructPtr = matched ; + here->BSIM3v0GgPtr = matched->CSC ; + } + + if ((here-> BSIM3v0sNode != 0) && (here-> BSIM3v0sNode != 0)) + { + i = here->BSIM3v0SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0SsStructPtr = matched ; + here->BSIM3v0SsPtr = matched->CSC ; + } + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0bNode != 0)) + { + i = here->BSIM3v0BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0BbStructPtr = matched ; + here->BSIM3v0BbPtr = matched->CSC ; + } + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0dNodePrime != 0)) + { + i = here->BSIM3v0DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0DPdpStructPtr = matched ; + here->BSIM3v0DPdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0sNodePrime != 0)) + { + i = here->BSIM3v0SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0SPspStructPtr = matched ; + here->BSIM3v0SPspPtr = matched->CSC ; + } + + if ((here-> BSIM3v0dNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + { + i = here->BSIM3v0DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0DdpStructPtr = matched ; + here->BSIM3v0DdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0bNode != 0)) + { + i = here->BSIM3v0GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0GbStructPtr = matched ; + here->BSIM3v0GbPtr = matched->CSC ; + } + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + { + i = here->BSIM3v0GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0GdpStructPtr = matched ; + here->BSIM3v0GdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + { + i = here->BSIM3v0GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0GspStructPtr = matched ; + here->BSIM3v0GspPtr = matched->CSC ; + } + + if ((here-> BSIM3v0sNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + { + i = here->BSIM3v0SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0SspStructPtr = matched ; + here->BSIM3v0SspPtr = matched->CSC ; + } + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + { + i = here->BSIM3v0BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0BdpStructPtr = matched ; + here->BSIM3v0BdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + { + i = here->BSIM3v0BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0BspStructPtr = matched ; + here->BSIM3v0BspPtr = matched->CSC ; + } + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0sNodePrime != 0)) + { + i = here->BSIM3v0DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0DPspStructPtr = matched ; + here->BSIM3v0DPspPtr = matched->CSC ; + } + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0dNode != 0)) + { + i = here->BSIM3v0DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0DPdStructPtr = matched ; + here->BSIM3v0DPdPtr = matched->CSC ; + } + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0gNode != 0)) + { + i = here->BSIM3v0BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0BgStructPtr = matched ; + here->BSIM3v0BgPtr = matched->CSC ; + } + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0gNode != 0)) + { + i = here->BSIM3v0DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0DPgStructPtr = matched ; + here->BSIM3v0DPgPtr = matched->CSC ; + } + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0gNode != 0)) + { + i = here->BSIM3v0SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0SPgStructPtr = matched ; + here->BSIM3v0SPgPtr = matched->CSC ; + } + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0sNode != 0)) + { + i = here->BSIM3v0SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0SPsStructPtr = matched ; + here->BSIM3v0SPsPtr = matched->CSC ; + } + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0bNode != 0)) + { + i = here->BSIM3v0DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0DPbStructPtr = matched ; + here->BSIM3v0DPbPtr = matched->CSC ; + } + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0bNode != 0)) + { + i = here->BSIM3v0SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0SPbStructPtr = matched ; + here->BSIM3v0SPbPtr = matched->CSC ; + } + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0dNodePrime != 0)) + { + i = here->BSIM3v0SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0SPdpStructPtr = matched ; + here->BSIM3v0SPdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0qNode != 0)) + { + i = here->BSIM3v0QqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0QqStructPtr = matched ; + here->BSIM3v0QqPtr = matched->CSC ; + } + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + { + i = here->BSIM3v0QdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0QdpStructPtr = matched ; + here->BSIM3v0QdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + { + i = here->BSIM3v0QspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0QspStructPtr = matched ; + here->BSIM3v0QspPtr = matched->CSC ; + } + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0gNode != 0)) + { + i = here->BSIM3v0QgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0QgStructPtr = matched ; + here->BSIM3v0QgPtr = matched->CSC ; + } + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0bNode != 0)) + { + i = here->BSIM3v0QbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0QbStructPtr = matched ; + here->BSIM3v0QbPtr = matched->CSC ; + } + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0qNode != 0)) + { + i = here->BSIM3v0DPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0DPqStructPtr = matched ; + here->BSIM3v0DPqPtr = matched->CSC ; + } + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0qNode != 0)) + { + i = here->BSIM3v0SPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0SPqStructPtr = matched ; + here->BSIM3v0SPqPtr = matched->CSC ; + } + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0qNode != 0)) + { + i = here->BSIM3v0GqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0GqStructPtr = matched ; + here->BSIM3v0GqPtr = matched->CSC ; + } + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0qNode != 0)) + { + i = here->BSIM3v0BqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v0BqStructPtr = matched ; + here->BSIM3v0BqPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +BSIM3v0bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3v0model *model = (BSIM3v0model *)inModel ; + BSIM3v0instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM3v0 models */ + for ( ; model != NULL ; model = model->BSIM3v0nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3v0instances ; here != NULL ; here = here->BSIM3v0nextInstance) + { + if ((here-> BSIM3v0dNode != 0) && (here-> BSIM3v0dNode != 0)) + here->BSIM3v0DdPtr = here->BSIM3v0DdStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0GgPtr = here->BSIM3v0GgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0sNode != 0) && (here-> BSIM3v0sNode != 0)) + here->BSIM3v0SsPtr = here->BSIM3v0SsStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0BbPtr = here->BSIM3v0BbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0DPdpPtr = here->BSIM3v0DPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0SPspPtr = here->BSIM3v0SPspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0dNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0DdpPtr = here->BSIM3v0DdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0GbPtr = here->BSIM3v0GbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0GdpPtr = here->BSIM3v0GdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0GspPtr = here->BSIM3v0GspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0sNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0SspPtr = here->BSIM3v0SspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0BdpPtr = here->BSIM3v0BdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0BspPtr = here->BSIM3v0BspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0DPspPtr = here->BSIM3v0DPspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0dNode != 0)) + here->BSIM3v0DPdPtr = here->BSIM3v0DPdStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0BgPtr = here->BSIM3v0BgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0DPgPtr = here->BSIM3v0DPgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0SPgPtr = here->BSIM3v0SPgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0sNode != 0)) + here->BSIM3v0SPsPtr = here->BSIM3v0SPsStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0DPbPtr = here->BSIM3v0DPbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0SPbPtr = here->BSIM3v0SPbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0SPdpPtr = here->BSIM3v0SPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0QqPtr = here->BSIM3v0QqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0QdpPtr = here->BSIM3v0QdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0QspPtr = here->BSIM3v0QspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0QgPtr = here->BSIM3v0QgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0QbPtr = here->BSIM3v0QbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0DPqPtr = here->BSIM3v0DPqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0SPqPtr = here->BSIM3v0SPqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0GqPtr = here->BSIM3v0GqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0BqPtr = here->BSIM3v0BqStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +BSIM3v0bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3v0model *model = (BSIM3v0model *)inModel ; + BSIM3v0instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM3v0 models */ + for ( ; model != NULL ; model = model->BSIM3v0nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3v0instances ; here != NULL ; here = here->BSIM3v0nextInstance) + { + if ((here-> BSIM3v0dNode != 0) && (here-> BSIM3v0dNode != 0)) + here->BSIM3v0DdPtr = here->BSIM3v0DdStructPtr->CSC ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0GgPtr = here->BSIM3v0GgStructPtr->CSC ; + + if ((here-> BSIM3v0sNode != 0) && (here-> BSIM3v0sNode != 0)) + here->BSIM3v0SsPtr = here->BSIM3v0SsStructPtr->CSC ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0BbPtr = here->BSIM3v0BbStructPtr->CSC ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0DPdpPtr = here->BSIM3v0DPdpStructPtr->CSC ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0SPspPtr = here->BSIM3v0SPspStructPtr->CSC ; + + if ((here-> BSIM3v0dNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0DdpPtr = here->BSIM3v0DdpStructPtr->CSC ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0GbPtr = here->BSIM3v0GbStructPtr->CSC ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0GdpPtr = here->BSIM3v0GdpStructPtr->CSC ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0GspPtr = here->BSIM3v0GspStructPtr->CSC ; + + if ((here-> BSIM3v0sNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0SspPtr = here->BSIM3v0SspStructPtr->CSC ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0BdpPtr = here->BSIM3v0BdpStructPtr->CSC ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0BspPtr = here->BSIM3v0BspStructPtr->CSC ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0DPspPtr = here->BSIM3v0DPspStructPtr->CSC ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0dNode != 0)) + here->BSIM3v0DPdPtr = here->BSIM3v0DPdStructPtr->CSC ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0BgPtr = here->BSIM3v0BgStructPtr->CSC ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0DPgPtr = here->BSIM3v0DPgStructPtr->CSC ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0SPgPtr = here->BSIM3v0SPgStructPtr->CSC ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0sNode != 0)) + here->BSIM3v0SPsPtr = here->BSIM3v0SPsStructPtr->CSC ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0DPbPtr = here->BSIM3v0DPbStructPtr->CSC ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0SPbPtr = here->BSIM3v0SPbStructPtr->CSC ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0SPdpPtr = here->BSIM3v0SPdpStructPtr->CSC ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0QqPtr = here->BSIM3v0QqStructPtr->CSC ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0dNodePrime != 0)) + here->BSIM3v0QdpPtr = here->BSIM3v0QdpStructPtr->CSC ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0sNodePrime != 0)) + here->BSIM3v0QspPtr = here->BSIM3v0QspStructPtr->CSC ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0gNode != 0)) + here->BSIM3v0QgPtr = here->BSIM3v0QgStructPtr->CSC ; + + if ((here-> BSIM3v0qNode != 0) && (here-> BSIM3v0bNode != 0)) + here->BSIM3v0QbPtr = here->BSIM3v0QbStructPtr->CSC ; + + if ((here-> BSIM3v0dNodePrime != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0DPqPtr = here->BSIM3v0DPqStructPtr->CSC ; + + if ((here-> BSIM3v0sNodePrime != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0SPqPtr = here->BSIM3v0SPqStructPtr->CSC ; + + if ((here-> BSIM3v0gNode != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0GqPtr = here->BSIM3v0GqStructPtr->CSC ; + + if ((here-> BSIM3v0bNode != 0) && (here-> BSIM3v0qNode != 0)) + here->BSIM3v0BqPtr = here->BSIM3v0BqStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim3v0/bsim3v0def.h b/src/spicelib/devices/bsim3v0/bsim3v0def.h index a72931e73..d776c787d 100644 --- a/src/spicelib/devices/bsim3v0/bsim3v0def.h +++ b/src/spicelib/devices/bsim3v0/bsim3v0def.h @@ -188,6 +188,40 @@ typedef struct sBSIM3v0instance double **BSIM3v0nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *BSIM3v0DdStructPtr ; + BindElement *BSIM3v0GgStructPtr ; + BindElement *BSIM3v0SsStructPtr ; + BindElement *BSIM3v0BbStructPtr ; + BindElement *BSIM3v0DPdpStructPtr ; + BindElement *BSIM3v0SPspStructPtr ; + BindElement *BSIM3v0DdpStructPtr ; + BindElement *BSIM3v0GbStructPtr ; + BindElement *BSIM3v0GdpStructPtr ; + BindElement *BSIM3v0GspStructPtr ; + BindElement *BSIM3v0SspStructPtr ; + BindElement *BSIM3v0BdpStructPtr ; + BindElement *BSIM3v0BspStructPtr ; + BindElement *BSIM3v0DPspStructPtr ; + BindElement *BSIM3v0DPdStructPtr ; + BindElement *BSIM3v0BgStructPtr ; + BindElement *BSIM3v0DPgStructPtr ; + BindElement *BSIM3v0SPgStructPtr ; + BindElement *BSIM3v0SPsStructPtr ; + BindElement *BSIM3v0DPbStructPtr ; + BindElement *BSIM3v0SPbStructPtr ; + BindElement *BSIM3v0SPdpStructPtr ; + BindElement *BSIM3v0QqStructPtr ; + BindElement *BSIM3v0QdpStructPtr ; + BindElement *BSIM3v0QspStructPtr ; + BindElement *BSIM3v0QgStructPtr ; + BindElement *BSIM3v0QbStructPtr ; + BindElement *BSIM3v0DPqStructPtr ; + BindElement *BSIM3v0SPqStructPtr ; + BindElement *BSIM3v0GqStructPtr ; + BindElement *BSIM3v0BqStructPtr ; +#endif + } BSIM3v0instance ; struct bsim3v0SizeDependParam diff --git a/src/spicelib/devices/bsim3v0/bsim3v0ext.h b/src/spicelib/devices/bsim3v0/bsim3v0ext.h index 02ad75173..b415e8364 100644 --- a/src/spicelib/devices/bsim3v0/bsim3v0ext.h +++ b/src/spicelib/devices/bsim3v0/bsim3v0ext.h @@ -28,3 +28,8 @@ extern int BSIM3v0trunc(GENmodel*,CKTcircuit*,double*); extern int BSIM3v0noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int BSIM3v0unsetup(GENmodel *, CKTcircuit *); +#ifdef KLU +extern int BSIM3v0bindCSC (GENmodel*, CKTcircuit*) ; +extern int BSIM3v0bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int BSIM3v0bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim3v0/bsim3v0init.c b/src/spicelib/devices/bsim3v0/bsim3v0init.c index 9eb299c49..cb5634a02 100644 --- a/src/spicelib/devices/bsim3v0/bsim3v0init.c +++ b/src/spicelib/devices/bsim3v0/bsim3v0init.c @@ -71,7 +71,13 @@ SPICEdev B3v0info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &BSIM3v0iSize, - /* DEVmodSize */ &BSIM3v0mSize + /* DEVmodSize */ &BSIM3v0mSize, + +#ifdef KLU + /* DEVbindCSC */ BSIM3v0bindCSC, + /* DEVbindCSCComplex */ BSIM3v0bindCSCComplex, + /* DEVbindCSCComplexToReal */ BSIM3v0bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/bsim3v1/Makefile.am b/src/spicelib/devices/bsim3v1/Makefile.am index 9ede60cb9..3b22e68ce 100644 --- a/src/spicelib/devices/bsim3v1/Makefile.am +++ b/src/spicelib/devices/bsim3v1/Makefile.am @@ -28,6 +28,9 @@ libbsim3v1_la_SOURCES = \ bsim3v1itf.h +if KLU_WANTED +libbsim3v1_la_SOURCES += b3v1bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim3v1/b3v1bindCSC.c b/src/spicelib/devices/bsim3v1/b3v1bindCSC.c new file mode 100644 index 000000000..4292a1ca9 --- /dev/null +++ b/src/spicelib/devices/bsim3v1/b3v1bindCSC.c @@ -0,0 +1,519 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bsim3v1def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +BSIM3v1bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3v1model *model = (BSIM3v1model *)inModel ; + BSIM3v1instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the BSIM3v1 models */ + for ( ; model != NULL ; model = model->BSIM3v1nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3v1instances ; here != NULL ; here = here->BSIM3v1nextInstance) + { + if ((here-> BSIM3v1dNode != 0) && (here-> BSIM3v1dNode != 0)) + { + i = here->BSIM3v1DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1DdStructPtr = matched ; + here->BSIM3v1DdPtr = matched->CSC ; + } + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1gNode != 0)) + { + i = here->BSIM3v1GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1GgStructPtr = matched ; + here->BSIM3v1GgPtr = matched->CSC ; + } + + if ((here-> BSIM3v1sNode != 0) && (here-> BSIM3v1sNode != 0)) + { + i = here->BSIM3v1SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1SsStructPtr = matched ; + here->BSIM3v1SsPtr = matched->CSC ; + } + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1bNode != 0)) + { + i = here->BSIM3v1BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1BbStructPtr = matched ; + here->BSIM3v1BbPtr = matched->CSC ; + } + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1dNodePrime != 0)) + { + i = here->BSIM3v1DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1DPdpStructPtr = matched ; + here->BSIM3v1DPdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1sNodePrime != 0)) + { + i = here->BSIM3v1SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1SPspStructPtr = matched ; + here->BSIM3v1SPspPtr = matched->CSC ; + } + + if ((here-> BSIM3v1dNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + { + i = here->BSIM3v1DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1DdpStructPtr = matched ; + here->BSIM3v1DdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1bNode != 0)) + { + i = here->BSIM3v1GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1GbStructPtr = matched ; + here->BSIM3v1GbPtr = matched->CSC ; + } + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + { + i = here->BSIM3v1GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1GdpStructPtr = matched ; + here->BSIM3v1GdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + { + i = here->BSIM3v1GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1GspStructPtr = matched ; + here->BSIM3v1GspPtr = matched->CSC ; + } + + if ((here-> BSIM3v1sNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + { + i = here->BSIM3v1SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1SspStructPtr = matched ; + here->BSIM3v1SspPtr = matched->CSC ; + } + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + { + i = here->BSIM3v1BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1BdpStructPtr = matched ; + here->BSIM3v1BdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + { + i = here->BSIM3v1BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1BspStructPtr = matched ; + here->BSIM3v1BspPtr = matched->CSC ; + } + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1sNodePrime != 0)) + { + i = here->BSIM3v1DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1DPspStructPtr = matched ; + here->BSIM3v1DPspPtr = matched->CSC ; + } + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1dNode != 0)) + { + i = here->BSIM3v1DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1DPdStructPtr = matched ; + here->BSIM3v1DPdPtr = matched->CSC ; + } + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1gNode != 0)) + { + i = here->BSIM3v1BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1BgStructPtr = matched ; + here->BSIM3v1BgPtr = matched->CSC ; + } + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1gNode != 0)) + { + i = here->BSIM3v1DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1DPgStructPtr = matched ; + here->BSIM3v1DPgPtr = matched->CSC ; + } + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1gNode != 0)) + { + i = here->BSIM3v1SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1SPgStructPtr = matched ; + here->BSIM3v1SPgPtr = matched->CSC ; + } + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1sNode != 0)) + { + i = here->BSIM3v1SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1SPsStructPtr = matched ; + here->BSIM3v1SPsPtr = matched->CSC ; + } + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1bNode != 0)) + { + i = here->BSIM3v1DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1DPbStructPtr = matched ; + here->BSIM3v1DPbPtr = matched->CSC ; + } + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1bNode != 0)) + { + i = here->BSIM3v1SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1SPbStructPtr = matched ; + here->BSIM3v1SPbPtr = matched->CSC ; + } + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1dNodePrime != 0)) + { + i = here->BSIM3v1SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1SPdpStructPtr = matched ; + here->BSIM3v1SPdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1qNode != 0)) + { + i = here->BSIM3v1QqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1QqStructPtr = matched ; + here->BSIM3v1QqPtr = matched->CSC ; + } + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + { + i = here->BSIM3v1QdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1QdpStructPtr = matched ; + here->BSIM3v1QdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + { + i = here->BSIM3v1QspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1QspStructPtr = matched ; + here->BSIM3v1QspPtr = matched->CSC ; + } + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1gNode != 0)) + { + i = here->BSIM3v1QgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1QgStructPtr = matched ; + here->BSIM3v1QgPtr = matched->CSC ; + } + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1bNode != 0)) + { + i = here->BSIM3v1QbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1QbStructPtr = matched ; + here->BSIM3v1QbPtr = matched->CSC ; + } + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1qNode != 0)) + { + i = here->BSIM3v1DPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1DPqStructPtr = matched ; + here->BSIM3v1DPqPtr = matched->CSC ; + } + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1qNode != 0)) + { + i = here->BSIM3v1SPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1SPqStructPtr = matched ; + here->BSIM3v1SPqPtr = matched->CSC ; + } + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1qNode != 0)) + { + i = here->BSIM3v1GqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1GqStructPtr = matched ; + here->BSIM3v1GqPtr = matched->CSC ; + } + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1qNode != 0)) + { + i = here->BSIM3v1BqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v1BqStructPtr = matched ; + here->BSIM3v1BqPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +BSIM3v1bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3v1model *model = (BSIM3v1model *)inModel ; + BSIM3v1instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM3v1 models */ + for ( ; model != NULL ; model = model->BSIM3v1nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3v1instances ; here != NULL ; here = here->BSIM3v1nextInstance) + { + if ((here-> BSIM3v1dNode != 0) && (here-> BSIM3v1dNode != 0)) + here->BSIM3v1DdPtr = here->BSIM3v1DdStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1GgPtr = here->BSIM3v1GgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1sNode != 0) && (here-> BSIM3v1sNode != 0)) + here->BSIM3v1SsPtr = here->BSIM3v1SsStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1BbPtr = here->BSIM3v1BbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1DPdpPtr = here->BSIM3v1DPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1SPspPtr = here->BSIM3v1SPspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1dNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1DdpPtr = here->BSIM3v1DdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1GbPtr = here->BSIM3v1GbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1GdpPtr = here->BSIM3v1GdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1GspPtr = here->BSIM3v1GspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1sNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1SspPtr = here->BSIM3v1SspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1BdpPtr = here->BSIM3v1BdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1BspPtr = here->BSIM3v1BspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1DPspPtr = here->BSIM3v1DPspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1dNode != 0)) + here->BSIM3v1DPdPtr = here->BSIM3v1DPdStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1BgPtr = here->BSIM3v1BgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1DPgPtr = here->BSIM3v1DPgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1SPgPtr = here->BSIM3v1SPgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1sNode != 0)) + here->BSIM3v1SPsPtr = here->BSIM3v1SPsStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1DPbPtr = here->BSIM3v1DPbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1SPbPtr = here->BSIM3v1SPbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1SPdpPtr = here->BSIM3v1SPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1QqPtr = here->BSIM3v1QqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1QdpPtr = here->BSIM3v1QdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1QspPtr = here->BSIM3v1QspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1QgPtr = here->BSIM3v1QgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1QbPtr = here->BSIM3v1QbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1DPqPtr = here->BSIM3v1DPqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1SPqPtr = here->BSIM3v1SPqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1GqPtr = here->BSIM3v1GqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1BqPtr = here->BSIM3v1BqStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +BSIM3v1bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3v1model *model = (BSIM3v1model *)inModel ; + BSIM3v1instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM3v1 models */ + for ( ; model != NULL ; model = model->BSIM3v1nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3v1instances ; here != NULL ; here = here->BSIM3v1nextInstance) + { + if ((here-> BSIM3v1dNode != 0) && (here-> BSIM3v1dNode != 0)) + here->BSIM3v1DdPtr = here->BSIM3v1DdStructPtr->CSC ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1GgPtr = here->BSIM3v1GgStructPtr->CSC ; + + if ((here-> BSIM3v1sNode != 0) && (here-> BSIM3v1sNode != 0)) + here->BSIM3v1SsPtr = here->BSIM3v1SsStructPtr->CSC ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1BbPtr = here->BSIM3v1BbStructPtr->CSC ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1DPdpPtr = here->BSIM3v1DPdpStructPtr->CSC ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1SPspPtr = here->BSIM3v1SPspStructPtr->CSC ; + + if ((here-> BSIM3v1dNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1DdpPtr = here->BSIM3v1DdpStructPtr->CSC ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1GbPtr = here->BSIM3v1GbStructPtr->CSC ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1GdpPtr = here->BSIM3v1GdpStructPtr->CSC ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1GspPtr = here->BSIM3v1GspStructPtr->CSC ; + + if ((here-> BSIM3v1sNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1SspPtr = here->BSIM3v1SspStructPtr->CSC ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1BdpPtr = here->BSIM3v1BdpStructPtr->CSC ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1BspPtr = here->BSIM3v1BspStructPtr->CSC ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1DPspPtr = here->BSIM3v1DPspStructPtr->CSC ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1dNode != 0)) + here->BSIM3v1DPdPtr = here->BSIM3v1DPdStructPtr->CSC ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1BgPtr = here->BSIM3v1BgStructPtr->CSC ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1DPgPtr = here->BSIM3v1DPgStructPtr->CSC ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1SPgPtr = here->BSIM3v1SPgStructPtr->CSC ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1sNode != 0)) + here->BSIM3v1SPsPtr = here->BSIM3v1SPsStructPtr->CSC ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1DPbPtr = here->BSIM3v1DPbStructPtr->CSC ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1SPbPtr = here->BSIM3v1SPbStructPtr->CSC ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1SPdpPtr = here->BSIM3v1SPdpStructPtr->CSC ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1QqPtr = here->BSIM3v1QqStructPtr->CSC ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1dNodePrime != 0)) + here->BSIM3v1QdpPtr = here->BSIM3v1QdpStructPtr->CSC ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1sNodePrime != 0)) + here->BSIM3v1QspPtr = here->BSIM3v1QspStructPtr->CSC ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1gNode != 0)) + here->BSIM3v1QgPtr = here->BSIM3v1QgStructPtr->CSC ; + + if ((here-> BSIM3v1qNode != 0) && (here-> BSIM3v1bNode != 0)) + here->BSIM3v1QbPtr = here->BSIM3v1QbStructPtr->CSC ; + + if ((here-> BSIM3v1dNodePrime != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1DPqPtr = here->BSIM3v1DPqStructPtr->CSC ; + + if ((here-> BSIM3v1sNodePrime != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1SPqPtr = here->BSIM3v1SPqStructPtr->CSC ; + + if ((here-> BSIM3v1gNode != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1GqPtr = here->BSIM3v1GqStructPtr->CSC ; + + if ((here-> BSIM3v1bNode != 0) && (here-> BSIM3v1qNode != 0)) + here->BSIM3v1BqPtr = here->BSIM3v1BqStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim3v1/bsim3v1def.h b/src/spicelib/devices/bsim3v1/bsim3v1def.h index 3424582f2..61517200f 100644 --- a/src/spicelib/devices/bsim3v1/bsim3v1def.h +++ b/src/spicelib/devices/bsim3v1/bsim3v1def.h @@ -189,6 +189,40 @@ typedef struct sBSIM3v1instance double **BSIM3v1nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *BSIM3v1DdStructPtr ; + BindElement *BSIM3v1GgStructPtr ; + BindElement *BSIM3v1SsStructPtr ; + BindElement *BSIM3v1BbStructPtr ; + BindElement *BSIM3v1DPdpStructPtr ; + BindElement *BSIM3v1SPspStructPtr ; + BindElement *BSIM3v1DdpStructPtr ; + BindElement *BSIM3v1GbStructPtr ; + BindElement *BSIM3v1GdpStructPtr ; + BindElement *BSIM3v1GspStructPtr ; + BindElement *BSIM3v1SspStructPtr ; + BindElement *BSIM3v1BdpStructPtr ; + BindElement *BSIM3v1BspStructPtr ; + BindElement *BSIM3v1DPspStructPtr ; + BindElement *BSIM3v1DPdStructPtr ; + BindElement *BSIM3v1BgStructPtr ; + BindElement *BSIM3v1DPgStructPtr ; + BindElement *BSIM3v1SPgStructPtr ; + BindElement *BSIM3v1SPsStructPtr ; + BindElement *BSIM3v1DPbStructPtr ; + BindElement *BSIM3v1SPbStructPtr ; + BindElement *BSIM3v1SPdpStructPtr ; + BindElement *BSIM3v1QqStructPtr ; + BindElement *BSIM3v1QdpStructPtr ; + BindElement *BSIM3v1QspStructPtr ; + BindElement *BSIM3v1QgStructPtr ; + BindElement *BSIM3v1QbStructPtr ; + BindElement *BSIM3v1DPqStructPtr ; + BindElement *BSIM3v1SPqStructPtr ; + BindElement *BSIM3v1GqStructPtr ; + BindElement *BSIM3v1BqStructPtr ; +#endif + } BSIM3v1instance ; struct bsim3v1SizeDependParam diff --git a/src/spicelib/devices/bsim3v1/bsim3v1ext.h b/src/spicelib/devices/bsim3v1/bsim3v1ext.h index 67c96c37e..3588d3ae2 100644 --- a/src/spicelib/devices/bsim3v1/bsim3v1ext.h +++ b/src/spicelib/devices/bsim3v1/bsim3v1ext.h @@ -29,3 +29,8 @@ extern int BSIM3v1trunc(GENmodel *, CKTcircuit *, double *); extern int BSIM3v1noise(int, int, GENmodel *, CKTcircuit *, Ndata *, double *); extern int BSIM3v1unsetup(GENmodel *, CKTcircuit *); +#ifdef KLU +extern int BSIM3v1bindCSC (GENmodel*, CKTcircuit*) ; +extern int BSIM3v1bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int BSIM3v1bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim3v1/bsim3v1init.c b/src/spicelib/devices/bsim3v1/bsim3v1init.c index 3efb57efc..d2c4daab7 100644 --- a/src/spicelib/devices/bsim3v1/bsim3v1init.c +++ b/src/spicelib/devices/bsim3v1/bsim3v1init.c @@ -71,7 +71,13 @@ SPICEdev BSIM3v1info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &BSIM3v1iSize, - /* DEVmodSize */ &BSIM3v1mSize + /* DEVmodSize */ &BSIM3v1mSize, + +#ifdef KLU + /* DEVbindCSC */ BSIM3v1bindCSC, + /* DEVbindCSCComplex */ BSIM3v1bindCSCComplex, + /* DEVbindCSCComplexToReal */ BSIM3v1bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/bsim3v32/Makefile.am b/src/spicelib/devices/bsim3v32/Makefile.am index 8c5bb529a..dccdb398f 100644 --- a/src/spicelib/devices/bsim3v32/Makefile.am +++ b/src/spicelib/devices/bsim3v32/Makefile.am @@ -29,6 +29,9 @@ libbsim3v32_la_SOURCES = \ bsim3v32itf.h +if KLU_WANTED +libbsim3v32_la_SOURCES += b3v32bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim3v32/b3v32bindCSC.c b/src/spicelib/devices/bsim3v32/b3v32bindCSC.c new file mode 100644 index 000000000..02513e0ef --- /dev/null +++ b/src/spicelib/devices/bsim3v32/b3v32bindCSC.c @@ -0,0 +1,519 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bsim3v32def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +BSIM3v32bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3v32model *model = (BSIM3v32model *)inModel ; + BSIM3v32instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the BSIM3v32 models */ + for ( ; model != NULL ; model = model->BSIM3v32nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3v32instances ; here != NULL ; here = here->BSIM3v32nextInstance) + { + if ((here-> BSIM3v32dNode != 0) && (here-> BSIM3v32dNode != 0)) + { + i = here->BSIM3v32DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32DdStructPtr = matched ; + here->BSIM3v32DdPtr = matched->CSC ; + } + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32gNode != 0)) + { + i = here->BSIM3v32GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32GgStructPtr = matched ; + here->BSIM3v32GgPtr = matched->CSC ; + } + + if ((here-> BSIM3v32sNode != 0) && (here-> BSIM3v32sNode != 0)) + { + i = here->BSIM3v32SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32SsStructPtr = matched ; + here->BSIM3v32SsPtr = matched->CSC ; + } + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32bNode != 0)) + { + i = here->BSIM3v32BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32BbStructPtr = matched ; + here->BSIM3v32BbPtr = matched->CSC ; + } + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32dNodePrime != 0)) + { + i = here->BSIM3v32DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32DPdpStructPtr = matched ; + here->BSIM3v32DPdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32sNodePrime != 0)) + { + i = here->BSIM3v32SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32SPspStructPtr = matched ; + here->BSIM3v32SPspPtr = matched->CSC ; + } + + if ((here-> BSIM3v32dNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + { + i = here->BSIM3v32DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32DdpStructPtr = matched ; + here->BSIM3v32DdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32bNode != 0)) + { + i = here->BSIM3v32GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32GbStructPtr = matched ; + here->BSIM3v32GbPtr = matched->CSC ; + } + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + { + i = here->BSIM3v32GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32GdpStructPtr = matched ; + here->BSIM3v32GdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + { + i = here->BSIM3v32GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32GspStructPtr = matched ; + here->BSIM3v32GspPtr = matched->CSC ; + } + + if ((here-> BSIM3v32sNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + { + i = here->BSIM3v32SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32SspStructPtr = matched ; + here->BSIM3v32SspPtr = matched->CSC ; + } + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + { + i = here->BSIM3v32BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32BdpStructPtr = matched ; + here->BSIM3v32BdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + { + i = here->BSIM3v32BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32BspStructPtr = matched ; + here->BSIM3v32BspPtr = matched->CSC ; + } + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32sNodePrime != 0)) + { + i = here->BSIM3v32DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32DPspStructPtr = matched ; + here->BSIM3v32DPspPtr = matched->CSC ; + } + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32dNode != 0)) + { + i = here->BSIM3v32DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32DPdStructPtr = matched ; + here->BSIM3v32DPdPtr = matched->CSC ; + } + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32gNode != 0)) + { + i = here->BSIM3v32BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32BgStructPtr = matched ; + here->BSIM3v32BgPtr = matched->CSC ; + } + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32gNode != 0)) + { + i = here->BSIM3v32DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32DPgStructPtr = matched ; + here->BSIM3v32DPgPtr = matched->CSC ; + } + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32gNode != 0)) + { + i = here->BSIM3v32SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32SPgStructPtr = matched ; + here->BSIM3v32SPgPtr = matched->CSC ; + } + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32sNode != 0)) + { + i = here->BSIM3v32SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32SPsStructPtr = matched ; + here->BSIM3v32SPsPtr = matched->CSC ; + } + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32bNode != 0)) + { + i = here->BSIM3v32DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32DPbStructPtr = matched ; + here->BSIM3v32DPbPtr = matched->CSC ; + } + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32bNode != 0)) + { + i = here->BSIM3v32SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32SPbStructPtr = matched ; + here->BSIM3v32SPbPtr = matched->CSC ; + } + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32dNodePrime != 0)) + { + i = here->BSIM3v32SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32SPdpStructPtr = matched ; + here->BSIM3v32SPdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32qNode != 0)) + { + i = here->BSIM3v32QqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32QqStructPtr = matched ; + here->BSIM3v32QqPtr = matched->CSC ; + } + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + { + i = here->BSIM3v32QdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32QdpStructPtr = matched ; + here->BSIM3v32QdpPtr = matched->CSC ; + } + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + { + i = here->BSIM3v32QspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32QspStructPtr = matched ; + here->BSIM3v32QspPtr = matched->CSC ; + } + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32gNode != 0)) + { + i = here->BSIM3v32QgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32QgStructPtr = matched ; + here->BSIM3v32QgPtr = matched->CSC ; + } + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32bNode != 0)) + { + i = here->BSIM3v32QbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32QbStructPtr = matched ; + here->BSIM3v32QbPtr = matched->CSC ; + } + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32qNode != 0)) + { + i = here->BSIM3v32DPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32DPqStructPtr = matched ; + here->BSIM3v32DPqPtr = matched->CSC ; + } + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32qNode != 0)) + { + i = here->BSIM3v32SPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32SPqStructPtr = matched ; + here->BSIM3v32SPqPtr = matched->CSC ; + } + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32qNode != 0)) + { + i = here->BSIM3v32GqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32GqStructPtr = matched ; + here->BSIM3v32GqPtr = matched->CSC ; + } + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32qNode != 0)) + { + i = here->BSIM3v32BqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM3v32BqStructPtr = matched ; + here->BSIM3v32BqPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +BSIM3v32bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3v32model *model = (BSIM3v32model *)inModel ; + BSIM3v32instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM3v32 models */ + for ( ; model != NULL ; model = model->BSIM3v32nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3v32instances ; here != NULL ; here = here->BSIM3v32nextInstance) + { + if ((here-> BSIM3v32dNode != 0) && (here-> BSIM3v32dNode != 0)) + here->BSIM3v32DdPtr = here->BSIM3v32DdStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32GgPtr = here->BSIM3v32GgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32sNode != 0) && (here-> BSIM3v32sNode != 0)) + here->BSIM3v32SsPtr = here->BSIM3v32SsStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32BbPtr = here->BSIM3v32BbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32DPdpPtr = here->BSIM3v32DPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32SPspPtr = here->BSIM3v32SPspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32dNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32DdpPtr = here->BSIM3v32DdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32GbPtr = here->BSIM3v32GbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32GdpPtr = here->BSIM3v32GdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32GspPtr = here->BSIM3v32GspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32sNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32SspPtr = here->BSIM3v32SspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32BdpPtr = here->BSIM3v32BdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32BspPtr = here->BSIM3v32BspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32DPspPtr = here->BSIM3v32DPspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32dNode != 0)) + here->BSIM3v32DPdPtr = here->BSIM3v32DPdStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32BgPtr = here->BSIM3v32BgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32DPgPtr = here->BSIM3v32DPgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32SPgPtr = here->BSIM3v32SPgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32sNode != 0)) + here->BSIM3v32SPsPtr = here->BSIM3v32SPsStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32DPbPtr = here->BSIM3v32DPbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32SPbPtr = here->BSIM3v32SPbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32SPdpPtr = here->BSIM3v32SPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32QqPtr = here->BSIM3v32QqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32QdpPtr = here->BSIM3v32QdpStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32QspPtr = here->BSIM3v32QspStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32QgPtr = here->BSIM3v32QgStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32QbPtr = here->BSIM3v32QbStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32DPqPtr = here->BSIM3v32DPqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32SPqPtr = here->BSIM3v32SPqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32GqPtr = here->BSIM3v32GqStructPtr->CSC_Complex ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32BqPtr = here->BSIM3v32BqStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +BSIM3v32bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM3v32model *model = (BSIM3v32model *)inModel ; + BSIM3v32instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM3v32 models */ + for ( ; model != NULL ; model = model->BSIM3v32nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM3v32instances ; here != NULL ; here = here->BSIM3v32nextInstance) + { + if ((here-> BSIM3v32dNode != 0) && (here-> BSIM3v32dNode != 0)) + here->BSIM3v32DdPtr = here->BSIM3v32DdStructPtr->CSC ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32GgPtr = here->BSIM3v32GgStructPtr->CSC ; + + if ((here-> BSIM3v32sNode != 0) && (here-> BSIM3v32sNode != 0)) + here->BSIM3v32SsPtr = here->BSIM3v32SsStructPtr->CSC ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32BbPtr = here->BSIM3v32BbStructPtr->CSC ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32DPdpPtr = here->BSIM3v32DPdpStructPtr->CSC ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32SPspPtr = here->BSIM3v32SPspStructPtr->CSC ; + + if ((here-> BSIM3v32dNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32DdpPtr = here->BSIM3v32DdpStructPtr->CSC ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32GbPtr = here->BSIM3v32GbStructPtr->CSC ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32GdpPtr = here->BSIM3v32GdpStructPtr->CSC ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32GspPtr = here->BSIM3v32GspStructPtr->CSC ; + + if ((here-> BSIM3v32sNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32SspPtr = here->BSIM3v32SspStructPtr->CSC ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32BdpPtr = here->BSIM3v32BdpStructPtr->CSC ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32BspPtr = here->BSIM3v32BspStructPtr->CSC ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32DPspPtr = here->BSIM3v32DPspStructPtr->CSC ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32dNode != 0)) + here->BSIM3v32DPdPtr = here->BSIM3v32DPdStructPtr->CSC ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32BgPtr = here->BSIM3v32BgStructPtr->CSC ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32DPgPtr = here->BSIM3v32DPgStructPtr->CSC ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32SPgPtr = here->BSIM3v32SPgStructPtr->CSC ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32sNode != 0)) + here->BSIM3v32SPsPtr = here->BSIM3v32SPsStructPtr->CSC ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32DPbPtr = here->BSIM3v32DPbStructPtr->CSC ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32SPbPtr = here->BSIM3v32SPbStructPtr->CSC ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32SPdpPtr = here->BSIM3v32SPdpStructPtr->CSC ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32QqPtr = here->BSIM3v32QqStructPtr->CSC ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32dNodePrime != 0)) + here->BSIM3v32QdpPtr = here->BSIM3v32QdpStructPtr->CSC ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32sNodePrime != 0)) + here->BSIM3v32QspPtr = here->BSIM3v32QspStructPtr->CSC ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32gNode != 0)) + here->BSIM3v32QgPtr = here->BSIM3v32QgStructPtr->CSC ; + + if ((here-> BSIM3v32qNode != 0) && (here-> BSIM3v32bNode != 0)) + here->BSIM3v32QbPtr = here->BSIM3v32QbStructPtr->CSC ; + + if ((here-> BSIM3v32dNodePrime != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32DPqPtr = here->BSIM3v32DPqStructPtr->CSC ; + + if ((here-> BSIM3v32sNodePrime != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32SPqPtr = here->BSIM3v32SPqStructPtr->CSC ; + + if ((here-> BSIM3v32gNode != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32GqPtr = here->BSIM3v32GqStructPtr->CSC ; + + if ((here-> BSIM3v32bNode != 0) && (here-> BSIM3v32qNode != 0)) + here->BSIM3v32BqPtr = here->BSIM3v32BqStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim3v32/bsim3v32def.h b/src/spicelib/devices/bsim3v32/bsim3v32def.h index a913d02df..01bf8810c 100644 --- a/src/spicelib/devices/bsim3v32/bsim3v32def.h +++ b/src/spicelib/devices/bsim3v32/bsim3v32def.h @@ -212,6 +212,40 @@ typedef struct sBSIM3v32instance double **BSIM3v32nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *BSIM3v32DdStructPtr ; + BindElement *BSIM3v32GgStructPtr ; + BindElement *BSIM3v32SsStructPtr ; + BindElement *BSIM3v32BbStructPtr ; + BindElement *BSIM3v32DPdpStructPtr ; + BindElement *BSIM3v32SPspStructPtr ; + BindElement *BSIM3v32DdpStructPtr ; + BindElement *BSIM3v32GbStructPtr ; + BindElement *BSIM3v32GdpStructPtr ; + BindElement *BSIM3v32GspStructPtr ; + BindElement *BSIM3v32SspStructPtr ; + BindElement *BSIM3v32BdpStructPtr ; + BindElement *BSIM3v32BspStructPtr ; + BindElement *BSIM3v32DPspStructPtr ; + BindElement *BSIM3v32DPdStructPtr ; + BindElement *BSIM3v32BgStructPtr ; + BindElement *BSIM3v32DPgStructPtr ; + BindElement *BSIM3v32SPgStructPtr ; + BindElement *BSIM3v32SPsStructPtr ; + BindElement *BSIM3v32DPbStructPtr ; + BindElement *BSIM3v32SPbStructPtr ; + BindElement *BSIM3v32SPdpStructPtr ; + BindElement *BSIM3v32QqStructPtr ; + BindElement *BSIM3v32QdpStructPtr ; + BindElement *BSIM3v32QspStructPtr ; + BindElement *BSIM3v32QgStructPtr ; + BindElement *BSIM3v32QbStructPtr ; + BindElement *BSIM3v32DPqStructPtr ; + BindElement *BSIM3v32SPqStructPtr ; + BindElement *BSIM3v32GqStructPtr ; + BindElement *BSIM3v32BqStructPtr ; +#endif + } BSIM3v32instance ; struct bsim3v32SizeDependParam diff --git a/src/spicelib/devices/bsim3v32/bsim3v32ext.h b/src/spicelib/devices/bsim3v32/bsim3v32ext.h index 64ff43ccf..7ef6f22dc 100644 --- a/src/spicelib/devices/bsim3v32/bsim3v32ext.h +++ b/src/spicelib/devices/bsim3v32/bsim3v32ext.h @@ -30,3 +30,9 @@ 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 *); + +#ifdef KLU +extern int BSIM3v32bindCSC (GENmodel*, CKTcircuit*) ; +extern int BSIM3v32bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int BSIM3v32bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim3v32/bsim3v32init.c b/src/spicelib/devices/bsim3v32/bsim3v32init.c index e109cf654..5ce5191c2 100644 --- a/src/spicelib/devices/bsim3v32/bsim3v32init.c +++ b/src/spicelib/devices/bsim3v32/bsim3v32init.c @@ -72,7 +72,13 @@ SPICEdev BSIM3v32info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &BSIM3v32iSize, - /* DEVmodSize */ &BSIM3v32mSize + /* DEVmodSize */ &BSIM3v32mSize, + +#ifdef KLU + /* DEVbindCSC */ BSIM3v32bindCSC, + /* DEVbindCSCComplex */ BSIM3v32bindCSCComplex, + /* DEVbindCSCComplexToReal */ BSIM3v32bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/bsim4v5/Makefile.am b/src/spicelib/devices/bsim4v5/Makefile.am index 4438ce323..7941bbdd5 100644 --- a/src/spicelib/devices/bsim4v5/Makefile.am +++ b/src/spicelib/devices/bsim4v5/Makefile.am @@ -30,6 +30,9 @@ libbsim4v5_la_SOURCES = \ bsim4v5itf.h +if KLU_WANTED +libbsim4v5_la_SOURCES += b4v5bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim4v5/b4v5bindCSC.c b/src/spicelib/devices/bsim4v5/b4v5bindCSC.c new file mode 100644 index 000000000..2da70de00 --- /dev/null +++ b/src/spicelib/devices/bsim4v5/b4v5bindCSC.c @@ -0,0 +1,1092 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bsim4v5def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +BSIM4v5bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM4v5model *model = (BSIM4v5model *)inModel ; + BSIM4v5instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the BSIM4v5 models */ + for ( ; model != NULL ; model = model->BSIM4v5nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM4v5instances ; here != NULL ; here = here->BSIM4v5nextInstance) + { + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5DPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DPbpStructPtr = matched ; + here->BSIM4v5DPbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5GPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GPbpStructPtr = matched ; + here->BSIM4v5GPbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5SPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SPbpStructPtr = matched ; + here->BSIM4v5SPbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5BPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BPdpStructPtr = matched ; + here->BSIM4v5BPdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + { + i = here->BSIM4v5BPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BPgpStructPtr = matched ; + here->BSIM4v5BPgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5BPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BPspStructPtr = matched ; + here->BSIM4v5BPspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5BPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BPbpStructPtr = matched ; + here->BSIM4v5BPbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5dNode != 0)) + { + i = here->BSIM4v5DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DdStructPtr = matched ; + here->BSIM4v5DdPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + { + i = here->BSIM4v5GPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GPgpStructPtr = matched ; + here->BSIM4v5GPgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5sNode != 0)) + { + i = here->BSIM4v5SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SsStructPtr = matched ; + here->BSIM4v5SsPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DPdpStructPtr = matched ; + here->BSIM4v5DPdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SPspStructPtr = matched ; + here->BSIM4v5SPspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DdpStructPtr = matched ; + here->BSIM4v5DdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5GPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GPdpStructPtr = matched ; + here->BSIM4v5GPdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5GPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GPspStructPtr = matched ; + here->BSIM4v5GPspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SspStructPtr = matched ; + here->BSIM4v5SspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DPspStructPtr = matched ; + here->BSIM4v5DPspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5dNode != 0)) + { + i = here->BSIM4v5DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DPdStructPtr = matched ; + here->BSIM4v5DPdPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + { + i = here->BSIM4v5DPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DPgpStructPtr = matched ; + here->BSIM4v5DPgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + { + i = here->BSIM4v5SPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SPgpStructPtr = matched ; + here->BSIM4v5SPgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5sNode != 0)) + { + i = here->BSIM4v5SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SPsStructPtr = matched ; + here->BSIM4v5SPsPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SPdpStructPtr = matched ; + here->BSIM4v5SPdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5qNode != 0)) + { + i = here->BSIM4v5QqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5QqStructPtr = matched ; + here->BSIM4v5QqPtr = matched->CSC ; + } + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5QbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5QbpStructPtr = matched ; + here->BSIM4v5QbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5QdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5QdpStructPtr = matched ; + here->BSIM4v5QdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5QspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5QspStructPtr = matched ; + here->BSIM4v5QspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5gNodePrime != 0)) + { + i = here->BSIM4v5QgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5QgpStructPtr = matched ; + here->BSIM4v5QgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5qNode != 0)) + { + i = here->BSIM4v5DPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DPqStructPtr = matched ; + here->BSIM4v5DPqPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5qNode != 0)) + { + i = here->BSIM4v5SPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SPqStructPtr = matched ; + here->BSIM4v5SPqPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5qNode != 0)) + { + i = here->BSIM4v5GPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GPqStructPtr = matched ; + here->BSIM4v5GPqPtr = matched->CSC ; + } + + if (here->BSIM4v5rgateMod != 0) + { + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5gNodeExt != 0)) + { + i = here->BSIM4v5GEgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GEgeStructPtr = matched ; + here->BSIM4v5GEgePtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5gNodePrime != 0)) + { + i = here->BSIM4v5GEgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GEgpStructPtr = matched ; + here->BSIM4v5GEgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5gNodeExt != 0)) + { + i = here->BSIM4v5GPgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GPgeStructPtr = matched ; + here->BSIM4v5GPgePtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5GEdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GEdpStructPtr = matched ; + here->BSIM4v5GEdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5GEspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GEspStructPtr = matched ; + here->BSIM4v5GEspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5GEbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GEbpStructPtr = matched ; + here->BSIM4v5GEbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5GMdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GMdpStructPtr = matched ; + here->BSIM4v5GMdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5gNodePrime != 0)) + { + i = here->BSIM4v5GMgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GMgpStructPtr = matched ; + here->BSIM4v5GMgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5gNodeMid != 0)) + { + i = here->BSIM4v5GMgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GMgmStructPtr = matched ; + here->BSIM4v5GMgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5gNodeExt != 0)) + { + i = here->BSIM4v5GMgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GMgeStructPtr = matched ; + here->BSIM4v5GMgePtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5GMspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GMspStructPtr = matched ; + here->BSIM4v5GMspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5GMbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GMbpStructPtr = matched ; + here->BSIM4v5GMbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + { + i = here->BSIM4v5DPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DPgmStructPtr = matched ; + here->BSIM4v5DPgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + { + i = here->BSIM4v5GPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GPgmStructPtr = matched ; + here->BSIM4v5GPgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5gNodeMid != 0)) + { + i = here->BSIM4v5GEgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5GEgmStructPtr = matched ; + here->BSIM4v5GEgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + { + i = here->BSIM4v5SPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SPgmStructPtr = matched ; + here->BSIM4v5SPgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + { + i = here->BSIM4v5BPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BPgmStructPtr = matched ; + here->BSIM4v5BPgmPtr = matched->CSC ; + } + + } + if ((here->BSIM4v5rbodyMod ==1) || (here->BSIM4v5rbodyMod ==2)) + { + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5dbNode != 0)) + { + i = here->BSIM4v5DPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DPdbStructPtr = matched ; + here->BSIM4v5DPdbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5sbNode != 0)) + { + i = here->BSIM4v5SPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SPsbStructPtr = matched ; + here->BSIM4v5SPsbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5DBdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DBdpStructPtr = matched ; + here->BSIM4v5DBdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5dbNode != 0)) + { + i = here->BSIM4v5DBdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DBdbStructPtr = matched ; + here->BSIM4v5DBdbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5DBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DBbpStructPtr = matched ; + here->BSIM4v5DBbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5bNode != 0)) + { + i = here->BSIM4v5DBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DBbStructPtr = matched ; + here->BSIM4v5DBbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5dbNode != 0)) + { + i = here->BSIM4v5BPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BPdbStructPtr = matched ; + here->BSIM4v5BPdbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5bNode != 0)) + { + i = here->BSIM4v5BPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BPbStructPtr = matched ; + here->BSIM4v5BPbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5sbNode != 0)) + { + i = here->BSIM4v5BPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BPsbStructPtr = matched ; + here->BSIM4v5BPsbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5SBspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SBspStructPtr = matched ; + here->BSIM4v5SBspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5SBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SBbpStructPtr = matched ; + here->BSIM4v5SBbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5bNode != 0)) + { + i = here->BSIM4v5SBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SBbStructPtr = matched ; + here->BSIM4v5SBbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5sbNode != 0)) + { + i = here->BSIM4v5SBsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SBsbStructPtr = matched ; + here->BSIM4v5SBsbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5dbNode != 0)) + { + i = here->BSIM4v5BdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BdbStructPtr = matched ; + here->BSIM4v5BdbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5BbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BbpStructPtr = matched ; + here->BSIM4v5BbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5sbNode != 0)) + { + i = here->BSIM4v5BsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BsbStructPtr = matched ; + here->BSIM4v5BsbPtr = matched->CSC ; + } + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5bNode != 0)) + { + i = here->BSIM4v5BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5BbStructPtr = matched ; + here->BSIM4v5BbPtr = matched->CSC ; + } + + } + if (model->BSIM4v5rdsMod) + { + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5gNodePrime != 0)) + { + i = here->BSIM4v5DgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DgpStructPtr = matched ; + here->BSIM4v5DgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + { + i = here->BSIM4v5DspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DspStructPtr = matched ; + here->BSIM4v5DspPtr = matched->CSC ; + } + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5DbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5DbpStructPtr = matched ; + here->BSIM4v5DbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + { + i = here->BSIM4v5SdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SdpStructPtr = matched ; + here->BSIM4v5SdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5gNodePrime != 0)) + { + i = here->BSIM4v5SgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SgpStructPtr = matched ; + here->BSIM4v5SgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + { + i = here->BSIM4v5SbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v5SbpStructPtr = matched ; + here->BSIM4v5SbpPtr = matched->CSC ; + } + + } + } + } + + return (OK) ; +} + +int +BSIM4v5bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM4v5model *model = (BSIM4v5model *)inModel ; + BSIM4v5instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM4v5 models */ + for ( ; model != NULL ; model = model->BSIM4v5nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM4v5instances ; here != NULL ; here = here->BSIM4v5nextInstance) + { + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5DPbpPtr = here->BSIM4v5DPbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5GPbpPtr = here->BSIM4v5GPbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5SPbpPtr = here->BSIM4v5SPbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5BPdpPtr = here->BSIM4v5BPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5BPgpPtr = here->BSIM4v5BPgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5BPspPtr = here->BSIM4v5BPspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5BPbpPtr = here->BSIM4v5BPbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5dNode != 0)) + here->BSIM4v5DdPtr = here->BSIM4v5DdStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5GPgpPtr = here->BSIM4v5GPgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5sNode != 0)) + here->BSIM4v5SsPtr = here->BSIM4v5SsStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5DPdpPtr = here->BSIM4v5DPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5SPspPtr = here->BSIM4v5SPspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5DdpPtr = here->BSIM4v5DdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5GPdpPtr = here->BSIM4v5GPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5GPspPtr = here->BSIM4v5GPspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5SspPtr = here->BSIM4v5SspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5DPspPtr = here->BSIM4v5DPspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5dNode != 0)) + here->BSIM4v5DPdPtr = here->BSIM4v5DPdStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5DPgpPtr = here->BSIM4v5DPgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5SPgpPtr = here->BSIM4v5SPgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5sNode != 0)) + here->BSIM4v5SPsPtr = here->BSIM4v5SPsStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5SPdpPtr = here->BSIM4v5SPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5qNode != 0)) + here->BSIM4v5QqPtr = here->BSIM4v5QqStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5QbpPtr = here->BSIM4v5QbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5QdpPtr = here->BSIM4v5QdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5QspPtr = here->BSIM4v5QspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5QgpPtr = here->BSIM4v5QgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5qNode != 0)) + here->BSIM4v5DPqPtr = here->BSIM4v5DPqStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5qNode != 0)) + here->BSIM4v5SPqPtr = here->BSIM4v5SPqStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5qNode != 0)) + here->BSIM4v5GPqPtr = here->BSIM4v5GPqStructPtr->CSC_Complex ; + + if (here->BSIM4v5rgateMod != 0) + { + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5gNodeExt != 0)) + here->BSIM4v5GEgePtr = here->BSIM4v5GEgeStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5GEgpPtr = here->BSIM4v5GEgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5gNodeExt != 0)) + here->BSIM4v5GPgePtr = here->BSIM4v5GPgeStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5GEdpPtr = here->BSIM4v5GEdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5GEspPtr = here->BSIM4v5GEspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5GEbpPtr = here->BSIM4v5GEbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5GMdpPtr = here->BSIM4v5GMdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5GMgpPtr = here->BSIM4v5GMgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5GMgmPtr = here->BSIM4v5GMgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5gNodeExt != 0)) + here->BSIM4v5GMgePtr = here->BSIM4v5GMgeStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5GMspPtr = here->BSIM4v5GMspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5GMbpPtr = here->BSIM4v5GMbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5DPgmPtr = here->BSIM4v5DPgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5GPgmPtr = here->BSIM4v5GPgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5GEgmPtr = here->BSIM4v5GEgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5SPgmPtr = here->BSIM4v5SPgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5BPgmPtr = here->BSIM4v5BPgmStructPtr->CSC_Complex ; + + } + if ((here->BSIM4v5rbodyMod ==1) || (here->BSIM4v5rbodyMod ==2)) + { + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5dbNode != 0)) + here->BSIM4v5DPdbPtr = here->BSIM4v5DPdbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5sbNode != 0)) + here->BSIM4v5SPsbPtr = here->BSIM4v5SPsbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5DBdpPtr = here->BSIM4v5DBdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5dbNode != 0)) + here->BSIM4v5DBdbPtr = here->BSIM4v5DBdbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5DBbpPtr = here->BSIM4v5DBbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5bNode != 0)) + here->BSIM4v5DBbPtr = here->BSIM4v5DBbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5dbNode != 0)) + here->BSIM4v5BPdbPtr = here->BSIM4v5BPdbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5bNode != 0)) + here->BSIM4v5BPbPtr = here->BSIM4v5BPbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5sbNode != 0)) + here->BSIM4v5BPsbPtr = here->BSIM4v5BPsbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5SBspPtr = here->BSIM4v5SBspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5SBbpPtr = here->BSIM4v5SBbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5bNode != 0)) + here->BSIM4v5SBbPtr = here->BSIM4v5SBbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5sbNode != 0)) + here->BSIM4v5SBsbPtr = here->BSIM4v5SBsbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5dbNode != 0)) + here->BSIM4v5BdbPtr = here->BSIM4v5BdbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5BbpPtr = here->BSIM4v5BbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5sbNode != 0)) + here->BSIM4v5BsbPtr = here->BSIM4v5BsbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5bNode != 0)) + here->BSIM4v5BbPtr = here->BSIM4v5BbStructPtr->CSC_Complex ; + + } + if (model->BSIM4v5rdsMod) + { + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5DgpPtr = here->BSIM4v5DgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5DspPtr = here->BSIM4v5DspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5DbpPtr = here->BSIM4v5DbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5SdpPtr = here->BSIM4v5SdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5SgpPtr = here->BSIM4v5SgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5SbpPtr = here->BSIM4v5SbpStructPtr->CSC_Complex ; + + } + } + } + + return (OK) ; +} + +int +BSIM4v5bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM4v5model *model = (BSIM4v5model *)inModel ; + BSIM4v5instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM4v5 models */ + for ( ; model != NULL ; model = model->BSIM4v5nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM4v5instances ; here != NULL ; here = here->BSIM4v5nextInstance) + { + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5DPbpPtr = here->BSIM4v5DPbpStructPtr->CSC ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5GPbpPtr = here->BSIM4v5GPbpStructPtr->CSC ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5SPbpPtr = here->BSIM4v5SPbpStructPtr->CSC ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5BPdpPtr = here->BSIM4v5BPdpStructPtr->CSC ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5BPgpPtr = here->BSIM4v5BPgpStructPtr->CSC ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5BPspPtr = here->BSIM4v5BPspStructPtr->CSC ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5BPbpPtr = here->BSIM4v5BPbpStructPtr->CSC ; + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5dNode != 0)) + here->BSIM4v5DdPtr = here->BSIM4v5DdStructPtr->CSC ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5GPgpPtr = here->BSIM4v5GPgpStructPtr->CSC ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5sNode != 0)) + here->BSIM4v5SsPtr = here->BSIM4v5SsStructPtr->CSC ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5DPdpPtr = here->BSIM4v5DPdpStructPtr->CSC ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5SPspPtr = here->BSIM4v5SPspStructPtr->CSC ; + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5DdpPtr = here->BSIM4v5DdpStructPtr->CSC ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5GPdpPtr = here->BSIM4v5GPdpStructPtr->CSC ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5GPspPtr = here->BSIM4v5GPspStructPtr->CSC ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5SspPtr = here->BSIM4v5SspStructPtr->CSC ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5DPspPtr = here->BSIM4v5DPspStructPtr->CSC ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5dNode != 0)) + here->BSIM4v5DPdPtr = here->BSIM4v5DPdStructPtr->CSC ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5DPgpPtr = here->BSIM4v5DPgpStructPtr->CSC ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5SPgpPtr = here->BSIM4v5SPgpStructPtr->CSC ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5sNode != 0)) + here->BSIM4v5SPsPtr = here->BSIM4v5SPsStructPtr->CSC ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5SPdpPtr = here->BSIM4v5SPdpStructPtr->CSC ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5qNode != 0)) + here->BSIM4v5QqPtr = here->BSIM4v5QqStructPtr->CSC ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5QbpPtr = here->BSIM4v5QbpStructPtr->CSC ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5QdpPtr = here->BSIM4v5QdpStructPtr->CSC ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5QspPtr = here->BSIM4v5QspStructPtr->CSC ; + + if ((here-> BSIM4v5qNode != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5QgpPtr = here->BSIM4v5QgpStructPtr->CSC ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5qNode != 0)) + here->BSIM4v5DPqPtr = here->BSIM4v5DPqStructPtr->CSC ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5qNode != 0)) + here->BSIM4v5SPqPtr = here->BSIM4v5SPqStructPtr->CSC ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5qNode != 0)) + here->BSIM4v5GPqPtr = here->BSIM4v5GPqStructPtr->CSC ; + + if (here->BSIM4v5rgateMod != 0) + { + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5gNodeExt != 0)) + here->BSIM4v5GEgePtr = here->BSIM4v5GEgeStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5GEgpPtr = here->BSIM4v5GEgpStructPtr->CSC ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5gNodeExt != 0)) + here->BSIM4v5GPgePtr = here->BSIM4v5GPgeStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5GEdpPtr = here->BSIM4v5GEdpStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5GEspPtr = here->BSIM4v5GEspStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5GEbpPtr = here->BSIM4v5GEbpStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5GMdpPtr = here->BSIM4v5GMdpStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5GMgpPtr = here->BSIM4v5GMgpStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5GMgmPtr = here->BSIM4v5GMgmStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5gNodeExt != 0)) + here->BSIM4v5GMgePtr = here->BSIM4v5GMgeStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5GMspPtr = here->BSIM4v5GMspStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeMid != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5GMbpPtr = here->BSIM4v5GMbpStructPtr->CSC ; + + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5DPgmPtr = here->BSIM4v5DPgmStructPtr->CSC ; + + if ((here-> BSIM4v5gNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5GPgmPtr = here->BSIM4v5GPgmStructPtr->CSC ; + + if ((here-> BSIM4v5gNodeExt != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5GEgmPtr = here->BSIM4v5GEgmStructPtr->CSC ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5SPgmPtr = here->BSIM4v5SPgmStructPtr->CSC ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5gNodeMid != 0)) + here->BSIM4v5BPgmPtr = here->BSIM4v5BPgmStructPtr->CSC ; + + } + if ((here->BSIM4v5rbodyMod ==1) || (here->BSIM4v5rbodyMod ==2)) + { + if ((here-> BSIM4v5dNodePrime != 0) && (here-> BSIM4v5dbNode != 0)) + here->BSIM4v5DPdbPtr = here->BSIM4v5DPdbStructPtr->CSC ; + + if ((here-> BSIM4v5sNodePrime != 0) && (here-> BSIM4v5sbNode != 0)) + here->BSIM4v5SPsbPtr = here->BSIM4v5SPsbStructPtr->CSC ; + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5DBdpPtr = here->BSIM4v5DBdpStructPtr->CSC ; + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5dbNode != 0)) + here->BSIM4v5DBdbPtr = here->BSIM4v5DBdbStructPtr->CSC ; + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5DBbpPtr = here->BSIM4v5DBbpStructPtr->CSC ; + + if ((here-> BSIM4v5dbNode != 0) && (here-> BSIM4v5bNode != 0)) + here->BSIM4v5DBbPtr = here->BSIM4v5DBbStructPtr->CSC ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5dbNode != 0)) + here->BSIM4v5BPdbPtr = here->BSIM4v5BPdbStructPtr->CSC ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5bNode != 0)) + here->BSIM4v5BPbPtr = here->BSIM4v5BPbStructPtr->CSC ; + + if ((here-> BSIM4v5bNodePrime != 0) && (here-> BSIM4v5sbNode != 0)) + here->BSIM4v5BPsbPtr = here->BSIM4v5BPsbStructPtr->CSC ; + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5SBspPtr = here->BSIM4v5SBspStructPtr->CSC ; + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5SBbpPtr = here->BSIM4v5SBbpStructPtr->CSC ; + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5bNode != 0)) + here->BSIM4v5SBbPtr = here->BSIM4v5SBbStructPtr->CSC ; + + if ((here-> BSIM4v5sbNode != 0) && (here-> BSIM4v5sbNode != 0)) + here->BSIM4v5SBsbPtr = here->BSIM4v5SBsbStructPtr->CSC ; + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5dbNode != 0)) + here->BSIM4v5BdbPtr = here->BSIM4v5BdbStructPtr->CSC ; + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5BbpPtr = here->BSIM4v5BbpStructPtr->CSC ; + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5sbNode != 0)) + here->BSIM4v5BsbPtr = here->BSIM4v5BsbStructPtr->CSC ; + + if ((here-> BSIM4v5bNode != 0) && (here-> BSIM4v5bNode != 0)) + here->BSIM4v5BbPtr = here->BSIM4v5BbStructPtr->CSC ; + + } + if (model->BSIM4v5rdsMod) + { + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5DgpPtr = here->BSIM4v5DgpStructPtr->CSC ; + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5sNodePrime != 0)) + here->BSIM4v5DspPtr = here->BSIM4v5DspStructPtr->CSC ; + + if ((here-> BSIM4v5dNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5DbpPtr = here->BSIM4v5DbpStructPtr->CSC ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5dNodePrime != 0)) + here->BSIM4v5SdpPtr = here->BSIM4v5SdpStructPtr->CSC ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5gNodePrime != 0)) + here->BSIM4v5SgpPtr = here->BSIM4v5SgpStructPtr->CSC ; + + if ((here-> BSIM4v5sNode != 0) && (here-> BSIM4v5bNodePrime != 0)) + here->BSIM4v5SbpPtr = here->BSIM4v5SbpStructPtr->CSC ; + + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim4v5/bsim4v5def.h b/src/spicelib/devices/bsim4v5/bsim4v5def.h index e20a53e67..9fb424217 100644 --- a/src/spicelib/devices/bsim4v5/bsim4v5def.h +++ b/src/spicelib/devices/bsim4v5/bsim4v5def.h @@ -438,6 +438,79 @@ typedef struct sBSIM4v5instance double **BSIM4v5nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *BSIM4v5DPbpStructPtr ; + BindElement *BSIM4v5GPbpStructPtr ; + BindElement *BSIM4v5SPbpStructPtr ; + BindElement *BSIM4v5BPdpStructPtr ; + BindElement *BSIM4v5BPgpStructPtr ; + BindElement *BSIM4v5BPspStructPtr ; + BindElement *BSIM4v5BPbpStructPtr ; + BindElement *BSIM4v5DdStructPtr ; + BindElement *BSIM4v5GPgpStructPtr ; + BindElement *BSIM4v5SsStructPtr ; + BindElement *BSIM4v5DPdpStructPtr ; + BindElement *BSIM4v5SPspStructPtr ; + BindElement *BSIM4v5DdpStructPtr ; + BindElement *BSIM4v5GPdpStructPtr ; + BindElement *BSIM4v5GPspStructPtr ; + BindElement *BSIM4v5SspStructPtr ; + BindElement *BSIM4v5DPspStructPtr ; + BindElement *BSIM4v5DPdStructPtr ; + BindElement *BSIM4v5DPgpStructPtr ; + BindElement *BSIM4v5SPgpStructPtr ; + BindElement *BSIM4v5SPsStructPtr ; + BindElement *BSIM4v5SPdpStructPtr ; + BindElement *BSIM4v5QqStructPtr ; + BindElement *BSIM4v5QbpStructPtr ; + BindElement *BSIM4v5QdpStructPtr ; + BindElement *BSIM4v5QspStructPtr ; + BindElement *BSIM4v5QgpStructPtr ; + BindElement *BSIM4v5DPqStructPtr ; + BindElement *BSIM4v5SPqStructPtr ; + BindElement *BSIM4v5GPqStructPtr ; + BindElement *BSIM4v5GEgeStructPtr ; + BindElement *BSIM4v5GEgpStructPtr ; + BindElement *BSIM4v5GPgeStructPtr ; + BindElement *BSIM4v5GEdpStructPtr ; + BindElement *BSIM4v5GEspStructPtr ; + BindElement *BSIM4v5GEbpStructPtr ; + BindElement *BSIM4v5GMdpStructPtr ; + BindElement *BSIM4v5GMgpStructPtr ; + BindElement *BSIM4v5GMgmStructPtr ; + BindElement *BSIM4v5GMgeStructPtr ; + BindElement *BSIM4v5GMspStructPtr ; + BindElement *BSIM4v5GMbpStructPtr ; + BindElement *BSIM4v5DPgmStructPtr ; + BindElement *BSIM4v5GPgmStructPtr ; + BindElement *BSIM4v5GEgmStructPtr ; + BindElement *BSIM4v5SPgmStructPtr ; + BindElement *BSIM4v5BPgmStructPtr ; + BindElement *BSIM4v5DPdbStructPtr ; + BindElement *BSIM4v5SPsbStructPtr ; + BindElement *BSIM4v5DBdpStructPtr ; + BindElement *BSIM4v5DBdbStructPtr ; + BindElement *BSIM4v5DBbpStructPtr ; + BindElement *BSIM4v5DBbStructPtr ; + BindElement *BSIM4v5BPdbStructPtr ; + BindElement *BSIM4v5BPbStructPtr ; + BindElement *BSIM4v5BPsbStructPtr ; + BindElement *BSIM4v5SBspStructPtr ; + BindElement *BSIM4v5SBbpStructPtr ; + BindElement *BSIM4v5SBbStructPtr ; + BindElement *BSIM4v5SBsbStructPtr ; + BindElement *BSIM4v5BdbStructPtr ; + BindElement *BSIM4v5BbpStructPtr ; + BindElement *BSIM4v5BsbStructPtr ; + BindElement *BSIM4v5BbStructPtr ; + BindElement *BSIM4v5DgpStructPtr ; + BindElement *BSIM4v5DspStructPtr ; + BindElement *BSIM4v5DbpStructPtr ; + BindElement *BSIM4v5SdpStructPtr ; + BindElement *BSIM4v5SgpStructPtr ; + BindElement *BSIM4v5SbpStructPtr ; +#endif + } BSIM4v5instance ; struct bsim4v5SizeDependParam diff --git a/src/spicelib/devices/bsim4v5/bsim4v5ext.h b/src/spicelib/devices/bsim4v5/bsim4v5ext.h index d4b72da68..1c019c85b 100644 --- a/src/spicelib/devices/bsim4v5/bsim4v5ext.h +++ b/src/spicelib/devices/bsim4v5/bsim4v5ext.h @@ -29,3 +29,9 @@ 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 *); + +#ifdef KLU +extern int BSIM4v5bindCSC (GENmodel*, CKTcircuit*) ; +extern int BSIM4v5bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int BSIM4v5bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim4v5/bsim4v5init.c b/src/spicelib/devices/bsim4v5/bsim4v5init.c index ba6aca999..5b08a2516 100644 --- a/src/spicelib/devices/bsim4v5/bsim4v5init.c +++ b/src/spicelib/devices/bsim4v5/bsim4v5init.c @@ -73,7 +73,14 @@ SPICEdev BSIM4v5info = { NULL, /* DEVacct */ #endif &BSIM4v5iSize, /* DEVinstSize */ - &BSIM4v5mSize /* DEVmodSize */ + &BSIM4v5mSize, /* DEVmodSize */ + +#ifdef KLU + BSIM4v5bindCSC, /* DEVbindCSC */ + BSIM4v5bindCSCComplex, /* DEVbindCSCComplex */ + BSIM4v5bindCSCComplexToReal, /* DEVbindCSCComplexToReal */ +#endif + }; diff --git a/src/spicelib/devices/bsim4v6/Makefile.am b/src/spicelib/devices/bsim4v6/Makefile.am index ad03052c0..a8277ad2c 100644 --- a/src/spicelib/devices/bsim4v6/Makefile.am +++ b/src/spicelib/devices/bsim4v6/Makefile.am @@ -30,6 +30,9 @@ libbsim4v6_la_SOURCES = \ bsim4v6itf.h +if KLU_WANTED +libbsim4v6_la_SOURCES += b4v6bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsim4v6/b4v6bindCSC.c b/src/spicelib/devices/bsim4v6/b4v6bindCSC.c new file mode 100644 index 000000000..7de76e8bf --- /dev/null +++ b/src/spicelib/devices/bsim4v6/b4v6bindCSC.c @@ -0,0 +1,1092 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "bsim4v6def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +BSIM4v6bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM4v6model *model = (BSIM4v6model *)inModel ; + BSIM4v6instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the BSIM4v6 models */ + for ( ; model != NULL ; model = model->BSIM4v6nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM4v6instances ; here != NULL ; here = here->BSIM4v6nextInstance) + { + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6DPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DPbpStructPtr = matched ; + here->BSIM4v6DPbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6GPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GPbpStructPtr = matched ; + here->BSIM4v6GPbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6SPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SPbpStructPtr = matched ; + here->BSIM4v6SPbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6BPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BPdpStructPtr = matched ; + here->BSIM4v6BPdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + { + i = here->BSIM4v6BPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BPgpStructPtr = matched ; + here->BSIM4v6BPgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6BPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BPspStructPtr = matched ; + here->BSIM4v6BPspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6BPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BPbpStructPtr = matched ; + here->BSIM4v6BPbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6dNode != 0)) + { + i = here->BSIM4v6DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DdStructPtr = matched ; + here->BSIM4v6DdPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + { + i = here->BSIM4v6GPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GPgpStructPtr = matched ; + here->BSIM4v6GPgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6sNode != 0)) + { + i = here->BSIM4v6SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SsStructPtr = matched ; + here->BSIM4v6SsPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DPdpStructPtr = matched ; + here->BSIM4v6DPdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SPspStructPtr = matched ; + here->BSIM4v6SPspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DdpStructPtr = matched ; + here->BSIM4v6DdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6GPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GPdpStructPtr = matched ; + here->BSIM4v6GPdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6GPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GPspStructPtr = matched ; + here->BSIM4v6GPspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SspStructPtr = matched ; + here->BSIM4v6SspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DPspStructPtr = matched ; + here->BSIM4v6DPspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6dNode != 0)) + { + i = here->BSIM4v6DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DPdStructPtr = matched ; + here->BSIM4v6DPdPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + { + i = here->BSIM4v6DPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DPgpStructPtr = matched ; + here->BSIM4v6DPgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + { + i = here->BSIM4v6SPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SPgpStructPtr = matched ; + here->BSIM4v6SPgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6sNode != 0)) + { + i = here->BSIM4v6SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SPsStructPtr = matched ; + here->BSIM4v6SPsPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SPdpStructPtr = matched ; + here->BSIM4v6SPdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6qNode != 0)) + { + i = here->BSIM4v6QqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6QqStructPtr = matched ; + here->BSIM4v6QqPtr = matched->CSC ; + } + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6QbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6QbpStructPtr = matched ; + here->BSIM4v6QbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6QdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6QdpStructPtr = matched ; + here->BSIM4v6QdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6QspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6QspStructPtr = matched ; + here->BSIM4v6QspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6gNodePrime != 0)) + { + i = here->BSIM4v6QgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6QgpStructPtr = matched ; + here->BSIM4v6QgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6qNode != 0)) + { + i = here->BSIM4v6DPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DPqStructPtr = matched ; + here->BSIM4v6DPqPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6qNode != 0)) + { + i = here->BSIM4v6SPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SPqStructPtr = matched ; + here->BSIM4v6SPqPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6qNode != 0)) + { + i = here->BSIM4v6GPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GPqStructPtr = matched ; + here->BSIM4v6GPqPtr = matched->CSC ; + } + + if (here->BSIM4v6rgateMod != 0) + { + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6gNodeExt != 0)) + { + i = here->BSIM4v6GEgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GEgeStructPtr = matched ; + here->BSIM4v6GEgePtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6gNodePrime != 0)) + { + i = here->BSIM4v6GEgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GEgpStructPtr = matched ; + here->BSIM4v6GEgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6gNodeExt != 0)) + { + i = here->BSIM4v6GPgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GPgeStructPtr = matched ; + here->BSIM4v6GPgePtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6GEdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GEdpStructPtr = matched ; + here->BSIM4v6GEdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6GEspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GEspStructPtr = matched ; + here->BSIM4v6GEspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6GEbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GEbpStructPtr = matched ; + here->BSIM4v6GEbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6GMdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GMdpStructPtr = matched ; + here->BSIM4v6GMdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6gNodePrime != 0)) + { + i = here->BSIM4v6GMgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GMgpStructPtr = matched ; + here->BSIM4v6GMgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6gNodeMid != 0)) + { + i = here->BSIM4v6GMgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GMgmStructPtr = matched ; + here->BSIM4v6GMgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6gNodeExt != 0)) + { + i = here->BSIM4v6GMgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GMgeStructPtr = matched ; + here->BSIM4v6GMgePtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6GMspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GMspStructPtr = matched ; + here->BSIM4v6GMspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6GMbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GMbpStructPtr = matched ; + here->BSIM4v6GMbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + { + i = here->BSIM4v6DPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DPgmStructPtr = matched ; + here->BSIM4v6DPgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + { + i = here->BSIM4v6GPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GPgmStructPtr = matched ; + here->BSIM4v6GPgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6gNodeMid != 0)) + { + i = here->BSIM4v6GEgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6GEgmStructPtr = matched ; + here->BSIM4v6GEgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + { + i = here->BSIM4v6SPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SPgmStructPtr = matched ; + here->BSIM4v6SPgmPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + { + i = here->BSIM4v6BPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BPgmStructPtr = matched ; + here->BSIM4v6BPgmPtr = matched->CSC ; + } + + } + if ((here->BSIM4v6rbodyMod ==1) || (here->BSIM4v6rbodyMod ==2)) + { + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6dbNode != 0)) + { + i = here->BSIM4v6DPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DPdbStructPtr = matched ; + here->BSIM4v6DPdbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6sbNode != 0)) + { + i = here->BSIM4v6SPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SPsbStructPtr = matched ; + here->BSIM4v6SPsbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6DBdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DBdpStructPtr = matched ; + here->BSIM4v6DBdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6dbNode != 0)) + { + i = here->BSIM4v6DBdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DBdbStructPtr = matched ; + here->BSIM4v6DBdbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6DBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DBbpStructPtr = matched ; + here->BSIM4v6DBbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6bNode != 0)) + { + i = here->BSIM4v6DBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DBbStructPtr = matched ; + here->BSIM4v6DBbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6dbNode != 0)) + { + i = here->BSIM4v6BPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BPdbStructPtr = matched ; + here->BSIM4v6BPdbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6bNode != 0)) + { + i = here->BSIM4v6BPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BPbStructPtr = matched ; + here->BSIM4v6BPbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6sbNode != 0)) + { + i = here->BSIM4v6BPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BPsbStructPtr = matched ; + here->BSIM4v6BPsbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6SBspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SBspStructPtr = matched ; + here->BSIM4v6SBspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6SBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SBbpStructPtr = matched ; + here->BSIM4v6SBbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6bNode != 0)) + { + i = here->BSIM4v6SBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SBbStructPtr = matched ; + here->BSIM4v6SBbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6sbNode != 0)) + { + i = here->BSIM4v6SBsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SBsbStructPtr = matched ; + here->BSIM4v6SBsbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6dbNode != 0)) + { + i = here->BSIM4v6BdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BdbStructPtr = matched ; + here->BSIM4v6BdbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6BbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BbpStructPtr = matched ; + here->BSIM4v6BbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6sbNode != 0)) + { + i = here->BSIM4v6BsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BsbStructPtr = matched ; + here->BSIM4v6BsbPtr = matched->CSC ; + } + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6bNode != 0)) + { + i = here->BSIM4v6BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6BbStructPtr = matched ; + here->BSIM4v6BbPtr = matched->CSC ; + } + + } + if (model->BSIM4v6rdsMod) + { + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6gNodePrime != 0)) + { + i = here->BSIM4v6DgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DgpStructPtr = matched ; + here->BSIM4v6DgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + { + i = here->BSIM4v6DspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DspStructPtr = matched ; + here->BSIM4v6DspPtr = matched->CSC ; + } + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6DbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6DbpStructPtr = matched ; + here->BSIM4v6DbpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + { + i = here->BSIM4v6SdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SdpStructPtr = matched ; + here->BSIM4v6SdpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6gNodePrime != 0)) + { + i = here->BSIM4v6SgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SgpStructPtr = matched ; + here->BSIM4v6SgpPtr = matched->CSC ; + } + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + { + i = here->BSIM4v6SbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4v6SbpStructPtr = matched ; + here->BSIM4v6SbpPtr = matched->CSC ; + } + + } + } + } + + return (OK) ; +} + +int +BSIM4v6bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM4v6model *model = (BSIM4v6model *)inModel ; + BSIM4v6instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM4v6 models */ + for ( ; model != NULL ; model = model->BSIM4v6nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM4v6instances ; here != NULL ; here = here->BSIM4v6nextInstance) + { + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6DPbpPtr = here->BSIM4v6DPbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6GPbpPtr = here->BSIM4v6GPbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6SPbpPtr = here->BSIM4v6SPbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6BPdpPtr = here->BSIM4v6BPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6BPgpPtr = here->BSIM4v6BPgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6BPspPtr = here->BSIM4v6BPspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6BPbpPtr = here->BSIM4v6BPbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6dNode != 0)) + here->BSIM4v6DdPtr = here->BSIM4v6DdStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6GPgpPtr = here->BSIM4v6GPgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6sNode != 0)) + here->BSIM4v6SsPtr = here->BSIM4v6SsStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6DPdpPtr = here->BSIM4v6DPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6SPspPtr = here->BSIM4v6SPspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6DdpPtr = here->BSIM4v6DdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6GPdpPtr = here->BSIM4v6GPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6GPspPtr = here->BSIM4v6GPspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6SspPtr = here->BSIM4v6SspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6DPspPtr = here->BSIM4v6DPspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6dNode != 0)) + here->BSIM4v6DPdPtr = here->BSIM4v6DPdStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6DPgpPtr = here->BSIM4v6DPgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6SPgpPtr = here->BSIM4v6SPgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6sNode != 0)) + here->BSIM4v6SPsPtr = here->BSIM4v6SPsStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6SPdpPtr = here->BSIM4v6SPdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6qNode != 0)) + here->BSIM4v6QqPtr = here->BSIM4v6QqStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6QbpPtr = here->BSIM4v6QbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6QdpPtr = here->BSIM4v6QdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6QspPtr = here->BSIM4v6QspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6QgpPtr = here->BSIM4v6QgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6qNode != 0)) + here->BSIM4v6DPqPtr = here->BSIM4v6DPqStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6qNode != 0)) + here->BSIM4v6SPqPtr = here->BSIM4v6SPqStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6qNode != 0)) + here->BSIM4v6GPqPtr = here->BSIM4v6GPqStructPtr->CSC_Complex ; + + if (here->BSIM4v6rgateMod != 0) + { + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6gNodeExt != 0)) + here->BSIM4v6GEgePtr = here->BSIM4v6GEgeStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6GEgpPtr = here->BSIM4v6GEgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6gNodeExt != 0)) + here->BSIM4v6GPgePtr = here->BSIM4v6GPgeStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6GEdpPtr = here->BSIM4v6GEdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6GEspPtr = here->BSIM4v6GEspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6GEbpPtr = here->BSIM4v6GEbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6GMdpPtr = here->BSIM4v6GMdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6GMgpPtr = here->BSIM4v6GMgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6GMgmPtr = here->BSIM4v6GMgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6gNodeExt != 0)) + here->BSIM4v6GMgePtr = here->BSIM4v6GMgeStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6GMspPtr = here->BSIM4v6GMspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6GMbpPtr = here->BSIM4v6GMbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6DPgmPtr = here->BSIM4v6DPgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6GPgmPtr = here->BSIM4v6GPgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6GEgmPtr = here->BSIM4v6GEgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6SPgmPtr = here->BSIM4v6SPgmStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6BPgmPtr = here->BSIM4v6BPgmStructPtr->CSC_Complex ; + + } + if ((here->BSIM4v6rbodyMod ==1) || (here->BSIM4v6rbodyMod ==2)) + { + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6dbNode != 0)) + here->BSIM4v6DPdbPtr = here->BSIM4v6DPdbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6sbNode != 0)) + here->BSIM4v6SPsbPtr = here->BSIM4v6SPsbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6DBdpPtr = here->BSIM4v6DBdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6dbNode != 0)) + here->BSIM4v6DBdbPtr = here->BSIM4v6DBdbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6DBbpPtr = here->BSIM4v6DBbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6bNode != 0)) + here->BSIM4v6DBbPtr = here->BSIM4v6DBbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6dbNode != 0)) + here->BSIM4v6BPdbPtr = here->BSIM4v6BPdbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6bNode != 0)) + here->BSIM4v6BPbPtr = here->BSIM4v6BPbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6sbNode != 0)) + here->BSIM4v6BPsbPtr = here->BSIM4v6BPsbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6SBspPtr = here->BSIM4v6SBspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6SBbpPtr = here->BSIM4v6SBbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6bNode != 0)) + here->BSIM4v6SBbPtr = here->BSIM4v6SBbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6sbNode != 0)) + here->BSIM4v6SBsbPtr = here->BSIM4v6SBsbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6dbNode != 0)) + here->BSIM4v6BdbPtr = here->BSIM4v6BdbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6BbpPtr = here->BSIM4v6BbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6sbNode != 0)) + here->BSIM4v6BsbPtr = here->BSIM4v6BsbStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6bNode != 0)) + here->BSIM4v6BbPtr = here->BSIM4v6BbStructPtr->CSC_Complex ; + + } + if (model->BSIM4v6rdsMod) + { + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6DgpPtr = here->BSIM4v6DgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6DspPtr = here->BSIM4v6DspStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6DbpPtr = here->BSIM4v6DbpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6SdpPtr = here->BSIM4v6SdpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6SgpPtr = here->BSIM4v6SgpStructPtr->CSC_Complex ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6SbpPtr = here->BSIM4v6SbpStructPtr->CSC_Complex ; + + } + } + } + + return (OK) ; +} + +int +BSIM4v6bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM4v6model *model = (BSIM4v6model *)inModel ; + BSIM4v6instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM4v6 models */ + for ( ; model != NULL ; model = model->BSIM4v6nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM4v6instances ; here != NULL ; here = here->BSIM4v6nextInstance) + { + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6DPbpPtr = here->BSIM4v6DPbpStructPtr->CSC ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6GPbpPtr = here->BSIM4v6GPbpStructPtr->CSC ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6SPbpPtr = here->BSIM4v6SPbpStructPtr->CSC ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6BPdpPtr = here->BSIM4v6BPdpStructPtr->CSC ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6BPgpPtr = here->BSIM4v6BPgpStructPtr->CSC ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6BPspPtr = here->BSIM4v6BPspStructPtr->CSC ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6BPbpPtr = here->BSIM4v6BPbpStructPtr->CSC ; + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6dNode != 0)) + here->BSIM4v6DdPtr = here->BSIM4v6DdStructPtr->CSC ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6GPgpPtr = here->BSIM4v6GPgpStructPtr->CSC ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6sNode != 0)) + here->BSIM4v6SsPtr = here->BSIM4v6SsStructPtr->CSC ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6DPdpPtr = here->BSIM4v6DPdpStructPtr->CSC ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6SPspPtr = here->BSIM4v6SPspStructPtr->CSC ; + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6DdpPtr = here->BSIM4v6DdpStructPtr->CSC ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6GPdpPtr = here->BSIM4v6GPdpStructPtr->CSC ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6GPspPtr = here->BSIM4v6GPspStructPtr->CSC ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6SspPtr = here->BSIM4v6SspStructPtr->CSC ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6DPspPtr = here->BSIM4v6DPspStructPtr->CSC ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6dNode != 0)) + here->BSIM4v6DPdPtr = here->BSIM4v6DPdStructPtr->CSC ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6DPgpPtr = here->BSIM4v6DPgpStructPtr->CSC ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6SPgpPtr = here->BSIM4v6SPgpStructPtr->CSC ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6sNode != 0)) + here->BSIM4v6SPsPtr = here->BSIM4v6SPsStructPtr->CSC ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6SPdpPtr = here->BSIM4v6SPdpStructPtr->CSC ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6qNode != 0)) + here->BSIM4v6QqPtr = here->BSIM4v6QqStructPtr->CSC ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6QbpPtr = here->BSIM4v6QbpStructPtr->CSC ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6QdpPtr = here->BSIM4v6QdpStructPtr->CSC ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6QspPtr = here->BSIM4v6QspStructPtr->CSC ; + + if ((here-> BSIM4v6qNode != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6QgpPtr = here->BSIM4v6QgpStructPtr->CSC ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6qNode != 0)) + here->BSIM4v6DPqPtr = here->BSIM4v6DPqStructPtr->CSC ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6qNode != 0)) + here->BSIM4v6SPqPtr = here->BSIM4v6SPqStructPtr->CSC ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6qNode != 0)) + here->BSIM4v6GPqPtr = here->BSIM4v6GPqStructPtr->CSC ; + + if (here->BSIM4v6rgateMod != 0) + { + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6gNodeExt != 0)) + here->BSIM4v6GEgePtr = here->BSIM4v6GEgeStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6GEgpPtr = here->BSIM4v6GEgpStructPtr->CSC ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6gNodeExt != 0)) + here->BSIM4v6GPgePtr = here->BSIM4v6GPgeStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6GEdpPtr = here->BSIM4v6GEdpStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6GEspPtr = here->BSIM4v6GEspStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6GEbpPtr = here->BSIM4v6GEbpStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6GMdpPtr = here->BSIM4v6GMdpStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6GMgpPtr = here->BSIM4v6GMgpStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6GMgmPtr = here->BSIM4v6GMgmStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6gNodeExt != 0)) + here->BSIM4v6GMgePtr = here->BSIM4v6GMgeStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6GMspPtr = here->BSIM4v6GMspStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeMid != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6GMbpPtr = here->BSIM4v6GMbpStructPtr->CSC ; + + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6DPgmPtr = here->BSIM4v6DPgmStructPtr->CSC ; + + if ((here-> BSIM4v6gNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6GPgmPtr = here->BSIM4v6GPgmStructPtr->CSC ; + + if ((here-> BSIM4v6gNodeExt != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6GEgmPtr = here->BSIM4v6GEgmStructPtr->CSC ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6SPgmPtr = here->BSIM4v6SPgmStructPtr->CSC ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6gNodeMid != 0)) + here->BSIM4v6BPgmPtr = here->BSIM4v6BPgmStructPtr->CSC ; + + } + if ((here->BSIM4v6rbodyMod ==1) || (here->BSIM4v6rbodyMod ==2)) + { + if ((here-> BSIM4v6dNodePrime != 0) && (here-> BSIM4v6dbNode != 0)) + here->BSIM4v6DPdbPtr = here->BSIM4v6DPdbStructPtr->CSC ; + + if ((here-> BSIM4v6sNodePrime != 0) && (here-> BSIM4v6sbNode != 0)) + here->BSIM4v6SPsbPtr = here->BSIM4v6SPsbStructPtr->CSC ; + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6DBdpPtr = here->BSIM4v6DBdpStructPtr->CSC ; + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6dbNode != 0)) + here->BSIM4v6DBdbPtr = here->BSIM4v6DBdbStructPtr->CSC ; + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6DBbpPtr = here->BSIM4v6DBbpStructPtr->CSC ; + + if ((here-> BSIM4v6dbNode != 0) && (here-> BSIM4v6bNode != 0)) + here->BSIM4v6DBbPtr = here->BSIM4v6DBbStructPtr->CSC ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6dbNode != 0)) + here->BSIM4v6BPdbPtr = here->BSIM4v6BPdbStructPtr->CSC ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6bNode != 0)) + here->BSIM4v6BPbPtr = here->BSIM4v6BPbStructPtr->CSC ; + + if ((here-> BSIM4v6bNodePrime != 0) && (here-> BSIM4v6sbNode != 0)) + here->BSIM4v6BPsbPtr = here->BSIM4v6BPsbStructPtr->CSC ; + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6SBspPtr = here->BSIM4v6SBspStructPtr->CSC ; + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6SBbpPtr = here->BSIM4v6SBbpStructPtr->CSC ; + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6bNode != 0)) + here->BSIM4v6SBbPtr = here->BSIM4v6SBbStructPtr->CSC ; + + if ((here-> BSIM4v6sbNode != 0) && (here-> BSIM4v6sbNode != 0)) + here->BSIM4v6SBsbPtr = here->BSIM4v6SBsbStructPtr->CSC ; + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6dbNode != 0)) + here->BSIM4v6BdbPtr = here->BSIM4v6BdbStructPtr->CSC ; + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6BbpPtr = here->BSIM4v6BbpStructPtr->CSC ; + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6sbNode != 0)) + here->BSIM4v6BsbPtr = here->BSIM4v6BsbStructPtr->CSC ; + + if ((here-> BSIM4v6bNode != 0) && (here-> BSIM4v6bNode != 0)) + here->BSIM4v6BbPtr = here->BSIM4v6BbStructPtr->CSC ; + + } + if (model->BSIM4v6rdsMod) + { + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6DgpPtr = here->BSIM4v6DgpStructPtr->CSC ; + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6sNodePrime != 0)) + here->BSIM4v6DspPtr = here->BSIM4v6DspStructPtr->CSC ; + + if ((here-> BSIM4v6dNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6DbpPtr = here->BSIM4v6DbpStructPtr->CSC ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6dNodePrime != 0)) + here->BSIM4v6SdpPtr = here->BSIM4v6SdpStructPtr->CSC ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6gNodePrime != 0)) + here->BSIM4v6SgpPtr = here->BSIM4v6SgpStructPtr->CSC ; + + if ((here-> BSIM4v6sNode != 0) && (here-> BSIM4v6bNodePrime != 0)) + here->BSIM4v6SbpPtr = here->BSIM4v6SbpStructPtr->CSC ; + + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim4v6/bsim4v6def.h b/src/spicelib/devices/bsim4v6/bsim4v6def.h index 04a5b776b..7804f0cdc 100644 --- a/src/spicelib/devices/bsim4v6/bsim4v6def.h +++ b/src/spicelib/devices/bsim4v6/bsim4v6def.h @@ -566,6 +566,79 @@ typedef struct sBSIM4v6instance double **BSIM4v6nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *BSIM4v6DPbpStructPtr ; + BindElement *BSIM4v6GPbpStructPtr ; + BindElement *BSIM4v6SPbpStructPtr ; + BindElement *BSIM4v6BPdpStructPtr ; + BindElement *BSIM4v6BPgpStructPtr ; + BindElement *BSIM4v6BPspStructPtr ; + BindElement *BSIM4v6BPbpStructPtr ; + BindElement *BSIM4v6DdStructPtr ; + BindElement *BSIM4v6GPgpStructPtr ; + BindElement *BSIM4v6SsStructPtr ; + BindElement *BSIM4v6DPdpStructPtr ; + BindElement *BSIM4v6SPspStructPtr ; + BindElement *BSIM4v6DdpStructPtr ; + BindElement *BSIM4v6GPdpStructPtr ; + BindElement *BSIM4v6GPspStructPtr ; + BindElement *BSIM4v6SspStructPtr ; + BindElement *BSIM4v6DPspStructPtr ; + BindElement *BSIM4v6DPdStructPtr ; + BindElement *BSIM4v6DPgpStructPtr ; + BindElement *BSIM4v6SPgpStructPtr ; + BindElement *BSIM4v6SPsStructPtr ; + BindElement *BSIM4v6SPdpStructPtr ; + BindElement *BSIM4v6QqStructPtr ; + BindElement *BSIM4v6QbpStructPtr ; + BindElement *BSIM4v6QdpStructPtr ; + BindElement *BSIM4v6QspStructPtr ; + BindElement *BSIM4v6QgpStructPtr ; + BindElement *BSIM4v6DPqStructPtr ; + BindElement *BSIM4v6SPqStructPtr ; + BindElement *BSIM4v6GPqStructPtr ; + BindElement *BSIM4v6GEgeStructPtr ; + BindElement *BSIM4v6GEgpStructPtr ; + BindElement *BSIM4v6GPgeStructPtr ; + BindElement *BSIM4v6GEdpStructPtr ; + BindElement *BSIM4v6GEspStructPtr ; + BindElement *BSIM4v6GEbpStructPtr ; + BindElement *BSIM4v6GMdpStructPtr ; + BindElement *BSIM4v6GMgpStructPtr ; + BindElement *BSIM4v6GMgmStructPtr ; + BindElement *BSIM4v6GMgeStructPtr ; + BindElement *BSIM4v6GMspStructPtr ; + BindElement *BSIM4v6GMbpStructPtr ; + BindElement *BSIM4v6DPgmStructPtr ; + BindElement *BSIM4v6GPgmStructPtr ; + BindElement *BSIM4v6GEgmStructPtr ; + BindElement *BSIM4v6SPgmStructPtr ; + BindElement *BSIM4v6BPgmStructPtr ; + BindElement *BSIM4v6DPdbStructPtr ; + BindElement *BSIM4v6SPsbStructPtr ; + BindElement *BSIM4v6DBdpStructPtr ; + BindElement *BSIM4v6DBdbStructPtr ; + BindElement *BSIM4v6DBbpStructPtr ; + BindElement *BSIM4v6DBbStructPtr ; + BindElement *BSIM4v6BPdbStructPtr ; + BindElement *BSIM4v6BPbStructPtr ; + BindElement *BSIM4v6BPsbStructPtr ; + BindElement *BSIM4v6SBspStructPtr ; + BindElement *BSIM4v6SBbpStructPtr ; + BindElement *BSIM4v6SBbStructPtr ; + BindElement *BSIM4v6SBsbStructPtr ; + BindElement *BSIM4v6BdbStructPtr ; + BindElement *BSIM4v6BbpStructPtr ; + BindElement *BSIM4v6BsbStructPtr ; + BindElement *BSIM4v6BbStructPtr ; + BindElement *BSIM4v6DgpStructPtr ; + BindElement *BSIM4v6DspStructPtr ; + BindElement *BSIM4v6DbpStructPtr ; + BindElement *BSIM4v6SdpStructPtr ; + BindElement *BSIM4v6SgpStructPtr ; + BindElement *BSIM4v6SbpStructPtr ; +#endif + } BSIM4v6instance ; struct bsim4v6SizeDependParam diff --git a/src/spicelib/devices/bsim4v6/bsim4v6ext.h b/src/spicelib/devices/bsim4v6/bsim4v6ext.h index c08a6b9b9..dbab8f334 100644 --- a/src/spicelib/devices/bsim4v6/bsim4v6ext.h +++ b/src/spicelib/devices/bsim4v6/bsim4v6ext.h @@ -29,3 +29,9 @@ extern int BSIM4v6trunc(GENmodel*,CKTcircuit*,double*); extern int BSIM4v6noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int BSIM4v6unsetup(GENmodel*,CKTcircuit*); extern int BSIM4v6soaCheck(CKTcircuit *, GENmodel *); + +#ifdef KLU +extern int BSIM4v6bindCSC (GENmodel*, CKTcircuit*) ; +extern int BSIM4v6bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int BSIM4v6bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsim4v6/bsim4v6init.c b/src/spicelib/devices/bsim4v6/bsim4v6init.c index 28cd3e28a..815bd0029 100644 --- a/src/spicelib/devices/bsim4v6/bsim4v6init.c +++ b/src/spicelib/devices/bsim4v6/bsim4v6init.c @@ -73,7 +73,14 @@ SPICEdev BSIM4v6info = { NULL, /* DEVacct */ #endif &BSIM4v6iSize, /* DEVinstSize */ - &BSIM4v6mSize /* DEVmodSize */ + &BSIM4v6mSize, /* DEVmodSize */ + +#ifdef KLU + BSIM4v6bindCSC, /* DEVbindCSC */ + BSIM4v6bindCSCComplex, /* DEVbindCSCComplex */ + BSIM4v6bindCSCComplexToReal, /* DEVbindCSCComplexToReal */ +#endif + }; diff --git a/src/spicelib/devices/bsimsoi/Makefile.am b/src/spicelib/devices/bsimsoi/Makefile.am index ba4676815..7ef42475a 100644 --- a/src/spicelib/devices/bsimsoi/Makefile.am +++ b/src/spicelib/devices/bsimsoi/Makefile.am @@ -29,6 +29,9 @@ libbsim4soi_la_SOURCES = \ b4soiitf.h +if KLU_WANTED +libbsim4soi_la_SOURCES += b4soibindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/bsimsoi/b4soibindCSC.c b/src/spicelib/devices/bsimsoi/b4soibindCSC.c new file mode 100644 index 000000000..a1b4a631e --- /dev/null +++ b/src/spicelib/devices/bsimsoi/b4soibindCSC.c @@ -0,0 +1,1630 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "b4soidef.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +B4SOIbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + B4SOImodel *model = (B4SOImodel *)inModel ; + B4SOIinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the B4SOI models */ + for ( ; model != NULL ; model = model->B4SOInextModel) + { + /* loop through all the instances of the model */ + for (here = model->B4SOIinstances ; here != NULL ; here = here->B4SOInextInstance) + { + if ((model->B4SOIshMod == 1) && (here->B4SOIrth0!=0.0)) + { + if ((here-> B4SOItempNode != 0) && (here-> B4SOItempNode != 0)) + { + i = here->B4SOITemptempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOITemptempStructPtr = matched ; + here->B4SOITemptempPtr = matched->CSC ; + } + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOITempdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOITempdpStructPtr = matched ; + here->B4SOITempdpPtr = matched->CSC ; + } + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOITempspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOITempspStructPtr = matched ; + here->B4SOITempspPtr = matched->CSC ; + } + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOITempgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOITempgStructPtr = matched ; + here->B4SOITempgPtr = matched->CSC ; + } + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOITempbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOITempbStructPtr = matched ; + here->B4SOITempbPtr = matched->CSC ; + } + + if ((here-> B4SOIgNode != 0) && (here-> B4SOItempNode != 0)) + { + i = here->B4SOIGtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGtempStructPtr = matched ; + here->B4SOIGtempPtr = matched->CSC ; + } + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOItempNode != 0)) + { + i = here->B4SOIDPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDPtempStructPtr = matched ; + here->B4SOIDPtempPtr = matched->CSC ; + } + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOItempNode != 0)) + { + i = here->B4SOISPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISPtempStructPtr = matched ; + here->B4SOISPtempPtr = matched->CSC ; + } + + if ((here-> B4SOIeNode != 0) && (here-> B4SOItempNode != 0)) + { + i = here->B4SOIEtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIEtempStructPtr = matched ; + here->B4SOIEtempPtr = matched->CSC ; + } + + if ((here-> B4SOIbNode != 0) && (here-> B4SOItempNode != 0)) + { + i = here->B4SOIBtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIBtempStructPtr = matched ; + here->B4SOIBtempPtr = matched->CSC ; + } + + if (here->B4SOIbodyMod == 1) + { + if ((here-> B4SOIpNode != 0) && (here-> B4SOItempNode != 0)) + { + i = here->B4SOIPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIPtempStructPtr = matched ; + here->B4SOIPtempPtr = matched->CSC ; + } + + } + if (here->B4SOIsoiMod != 0) + { + if ((here-> B4SOItempNode != 0) && (here-> B4SOIeNode != 0)) + { + i = here->B4SOITempePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOITempeStructPtr = matched ; + here->B4SOITempePtr = matched->CSC ; + } + + } + } + if (here->B4SOIbodyMod == 2) + { + } + else if (here->B4SOIbodyMod == 1) + { + if ((here-> B4SOIbNode != 0) && (here-> B4SOIpNode != 0)) + { + i = here->B4SOIBpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIBpStructPtr = matched ; + here->B4SOIBpPtr = matched->CSC ; + } + + if ((here-> B4SOIpNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIPbStructPtr = matched ; + here->B4SOIPbPtr = matched->CSC ; + } + + if ((here-> B4SOIpNode != 0) && (here-> B4SOIpNode != 0)) + { + i = here->B4SOIPpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIPpStructPtr = matched ; + here->B4SOIPpPtr = matched->CSC ; + } + + if ((here-> B4SOIpNode != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOIPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIPgStructPtr = matched ; + here->B4SOIPgPtr = matched->CSC ; + } + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIpNode != 0)) + { + i = here->B4SOIGpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGpStructPtr = matched ; + here->B4SOIGpPtr = matched->CSC ; + } + + } + if (here->B4SOIrgateMod != 0) + { + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIgNodeExt != 0)) + { + i = here->B4SOIGEgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGEgeStructPtr = matched ; + here->B4SOIGEgePtr = matched->CSC ; + } + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOIGEgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGEgStructPtr = matched ; + here->B4SOIGEgPtr = matched->CSC ; + } + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIgNodeExt != 0)) + { + i = here->B4SOIGgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGgeStructPtr = matched ; + here->B4SOIGgePtr = matched->CSC ; + } + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOIGEdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGEdpStructPtr = matched ; + here->B4SOIGEdpPtr = matched->CSC ; + } + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOIGEspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGEspStructPtr = matched ; + here->B4SOIGEspPtr = matched->CSC ; + } + + if (here->B4SOIsoiMod !=2) + { + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIGEbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGEbStructPtr = matched ; + here->B4SOIGEbPtr = matched->CSC ; + } + + } + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOIGMdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGMdpStructPtr = matched ; + here->B4SOIGMdpPtr = matched->CSC ; + } + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOIGMgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGMgStructPtr = matched ; + here->B4SOIGMgPtr = matched->CSC ; + } + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIgNodeMid != 0)) + { + i = here->B4SOIGMgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGMgmStructPtr = matched ; + here->B4SOIGMgmPtr = matched->CSC ; + } + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIgNodeExt != 0)) + { + i = here->B4SOIGMgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGMgeStructPtr = matched ; + here->B4SOIGMgePtr = matched->CSC ; + } + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOIGMspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGMspStructPtr = matched ; + here->B4SOIGMspPtr = matched->CSC ; + } + + if (here->B4SOIsoiMod !=2) + { + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIGMbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGMbStructPtr = matched ; + here->B4SOIGMbPtr = matched->CSC ; + } + + } + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIeNode != 0)) + { + i = here->B4SOIGMePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGMeStructPtr = matched ; + here->B4SOIGMePtr = matched->CSC ; + } + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIgNodeMid != 0)) + { + i = here->B4SOIDPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDPgmStructPtr = matched ; + here->B4SOIDPgmPtr = matched->CSC ; + } + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIgNodeMid != 0)) + { + i = here->B4SOIGgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGgmStructPtr = matched ; + here->B4SOIGgmPtr = matched->CSC ; + } + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIgNodeMid != 0)) + { + i = here->B4SOIGEgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGEgmStructPtr = matched ; + here->B4SOIGEgmPtr = matched->CSC ; + } + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIgNodeMid != 0)) + { + i = here->B4SOISPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISPgmStructPtr = matched ; + here->B4SOISPgmPtr = matched->CSC ; + } + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIgNodeMid != 0)) + { + i = here->B4SOIEgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIEgmStructPtr = matched ; + here->B4SOIEgmPtr = matched->CSC ; + } + + } + if (here->B4SOIsoiMod != 2) /* v3.2 */ + { + if ((here-> B4SOIeNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIEbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIEbStructPtr = matched ; + here->B4SOIEbPtr = matched->CSC ; + } + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIGbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGbStructPtr = matched ; + here->B4SOIGbPtr = matched->CSC ; + } + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIDPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDPbStructPtr = matched ; + here->B4SOIDPbPtr = matched->CSC ; + } + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOISPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISPbStructPtr = matched ; + here->B4SOISPbPtr = matched->CSC ; + } + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIeNode != 0)) + { + i = here->B4SOIBePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIBeStructPtr = matched ; + here->B4SOIBePtr = matched->CSC ; + } + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOIBgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIBgStructPtr = matched ; + here->B4SOIBgPtr = matched->CSC ; + } + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOIBdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIBdpStructPtr = matched ; + here->B4SOIBdpPtr = matched->CSC ; + } + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOIBspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIBspStructPtr = matched ; + here->B4SOIBspPtr = matched->CSC ; + } + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIBbStructPtr = matched ; + here->B4SOIBbPtr = matched->CSC ; + } + + } + if ((here-> B4SOIeNode != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOIEgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIEgStructPtr = matched ; + here->B4SOIEgPtr = matched->CSC ; + } + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOIEdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIEdpStructPtr = matched ; + here->B4SOIEdpPtr = matched->CSC ; + } + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOIEspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIEspStructPtr = matched ; + here->B4SOIEspPtr = matched->CSC ; + } + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIeNode != 0)) + { + i = here->B4SOIGePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGeStructPtr = matched ; + here->B4SOIGePtr = matched->CSC ; + } + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIeNode != 0)) + { + i = here->B4SOIDPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDPeStructPtr = matched ; + here->B4SOIDPePtr = matched->CSC ; + } + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIeNode != 0)) + { + i = here->B4SOISPePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISPeStructPtr = matched ; + here->B4SOISPePtr = matched->CSC ; + } + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIEbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIEbStructPtr = matched ; + here->B4SOIEbPtr = matched->CSC ; + } + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIeNode != 0)) + { + i = here->B4SOIEePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIEeStructPtr = matched ; + here->B4SOIEePtr = matched->CSC ; + } + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOIGgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGgStructPtr = matched ; + here->B4SOIGgPtr = matched->CSC ; + } + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOIGdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGdpStructPtr = matched ; + here->B4SOIGdpPtr = matched->CSC ; + } + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOIGspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGspStructPtr = matched ; + here->B4SOIGspPtr = matched->CSC ; + } + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOIDPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDPgStructPtr = matched ; + here->B4SOIDPgPtr = matched->CSC ; + } + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOIDPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDPdpStructPtr = matched ; + here->B4SOIDPdpPtr = matched->CSC ; + } + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOIDPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDPspStructPtr = matched ; + here->B4SOIDPspPtr = matched->CSC ; + } + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIdNode != 0)) + { + i = here->B4SOIDPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDPdStructPtr = matched ; + here->B4SOIDPdPtr = matched->CSC ; + } + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOISPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISPgStructPtr = matched ; + here->B4SOISPgPtr = matched->CSC ; + } + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOISPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISPdpStructPtr = matched ; + here->B4SOISPdpPtr = matched->CSC ; + } + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOISPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISPspStructPtr = matched ; + here->B4SOISPspPtr = matched->CSC ; + } + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIsNode != 0)) + { + i = here->B4SOISPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISPsStructPtr = matched ; + here->B4SOISPsPtr = matched->CSC ; + } + + if ((here-> B4SOIdNode != 0) && (here-> B4SOIdNode != 0)) + { + i = here->B4SOIDdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDdStructPtr = matched ; + here->B4SOIDdPtr = matched->CSC ; + } + + if ((here-> B4SOIdNode != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOIDdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDdpStructPtr = matched ; + here->B4SOIDdpPtr = matched->CSC ; + } + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIsNode != 0)) + { + i = here->B4SOISsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISsStructPtr = matched ; + here->B4SOISsPtr = matched->CSC ; + } + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOISspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISspStructPtr = matched ; + here->B4SOISspPtr = matched->CSC ; + } + + if (here->B4SOIrbodyMod == 1) + { + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIdbNode != 0)) + { + i = here->B4SOIDPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDPdbStructPtr = matched ; + here->B4SOIDPdbPtr = matched->CSC ; + } + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIsbNode != 0)) + { + i = here->B4SOISPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISPsbStructPtr = matched ; + here->B4SOISPsbPtr = matched->CSC ; + } + + if ((here-> B4SOIdbNode != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOIDBdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDBdpStructPtr = matched ; + here->B4SOIDBdpPtr = matched->CSC ; + } + + if ((here-> B4SOIdbNode != 0) && (here-> B4SOIdbNode != 0)) + { + i = here->B4SOIDBdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDBdbStructPtr = matched ; + here->B4SOIDBdbPtr = matched->CSC ; + } + + if ((here-> B4SOIdbNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIDBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDBbStructPtr = matched ; + here->B4SOIDBbPtr = matched->CSC ; + } + + if ((here-> B4SOIsbNode != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOISBspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISBspStructPtr = matched ; + here->B4SOISBspPtr = matched->CSC ; + } + + if ((here-> B4SOIsbNode != 0) && (here-> B4SOIsbNode != 0)) + { + i = here->B4SOISBsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISBsbStructPtr = matched ; + here->B4SOISBsbPtr = matched->CSC ; + } + + if ((here-> B4SOIsbNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOISBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISBbStructPtr = matched ; + here->B4SOISBbPtr = matched->CSC ; + } + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIdbNode != 0)) + { + i = here->B4SOIBdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIBdbStructPtr = matched ; + here->B4SOIBdbPtr = matched->CSC ; + } + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIsbNode != 0)) + { + i = here->B4SOIBsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIBsbStructPtr = matched ; + here->B4SOIBsbPtr = matched->CSC ; + } + + } + if (model->B4SOIrdsMod) + { + if ((here-> B4SOIdNode != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOIDgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDgStructPtr = matched ; + here->B4SOIDgPtr = matched->CSC ; + } + + if ((here-> B4SOIdNode != 0) && (here-> B4SOIsNodePrime != 0)) + { + i = here->B4SOIDspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDspStructPtr = matched ; + here->B4SOIDspPtr = matched->CSC ; + } + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIdNodePrime != 0)) + { + i = here->B4SOISdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISdpStructPtr = matched ; + here->B4SOISdpPtr = matched->CSC ; + } + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIgNode != 0)) + { + i = here->B4SOISgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISgStructPtr = matched ; + here->B4SOISgPtr = matched->CSC ; + } + + if (model->B4SOIsoiMod != 2) + { + if ((here-> B4SOIdNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOIDbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIDbStructPtr = matched ; + here->B4SOIDbPtr = matched->CSC ; + } + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIbNode != 0)) + { + i = here->B4SOISbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOISbStructPtr = matched ; + here->B4SOISbPtr = matched->CSC ; + } + + } + } + if (here->B4SOIdebugMod != 0) + { + if ((here-> B4SOIvbsNode != 0) && (here-> B4SOIvbsNode != 0)) + { + i = here->B4SOIVbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIVbsStructPtr = matched ; + here->B4SOIVbsPtr = matched->CSC ; + } + + if ((here-> B4SOIidsNode != 0) && (here-> B4SOIidsNode != 0)) + { + i = here->B4SOIIdsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIIdsStructPtr = matched ; + here->B4SOIIdsPtr = matched->CSC ; + } + + if ((here-> B4SOIicNode != 0) && (here-> B4SOIicNode != 0)) + { + i = here->B4SOIIcPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIIcStructPtr = matched ; + here->B4SOIIcPtr = matched->CSC ; + } + + if ((here-> B4SOIibsNode != 0) && (here-> B4SOIibsNode != 0)) + { + i = here->B4SOIIbsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIIbsStructPtr = matched ; + here->B4SOIIbsPtr = matched->CSC ; + } + + if ((here-> B4SOIibdNode != 0) && (here-> B4SOIibdNode != 0)) + { + i = here->B4SOIIbdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIIbdStructPtr = matched ; + here->B4SOIIbdPtr = matched->CSC ; + } + + if ((here-> B4SOIiiiNode != 0) && (here-> B4SOIiiiNode != 0)) + { + i = here->B4SOIIiiPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIIiiStructPtr = matched ; + here->B4SOIIiiPtr = matched->CSC ; + } + + if ((here-> B4SOIigNode != 0) && (here-> B4SOIigNode != 0)) + { + i = here->B4SOIIgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIIgStructPtr = matched ; + here->B4SOIIgPtr = matched->CSC ; + } + + if ((here-> B4SOIgiggNode != 0) && (here-> B4SOIgiggNode != 0)) + { + i = here->B4SOIGiggPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGiggStructPtr = matched ; + here->B4SOIGiggPtr = matched->CSC ; + } + + if ((here-> B4SOIgigdNode != 0) && (here-> B4SOIgigdNode != 0)) + { + i = here->B4SOIGigdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGigdStructPtr = matched ; + here->B4SOIGigdPtr = matched->CSC ; + } + + if ((here-> B4SOIgigbNode != 0) && (here-> B4SOIgigbNode != 0)) + { + i = here->B4SOIGigbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIGigbStructPtr = matched ; + here->B4SOIGigbPtr = matched->CSC ; + } + + if ((here-> B4SOIigidlNode != 0) && (here-> B4SOIigidlNode != 0)) + { + i = here->B4SOIIgidlPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIIgidlStructPtr = matched ; + here->B4SOIIgidlPtr = matched->CSC ; + } + + if ((here-> B4SOIitunNode != 0) && (here-> B4SOIitunNode != 0)) + { + i = here->B4SOIItunPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIItunStructPtr = matched ; + here->B4SOIItunPtr = matched->CSC ; + } + + if ((here-> B4SOIibpNode != 0) && (here-> B4SOIibpNode != 0)) + { + i = here->B4SOIIbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIIbpStructPtr = matched ; + here->B4SOIIbpPtr = matched->CSC ; + } + + if ((here-> B4SOIcbbNode != 0) && (here-> B4SOIcbbNode != 0)) + { + i = here->B4SOICbbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOICbbStructPtr = matched ; + here->B4SOICbbPtr = matched->CSC ; + } + + if ((here-> B4SOIcbdNode != 0) && (here-> B4SOIcbdNode != 0)) + { + i = here->B4SOICbdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOICbdStructPtr = matched ; + here->B4SOICbdPtr = matched->CSC ; + } + + if ((here-> B4SOIcbgNode != 0) && (here-> B4SOIcbgNode != 0)) + { + i = here->B4SOICbgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOICbgStructPtr = matched ; + here->B4SOICbgPtr = matched->CSC ; + } + + if ((here-> B4SOIqbfNode != 0) && (here-> B4SOIqbfNode != 0)) + { + i = here->B4SOIQbfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIQbfStructPtr = matched ; + here->B4SOIQbfPtr = matched->CSC ; + } + + if ((here-> B4SOIqjsNode != 0) && (here-> B4SOIqjsNode != 0)) + { + i = here->B4SOIQjsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIQjsStructPtr = matched ; + here->B4SOIQjsPtr = matched->CSC ; + } + + if ((here-> B4SOIqjdNode != 0) && (here-> B4SOIqjdNode != 0)) + { + i = here->B4SOIQjdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->B4SOIQjdStructPtr = matched ; + here->B4SOIQjdPtr = matched->CSC ; + } + + } + } + } + + return (OK) ; +} + +int +B4SOIbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + B4SOImodel *model = (B4SOImodel *)inModel ; + B4SOIinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B4SOI models */ + for ( ; model != NULL ; model = model->B4SOInextModel) + { + /* loop through all the instances of the model */ + for (here = model->B4SOIinstances ; here != NULL ; here = here->B4SOInextInstance) + { + if ((model->B4SOIshMod == 1) && (here->B4SOIrth0!=0.0)) + { + if ((here-> B4SOItempNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOITemptempPtr = here->B4SOITemptempStructPtr->CSC_Complex ; + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOITempdpPtr = here->B4SOITempdpStructPtr->CSC_Complex ; + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOITempspPtr = here->B4SOITempspStructPtr->CSC_Complex ; + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOITempgPtr = here->B4SOITempgStructPtr->CSC_Complex ; + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOITempbPtr = here->B4SOITempbStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIGtempPtr = here->B4SOIGtempStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIDPtempPtr = here->B4SOIDPtempStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOItempNode != 0)) + here->B4SOISPtempPtr = here->B4SOISPtempStructPtr->CSC_Complex ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIEtempPtr = here->B4SOIEtempStructPtr->CSC_Complex ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIBtempPtr = here->B4SOIBtempStructPtr->CSC_Complex ; + + if (here->B4SOIbodyMod == 1) + { + if ((here-> B4SOIpNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIPtempPtr = here->B4SOIPtempStructPtr->CSC_Complex ; + + } + if (here->B4SOIsoiMod != 0) + { + if ((here-> B4SOItempNode != 0) && (here-> B4SOIeNode != 0)) + here->B4SOITempePtr = here->B4SOITempeStructPtr->CSC_Complex ; + + } + } + if (here->B4SOIbodyMod == 2) + { + } + else if (here->B4SOIbodyMod == 1) + { + if ((here-> B4SOIbNode != 0) && (here-> B4SOIpNode != 0)) + here->B4SOIBpPtr = here->B4SOIBpStructPtr->CSC_Complex ; + + if ((here-> B4SOIpNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIPbPtr = here->B4SOIPbStructPtr->CSC_Complex ; + + if ((here-> B4SOIpNode != 0) && (here-> B4SOIpNode != 0)) + here->B4SOIPpPtr = here->B4SOIPpStructPtr->CSC_Complex ; + + if ((here-> B4SOIpNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIPgPtr = here->B4SOIPgStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIpNode != 0)) + here->B4SOIGpPtr = here->B4SOIGpStructPtr->CSC_Complex ; + + } + if (here->B4SOIrgateMod != 0) + { + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIgNodeExt != 0)) + here->B4SOIGEgePtr = here->B4SOIGEgeStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIGEgPtr = here->B4SOIGEgStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIgNodeExt != 0)) + here->B4SOIGgePtr = here->B4SOIGgeStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIGEdpPtr = here->B4SOIGEdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIGEspPtr = here->B4SOIGEspStructPtr->CSC_Complex ; + + if (here->B4SOIsoiMod !=2) + { + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIGEbPtr = here->B4SOIGEbStructPtr->CSC_Complex ; + + } + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIGMdpPtr = here->B4SOIGMdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIGMgPtr = here->B4SOIGMgStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIGMgmPtr = here->B4SOIGMgmStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIgNodeExt != 0)) + here->B4SOIGMgePtr = here->B4SOIGMgeStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIGMspPtr = here->B4SOIGMspStructPtr->CSC_Complex ; + + if (here->B4SOIsoiMod !=2) + { + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIGMbPtr = here->B4SOIGMbStructPtr->CSC_Complex ; + + } + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIGMePtr = here->B4SOIGMeStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIDPgmPtr = here->B4SOIDPgmStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIGgmPtr = here->B4SOIGgmStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIGEgmPtr = here->B4SOIGEgmStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOISPgmPtr = here->B4SOISPgmStructPtr->CSC_Complex ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIEgmPtr = here->B4SOIEgmStructPtr->CSC_Complex ; + + } + if (here->B4SOIsoiMod != 2) /* v3.2 */ + { + if ((here-> B4SOIeNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIEbPtr = here->B4SOIEbStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIGbPtr = here->B4SOIGbStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIDPbPtr = here->B4SOIDPbStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIbNode != 0)) + here->B4SOISPbPtr = here->B4SOISPbStructPtr->CSC_Complex ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIBePtr = here->B4SOIBeStructPtr->CSC_Complex ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIBgPtr = here->B4SOIBgStructPtr->CSC_Complex ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIBdpPtr = here->B4SOIBdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIBspPtr = here->B4SOIBspStructPtr->CSC_Complex ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIBbPtr = here->B4SOIBbStructPtr->CSC_Complex ; + + } + if ((here-> B4SOIeNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIEgPtr = here->B4SOIEgStructPtr->CSC_Complex ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIEdpPtr = here->B4SOIEdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIEspPtr = here->B4SOIEspStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIGePtr = here->B4SOIGeStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIDPePtr = here->B4SOIDPeStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIeNode != 0)) + here->B4SOISPePtr = here->B4SOISPeStructPtr->CSC_Complex ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIEbPtr = here->B4SOIEbStructPtr->CSC_Complex ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIEePtr = here->B4SOIEeStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIGgPtr = here->B4SOIGgStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIGdpPtr = here->B4SOIGdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIGspPtr = here->B4SOIGspStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIDPgPtr = here->B4SOIDPgStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIDPdpPtr = here->B4SOIDPdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIDPspPtr = here->B4SOIDPspStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIdNode != 0)) + here->B4SOIDPdPtr = here->B4SOIDPdStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIgNode != 0)) + here->B4SOISPgPtr = here->B4SOISPgStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOISPdpPtr = here->B4SOISPdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOISPspPtr = here->B4SOISPspStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIsNode != 0)) + here->B4SOISPsPtr = here->B4SOISPsStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNode != 0) && (here-> B4SOIdNode != 0)) + here->B4SOIDdPtr = here->B4SOIDdStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIDdpPtr = here->B4SOIDdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIsNode != 0)) + here->B4SOISsPtr = here->B4SOISsStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOISspPtr = here->B4SOISspStructPtr->CSC_Complex ; + + if (here->B4SOIrbodyMod == 1) + { + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIdbNode != 0)) + here->B4SOIDPdbPtr = here->B4SOIDPdbStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIsbNode != 0)) + here->B4SOISPsbPtr = here->B4SOISPsbStructPtr->CSC_Complex ; + + if ((here-> B4SOIdbNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIDBdpPtr = here->B4SOIDBdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIdbNode != 0) && (here-> B4SOIdbNode != 0)) + here->B4SOIDBdbPtr = here->B4SOIDBdbStructPtr->CSC_Complex ; + + if ((here-> B4SOIdbNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIDBbPtr = here->B4SOIDBbStructPtr->CSC_Complex ; + + if ((here-> B4SOIsbNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOISBspPtr = here->B4SOISBspStructPtr->CSC_Complex ; + + if ((here-> B4SOIsbNode != 0) && (here-> B4SOIsbNode != 0)) + here->B4SOISBsbPtr = here->B4SOISBsbStructPtr->CSC_Complex ; + + if ((here-> B4SOIsbNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOISBbPtr = here->B4SOISBbStructPtr->CSC_Complex ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIdbNode != 0)) + here->B4SOIBdbPtr = here->B4SOIBdbStructPtr->CSC_Complex ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIsbNode != 0)) + here->B4SOIBsbPtr = here->B4SOIBsbStructPtr->CSC_Complex ; + + } + if (model->B4SOIrdsMod) + { + if ((here-> B4SOIdNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIDgPtr = here->B4SOIDgStructPtr->CSC_Complex ; + + if ((here-> B4SOIdNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIDspPtr = here->B4SOIDspStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOISdpPtr = here->B4SOISdpStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOISgPtr = here->B4SOISgStructPtr->CSC_Complex ; + + if (model->B4SOIsoiMod != 2) + { + if ((here-> B4SOIdNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIDbPtr = here->B4SOIDbStructPtr->CSC_Complex ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOISbPtr = here->B4SOISbStructPtr->CSC_Complex ; + + } + } + if (here->B4SOIdebugMod != 0) + { + if ((here-> B4SOIvbsNode != 0) && (here-> B4SOIvbsNode != 0)) + here->B4SOIVbsPtr = here->B4SOIVbsStructPtr->CSC_Complex ; + + if ((here-> B4SOIidsNode != 0) && (here-> B4SOIidsNode != 0)) + here->B4SOIIdsPtr = here->B4SOIIdsStructPtr->CSC_Complex ; + + if ((here-> B4SOIicNode != 0) && (here-> B4SOIicNode != 0)) + here->B4SOIIcPtr = here->B4SOIIcStructPtr->CSC_Complex ; + + if ((here-> B4SOIibsNode != 0) && (here-> B4SOIibsNode != 0)) + here->B4SOIIbsPtr = here->B4SOIIbsStructPtr->CSC_Complex ; + + if ((here-> B4SOIibdNode != 0) && (here-> B4SOIibdNode != 0)) + here->B4SOIIbdPtr = here->B4SOIIbdStructPtr->CSC_Complex ; + + if ((here-> B4SOIiiiNode != 0) && (here-> B4SOIiiiNode != 0)) + here->B4SOIIiiPtr = here->B4SOIIiiStructPtr->CSC_Complex ; + + if ((here-> B4SOIigNode != 0) && (here-> B4SOIigNode != 0)) + here->B4SOIIgPtr = here->B4SOIIgStructPtr->CSC_Complex ; + + if ((here-> B4SOIgiggNode != 0) && (here-> B4SOIgiggNode != 0)) + here->B4SOIGiggPtr = here->B4SOIGiggStructPtr->CSC_Complex ; + + if ((here-> B4SOIgigdNode != 0) && (here-> B4SOIgigdNode != 0)) + here->B4SOIGigdPtr = here->B4SOIGigdStructPtr->CSC_Complex ; + + if ((here-> B4SOIgigbNode != 0) && (here-> B4SOIgigbNode != 0)) + here->B4SOIGigbPtr = here->B4SOIGigbStructPtr->CSC_Complex ; + + if ((here-> B4SOIigidlNode != 0) && (here-> B4SOIigidlNode != 0)) + here->B4SOIIgidlPtr = here->B4SOIIgidlStructPtr->CSC_Complex ; + + if ((here-> B4SOIitunNode != 0) && (here-> B4SOIitunNode != 0)) + here->B4SOIItunPtr = here->B4SOIItunStructPtr->CSC_Complex ; + + if ((here-> B4SOIibpNode != 0) && (here-> B4SOIibpNode != 0)) + here->B4SOIIbpPtr = here->B4SOIIbpStructPtr->CSC_Complex ; + + if ((here-> B4SOIcbbNode != 0) && (here-> B4SOIcbbNode != 0)) + here->B4SOICbbPtr = here->B4SOICbbStructPtr->CSC_Complex ; + + if ((here-> B4SOIcbdNode != 0) && (here-> B4SOIcbdNode != 0)) + here->B4SOICbdPtr = here->B4SOICbdStructPtr->CSC_Complex ; + + if ((here-> B4SOIcbgNode != 0) && (here-> B4SOIcbgNode != 0)) + here->B4SOICbgPtr = here->B4SOICbgStructPtr->CSC_Complex ; + + if ((here-> B4SOIqbfNode != 0) && (here-> B4SOIqbfNode != 0)) + here->B4SOIQbfPtr = here->B4SOIQbfStructPtr->CSC_Complex ; + + if ((here-> B4SOIqjsNode != 0) && (here-> B4SOIqjsNode != 0)) + here->B4SOIQjsPtr = here->B4SOIQjsStructPtr->CSC_Complex ; + + if ((here-> B4SOIqjdNode != 0) && (here-> B4SOIqjdNode != 0)) + here->B4SOIQjdPtr = here->B4SOIQjdStructPtr->CSC_Complex ; + + } + } + } + + return (OK) ; +} + +int +B4SOIbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + B4SOImodel *model = (B4SOImodel *)inModel ; + B4SOIinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the B4SOI models */ + for ( ; model != NULL ; model = model->B4SOInextModel) + { + /* loop through all the instances of the model */ + for (here = model->B4SOIinstances ; here != NULL ; here = here->B4SOInextInstance) + { + if ((model->B4SOIshMod == 1) && (here->B4SOIrth0!=0.0)) + { + if ((here-> B4SOItempNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOITemptempPtr = here->B4SOITemptempStructPtr->CSC ; + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOITempdpPtr = here->B4SOITempdpStructPtr->CSC ; + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOITempspPtr = here->B4SOITempspStructPtr->CSC ; + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOITempgPtr = here->B4SOITempgStructPtr->CSC ; + + if ((here-> B4SOItempNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOITempbPtr = here->B4SOITempbStructPtr->CSC ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIGtempPtr = here->B4SOIGtempStructPtr->CSC ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIDPtempPtr = here->B4SOIDPtempStructPtr->CSC ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOItempNode != 0)) + here->B4SOISPtempPtr = here->B4SOISPtempStructPtr->CSC ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIEtempPtr = here->B4SOIEtempStructPtr->CSC ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIBtempPtr = here->B4SOIBtempStructPtr->CSC ; + + if (here->B4SOIbodyMod == 1) + { + if ((here-> B4SOIpNode != 0) && (here-> B4SOItempNode != 0)) + here->B4SOIPtempPtr = here->B4SOIPtempStructPtr->CSC ; + + } + if (here->B4SOIsoiMod != 0) + { + if ((here-> B4SOItempNode != 0) && (here-> B4SOIeNode != 0)) + here->B4SOITempePtr = here->B4SOITempeStructPtr->CSC ; + + } + } + if (here->B4SOIbodyMod == 2) + { + } + else if (here->B4SOIbodyMod == 1) + { + if ((here-> B4SOIbNode != 0) && (here-> B4SOIpNode != 0)) + here->B4SOIBpPtr = here->B4SOIBpStructPtr->CSC ; + + if ((here-> B4SOIpNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIPbPtr = here->B4SOIPbStructPtr->CSC ; + + if ((here-> B4SOIpNode != 0) && (here-> B4SOIpNode != 0)) + here->B4SOIPpPtr = here->B4SOIPpStructPtr->CSC ; + + if ((here-> B4SOIpNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIPgPtr = here->B4SOIPgStructPtr->CSC ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIpNode != 0)) + here->B4SOIGpPtr = here->B4SOIGpStructPtr->CSC ; + + } + if (here->B4SOIrgateMod != 0) + { + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIgNodeExt != 0)) + here->B4SOIGEgePtr = here->B4SOIGEgeStructPtr->CSC ; + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIGEgPtr = here->B4SOIGEgStructPtr->CSC ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIgNodeExt != 0)) + here->B4SOIGgePtr = here->B4SOIGgeStructPtr->CSC ; + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIGEdpPtr = here->B4SOIGEdpStructPtr->CSC ; + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIGEspPtr = here->B4SOIGEspStructPtr->CSC ; + + if (here->B4SOIsoiMod !=2) + { + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIGEbPtr = here->B4SOIGEbStructPtr->CSC ; + + } + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIGMdpPtr = here->B4SOIGMdpStructPtr->CSC ; + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIGMgPtr = here->B4SOIGMgStructPtr->CSC ; + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIGMgmPtr = here->B4SOIGMgmStructPtr->CSC ; + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIgNodeExt != 0)) + here->B4SOIGMgePtr = here->B4SOIGMgeStructPtr->CSC ; + + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIGMspPtr = here->B4SOIGMspStructPtr->CSC ; + + if (here->B4SOIsoiMod !=2) + { + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIGMbPtr = here->B4SOIGMbStructPtr->CSC ; + + } + if ((here-> B4SOIgNodeMid != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIGMePtr = here->B4SOIGMeStructPtr->CSC ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIDPgmPtr = here->B4SOIDPgmStructPtr->CSC ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIGgmPtr = here->B4SOIGgmStructPtr->CSC ; + + if ((here-> B4SOIgNodeExt != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIGEgmPtr = here->B4SOIGEgmStructPtr->CSC ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOISPgmPtr = here->B4SOISPgmStructPtr->CSC ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIgNodeMid != 0)) + here->B4SOIEgmPtr = here->B4SOIEgmStructPtr->CSC ; + + } + if (here->B4SOIsoiMod != 2) /* v3.2 */ + { + if ((here-> B4SOIeNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIEbPtr = here->B4SOIEbStructPtr->CSC ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIGbPtr = here->B4SOIGbStructPtr->CSC ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIDPbPtr = here->B4SOIDPbStructPtr->CSC ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIbNode != 0)) + here->B4SOISPbPtr = here->B4SOISPbStructPtr->CSC ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIBePtr = here->B4SOIBeStructPtr->CSC ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIBgPtr = here->B4SOIBgStructPtr->CSC ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIBdpPtr = here->B4SOIBdpStructPtr->CSC ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIBspPtr = here->B4SOIBspStructPtr->CSC ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIBbPtr = here->B4SOIBbStructPtr->CSC ; + + } + if ((here-> B4SOIeNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIEgPtr = here->B4SOIEgStructPtr->CSC ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIEdpPtr = here->B4SOIEdpStructPtr->CSC ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIEspPtr = here->B4SOIEspStructPtr->CSC ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIGePtr = here->B4SOIGeStructPtr->CSC ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIDPePtr = here->B4SOIDPeStructPtr->CSC ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIeNode != 0)) + here->B4SOISPePtr = here->B4SOISPeStructPtr->CSC ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIEbPtr = here->B4SOIEbStructPtr->CSC ; + + if ((here-> B4SOIeNode != 0) && (here-> B4SOIeNode != 0)) + here->B4SOIEePtr = here->B4SOIEeStructPtr->CSC ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIGgPtr = here->B4SOIGgStructPtr->CSC ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIGdpPtr = here->B4SOIGdpStructPtr->CSC ; + + if ((here-> B4SOIgNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIGspPtr = here->B4SOIGspStructPtr->CSC ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIDPgPtr = here->B4SOIDPgStructPtr->CSC ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIDPdpPtr = here->B4SOIDPdpStructPtr->CSC ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIDPspPtr = here->B4SOIDPspStructPtr->CSC ; + + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIdNode != 0)) + here->B4SOIDPdPtr = here->B4SOIDPdStructPtr->CSC ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIgNode != 0)) + here->B4SOISPgPtr = here->B4SOISPgStructPtr->CSC ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOISPdpPtr = here->B4SOISPdpStructPtr->CSC ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOISPspPtr = here->B4SOISPspStructPtr->CSC ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIsNode != 0)) + here->B4SOISPsPtr = here->B4SOISPsStructPtr->CSC ; + + if ((here-> B4SOIdNode != 0) && (here-> B4SOIdNode != 0)) + here->B4SOIDdPtr = here->B4SOIDdStructPtr->CSC ; + + if ((here-> B4SOIdNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIDdpPtr = here->B4SOIDdpStructPtr->CSC ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIsNode != 0)) + here->B4SOISsPtr = here->B4SOISsStructPtr->CSC ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOISspPtr = here->B4SOISspStructPtr->CSC ; + + if (here->B4SOIrbodyMod == 1) + { + if ((here-> B4SOIdNodePrime != 0) && (here-> B4SOIdbNode != 0)) + here->B4SOIDPdbPtr = here->B4SOIDPdbStructPtr->CSC ; + + if ((here-> B4SOIsNodePrime != 0) && (here-> B4SOIsbNode != 0)) + here->B4SOISPsbPtr = here->B4SOISPsbStructPtr->CSC ; + + if ((here-> B4SOIdbNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOIDBdpPtr = here->B4SOIDBdpStructPtr->CSC ; + + if ((here-> B4SOIdbNode != 0) && (here-> B4SOIdbNode != 0)) + here->B4SOIDBdbPtr = here->B4SOIDBdbStructPtr->CSC ; + + if ((here-> B4SOIdbNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIDBbPtr = here->B4SOIDBbStructPtr->CSC ; + + if ((here-> B4SOIsbNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOISBspPtr = here->B4SOISBspStructPtr->CSC ; + + if ((here-> B4SOIsbNode != 0) && (here-> B4SOIsbNode != 0)) + here->B4SOISBsbPtr = here->B4SOISBsbStructPtr->CSC ; + + if ((here-> B4SOIsbNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOISBbPtr = here->B4SOISBbStructPtr->CSC ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIdbNode != 0)) + here->B4SOIBdbPtr = here->B4SOIBdbStructPtr->CSC ; + + if ((here-> B4SOIbNode != 0) && (here-> B4SOIsbNode != 0)) + here->B4SOIBsbPtr = here->B4SOIBsbStructPtr->CSC ; + + } + if (model->B4SOIrdsMod) + { + if ((here-> B4SOIdNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOIDgPtr = here->B4SOIDgStructPtr->CSC ; + + if ((here-> B4SOIdNode != 0) && (here-> B4SOIsNodePrime != 0)) + here->B4SOIDspPtr = here->B4SOIDspStructPtr->CSC ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIdNodePrime != 0)) + here->B4SOISdpPtr = here->B4SOISdpStructPtr->CSC ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIgNode != 0)) + here->B4SOISgPtr = here->B4SOISgStructPtr->CSC ; + + if (model->B4SOIsoiMod != 2) + { + if ((here-> B4SOIdNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOIDbPtr = here->B4SOIDbStructPtr->CSC ; + + if ((here-> B4SOIsNode != 0) && (here-> B4SOIbNode != 0)) + here->B4SOISbPtr = here->B4SOISbStructPtr->CSC ; + + } + } + if (here->B4SOIdebugMod != 0) + { + if ((here-> B4SOIvbsNode != 0) && (here-> B4SOIvbsNode != 0)) + here->B4SOIVbsPtr = here->B4SOIVbsStructPtr->CSC ; + + if ((here-> B4SOIidsNode != 0) && (here-> B4SOIidsNode != 0)) + here->B4SOIIdsPtr = here->B4SOIIdsStructPtr->CSC ; + + if ((here-> B4SOIicNode != 0) && (here-> B4SOIicNode != 0)) + here->B4SOIIcPtr = here->B4SOIIcStructPtr->CSC ; + + if ((here-> B4SOIibsNode != 0) && (here-> B4SOIibsNode != 0)) + here->B4SOIIbsPtr = here->B4SOIIbsStructPtr->CSC ; + + if ((here-> B4SOIibdNode != 0) && (here-> B4SOIibdNode != 0)) + here->B4SOIIbdPtr = here->B4SOIIbdStructPtr->CSC ; + + if ((here-> B4SOIiiiNode != 0) && (here-> B4SOIiiiNode != 0)) + here->B4SOIIiiPtr = here->B4SOIIiiStructPtr->CSC ; + + if ((here-> B4SOIigNode != 0) && (here-> B4SOIigNode != 0)) + here->B4SOIIgPtr = here->B4SOIIgStructPtr->CSC ; + + if ((here-> B4SOIgiggNode != 0) && (here-> B4SOIgiggNode != 0)) + here->B4SOIGiggPtr = here->B4SOIGiggStructPtr->CSC ; + + if ((here-> B4SOIgigdNode != 0) && (here-> B4SOIgigdNode != 0)) + here->B4SOIGigdPtr = here->B4SOIGigdStructPtr->CSC ; + + if ((here-> B4SOIgigbNode != 0) && (here-> B4SOIgigbNode != 0)) + here->B4SOIGigbPtr = here->B4SOIGigbStructPtr->CSC ; + + if ((here-> B4SOIigidlNode != 0) && (here-> B4SOIigidlNode != 0)) + here->B4SOIIgidlPtr = here->B4SOIIgidlStructPtr->CSC ; + + if ((here-> B4SOIitunNode != 0) && (here-> B4SOIitunNode != 0)) + here->B4SOIItunPtr = here->B4SOIItunStructPtr->CSC ; + + if ((here-> B4SOIibpNode != 0) && (here-> B4SOIibpNode != 0)) + here->B4SOIIbpPtr = here->B4SOIIbpStructPtr->CSC ; + + if ((here-> B4SOIcbbNode != 0) && (here-> B4SOIcbbNode != 0)) + here->B4SOICbbPtr = here->B4SOICbbStructPtr->CSC ; + + if ((here-> B4SOIcbdNode != 0) && (here-> B4SOIcbdNode != 0)) + here->B4SOICbdPtr = here->B4SOICbdStructPtr->CSC ; + + if ((here-> B4SOIcbgNode != 0) && (here-> B4SOIcbgNode != 0)) + here->B4SOICbgPtr = here->B4SOICbgStructPtr->CSC ; + + if ((here-> B4SOIqbfNode != 0) && (here-> B4SOIqbfNode != 0)) + here->B4SOIQbfPtr = here->B4SOIQbfStructPtr->CSC ; + + if ((here-> B4SOIqjsNode != 0) && (here-> B4SOIqjsNode != 0)) + here->B4SOIQjsPtr = here->B4SOIQjsStructPtr->CSC ; + + if ((here-> B4SOIqjdNode != 0) && (here-> B4SOIqjdNode != 0)) + here->B4SOIQjdPtr = here->B4SOIQjdStructPtr->CSC ; + + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsimsoi/b4soidef.h b/src/spicelib/devices/bsimsoi/b4soidef.h index 8ebb90ada..f92245fbe 100644 --- a/src/spicelib/devices/bsimsoi/b4soidef.h +++ b/src/spicelib/devices/bsimsoi/b4soidef.h @@ -736,6 +736,110 @@ typedef struct sB4SOIinstance double **B4SOInVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *B4SOITemptempStructPtr ; + BindElement *B4SOITempdpStructPtr ; + BindElement *B4SOITempspStructPtr ; + BindElement *B4SOITempgStructPtr ; + BindElement *B4SOITempbStructPtr ; + BindElement *B4SOIGtempStructPtr ; + BindElement *B4SOIDPtempStructPtr ; + BindElement *B4SOISPtempStructPtr ; + BindElement *B4SOIEtempStructPtr ; + BindElement *B4SOIBtempStructPtr ; + BindElement *B4SOIPtempStructPtr ; + BindElement *B4SOITempeStructPtr ; + BindElement *B4SOIBpStructPtr ; + BindElement *B4SOIPbStructPtr ; + BindElement *B4SOIPpStructPtr ; + BindElement *B4SOIPgStructPtr ; + BindElement *B4SOIGpStructPtr ; + BindElement *B4SOIGEgeStructPtr ; + BindElement *B4SOIGEgStructPtr ; + BindElement *B4SOIGgeStructPtr ; + BindElement *B4SOIGEdpStructPtr ; + BindElement *B4SOIGEspStructPtr ; + BindElement *B4SOIGEbStructPtr ; + BindElement *B4SOIGMdpStructPtr ; + BindElement *B4SOIGMgStructPtr ; + BindElement *B4SOIGMgmStructPtr ; + BindElement *B4SOIGMgeStructPtr ; + BindElement *B4SOIGMspStructPtr ; + BindElement *B4SOIGMbStructPtr ; + BindElement *B4SOIGMeStructPtr ; + BindElement *B4SOIDPgmStructPtr ; + BindElement *B4SOIGgmStructPtr ; + BindElement *B4SOIGEgmStructPtr ; + BindElement *B4SOISPgmStructPtr ; + BindElement *B4SOIEgmStructPtr ; + BindElement *B4SOIEbStructPtr ; + BindElement *B4SOIGbStructPtr ; + BindElement *B4SOIDPbStructPtr ; + BindElement *B4SOISPbStructPtr ; + BindElement *B4SOIBeStructPtr ; + BindElement *B4SOIBgStructPtr ; + BindElement *B4SOIBdpStructPtr ; + BindElement *B4SOIBspStructPtr ; + BindElement *B4SOIBbStructPtr ; + BindElement *B4SOIEgStructPtr ; + BindElement *B4SOIEdpStructPtr ; + BindElement *B4SOIEspStructPtr ; + BindElement *B4SOIGeStructPtr ; + BindElement *B4SOIDPeStructPtr ; + BindElement *B4SOISPeStructPtr ; + BindElement *B4SOIEeStructPtr ; + BindElement *B4SOIGgStructPtr ; + BindElement *B4SOIGdpStructPtr ; + BindElement *B4SOIGspStructPtr ; + BindElement *B4SOIDPgStructPtr ; + BindElement *B4SOIDPdpStructPtr ; + BindElement *B4SOIDPspStructPtr ; + BindElement *B4SOIDPdStructPtr ; + BindElement *B4SOISPgStructPtr ; + BindElement *B4SOISPdpStructPtr ; + BindElement *B4SOISPspStructPtr ; + BindElement *B4SOISPsStructPtr ; + BindElement *B4SOIDdStructPtr ; + BindElement *B4SOIDdpStructPtr ; + BindElement *B4SOISsStructPtr ; + BindElement *B4SOISspStructPtr ; + BindElement *B4SOIDPdbStructPtr ; + BindElement *B4SOISPsbStructPtr ; + BindElement *B4SOIDBdpStructPtr ; + BindElement *B4SOIDBdbStructPtr ; + BindElement *B4SOIDBbStructPtr ; + BindElement *B4SOISBspStructPtr ; + BindElement *B4SOISBsbStructPtr ; + BindElement *B4SOISBbStructPtr ; + BindElement *B4SOIBdbStructPtr ; + BindElement *B4SOIBsbStructPtr ; + BindElement *B4SOIDgStructPtr ; + BindElement *B4SOIDspStructPtr ; + BindElement *B4SOISdpStructPtr ; + BindElement *B4SOISgStructPtr ; + BindElement *B4SOIDbStructPtr ; + BindElement *B4SOISbStructPtr ; + BindElement *B4SOIVbsStructPtr ; + BindElement *B4SOIIdsStructPtr ; + BindElement *B4SOIIcStructPtr ; + BindElement *B4SOIIbsStructPtr ; + BindElement *B4SOIIbdStructPtr ; + BindElement *B4SOIIiiStructPtr ; + BindElement *B4SOIIgStructPtr ; + BindElement *B4SOIGiggStructPtr ; + BindElement *B4SOIGigdStructPtr ; + BindElement *B4SOIGigbStructPtr ; + BindElement *B4SOIIgidlStructPtr ; + BindElement *B4SOIItunStructPtr ; + BindElement *B4SOIIbpStructPtr ; + BindElement *B4SOICbbStructPtr ; + BindElement *B4SOICbdStructPtr ; + BindElement *B4SOICbgStructPtr ; + BindElement *B4SOIQbfStructPtr ; + BindElement *B4SOIQjsStructPtr ; + BindElement *B4SOIQjdStructPtr ; +#endif + } B4SOIinstance ; struct b4soiSizeDependParam diff --git a/src/spicelib/devices/bsimsoi/b4soiext.h b/src/spicelib/devices/bsimsoi/b4soiext.h index bb252b941..a5fd9b539 100644 --- a/src/spicelib/devices/bsimsoi/b4soiext.h +++ b/src/spicelib/devices/bsimsoi/b4soiext.h @@ -31,3 +31,9 @@ extern int B4SOItrunc(GENmodel*,CKTcircuit*,double*); extern int B4SOInoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int B4SOIunsetup(GENmodel*,CKTcircuit*); extern int B4SOIsoaCheck(CKTcircuit *, GENmodel *); + +#ifdef KLU +extern int B4SOIbindCSC (GENmodel*, CKTcircuit*) ; +extern int B4SOIbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int B4SOIbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/bsimsoi/b4soiinit.c b/src/spicelib/devices/bsimsoi/b4soiinit.c index 1372967e4..e2d9f28bc 100644 --- a/src/spicelib/devices/bsimsoi/b4soiinit.c +++ b/src/spicelib/devices/bsimsoi/b4soiinit.c @@ -71,7 +71,14 @@ SPICEdev B4SOIinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &B4SOIiSize, - /* DEVmodSize */ &B4SOImSize + /* DEVmodSize */ &B4SOImSize, + +#ifdef KLU + /* DEVbindCSC */ B4SOIbindCSC, + /* DEVbindCSCComplex */ B4SOIbindCSCComplex, + /* DEVbindCSCComplexToReal */ B4SOIbindCSCComplexToReal, +#endif + }; SPICEdev * diff --git a/src/spicelib/devices/cap/Makefile.am b/src/spicelib/devices/cap/Makefile.am index 4205040ae..e0916e32b 100644 --- a/src/spicelib/devices/cap/Makefile.am +++ b/src/spicelib/devices/cap/Makefile.am @@ -31,6 +31,9 @@ libcap_la_SOURCES = \ captrunc.c +if KLU_WANTED +libcap_la_SOURCES += capbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/cap/capbindCSC.c b/src/spicelib/devices/cap/capbindCSC.c new file mode 100644 index 000000000..575b4537a --- /dev/null +++ b/src/spicelib/devices/cap/capbindCSC.c @@ -0,0 +1,140 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "capdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +CAPbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + CAPmodel *model = (CAPmodel *)inModel ; + CAPinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the CAP models */ + for ( ; model != NULL ; model = model->CAPnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CAPinstances ; here != NULL ; here = here->CAPnextInstance) + { + if ((here->CAPposNode != 0) && (here->CAPposNode != 0)) + { + i = here->CAPposPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CAPposPosptrStructPtr = matched ; + here->CAPposPosptr = matched->CSC ; + } + + if ((here->CAPnegNode != 0) && (here->CAPnegNode != 0)) + { + i = here->CAPnegNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CAPnegNegptrStructPtr = matched ; + here->CAPnegNegptr = matched->CSC ; + } + + if ((here->CAPposNode != 0) && (here->CAPnegNode != 0)) + { + i = here->CAPposNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CAPposNegptrStructPtr = matched ; + here->CAPposNegptr = matched->CSC ; + } + + if ((here->CAPnegNode != 0) && (here->CAPposNode != 0)) + { + i = here->CAPnegPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CAPnegPosptrStructPtr = matched ; + here->CAPnegPosptr = matched->CSC ; + } + } + } + + return (OK) ; +} + +int +CAPbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + CAPmodel *model = (CAPmodel *)inModel ; + CAPinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the CAP models */ + for ( ; model != NULL ; model = model->CAPnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CAPinstances ; here != NULL ; here = here->CAPnextInstance) + { + if ((here->CAPposNode != 0) && (here->CAPposNode != 0)) + here->CAPposPosptr = here->CAPposPosptrStructPtr->CSC_Complex ; + + if ((here->CAPnegNode != 0) && (here->CAPnegNode != 0)) + here->CAPnegNegptr = here->CAPnegNegptrStructPtr->CSC_Complex ; + + if ((here->CAPposNode != 0) && (here->CAPnegNode != 0)) + here->CAPposNegptr = here->CAPposNegptrStructPtr->CSC_Complex ; + + if ((here->CAPnegNode != 0) && (here->CAPposNode != 0)) + here->CAPnegPosptr = here->CAPnegPosptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +CAPbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + CAPmodel *model = (CAPmodel *)inModel ; + CAPinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the CAP models */ + for ( ; model != NULL ; model = model->CAPnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CAPinstances ; here != NULL ; here = here->CAPnextInstance) + { + if ((here->CAPposNode != 0) && (here->CAPposNode != 0)) + here->CAPposPosptr = here->CAPposPosptrStructPtr->CSC ; + + if ((here->CAPnegNode != 0) && (here->CAPnegNode != 0)) + here->CAPnegNegptr = here->CAPnegNegptrStructPtr->CSC ; + + if ((here->CAPposNode != 0) && (here->CAPnegNode != 0)) + here->CAPposNegptr = here->CAPposNegptrStructPtr->CSC ; + + if ((here->CAPnegNode != 0) && (here->CAPposNode != 0)) + here->CAPnegPosptr = here->CAPnegPosptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/cap/capdefs.h b/src/spicelib/devices/cap/capdefs.h index fbf860f9a..e036746b9 100644 --- a/src/spicelib/devices/cap/capdefs.h +++ b/src/spicelib/devices/cap/capdefs.h @@ -61,6 +61,13 @@ typedef struct sCAPinstance { int CAPsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ +#ifdef KLU + BindElement *CAPposPosptrStructPtr ; + BindElement *CAPnegNegptrStructPtr ; + BindElement *CAPposNegptrStructPtr ; + BindElement *CAPnegPosptrStructPtr ; +#endif + } CAPinstance ; #define CAPqcap CAPstate /* charge on the capacitor */ diff --git a/src/spicelib/devices/cap/capext.h b/src/spicelib/devices/cap/capext.h index d128959c4..570053639 100644 --- a/src/spicelib/devices/cap/capext.h +++ b/src/spicelib/devices/cap/capext.h @@ -24,3 +24,8 @@ extern int CAPtemp(GENmodel*,CKTcircuit*); extern int CAPtrunc(GENmodel*,CKTcircuit*,double*); extern int CAPsoaCheck(CKTcircuit *, GENmodel *); +#ifdef KLU +extern int CAPbindCSC (GENmodel*, CKTcircuit*) ; +extern int CAPbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int CAPbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/cap/capinit.c b/src/spicelib/devices/cap/capinit.c index 1c8bb5126..dd272adc8 100644 --- a/src/spicelib/devices/cap/capinit.c +++ b/src/spicelib/devices/cap/capinit.c @@ -72,7 +72,14 @@ SPICEdev CAPinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &CAPiSize, - /* DEVmodSize */ &CAPmSize + /* DEVmodSize */ &CAPmSize, + +#ifdef KLU + /* DEVbindCSC */ CAPbindCSC, + /* DEVbindCSCComplex */ CAPbindCSCComplex, + /* DEVbindCSCComplexToReal */ CAPbindCSCComplexToReal, +#endif + }; diff --git a/src/spicelib/devices/cccs/Makefile.am b/src/spicelib/devices/cccs/Makefile.am index 566cb2774..57c62b60a 100644 --- a/src/spicelib/devices/cccs/Makefile.am +++ b/src/spicelib/devices/cccs/Makefile.am @@ -23,7 +23,11 @@ libcccs_la_SOURCES = \ cccssset.c +if KLU_WANTED +libcccs_la_SOURCES += cccsbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/cccs/cccsbindCSC.c b/src/spicelib/devices/cccs/cccsbindCSC.c new file mode 100644 index 000000000..b7070182b --- /dev/null +++ b/src/spicelib/devices/cccs/cccsbindCSC.c @@ -0,0 +1,113 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "cccsdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +CCCSbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + CCCSmodel *model = (CCCSmodel *)inModel ; + CCCSinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the CCCS models */ + for ( ; model != NULL ; model = model->CCCSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CCCSinstances ; here != NULL ; here = here->CCCSnextInstance) + { + if ((here->CCCSposNode != 0) && (here->CCCScontBranch != 0)) + { + i = here->CCCSposContBrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CCCSposContBrptrStructPtr = matched ; + here->CCCSposContBrptr = matched->CSC ; + } + + if ((here->CCCSnegNode != 0) && (here->CCCScontBranch != 0)) + { + i = here->CCCSnegContBrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CCCSnegContBrptrStructPtr = matched ; + here->CCCSnegContBrptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +CCCSbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + CCCSmodel *model = (CCCSmodel *)inModel ; + CCCSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the CCCS models */ + for ( ; model != NULL ; model = model->CCCSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CCCSinstances ; here != NULL ; here = here->CCCSnextInstance) + { + if ((here->CCCSposNode != 0) && (here->CCCScontBranch != 0)) + here->CCCSposContBrptr = here->CCCSposContBrptrStructPtr->CSC_Complex ; + + if ((here->CCCSnegNode != 0) && (here->CCCScontBranch != 0)) + here->CCCSnegContBrptr = here->CCCSnegContBrptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +CCCSbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + CCCSmodel *model = (CCCSmodel *)inModel ; + CCCSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the CCCS models */ + for ( ; model != NULL ; model = model->CCCSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CCCSinstances ; here != NULL ; here = here->CCCSnextInstance) + { + if ((here->CCCSposNode != 0) && (here->CCCScontBranch != 0)) + here->CCCSposContBrptr = here->CCCSposContBrptrStructPtr->CSC ; + + if ((here->CCCSnegNode != 0) && (here->CCCScontBranch != 0)) + here->CCCSnegContBrptr = here->CCCSnegContBrptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/cccs/cccsdefs.h b/src/spicelib/devices/cccs/cccsdefs.h index 036a0f15d..2c361bb6f 100644 --- a/src/spicelib/devices/cccs/cccsdefs.h +++ b/src/spicelib/devices/cccs/cccsdefs.h @@ -42,6 +42,11 @@ typedef struct sCCCSinstance { int CCCSsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ +#ifdef KLU + BindElement *CCCSposContBrptrStructPtr ; + BindElement *CCCSnegContBrptrStructPtr ; +#endif + } CCCSinstance ; /* per model data */ diff --git a/src/spicelib/devices/cccs/cccsext.h b/src/spicelib/devices/cccs/cccsext.h index 5a8934518..405e7cc78 100644 --- a/src/spicelib/devices/cccs/cccsext.h +++ b/src/spicelib/devices/cccs/cccsext.h @@ -17,3 +17,8 @@ extern void CCCSsPrint(GENmodel*,CKTcircuit*); extern int CCCSsSetup(SENstruct*,GENmodel*); extern int CCCSsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); +#ifdef KLU +extern int CCCSbindCSC (GENmodel*, CKTcircuit*) ; +extern int CCCSbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int CCCSbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/cccs/cccsinit.c b/src/spicelib/devices/cccs/cccsinit.c index 92b593ae4..69a1cbe79 100644 --- a/src/spicelib/devices/cccs/cccsinit.c +++ b/src/spicelib/devices/cccs/cccsinit.c @@ -72,7 +72,13 @@ SPICEdev CCCSinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &CCCSiSize, - /* DEVmodSize */ &CCCSmSize + /* DEVmodSize */ &CCCSmSize, + +#ifdef KLU + /* DEVbindCSC */ CCCSbindCSC, + /* DEVbindCSCComplex */ CCCSbindCSCComplex, + /* DEVbindCSCComplexToReal */ CCCSbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/ccvs/Makefile.am b/src/spicelib/devices/ccvs/Makefile.am index 3e72d2145..0faa88b17 100644 --- a/src/spicelib/devices/ccvs/Makefile.am +++ b/src/spicelib/devices/ccvs/Makefile.am @@ -24,6 +24,9 @@ libccvs_la_SOURCES = \ ccvssset.c +if KLU_WANTED +libccvs_la_SOURCES += ccvsbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/ccvs/ccvsbindCSC.c b/src/spicelib/devices/ccvs/ccvsbindCSC.c new file mode 100644 index 000000000..7a6628d97 --- /dev/null +++ b/src/spicelib/devices/ccvs/ccvsbindCSC.c @@ -0,0 +1,155 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "ccvsdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +CCVSbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + CCVSmodel *model = (CCVSmodel *)inModel ; + CCVSinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the CCVS models */ + for ( ; model != NULL ; model = model->CCVSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CCVSinstances ; here != NULL ; here = here->CCVSnextInstance) + { + if ((here-> CCVSposNode != 0) && (here-> CCVSbranch != 0)) + { + i = here->CCVSposIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CCVSposIbrptrStructPtr = matched ; + here->CCVSposIbrptr = matched->CSC ; + } + + if ((here-> CCVSnegNode != 0) && (here-> CCVSbranch != 0)) + { + i = here->CCVSnegIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CCVSnegIbrptrStructPtr = matched ; + here->CCVSnegIbrptr = matched->CSC ; + } + + if ((here-> CCVSbranch != 0) && (here-> CCVSnegNode != 0)) + { + i = here->CCVSibrNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CCVSibrNegptrStructPtr = matched ; + here->CCVSibrNegptr = matched->CSC ; + } + + if ((here-> CCVSbranch != 0) && (here-> CCVSposNode != 0)) + { + i = here->CCVSibrPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CCVSibrPosptrStructPtr = matched ; + here->CCVSibrPosptr = matched->CSC ; + } + + if ((here-> CCVSbranch != 0) && (here-> CCVScontBranch != 0)) + { + i = here->CCVSibrContBrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CCVSibrContBrptrStructPtr = matched ; + here->CCVSibrContBrptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +CCVSbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + CCVSmodel *model = (CCVSmodel *)inModel ; + CCVSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the CCVS models */ + for ( ; model != NULL ; model = model->CCVSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CCVSinstances ; here != NULL ; here = here->CCVSnextInstance) + { + if ((here-> CCVSposNode != 0) && (here-> CCVSbranch != 0)) + here->CCVSposIbrptr = here->CCVSposIbrptrStructPtr->CSC_Complex ; + + if ((here-> CCVSnegNode != 0) && (here-> CCVSbranch != 0)) + here->CCVSnegIbrptr = here->CCVSnegIbrptrStructPtr->CSC_Complex ; + + if ((here-> CCVSbranch != 0) && (here-> CCVSnegNode != 0)) + here->CCVSibrNegptr = here->CCVSibrNegptrStructPtr->CSC_Complex ; + + if ((here-> CCVSbranch != 0) && (here-> CCVSposNode != 0)) + here->CCVSibrPosptr = here->CCVSibrPosptrStructPtr->CSC_Complex ; + + if ((here-> CCVSbranch != 0) && (here-> CCVScontBranch != 0)) + here->CCVSibrContBrptr = here->CCVSibrContBrptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +CCVSbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + CCVSmodel *model = (CCVSmodel *)inModel ; + CCVSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the CCVS models */ + for ( ; model != NULL ; model = model->CCVSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CCVSinstances ; here != NULL ; here = here->CCVSnextInstance) + { + if ((here-> CCVSposNode != 0) && (here-> CCVSbranch != 0)) + here->CCVSposIbrptr = here->CCVSposIbrptrStructPtr->CSC ; + + if ((here-> CCVSnegNode != 0) && (here-> CCVSbranch != 0)) + here->CCVSnegIbrptr = here->CCVSnegIbrptrStructPtr->CSC ; + + if ((here-> CCVSbranch != 0) && (here-> CCVSnegNode != 0)) + here->CCVSibrNegptr = here->CCVSibrNegptrStructPtr->CSC ; + + if ((here-> CCVSbranch != 0) && (here-> CCVSposNode != 0)) + here->CCVSibrPosptr = here->CCVSibrPosptrStructPtr->CSC ; + + if ((here-> CCVSbranch != 0) && (here-> CCVScontBranch != 0)) + here->CCVSibrContBrptr = here->CCVSibrContBrptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/ccvs/ccvsdefs.h b/src/spicelib/devices/ccvs/ccvsdefs.h index 5ad545fef..a7280d470 100644 --- a/src/spicelib/devices/ccvs/ccvsdefs.h +++ b/src/spicelib/devices/ccvs/ccvsdefs.h @@ -46,6 +46,14 @@ typedef struct sCCVSinstance { int CCVSsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ +#ifdef KLU + BindElement *CCVSposIbrptrStructPtr ; + BindElement *CCVSnegIbrptrStructPtr ; + BindElement *CCVSibrNegptrStructPtr ; + BindElement *CCVSibrPosptrStructPtr ; + BindElement *CCVSibrContBrptrStructPtr ; +#endif + } CCVSinstance ; /* per model data */ diff --git a/src/spicelib/devices/ccvs/ccvsext.h b/src/spicelib/devices/ccvs/ccvsext.h index 779cdd225..7b4e5d772 100644 --- a/src/spicelib/devices/ccvs/ccvsext.h +++ b/src/spicelib/devices/ccvs/ccvsext.h @@ -17,3 +17,9 @@ extern void CCVSsPrint(GENmodel*,CKTcircuit*); extern int CCVSsSetup(SENstruct*,GENmodel*); extern int CCVSsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int CCVSunsetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int CCVSbindCSC (GENmodel*, CKTcircuit*) ; +extern int CCVSbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int CCVSbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/ccvs/ccvsinit.c b/src/spicelib/devices/ccvs/ccvsinit.c index 952f54124..85d9304c8 100644 --- a/src/spicelib/devices/ccvs/ccvsinit.c +++ b/src/spicelib/devices/ccvs/ccvsinit.c @@ -73,7 +73,13 @@ SPICEdev CCVSinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &CCVSiSize, - /* DEVmodSize */ &CCVSmSize + /* DEVmodSize */ &CCVSmSize, + +#ifdef KLU + /* DEVbindCSC */ CCVSbindCSC, + /* DEVbindCSCComplex */ CCVSbindCSCComplex, + /* DEVbindCSCComplexToReal */ CCVSbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/cpl/cplinit.c b/src/spicelib/devices/cpl/cplinit.c index 34f1bc43c..df9b22e67 100644 --- a/src/spicelib/devices/cpl/cplinit.c +++ b/src/spicelib/devices/cpl/cplinit.c @@ -73,7 +73,13 @@ SPICEdev CPLinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &CPLiSize, -/* DEVmodSize */ &CPLmSize +/* DEVmodSize */ &CPLmSize, + +#ifdef KLU + /* DEVbindCSC */ NULL, + /* DEVbindCSCComplex */ NULL, + /* DEVbindCSCComplexToReal */ NULL, +#endif }; diff --git a/src/spicelib/devices/csw/Makefile.am b/src/spicelib/devices/csw/Makefile.am index 715d29da5..c2886f90d 100644 --- a/src/spicelib/devices/csw/Makefile.am +++ b/src/spicelib/devices/csw/Makefile.am @@ -24,7 +24,11 @@ libcsw_la_SOURCES = \ cswtrunc.c +if KLU_WANTED +libcsw_la_SOURCES += cswbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/csw/cswbindCSC.c b/src/spicelib/devices/csw/cswbindCSC.c new file mode 100644 index 000000000..26ea06f03 --- /dev/null +++ b/src/spicelib/devices/csw/cswbindCSC.c @@ -0,0 +1,141 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "cswdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +CSWbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + CSWmodel *model = (CSWmodel *)inModel ; + CSWinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the CSW models */ + for ( ; model != NULL ; model = model->CSWnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CSWinstances ; here != NULL ; here = here->CSWnextInstance) + { + if ((here-> CSWposNode != 0) && (here-> CSWposNode != 0)) + { + i = here->CSWposPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CSWposPosptrStructPtr = matched ; + here->CSWposPosptr = matched->CSC ; + } + + if ((here-> CSWposNode != 0) && (here-> CSWnegNode != 0)) + { + i = here->CSWposNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CSWposNegptrStructPtr = matched ; + here->CSWposNegptr = matched->CSC ; + } + + if ((here-> CSWnegNode != 0) && (here-> CSWposNode != 0)) + { + i = here->CSWnegPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CSWnegPosptrStructPtr = matched ; + here->CSWnegPosptr = matched->CSC ; + } + + if ((here-> CSWnegNode != 0) && (here-> CSWnegNode != 0)) + { + i = here->CSWnegNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CSWnegNegptrStructPtr = matched ; + here->CSWnegNegptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +CSWbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + CSWmodel *model = (CSWmodel *)inModel ; + CSWinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the CSW models */ + for ( ; model != NULL ; model = model->CSWnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CSWinstances ; here != NULL ; here = here->CSWnextInstance) + { + if ((here-> CSWposNode != 0) && (here-> CSWposNode != 0)) + here->CSWposPosptr = here->CSWposPosptrStructPtr->CSC_Complex ; + + if ((here-> CSWposNode != 0) && (here-> CSWnegNode != 0)) + here->CSWposNegptr = here->CSWposNegptrStructPtr->CSC_Complex ; + + if ((here-> CSWnegNode != 0) && (here-> CSWposNode != 0)) + here->CSWnegPosptr = here->CSWnegPosptrStructPtr->CSC_Complex ; + + if ((here-> CSWnegNode != 0) && (here-> CSWnegNode != 0)) + here->CSWnegNegptr = here->CSWnegNegptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +CSWbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + CSWmodel *model = (CSWmodel *)inModel ; + CSWinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the CSW models */ + for ( ; model != NULL ; model = model->CSWnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CSWinstances ; here != NULL ; here = here->CSWnextInstance) + { + if ((here-> CSWposNode != 0) && (here-> CSWposNode != 0)) + here->CSWposPosptr = here->CSWposPosptrStructPtr->CSC ; + + if ((here-> CSWposNode != 0) && (here-> CSWnegNode != 0)) + here->CSWposNegptr = here->CSWposNegptrStructPtr->CSC ; + + if ((here-> CSWnegNode != 0) && (here-> CSWposNode != 0)) + here->CSWnegPosptr = here->CSWnegPosptrStructPtr->CSC ; + + if ((here-> CSWnegNode != 0) && (here-> CSWnegNode != 0)) + here->CSWnegNegptr = here->CSWnegNegptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/csw/cswdefs.h b/src/spicelib/devices/csw/cswdefs.h index 3ccb78796..633aaa387 100644 --- a/src/spicelib/devices/csw/cswdefs.h +++ b/src/spicelib/devices/csw/cswdefs.h @@ -48,6 +48,14 @@ typedef struct sCSWinstance { #else /* NONOISE */ double *CSWnVar; #endif /* NONOISE */ + +#ifdef KLU + BindElement *CSWposPosptrStructPtr ; + BindElement *CSWposNegptrStructPtr ; + BindElement *CSWnegPosptrStructPtr ; + BindElement *CSWnegNegptrStructPtr ; +#endif + } CSWinstance ; /* data per model */ diff --git a/src/spicelib/devices/csw/cswext.h b/src/spicelib/devices/csw/cswext.h index daf6dbc11..92f2144da 100644 --- a/src/spicelib/devices/csw/cswext.h +++ b/src/spicelib/devices/csw/cswext.h @@ -17,3 +17,9 @@ extern int CSWpzLoad(GENmodel*,CKTcircuit*,SPcomplex*); extern int CSWsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int CSWnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int CSWtrunc(GENmodel*,CKTcircuit*,double*); + +#ifdef KLU +extern int CSWbindCSC (GENmodel*, CKTcircuit*) ; +extern int CSWbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int CSWbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/csw/cswinit.c b/src/spicelib/devices/csw/cswinit.c index de4a7bf89..6ddad52f0 100644 --- a/src/spicelib/devices/csw/cswinit.c +++ b/src/spicelib/devices/csw/cswinit.c @@ -75,7 +75,13 @@ SPICEdev CSWinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &CSWiSize, - /* DEVmodSize */ &CSWmSize + /* DEVmodSize */ &CSWmSize, + +#ifdef KLU + /* DEVbindCSC */ CSWbindCSC, + /* DEVbindCSCComplex */ CSWbindCSCComplex, + /* DEVbindCSCComplexToReal */ CSWbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/dio/Makefile.am b/src/spicelib/devices/dio/Makefile.am index abb29045e..e0a06564d 100644 --- a/src/spicelib/devices/dio/Makefile.am +++ b/src/spicelib/devices/dio/Makefile.am @@ -35,6 +35,11 @@ libdio_la_SOURCES = \ diotrunc.c +if KLU_WANTED +libdio_la_SOURCES += diobindCSC.c +endif + AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/dio/diobindCSC.c b/src/spicelib/devices/dio/diobindCSC.c new file mode 100644 index 000000000..89576f811 --- /dev/null +++ b/src/spicelib/devices/dio/diobindCSC.c @@ -0,0 +1,183 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "diodefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +DIObindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + DIOmodel *model = (DIOmodel *)inModel ; + DIOinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the DIO models */ + for ( ; model != NULL ; model = model->DIOnextModel) + { + /* loop through all the instances of the model */ + for (here = model->DIOinstances ; here != NULL ; here = here->DIOnextInstance) + { + if ((here->DIOposNode != 0) && (here->DIOposPrimeNode != 0)) + { + i = here->DIOposPosPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->DIOposPosPrimeStructPtr = matched ; + here->DIOposPosPrimePtr = matched->CSC ; + } + + if ((here->DIOnegNode != 0) && (here->DIOposPrimeNode != 0)) + { + i = here->DIOnegPosPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->DIOnegPosPrimeStructPtr = matched ; + here->DIOnegPosPrimePtr = matched->CSC ; + } + + if ((here->DIOposPrimeNode != 0) && (here->DIOposNode != 0)) + { + i = here->DIOposPrimePosPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->DIOposPrimePosStructPtr = matched ; + here->DIOposPrimePosPtr = matched->CSC ; + } + + if ((here->DIOposPrimeNode != 0) && (here->DIOnegNode != 0)) + { + i = here->DIOposPrimeNegPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->DIOposPrimeNegStructPtr = matched ; + here->DIOposPrimeNegPtr = matched->CSC ; + } + + if ((here->DIOposNode != 0) && (here->DIOposNode != 0)) + { + i = here->DIOposPosPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->DIOposPosStructPtr = matched ; + here->DIOposPosPtr = matched->CSC ; + } + + if ((here->DIOnegNode != 0) && (here->DIOnegNode != 0)) + { + i = here->DIOnegNegPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->DIOnegNegStructPtr = matched ; + here->DIOnegNegPtr = matched->CSC ; + } + + if ((here->DIOposPrimeNode != 0) && (here->DIOposPrimeNode != 0)) + { + i = here->DIOposPrimePosPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->DIOposPrimePosPrimeStructPtr = matched ; + here->DIOposPrimePosPrimePtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +DIObindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + DIOmodel *model = (DIOmodel *)inModel ; + DIOinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the DIO models */ + for ( ; model != NULL ; model = model->DIOnextModel) + { + /* loop through all the instances of the model */ + for (here = model->DIOinstances ; here != NULL ; here = here->DIOnextInstance) + { + if ((here->DIOposNode != 0) && (here->DIOposPrimeNode != 0)) + here->DIOposPosPrimePtr = here->DIOposPosPrimeStructPtr->CSC_Complex ; + + if ((here->DIOnegNode != 0) && (here->DIOposPrimeNode != 0)) + here->DIOnegPosPrimePtr = here->DIOnegPosPrimeStructPtr->CSC_Complex ; + + if ((here->DIOposPrimeNode != 0) && (here->DIOposNode != 0)) + here->DIOposPrimePosPtr = here->DIOposPrimePosStructPtr->CSC_Complex ; + + if ((here->DIOposPrimeNode != 0) && (here->DIOnegNode != 0)) + here->DIOposPrimeNegPtr = here->DIOposPrimeNegStructPtr->CSC_Complex ; + + if ((here->DIOposNode != 0) && (here->DIOposNode != 0)) + here->DIOposPosPtr = here->DIOposPosStructPtr->CSC_Complex ; + + if ((here->DIOnegNode != 0) && (here->DIOnegNode != 0)) + here->DIOnegNegPtr = here->DIOnegNegStructPtr->CSC_Complex ; + + if ((here->DIOposPrimeNode != 0) && (here->DIOposPrimeNode != 0)) + here->DIOposPrimePosPrimePtr = here->DIOposPrimePosPrimeStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +DIObindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + DIOmodel *model = (DIOmodel *)inModel ; + DIOinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the DIO models */ + for ( ; model != NULL ; model = model->DIOnextModel) + { + /* loop through all the instances of the model */ + for (here = model->DIOinstances ; here != NULL ; here = here->DIOnextInstance) + { + if ((here->DIOposNode != 0) && (here->DIOposPrimeNode != 0)) + here->DIOposPosPrimePtr = here->DIOposPosPrimeStructPtr->CSC ; + + if ((here->DIOnegNode != 0) && (here->DIOposPrimeNode != 0)) + here->DIOnegPosPrimePtr = here->DIOnegPosPrimeStructPtr->CSC ; + + if ((here->DIOposPrimeNode != 0) && (here->DIOposNode != 0)) + here->DIOposPrimePosPtr = here->DIOposPrimePosStructPtr->CSC ; + + if ((here->DIOposPrimeNode != 0) && (here->DIOnegNode != 0)) + here->DIOposPrimeNegPtr = here->DIOposPrimeNegStructPtr->CSC ; + + if ((here->DIOposNode != 0) && (here->DIOposNode != 0)) + here->DIOposPosPtr = here->DIOposPosStructPtr->CSC ; + + if ((here->DIOnegNode != 0) && (here->DIOnegNode != 0)) + here->DIOnegNegPtr = here->DIOnegNegStructPtr->CSC ; + + if ((here->DIOposPrimeNode != 0) && (here->DIOposPrimeNode != 0)) + here->DIOposPrimePosPrimePtr = here->DIOposPrimePosPrimeStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/dio/diodefs.h b/src/spicelib/devices/dio/diodefs.h index c80364862..684321b70 100644 --- a/src/spicelib/devices/dio/diodefs.h +++ b/src/spicelib/devices/dio/diodefs.h @@ -144,6 +144,16 @@ typedef struct sDIOinstance { double **DIOnVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *DIOposPosPrimeStructPtr ; + BindElement *DIOnegPosPrimeStructPtr ; + BindElement *DIOposPrimePosStructPtr ; + BindElement *DIOposPrimeNegStructPtr ; + BindElement *DIOposPosStructPtr ; + BindElement *DIOnegNegStructPtr ; + BindElement *DIOposPrimePosPrimeStructPtr ; +#endif + } DIOinstance ; #define DIOsenGeq DIOsens /* stores the perturbed values of geq */ diff --git a/src/spicelib/devices/dio/dioext.h b/src/spicelib/devices/dio/dioext.h index 803efea33..bd7115468 100644 --- a/src/spicelib/devices/dio/dioext.h +++ b/src/spicelib/devices/dio/dioext.h @@ -30,3 +30,8 @@ extern int DIOnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int DIOdSetup(DIOmodel*,CKTcircuit*); extern int DIOsoaCheck(CKTcircuit *, GENmodel *); +#ifdef KLU +extern int DIObindCSC (GENmodel*, CKTcircuit*) ; +extern int DIObindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int DIObindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/dio/dioinit.c b/src/spicelib/devices/dio/dioinit.c index 4161316d2..cb75a21a5 100644 --- a/src/spicelib/devices/dio/dioinit.c +++ b/src/spicelib/devices/dio/dioinit.c @@ -74,7 +74,14 @@ SPICEdev DIOinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &DIOiSize, - /* DEVmodSize */ &DIOmSize + /* DEVmodSize */ &DIOmSize, + +#ifdef KLU + /* DEVbindCSC */ DIObindCSC, + /* DEVbindCSCComplex */ DIObindCSCComplex, + /* DEVbindCSCComplexToReal */ DIObindCSCComplexToReal, +#endif + }; diff --git a/src/spicelib/devices/hfet1/Makefile.am b/src/spicelib/devices/hfet1/Makefile.am index 5d9ef9eee..7a6ccddf6 100644 --- a/src/spicelib/devices/hfet1/Makefile.am +++ b/src/spicelib/devices/hfet1/Makefile.am @@ -25,7 +25,11 @@ libhfet_la_SOURCES = \ hfettrunc.c +if KLU_WANTED +libhfet_la_SOURCES += hfetbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/hfet1/hfetbindCSC.c b/src/spicelib/devices/hfet1/hfetbindCSC.c new file mode 100644 index 000000000..b92291bff --- /dev/null +++ b/src/spicelib/devices/hfet1/hfetbindCSC.c @@ -0,0 +1,477 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "hfetdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +HFETAbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + HFETAmodel *model = (HFETAmodel *)inModel ; + HFETAinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the HFETA models */ + for ( ; model != NULL ; model = model->HFETAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->HFETAinstances ; here != NULL ; here = here->HFETAnextInstance) + { + if ((here->HFETAdrainNode != 0) && (here->HFETAdrainPrimeNode != 0)) + { + i = here->HFETAdrainDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainDrainPrimeStructPtr = matched ; + here->HFETAdrainDrainPrimePtr = matched->CSC ; + } + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAdrainPrimeNode != 0)) + { + i = here->HFETAgatePrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAgatePrimeDrainPrimeStructPtr = matched ; + here->HFETAgatePrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAsourcePrimeNode != 0)) + { + i = here->HFETAgatePrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAgatePrimeSourcePrimeStructPtr = matched ; + here->HFETAgatePrimeSourcePrimePtr = matched->CSC ; + } + + if ((here->HFETAsourceNode != 0) && (here->HFETAsourcePrimeNode != 0)) + { + i = here->HFETAsourceSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourceSourcePrimeStructPtr = matched ; + here->HFETAsourceSourcePrimePtr = matched->CSC ; + } + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAdrainNode != 0)) + { + i = here->HFETAdrainPrimeDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainPrimeDrainStructPtr = matched ; + here->HFETAdrainPrimeDrainPtr = matched->CSC ; + } + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAgatePrimeNode != 0)) + { + i = here->HFETAdrainPrimeGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainPrimeGatePrimeStructPtr = matched ; + here->HFETAdrainPrimeGatePrimePtr = matched->CSC ; + } + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAsourcePrimeNode != 0)) + { + i = here->HFETAdrainPrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainPrimeSourcePrimeStructPtr = matched ; + here->HFETAdrainPrimeSourcePrimePtr = matched->CSC ; + } + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAgatePrimeNode != 0)) + { + i = here->HFETAsourcePrimeGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourcePrimeGatePrimeStructPtr = matched ; + here->HFETAsourcePrimeGatePrimePtr = matched->CSC ; + } + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAsourceNode != 0)) + { + i = here->HFETAsourcePrimeSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourcePrimeSourceStructPtr = matched ; + here->HFETAsourcePrimeSourcePtr = matched->CSC ; + } + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAdrainPrimeNode != 0)) + { + i = here->HFETAsourcePrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourcePrimeDrainPrimeStructPtr = matched ; + here->HFETAsourcePrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->HFETAdrainNode != 0) && (here->HFETAdrainNode != 0)) + { + i = here->HFETAdrainDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainDrainStructPtr = matched ; + here->HFETAdrainDrainPtr = matched->CSC ; + } + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAgatePrimeNode != 0)) + { + i = here->HFETAgatePrimeGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAgatePrimeGatePrimeStructPtr = matched ; + here->HFETAgatePrimeGatePrimePtr = matched->CSC ; + } + + if ((here->HFETAsourceNode != 0) && (here->HFETAsourceNode != 0)) + { + i = here->HFETAsourceSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourceSourceStructPtr = matched ; + here->HFETAsourceSourcePtr = matched->CSC ; + } + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAdrainPrimeNode != 0)) + { + i = here->HFETAdrainPrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainPrimeDrainPrimeStructPtr = matched ; + here->HFETAdrainPrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAsourcePrimeNode != 0)) + { + i = here->HFETAsourcePrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourcePrimeSourcePrimeStructPtr = matched ; + here->HFETAsourcePrimeSourcePrimePtr = matched->CSC ; + } + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAdrainPrmPrmNode != 0)) + { + i = here->HFETAdrainPrimeDrainPrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainPrimeDrainPrmPrmStructPtr = matched ; + here->HFETAdrainPrimeDrainPrmPrmPtr = matched->CSC ; + } + + if ((here->HFETAdrainPrmPrmNode != 0) && (here->HFETAdrainPrimeNode != 0)) + { + i = here->HFETAdrainPrmPrmDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainPrmPrmDrainPrimeStructPtr = matched ; + here->HFETAdrainPrmPrmDrainPrimePtr = matched->CSC ; + } + + if ((here->HFETAdrainPrmPrmNode != 0) && (here->HFETAgatePrimeNode != 0)) + { + i = here->HFETAdrainPrmPrmGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainPrmPrmGatePrimeStructPtr = matched ; + here->HFETAdrainPrmPrmGatePrimePtr = matched->CSC ; + } + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAdrainPrmPrmNode != 0)) + { + i = here->HFETAgatePrimeDrainPrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAgatePrimeDrainPrmPrmStructPtr = matched ; + here->HFETAgatePrimeDrainPrmPrmPtr = matched->CSC ; + } + + if ((here->HFETAdrainPrmPrmNode != 0) && (here->HFETAdrainPrmPrmNode != 0)) + { + i = here->HFETAdrainPrmPrmDrainPrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAdrainPrmPrmDrainPrmPrmStructPtr = matched ; + here->HFETAdrainPrmPrmDrainPrmPrmPtr = matched->CSC ; + } + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAsourcePrmPrmNode != 0)) + { + i = here->HFETAsourcePrimeSourcePrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourcePrimeSourcePrmPrmStructPtr = matched ; + here->HFETAsourcePrimeSourcePrmPrmPtr = matched->CSC ; + } + + if ((here->HFETAsourcePrmPrmNode != 0) && (here->HFETAsourcePrimeNode != 0)) + { + i = here->HFETAsourcePrmPrmSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourcePrmPrmSourcePrimeStructPtr = matched ; + here->HFETAsourcePrmPrmSourcePrimePtr = matched->CSC ; + } + + if ((here->HFETAsourcePrmPrmNode != 0) && (here->HFETAgatePrimeNode != 0)) + { + i = here->HFETAsourcePrmPrmGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourcePrmPrmGatePrimeStructPtr = matched ; + here->HFETAsourcePrmPrmGatePrimePtr = matched->CSC ; + } + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAsourcePrmPrmNode != 0)) + { + i = here->HFETAgatePrimeSourcePrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAgatePrimeSourcePrmPrmStructPtr = matched ; + here->HFETAgatePrimeSourcePrmPrmPtr = matched->CSC ; + } + + if ((here->HFETAsourcePrmPrmNode != 0) && (here->HFETAsourcePrmPrmNode != 0)) + { + i = here->HFETAsourcePrmPrmSourcePrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAsourcePrmPrmSourcePrmPrmStructPtr = matched ; + here->HFETAsourcePrmPrmSourcePrmPrmPtr = matched->CSC ; + } + + if ((here->HFETAgateNode != 0) && (here->HFETAgateNode != 0)) + { + i = here->HFETAgateGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAgateGateStructPtr = matched ; + here->HFETAgateGatePtr = matched->CSC ; + } + + if ((here->HFETAgateNode != 0) && (here->HFETAgatePrimeNode != 0)) + { + i = here->HFETAgateGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAgateGatePrimeStructPtr = matched ; + here->HFETAgateGatePrimePtr = matched->CSC ; + } + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAgateNode != 0)) + { + i = here->HFETAgatePrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFETAgatePrimeGateStructPtr = matched ; + here->HFETAgatePrimeGatePtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +HFETAbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + HFETAmodel *model = (HFETAmodel *)inModel ; + HFETAinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the HFETA models */ + for ( ; model != NULL ; model = model->HFETAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->HFETAinstances ; here != NULL ; here = here->HFETAnextInstance) + { + if ((here->HFETAdrainNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAdrainDrainPrimePtr = here->HFETAdrainDrainPrimeStructPtr->CSC_Complex ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAgatePrimeDrainPrimePtr = here->HFETAgatePrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAgatePrimeSourcePrimePtr = here->HFETAgatePrimeSourcePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAsourceNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAsourceSourcePrimePtr = here->HFETAsourceSourcePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAdrainNode != 0)) + here->HFETAdrainPrimeDrainPtr = here->HFETAdrainPrimeDrainStructPtr->CSC_Complex ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAdrainPrimeGatePrimePtr = here->HFETAdrainPrimeGatePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAdrainPrimeSourcePrimePtr = here->HFETAdrainPrimeSourcePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAsourcePrimeGatePrimePtr = here->HFETAsourcePrimeGatePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAsourceNode != 0)) + here->HFETAsourcePrimeSourcePtr = here->HFETAsourcePrimeSourceStructPtr->CSC_Complex ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAsourcePrimeDrainPrimePtr = here->HFETAsourcePrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->HFETAdrainNode != 0) && (here->HFETAdrainNode != 0)) + here->HFETAdrainDrainPtr = here->HFETAdrainDrainStructPtr->CSC_Complex ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAgatePrimeGatePrimePtr = here->HFETAgatePrimeGatePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAsourceNode != 0) && (here->HFETAsourceNode != 0)) + here->HFETAsourceSourcePtr = here->HFETAsourceSourceStructPtr->CSC_Complex ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAdrainPrimeDrainPrimePtr = here->HFETAdrainPrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAsourcePrimeSourcePrimePtr = here->HFETAsourcePrimeSourcePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAdrainPrmPrmNode != 0)) + here->HFETAdrainPrimeDrainPrmPrmPtr = here->HFETAdrainPrimeDrainPrmPrmStructPtr->CSC_Complex ; + + if ((here->HFETAdrainPrmPrmNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAdrainPrmPrmDrainPrimePtr = here->HFETAdrainPrmPrmDrainPrimeStructPtr->CSC_Complex ; + + if ((here->HFETAdrainPrmPrmNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAdrainPrmPrmGatePrimePtr = here->HFETAdrainPrmPrmGatePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAdrainPrmPrmNode != 0)) + here->HFETAgatePrimeDrainPrmPrmPtr = here->HFETAgatePrimeDrainPrmPrmStructPtr->CSC_Complex ; + + if ((here->HFETAdrainPrmPrmNode != 0) && (here->HFETAdrainPrmPrmNode != 0)) + here->HFETAdrainPrmPrmDrainPrmPrmPtr = here->HFETAdrainPrmPrmDrainPrmPrmStructPtr->CSC_Complex ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAsourcePrmPrmNode != 0)) + here->HFETAsourcePrimeSourcePrmPrmPtr = here->HFETAsourcePrimeSourcePrmPrmStructPtr->CSC_Complex ; + + if ((here->HFETAsourcePrmPrmNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAsourcePrmPrmSourcePrimePtr = here->HFETAsourcePrmPrmSourcePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAsourcePrmPrmNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAsourcePrmPrmGatePrimePtr = here->HFETAsourcePrmPrmGatePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAsourcePrmPrmNode != 0)) + here->HFETAgatePrimeSourcePrmPrmPtr = here->HFETAgatePrimeSourcePrmPrmStructPtr->CSC_Complex ; + + if ((here->HFETAsourcePrmPrmNode != 0) && (here->HFETAsourcePrmPrmNode != 0)) + here->HFETAsourcePrmPrmSourcePrmPrmPtr = here->HFETAsourcePrmPrmSourcePrmPrmStructPtr->CSC_Complex ; + + if ((here->HFETAgateNode != 0) && (here->HFETAgateNode != 0)) + here->HFETAgateGatePtr = here->HFETAgateGateStructPtr->CSC_Complex ; + + if ((here->HFETAgateNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAgateGatePrimePtr = here->HFETAgateGatePrimeStructPtr->CSC_Complex ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAgateNode != 0)) + here->HFETAgatePrimeGatePtr = here->HFETAgatePrimeGateStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +HFETAbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + HFETAmodel *model = (HFETAmodel *)inModel ; + HFETAinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the HFETA models */ + for ( ; model != NULL ; model = model->HFETAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->HFETAinstances ; here != NULL ; here = here->HFETAnextInstance) + { + if ((here->HFETAdrainNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAdrainDrainPrimePtr = here->HFETAdrainDrainPrimeStructPtr->CSC ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAgatePrimeDrainPrimePtr = here->HFETAgatePrimeDrainPrimeStructPtr->CSC ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAgatePrimeSourcePrimePtr = here->HFETAgatePrimeSourcePrimeStructPtr->CSC ; + + if ((here->HFETAsourceNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAsourceSourcePrimePtr = here->HFETAsourceSourcePrimeStructPtr->CSC ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAdrainNode != 0)) + here->HFETAdrainPrimeDrainPtr = here->HFETAdrainPrimeDrainStructPtr->CSC ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAdrainPrimeGatePrimePtr = here->HFETAdrainPrimeGatePrimeStructPtr->CSC ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAdrainPrimeSourcePrimePtr = here->HFETAdrainPrimeSourcePrimeStructPtr->CSC ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAsourcePrimeGatePrimePtr = here->HFETAsourcePrimeGatePrimeStructPtr->CSC ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAsourceNode != 0)) + here->HFETAsourcePrimeSourcePtr = here->HFETAsourcePrimeSourceStructPtr->CSC ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAsourcePrimeDrainPrimePtr = here->HFETAsourcePrimeDrainPrimeStructPtr->CSC ; + + if ((here->HFETAdrainNode != 0) && (here->HFETAdrainNode != 0)) + here->HFETAdrainDrainPtr = here->HFETAdrainDrainStructPtr->CSC ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAgatePrimeGatePrimePtr = here->HFETAgatePrimeGatePrimeStructPtr->CSC ; + + if ((here->HFETAsourceNode != 0) && (here->HFETAsourceNode != 0)) + here->HFETAsourceSourcePtr = here->HFETAsourceSourceStructPtr->CSC ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAdrainPrimeDrainPrimePtr = here->HFETAdrainPrimeDrainPrimeStructPtr->CSC ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAsourcePrimeSourcePrimePtr = here->HFETAsourcePrimeSourcePrimeStructPtr->CSC ; + + if ((here->HFETAdrainPrimeNode != 0) && (here->HFETAdrainPrmPrmNode != 0)) + here->HFETAdrainPrimeDrainPrmPrmPtr = here->HFETAdrainPrimeDrainPrmPrmStructPtr->CSC ; + + if ((here->HFETAdrainPrmPrmNode != 0) && (here->HFETAdrainPrimeNode != 0)) + here->HFETAdrainPrmPrmDrainPrimePtr = here->HFETAdrainPrmPrmDrainPrimeStructPtr->CSC ; + + if ((here->HFETAdrainPrmPrmNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAdrainPrmPrmGatePrimePtr = here->HFETAdrainPrmPrmGatePrimeStructPtr->CSC ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAdrainPrmPrmNode != 0)) + here->HFETAgatePrimeDrainPrmPrmPtr = here->HFETAgatePrimeDrainPrmPrmStructPtr->CSC ; + + if ((here->HFETAdrainPrmPrmNode != 0) && (here->HFETAdrainPrmPrmNode != 0)) + here->HFETAdrainPrmPrmDrainPrmPrmPtr = here->HFETAdrainPrmPrmDrainPrmPrmStructPtr->CSC ; + + if ((here->HFETAsourcePrimeNode != 0) && (here->HFETAsourcePrmPrmNode != 0)) + here->HFETAsourcePrimeSourcePrmPrmPtr = here->HFETAsourcePrimeSourcePrmPrmStructPtr->CSC ; + + if ((here->HFETAsourcePrmPrmNode != 0) && (here->HFETAsourcePrimeNode != 0)) + here->HFETAsourcePrmPrmSourcePrimePtr = here->HFETAsourcePrmPrmSourcePrimeStructPtr->CSC ; + + if ((here->HFETAsourcePrmPrmNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAsourcePrmPrmGatePrimePtr = here->HFETAsourcePrmPrmGatePrimeStructPtr->CSC ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAsourcePrmPrmNode != 0)) + here->HFETAgatePrimeSourcePrmPrmPtr = here->HFETAgatePrimeSourcePrmPrmStructPtr->CSC ; + + if ((here->HFETAsourcePrmPrmNode != 0) && (here->HFETAsourcePrmPrmNode != 0)) + here->HFETAsourcePrmPrmSourcePrmPrmPtr = here->HFETAsourcePrmPrmSourcePrmPrmStructPtr->CSC ; + + if ((here->HFETAgateNode != 0) && (here->HFETAgateNode != 0)) + here->HFETAgateGatePtr = here->HFETAgateGateStructPtr->CSC ; + + if ((here->HFETAgateNode != 0) && (here->HFETAgatePrimeNode != 0)) + here->HFETAgateGatePrimePtr = here->HFETAgateGatePrimeStructPtr->CSC ; + + if ((here->HFETAgatePrimeNode != 0) && (here->HFETAgateNode != 0)) + here->HFETAgatePrimeGatePtr = here->HFETAgatePrimeGateStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/hfet1/hfetdefs.h b/src/spicelib/devices/hfet1/hfetdefs.h index 9a324b4c6..1c06b5840 100644 --- a/src/spicelib/devices/hfet1/hfetdefs.h +++ b/src/spicelib/devices/hfet1/hfetdefs.h @@ -122,6 +122,37 @@ typedef struct sHFETAinstance { double HFETAfgds; double HFETAggrwl; +#ifdef KLU + BindElement *HFETAdrainDrainPrimeStructPtr ; + BindElement *HFETAgatePrimeDrainPrimeStructPtr ; + BindElement *HFETAgatePrimeSourcePrimeStructPtr ; + BindElement *HFETAsourceSourcePrimeStructPtr ; + BindElement *HFETAdrainPrimeDrainStructPtr ; + BindElement *HFETAdrainPrimeGatePrimeStructPtr ; + BindElement *HFETAdrainPrimeSourcePrimeStructPtr ; + BindElement *HFETAsourcePrimeGatePrimeStructPtr ; + BindElement *HFETAsourcePrimeSourceStructPtr ; + BindElement *HFETAsourcePrimeDrainPrimeStructPtr ; + BindElement *HFETAdrainDrainStructPtr ; + BindElement *HFETAgatePrimeGatePrimeStructPtr ; + BindElement *HFETAsourceSourceStructPtr ; + BindElement *HFETAdrainPrimeDrainPrimeStructPtr ; + BindElement *HFETAsourcePrimeSourcePrimeStructPtr ; + BindElement *HFETAdrainPrimeDrainPrmPrmStructPtr ; + BindElement *HFETAdrainPrmPrmDrainPrimeStructPtr ; + BindElement *HFETAdrainPrmPrmGatePrimeStructPtr ; + BindElement *HFETAgatePrimeDrainPrmPrmStructPtr ; + BindElement *HFETAdrainPrmPrmDrainPrmPrmStructPtr ; + BindElement *HFETAsourcePrimeSourcePrmPrmStructPtr ; + BindElement *HFETAsourcePrmPrmSourcePrimeStructPtr ; + BindElement *HFETAsourcePrmPrmGatePrimeStructPtr ; + BindElement *HFETAgatePrimeSourcePrmPrmStructPtr ; + BindElement *HFETAsourcePrmPrmSourcePrmPrmStructPtr ; + BindElement *HFETAgateGateStructPtr ; + BindElement *HFETAgateGatePrimeStructPtr ; + BindElement *HFETAgatePrimeGateStructPtr ; +#endif + } HFETAinstance ; diff --git a/src/spicelib/devices/hfet1/hfetext.h b/src/spicelib/devices/hfet1/hfetext.h index 36d866f2d..2929482a4 100644 --- a/src/spicelib/devices/hfet1/hfetext.h +++ b/src/spicelib/devices/hfet1/hfetext.h @@ -18,3 +18,9 @@ extern int HFETAsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int HFETAtemp(GENmodel*,CKTcircuit*); extern int HFETAtrunc(GENmodel*,CKTcircuit*,double*); extern int HFETAunsetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int HFETAbindCSC (GENmodel*, CKTcircuit*) ; +extern int HFETAbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int HFETAbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/hfet1/hfetinit.c b/src/spicelib/devices/hfet1/hfetinit.c index 8af00cbad..c154ab3f5 100644 --- a/src/spicelib/devices/hfet1/hfetinit.c +++ b/src/spicelib/devices/hfet1/hfetinit.c @@ -73,7 +73,13 @@ SPICEdev HFETAinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &HFETAiSize, - /* DEVmodSize */ &HFETAmSize + /* DEVmodSize */ &HFETAmSize, + +#ifdef KLU + /* DEVbindCSC */ HFETAbindCSC, + /* DEVbindCSCComplex */ HFETAbindCSC, + /* DEVbindCSCComplexToReal */ HFETAbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/hfet2/Makefile.am b/src/spicelib/devices/hfet2/Makefile.am index 743fae0a2..14f1ad5c1 100644 --- a/src/spicelib/devices/hfet2/Makefile.am +++ b/src/spicelib/devices/hfet2/Makefile.am @@ -25,7 +25,11 @@ libhfet2_la_SOURCES = \ hfet2trunc.c +if KLU_WANTED +libhfet2_la_SOURCES += hfet2bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/hfet2/hfet2bindCSC.c b/src/spicelib/devices/hfet2/hfet2bindCSC.c new file mode 100644 index 000000000..31a3cda29 --- /dev/null +++ b/src/spicelib/devices/hfet2/hfet2bindCSC.c @@ -0,0 +1,295 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "hfet2defs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +HFET2bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + HFET2model *model = (HFET2model *)inModel ; + HFET2instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the HFET2 models */ + for ( ; model != NULL ; model = model->HFET2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->HFET2instances ; here != NULL ; here = here->HFET2nextInstance) + { + if ((here->HFET2drainNode != 0) && (here->HFET2drainPrimeNode != 0)) + { + i = here->HFET2drainDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2drainDrainPrimeStructPtr = matched ; + here->HFET2drainDrainPrimePtr = matched->CSC ; + } + + if ((here->HFET2gateNode != 0) && (here->HFET2drainPrimeNode != 0)) + { + i = here->HFET2gateDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2gateDrainPrimeStructPtr = matched ; + here->HFET2gateDrainPrimePtr = matched->CSC ; + } + + if ((here->HFET2gateNode != 0) && (here->HFET2sourcePrimeNode != 0)) + { + i = here->HFET2gateSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2gateSourcePrimeStructPtr = matched ; + here->HFET2gateSourcePrimePtr = matched->CSC ; + } + + if ((here->HFET2sourceNode != 0) && (here->HFET2sourcePrimeNode != 0)) + { + i = here->HFET2sourceSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2sourceSourcePrimeStructPtr = matched ; + here->HFET2sourceSourcePrimePtr = matched->CSC ; + } + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2drainNode != 0)) + { + i = here->HFET2drainPrimeDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2drainPrimeDrainStructPtr = matched ; + here->HFET2drainPrimeDrainPtr = matched->CSC ; + } + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2gateNode != 0)) + { + i = here->HFET2drainPrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2drainPrimeGateStructPtr = matched ; + here->HFET2drainPrimeGatePtr = matched->CSC ; + } + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2sourcePrimeNode != 0)) + { + i = here->HFET2drainPriHFET2ourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2drainPriHFET2ourcePrimeStructPtr = matched ; + here->HFET2drainPriHFET2ourcePrimePtr = matched->CSC ; + } + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2gateNode != 0)) + { + i = here->HFET2sourcePrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2sourcePrimeGateStructPtr = matched ; + here->HFET2sourcePrimeGatePtr = matched->CSC ; + } + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2sourceNode != 0)) + { + i = here->HFET2sourcePriHFET2ourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2sourcePriHFET2ourceStructPtr = matched ; + here->HFET2sourcePriHFET2ourcePtr = matched->CSC ; + } + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2drainPrimeNode != 0)) + { + i = here->HFET2sourcePrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2sourcePrimeDrainPrimeStructPtr = matched ; + here->HFET2sourcePrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->HFET2drainNode != 0) && (here->HFET2drainNode != 0)) + { + i = here->HFET2drainDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2drainDrainStructPtr = matched ; + here->HFET2drainDrainPtr = matched->CSC ; + } + + if ((here->HFET2gateNode != 0) && (here->HFET2gateNode != 0)) + { + i = here->HFET2gateGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2gateGateStructPtr = matched ; + here->HFET2gateGatePtr = matched->CSC ; + } + + if ((here->HFET2sourceNode != 0) && (here->HFET2sourceNode != 0)) + { + i = here->HFET2sourceSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2sourceSourceStructPtr = matched ; + here->HFET2sourceSourcePtr = matched->CSC ; + } + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2drainPrimeNode != 0)) + { + i = here->HFET2drainPrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2drainPrimeDrainPrimeStructPtr = matched ; + here->HFET2drainPrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2sourcePrimeNode != 0)) + { + i = here->HFET2sourcePriHFET2ourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HFET2sourcePriHFET2ourcePrimeStructPtr = matched ; + here->HFET2sourcePriHFET2ourcePrimePtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +HFET2bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + HFET2model *model = (HFET2model *)inModel ; + HFET2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the HFET2 models */ + for ( ; model != NULL ; model = model->HFET2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->HFET2instances ; here != NULL ; here = here->HFET2nextInstance) + { + if ((here->HFET2drainNode != 0) && (here->HFET2drainPrimeNode != 0)) + here->HFET2drainDrainPrimePtr = here->HFET2drainDrainPrimeStructPtr->CSC_Complex ; + + if ((here->HFET2gateNode != 0) && (here->HFET2drainPrimeNode != 0)) + here->HFET2gateDrainPrimePtr = here->HFET2gateDrainPrimeStructPtr->CSC_Complex ; + + if ((here->HFET2gateNode != 0) && (here->HFET2sourcePrimeNode != 0)) + here->HFET2gateSourcePrimePtr = here->HFET2gateSourcePrimeStructPtr->CSC_Complex ; + + if ((here->HFET2sourceNode != 0) && (here->HFET2sourcePrimeNode != 0)) + here->HFET2sourceSourcePrimePtr = here->HFET2sourceSourcePrimeStructPtr->CSC_Complex ; + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2drainNode != 0)) + here->HFET2drainPrimeDrainPtr = here->HFET2drainPrimeDrainStructPtr->CSC_Complex ; + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2gateNode != 0)) + here->HFET2drainPrimeGatePtr = here->HFET2drainPrimeGateStructPtr->CSC_Complex ; + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2sourcePrimeNode != 0)) + here->HFET2drainPriHFET2ourcePrimePtr = here->HFET2drainPriHFET2ourcePrimeStructPtr->CSC_Complex ; + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2gateNode != 0)) + here->HFET2sourcePrimeGatePtr = here->HFET2sourcePrimeGateStructPtr->CSC_Complex ; + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2sourceNode != 0)) + here->HFET2sourcePriHFET2ourcePtr = here->HFET2sourcePriHFET2ourceStructPtr->CSC_Complex ; + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2drainPrimeNode != 0)) + here->HFET2sourcePrimeDrainPrimePtr = here->HFET2sourcePrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->HFET2drainNode != 0) && (here->HFET2drainNode != 0)) + here->HFET2drainDrainPtr = here->HFET2drainDrainStructPtr->CSC_Complex ; + + if ((here->HFET2gateNode != 0) && (here->HFET2gateNode != 0)) + here->HFET2gateGatePtr = here->HFET2gateGateStructPtr->CSC_Complex ; + + if ((here->HFET2sourceNode != 0) && (here->HFET2sourceNode != 0)) + here->HFET2sourceSourcePtr = here->HFET2sourceSourceStructPtr->CSC_Complex ; + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2drainPrimeNode != 0)) + here->HFET2drainPrimeDrainPrimePtr = here->HFET2drainPrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2sourcePrimeNode != 0)) + here->HFET2sourcePriHFET2ourcePrimePtr = here->HFET2sourcePriHFET2ourcePrimeStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +HFET2bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + HFET2model *model = (HFET2model *)inModel ; + HFET2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the HFET2 models */ + for ( ; model != NULL ; model = model->HFET2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->HFET2instances ; here != NULL ; here = here->HFET2nextInstance) + { + if ((here->HFET2drainNode != 0) && (here->HFET2drainPrimeNode != 0)) + here->HFET2drainDrainPrimePtr = here->HFET2drainDrainPrimeStructPtr->CSC ; + + if ((here->HFET2gateNode != 0) && (here->HFET2drainPrimeNode != 0)) + here->HFET2gateDrainPrimePtr = here->HFET2gateDrainPrimeStructPtr->CSC ; + + if ((here->HFET2gateNode != 0) && (here->HFET2sourcePrimeNode != 0)) + here->HFET2gateSourcePrimePtr = here->HFET2gateSourcePrimeStructPtr->CSC ; + + if ((here->HFET2sourceNode != 0) && (here->HFET2sourcePrimeNode != 0)) + here->HFET2sourceSourcePrimePtr = here->HFET2sourceSourcePrimeStructPtr->CSC ; + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2drainNode != 0)) + here->HFET2drainPrimeDrainPtr = here->HFET2drainPrimeDrainStructPtr->CSC ; + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2gateNode != 0)) + here->HFET2drainPrimeGatePtr = here->HFET2drainPrimeGateStructPtr->CSC ; + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2sourcePrimeNode != 0)) + here->HFET2drainPriHFET2ourcePrimePtr = here->HFET2drainPriHFET2ourcePrimeStructPtr->CSC ; + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2gateNode != 0)) + here->HFET2sourcePrimeGatePtr = here->HFET2sourcePrimeGateStructPtr->CSC ; + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2sourceNode != 0)) + here->HFET2sourcePriHFET2ourcePtr = here->HFET2sourcePriHFET2ourceStructPtr->CSC ; + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2drainPrimeNode != 0)) + here->HFET2sourcePrimeDrainPrimePtr = here->HFET2sourcePrimeDrainPrimeStructPtr->CSC ; + + if ((here->HFET2drainNode != 0) && (here->HFET2drainNode != 0)) + here->HFET2drainDrainPtr = here->HFET2drainDrainStructPtr->CSC ; + + if ((here->HFET2gateNode != 0) && (here->HFET2gateNode != 0)) + here->HFET2gateGatePtr = here->HFET2gateGateStructPtr->CSC ; + + if ((here->HFET2sourceNode != 0) && (here->HFET2sourceNode != 0)) + here->HFET2sourceSourcePtr = here->HFET2sourceSourceStructPtr->CSC ; + + if ((here->HFET2drainPrimeNode != 0) && (here->HFET2drainPrimeNode != 0)) + here->HFET2drainPrimeDrainPrimePtr = here->HFET2drainPrimeDrainPrimeStructPtr->CSC ; + + if ((here->HFET2sourcePrimeNode != 0) && (here->HFET2sourcePrimeNode != 0)) + here->HFET2sourcePriHFET2ourcePrimePtr = here->HFET2sourcePriHFET2ourcePrimeStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/hfet2/hfet2defs.h b/src/spicelib/devices/hfet2/hfet2defs.h index d042e5886..643a6eb9f 100644 --- a/src/spicelib/devices/hfet2/hfet2defs.h +++ b/src/spicelib/devices/hfet2/hfet2defs.h @@ -80,7 +80,25 @@ typedef struct sHFET2instance { double HFET2vcrit; double HFET2ggrlw; double HFET2jslw; - + +#ifdef KLU + BindElement *HFET2drainDrainPrimeStructPtr ; + BindElement *HFET2gateDrainPrimeStructPtr ; + BindElement *HFET2gateSourcePrimeStructPtr ; + BindElement *HFET2sourceSourcePrimeStructPtr ; + BindElement *HFET2drainPrimeDrainStructPtr ; + BindElement *HFET2drainPrimeGateStructPtr ; + BindElement *HFET2drainPriHFET2ourcePrimeStructPtr ; + BindElement *HFET2sourcePrimeGateStructPtr ; + BindElement *HFET2sourcePriHFET2ourceStructPtr ; + BindElement *HFET2sourcePrimeDrainPrimeStructPtr ; + BindElement *HFET2drainDrainStructPtr ; + BindElement *HFET2gateGateStructPtr ; + BindElement *HFET2sourceSourceStructPtr ; + BindElement *HFET2drainPrimeDrainPrimeStructPtr ; + BindElement *HFET2sourcePriHFET2ourcePrimeStructPtr ; +#endif + } HFET2instance ; diff --git a/src/spicelib/devices/hfet2/hfet2ext.h b/src/spicelib/devices/hfet2/hfet2ext.h index 243861744..180bb04bf 100644 --- a/src/spicelib/devices/hfet2/hfet2ext.h +++ b/src/spicelib/devices/hfet2/hfet2ext.h @@ -18,3 +18,9 @@ extern int HFET2setup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int HFET2temp(GENmodel*,CKTcircuit*); extern int HFET2trunc(GENmodel*,CKTcircuit*,double*); extern int HFET2unsetup( GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int HFET2bindCSC (GENmodel*, CKTcircuit*) ; +extern int HFET2bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int HFET2bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/hfet2/hfet2init.c b/src/spicelib/devices/hfet2/hfet2init.c index 7c1679970..59beb1ebf 100644 --- a/src/spicelib/devices/hfet2/hfet2init.c +++ b/src/spicelib/devices/hfet2/hfet2init.c @@ -73,7 +73,13 @@ SPICEdev HFET2info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &HFET2iSize, - /* DEVmodSize */ &HFET2mSize + /* DEVmodSize */ &HFET2mSize, + +#ifdef KLU + /* DEVbindCSC */ HFET2bindCSC, + /* DEVbindCSCComplex */ HFET2bindCSCComplex, + /* DEVbindCSCComplexToReal */ HFET2bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/hisim2/Makefile.am b/src/spicelib/devices/hisim2/Makefile.am index f5e8106e8..25e31f277 100644 --- a/src/spicelib/devices/hisim2/Makefile.am +++ b/src/spicelib/devices/hisim2/Makefile.am @@ -33,6 +33,10 @@ libhisim2_la_SOURCES = hisim2.h \ hsm2trunc.c +if KLU_WANTED +libhisim2_la_SOURCES += hsm2bindCSC.c +endif + AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/hisim2/hsm2bindCSC.c b/src/spicelib/devices/hisim2/hsm2bindCSC.c new file mode 100644 index 000000000..7466116a7 --- /dev/null +++ b/src/spicelib/devices/hisim2/hsm2bindCSC.c @@ -0,0 +1,733 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "hsm2def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +HSM2bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + HSM2model *model = (HSM2model *)inModel ; + HSM2instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the HSM2 models */ + for ( ; model != NULL ; model = model->HSM2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->HSM2instances ; here != NULL ; here = here->HSM2nextInstance) + { + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + { + i = here->HSM2DPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DPbpStructPtr = matched ; + here->HSM2DPbpPtr = matched->CSC ; + } + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + { + i = here->HSM2SPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SPbpStructPtr = matched ; + here->HSM2SPbpPtr = matched->CSC ; + } + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + { + i = here->HSM2GPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GPbpStructPtr = matched ; + here->HSM2GPbpPtr = matched->CSC ; + } + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + { + i = here->HSM2BPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BPdpStructPtr = matched ; + here->HSM2BPdpPtr = matched->CSC ; + } + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + { + i = here->HSM2BPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BPspStructPtr = matched ; + here->HSM2BPspPtr = matched->CSC ; + } + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + { + i = here->HSM2BPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BPgpStructPtr = matched ; + here->HSM2BPgpPtr = matched->CSC ; + } + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + { + i = here->HSM2BPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BPbpStructPtr = matched ; + here->HSM2BPbpPtr = matched->CSC ; + } + + if ((here-> HSM2dNode != 0) && (here-> HSM2dNode != 0)) + { + i = here->HSM2DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DdStructPtr = matched ; + here->HSM2DdPtr = matched->CSC ; + } + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + { + i = here->HSM2GPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GPgpStructPtr = matched ; + here->HSM2GPgpPtr = matched->CSC ; + } + + if ((here-> HSM2sNode != 0) && (here-> HSM2sNode != 0)) + { + i = here->HSM2SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SsStructPtr = matched ; + here->HSM2SsPtr = matched->CSC ; + } + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + { + i = here->HSM2DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DPdpStructPtr = matched ; + here->HSM2DPdpPtr = matched->CSC ; + } + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + { + i = here->HSM2SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SPspStructPtr = matched ; + here->HSM2SPspPtr = matched->CSC ; + } + + if ((here-> HSM2dNode != 0) && (here-> HSM2dNodePrime != 0)) + { + i = here->HSM2DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DdpStructPtr = matched ; + here->HSM2DdpPtr = matched->CSC ; + } + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + { + i = here->HSM2GPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GPdpStructPtr = matched ; + here->HSM2GPdpPtr = matched->CSC ; + } + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + { + i = here->HSM2GPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GPspStructPtr = matched ; + here->HSM2GPspPtr = matched->CSC ; + } + + if ((here-> HSM2sNode != 0) && (here-> HSM2sNodePrime != 0)) + { + i = here->HSM2SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SspStructPtr = matched ; + here->HSM2SspPtr = matched->CSC ; + } + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + { + i = here->HSM2DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DPspStructPtr = matched ; + here->HSM2DPspPtr = matched->CSC ; + } + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2dNode != 0)) + { + i = here->HSM2DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DPdStructPtr = matched ; + here->HSM2DPdPtr = matched->CSC ; + } + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + { + i = here->HSM2DPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DPgpStructPtr = matched ; + here->HSM2DPgpPtr = matched->CSC ; + } + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + { + i = here->HSM2SPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SPgpStructPtr = matched ; + here->HSM2SPgpPtr = matched->CSC ; + } + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2sNode != 0)) + { + i = here->HSM2SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SPsStructPtr = matched ; + here->HSM2SPsPtr = matched->CSC ; + } + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + { + i = here->HSM2SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SPdpStructPtr = matched ; + here->HSM2SPdpPtr = matched->CSC ; + } + + if ( here->HSM2_corg == 1 ) + { + if ((here-> HSM2gNode != 0) && (here-> HSM2gNode != 0)) + { + i = here->HSM2GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GgStructPtr = matched ; + here->HSM2GgPtr = matched->CSC ; + } + + if ((here-> HSM2gNode != 0) && (here-> HSM2gNodePrime != 0)) + { + i = here->HSM2GgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GgpStructPtr = matched ; + here->HSM2GgpPtr = matched->CSC ; + } + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2gNode != 0)) + { + i = here->HSM2GPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GPgStructPtr = matched ; + here->HSM2GPgPtr = matched->CSC ; + } + + if ((here-> HSM2gNode != 0) && (here-> HSM2dNodePrime != 0)) + { + i = here->HSM2GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GdpStructPtr = matched ; + here->HSM2GdpPtr = matched->CSC ; + } + + if ((here-> HSM2gNode != 0) && (here-> HSM2sNodePrime != 0)) + { + i = here->HSM2GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GspStructPtr = matched ; + here->HSM2GspPtr = matched->CSC ; + } + + if ((here-> HSM2gNode != 0) && (here-> HSM2bNodePrime != 0)) + { + i = here->HSM2GbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2GbpStructPtr = matched ; + here->HSM2GbpPtr = matched->CSC ; + } + + } + if ( here->HSM2_corbnet == 1 ) + { + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2dbNode != 0)) + { + i = here->HSM2DPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DPdbStructPtr = matched ; + here->HSM2DPdbPtr = matched->CSC ; + } + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2sbNode != 0)) + { + i = here->HSM2SPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SPsbStructPtr = matched ; + here->HSM2SPsbPtr = matched->CSC ; + } + + if ((here-> HSM2dbNode != 0) && (here-> HSM2dNodePrime != 0)) + { + i = here->HSM2DBdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DBdpStructPtr = matched ; + here->HSM2DBdpPtr = matched->CSC ; + } + + if ((here-> HSM2dbNode != 0) && (here-> HSM2dbNode != 0)) + { + i = here->HSM2DBdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DBdbStructPtr = matched ; + here->HSM2DBdbPtr = matched->CSC ; + } + + if ((here-> HSM2dbNode != 0) && (here-> HSM2bNodePrime != 0)) + { + i = here->HSM2DBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DBbpStructPtr = matched ; + here->HSM2DBbpPtr = matched->CSC ; + } + + if ((here-> HSM2dbNode != 0) && (here-> HSM2bNode != 0)) + { + i = here->HSM2DBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2DBbStructPtr = matched ; + here->HSM2DBbPtr = matched->CSC ; + } + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2dbNode != 0)) + { + i = here->HSM2BPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BPdbStructPtr = matched ; + here->HSM2BPdbPtr = matched->CSC ; + } + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2bNode != 0)) + { + i = here->HSM2BPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BPbStructPtr = matched ; + here->HSM2BPbPtr = matched->CSC ; + } + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2sbNode != 0)) + { + i = here->HSM2BPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BPsbStructPtr = matched ; + here->HSM2BPsbPtr = matched->CSC ; + } + + if ((here-> HSM2sbNode != 0) && (here-> HSM2sNodePrime != 0)) + { + i = here->HSM2SBspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SBspStructPtr = matched ; + here->HSM2SBspPtr = matched->CSC ; + } + + if ((here-> HSM2sbNode != 0) && (here-> HSM2bNodePrime != 0)) + { + i = here->HSM2SBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SBbpStructPtr = matched ; + here->HSM2SBbpPtr = matched->CSC ; + } + + if ((here-> HSM2sbNode != 0) && (here-> HSM2bNode != 0)) + { + i = here->HSM2SBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SBbStructPtr = matched ; + here->HSM2SBbPtr = matched->CSC ; + } + + if ((here-> HSM2sbNode != 0) && (here-> HSM2sbNode != 0)) + { + i = here->HSM2SBsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2SBsbStructPtr = matched ; + here->HSM2SBsbPtr = matched->CSC ; + } + + if ((here-> HSM2bNode != 0) && (here-> HSM2dbNode != 0)) + { + i = here->HSM2BdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BdbStructPtr = matched ; + here->HSM2BdbPtr = matched->CSC ; + } + + if ((here-> HSM2bNode != 0) && (here-> HSM2bNodePrime != 0)) + { + i = here->HSM2BbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BbpStructPtr = matched ; + here->HSM2BbpPtr = matched->CSC ; + } + + if ((here-> HSM2bNode != 0) && (here-> HSM2sbNode != 0)) + { + i = here->HSM2BsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BsbStructPtr = matched ; + here->HSM2BsbPtr = matched->CSC ; + } + + if ((here-> HSM2bNode != 0) && (here-> HSM2bNode != 0)) + { + i = here->HSM2BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSM2BbStructPtr = matched ; + here->HSM2BbPtr = matched->CSC ; + } + + } + } + } + + return (OK) ; +} + +int +HSM2bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + HSM2model *model = (HSM2model *)inModel ; + HSM2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the HSM2 models */ + for ( ; model != NULL ; model = model->HSM2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->HSM2instances ; here != NULL ; here = here->HSM2nextInstance) + { + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2DPbpPtr = here->HSM2DPbpStructPtr->CSC_Complex ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2SPbpPtr = here->HSM2SPbpStructPtr->CSC_Complex ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2GPbpPtr = here->HSM2GPbpStructPtr->CSC_Complex ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2BPdpPtr = here->HSM2BPdpStructPtr->CSC_Complex ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2BPspPtr = here->HSM2BPspStructPtr->CSC_Complex ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2BPgpPtr = here->HSM2BPgpStructPtr->CSC_Complex ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2BPbpPtr = here->HSM2BPbpStructPtr->CSC_Complex ; + + if ((here-> HSM2dNode != 0) && (here-> HSM2dNode != 0)) + here->HSM2DdPtr = here->HSM2DdStructPtr->CSC_Complex ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2GPgpPtr = here->HSM2GPgpStructPtr->CSC_Complex ; + + if ((here-> HSM2sNode != 0) && (here-> HSM2sNode != 0)) + here->HSM2SsPtr = here->HSM2SsStructPtr->CSC_Complex ; + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2DPdpPtr = here->HSM2DPdpStructPtr->CSC_Complex ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2SPspPtr = here->HSM2SPspStructPtr->CSC_Complex ; + + if ((here-> HSM2dNode != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2DdpPtr = here->HSM2DdpStructPtr->CSC_Complex ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2GPdpPtr = here->HSM2GPdpStructPtr->CSC_Complex ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2GPspPtr = here->HSM2GPspStructPtr->CSC_Complex ; + + if ((here-> HSM2sNode != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2SspPtr = here->HSM2SspStructPtr->CSC_Complex ; + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2DPspPtr = here->HSM2DPspStructPtr->CSC_Complex ; + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2dNode != 0)) + here->HSM2DPdPtr = here->HSM2DPdStructPtr->CSC_Complex ; + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2DPgpPtr = here->HSM2DPgpStructPtr->CSC_Complex ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2SPgpPtr = here->HSM2SPgpStructPtr->CSC_Complex ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2sNode != 0)) + here->HSM2SPsPtr = here->HSM2SPsStructPtr->CSC_Complex ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2SPdpPtr = here->HSM2SPdpStructPtr->CSC_Complex ; + + if ( here->HSM2_corg == 1 ) + { + if ((here-> HSM2gNode != 0) && (here-> HSM2gNode != 0)) + here->HSM2GgPtr = here->HSM2GgStructPtr->CSC_Complex ; + + if ((here-> HSM2gNode != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2GgpPtr = here->HSM2GgpStructPtr->CSC_Complex ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2gNode != 0)) + here->HSM2GPgPtr = here->HSM2GPgStructPtr->CSC_Complex ; + + if ((here-> HSM2gNode != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2GdpPtr = here->HSM2GdpStructPtr->CSC_Complex ; + + if ((here-> HSM2gNode != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2GspPtr = here->HSM2GspStructPtr->CSC_Complex ; + + if ((here-> HSM2gNode != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2GbpPtr = here->HSM2GbpStructPtr->CSC_Complex ; + + } + if ( here->HSM2_corbnet == 1 ) + { + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2dbNode != 0)) + here->HSM2DPdbPtr = here->HSM2DPdbStructPtr->CSC_Complex ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2sbNode != 0)) + here->HSM2SPsbPtr = here->HSM2SPsbStructPtr->CSC_Complex ; + + if ((here-> HSM2dbNode != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2DBdpPtr = here->HSM2DBdpStructPtr->CSC_Complex ; + + if ((here-> HSM2dbNode != 0) && (here-> HSM2dbNode != 0)) + here->HSM2DBdbPtr = here->HSM2DBdbStructPtr->CSC_Complex ; + + if ((here-> HSM2dbNode != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2DBbpPtr = here->HSM2DBbpStructPtr->CSC_Complex ; + + if ((here-> HSM2dbNode != 0) && (here-> HSM2bNode != 0)) + here->HSM2DBbPtr = here->HSM2DBbStructPtr->CSC_Complex ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2dbNode != 0)) + here->HSM2BPdbPtr = here->HSM2BPdbStructPtr->CSC_Complex ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2bNode != 0)) + here->HSM2BPbPtr = here->HSM2BPbStructPtr->CSC_Complex ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2sbNode != 0)) + here->HSM2BPsbPtr = here->HSM2BPsbStructPtr->CSC_Complex ; + + if ((here-> HSM2sbNode != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2SBspPtr = here->HSM2SBspStructPtr->CSC_Complex ; + + if ((here-> HSM2sbNode != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2SBbpPtr = here->HSM2SBbpStructPtr->CSC_Complex ; + + if ((here-> HSM2sbNode != 0) && (here-> HSM2bNode != 0)) + here->HSM2SBbPtr = here->HSM2SBbStructPtr->CSC_Complex ; + + if ((here-> HSM2sbNode != 0) && (here-> HSM2sbNode != 0)) + here->HSM2SBsbPtr = here->HSM2SBsbStructPtr->CSC_Complex ; + + if ((here-> HSM2bNode != 0) && (here-> HSM2dbNode != 0)) + here->HSM2BdbPtr = here->HSM2BdbStructPtr->CSC_Complex ; + + if ((here-> HSM2bNode != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2BbpPtr = here->HSM2BbpStructPtr->CSC_Complex ; + + if ((here-> HSM2bNode != 0) && (here-> HSM2sbNode != 0)) + here->HSM2BsbPtr = here->HSM2BsbStructPtr->CSC_Complex ; + + if ((here-> HSM2bNode != 0) && (here-> HSM2bNode != 0)) + here->HSM2BbPtr = here->HSM2BbStructPtr->CSC_Complex ; + + } + } + } + + return (OK) ; +} + +int +HSM2bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + HSM2model *model = (HSM2model *)inModel ; + HSM2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the HSM2 models */ + for ( ; model != NULL ; model = model->HSM2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->HSM2instances ; here != NULL ; here = here->HSM2nextInstance) + { + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2DPbpPtr = here->HSM2DPbpStructPtr->CSC ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2SPbpPtr = here->HSM2SPbpStructPtr->CSC ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2GPbpPtr = here->HSM2GPbpStructPtr->CSC ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2BPdpPtr = here->HSM2BPdpStructPtr->CSC ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2BPspPtr = here->HSM2BPspStructPtr->CSC ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2BPgpPtr = here->HSM2BPgpStructPtr->CSC ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2BPbpPtr = here->HSM2BPbpStructPtr->CSC ; + + if ((here-> HSM2dNode != 0) && (here-> HSM2dNode != 0)) + here->HSM2DdPtr = here->HSM2DdStructPtr->CSC ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2GPgpPtr = here->HSM2GPgpStructPtr->CSC ; + + if ((here-> HSM2sNode != 0) && (here-> HSM2sNode != 0)) + here->HSM2SsPtr = here->HSM2SsStructPtr->CSC ; + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2DPdpPtr = here->HSM2DPdpStructPtr->CSC ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2SPspPtr = here->HSM2SPspStructPtr->CSC ; + + if ((here-> HSM2dNode != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2DdpPtr = here->HSM2DdpStructPtr->CSC ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2GPdpPtr = here->HSM2GPdpStructPtr->CSC ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2GPspPtr = here->HSM2GPspStructPtr->CSC ; + + if ((here-> HSM2sNode != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2SspPtr = here->HSM2SspStructPtr->CSC ; + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2DPspPtr = here->HSM2DPspStructPtr->CSC ; + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2dNode != 0)) + here->HSM2DPdPtr = here->HSM2DPdStructPtr->CSC ; + + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2DPgpPtr = here->HSM2DPgpStructPtr->CSC ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2SPgpPtr = here->HSM2SPgpStructPtr->CSC ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2sNode != 0)) + here->HSM2SPsPtr = here->HSM2SPsStructPtr->CSC ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2SPdpPtr = here->HSM2SPdpStructPtr->CSC ; + + if ( here->HSM2_corg == 1 ) + { + if ((here-> HSM2gNode != 0) && (here-> HSM2gNode != 0)) + here->HSM2GgPtr = here->HSM2GgStructPtr->CSC ; + + if ((here-> HSM2gNode != 0) && (here-> HSM2gNodePrime != 0)) + here->HSM2GgpPtr = here->HSM2GgpStructPtr->CSC ; + + if ((here-> HSM2gNodePrime != 0) && (here-> HSM2gNode != 0)) + here->HSM2GPgPtr = here->HSM2GPgStructPtr->CSC ; + + if ((here-> HSM2gNode != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2GdpPtr = here->HSM2GdpStructPtr->CSC ; + + if ((here-> HSM2gNode != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2GspPtr = here->HSM2GspStructPtr->CSC ; + + if ((here-> HSM2gNode != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2GbpPtr = here->HSM2GbpStructPtr->CSC ; + + } + if ( here->HSM2_corbnet == 1 ) + { + if ((here-> HSM2dNodePrime != 0) && (here-> HSM2dbNode != 0)) + here->HSM2DPdbPtr = here->HSM2DPdbStructPtr->CSC ; + + if ((here-> HSM2sNodePrime != 0) && (here-> HSM2sbNode != 0)) + here->HSM2SPsbPtr = here->HSM2SPsbStructPtr->CSC ; + + if ((here-> HSM2dbNode != 0) && (here-> HSM2dNodePrime != 0)) + here->HSM2DBdpPtr = here->HSM2DBdpStructPtr->CSC ; + + if ((here-> HSM2dbNode != 0) && (here-> HSM2dbNode != 0)) + here->HSM2DBdbPtr = here->HSM2DBdbStructPtr->CSC ; + + if ((here-> HSM2dbNode != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2DBbpPtr = here->HSM2DBbpStructPtr->CSC ; + + if ((here-> HSM2dbNode != 0) && (here-> HSM2bNode != 0)) + here->HSM2DBbPtr = here->HSM2DBbStructPtr->CSC ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2dbNode != 0)) + here->HSM2BPdbPtr = here->HSM2BPdbStructPtr->CSC ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2bNode != 0)) + here->HSM2BPbPtr = here->HSM2BPbStructPtr->CSC ; + + if ((here-> HSM2bNodePrime != 0) && (here-> HSM2sbNode != 0)) + here->HSM2BPsbPtr = here->HSM2BPsbStructPtr->CSC ; + + if ((here-> HSM2sbNode != 0) && (here-> HSM2sNodePrime != 0)) + here->HSM2SBspPtr = here->HSM2SBspStructPtr->CSC ; + + if ((here-> HSM2sbNode != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2SBbpPtr = here->HSM2SBbpStructPtr->CSC ; + + if ((here-> HSM2sbNode != 0) && (here-> HSM2bNode != 0)) + here->HSM2SBbPtr = here->HSM2SBbStructPtr->CSC ; + + if ((here-> HSM2sbNode != 0) && (here-> HSM2sbNode != 0)) + here->HSM2SBsbPtr = here->HSM2SBsbStructPtr->CSC ; + + if ((here-> HSM2bNode != 0) && (here-> HSM2dbNode != 0)) + here->HSM2BdbPtr = here->HSM2BdbStructPtr->CSC ; + + if ((here-> HSM2bNode != 0) && (here-> HSM2bNodePrime != 0)) + here->HSM2BbpPtr = here->HSM2BbpStructPtr->CSC ; + + if ((here-> HSM2bNode != 0) && (here-> HSM2sbNode != 0)) + here->HSM2BsbPtr = here->HSM2BsbStructPtr->CSC ; + + if ((here-> HSM2bNode != 0) && (here-> HSM2bNode != 0)) + here->HSM2BbPtr = here->HSM2BbStructPtr->CSC ; + + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/hisim2/hsm2def.h b/src/spicelib/devices/hisim2/hsm2def.h index 3a941aaf2..e0315de42 100644 --- a/src/spicelib/devices/hisim2/hsm2def.h +++ b/src/spicelib/devices/hisim2/hsm2def.h @@ -675,6 +675,54 @@ typedef struct sHSM2instance { double **HSM2nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *HSM2DPbpStructPtr ; + BindElement *HSM2SPbpStructPtr ; + BindElement *HSM2GPbpStructPtr ; + BindElement *HSM2BPdpStructPtr ; + BindElement *HSM2BPspStructPtr ; + BindElement *HSM2BPgpStructPtr ; + BindElement *HSM2BPbpStructPtr ; + BindElement *HSM2DdStructPtr ; + BindElement *HSM2GPgpStructPtr ; + BindElement *HSM2SsStructPtr ; + BindElement *HSM2DPdpStructPtr ; + BindElement *HSM2SPspStructPtr ; + BindElement *HSM2DdpStructPtr ; + BindElement *HSM2GPdpStructPtr ; + BindElement *HSM2GPspStructPtr ; + BindElement *HSM2SspStructPtr ; + BindElement *HSM2DPspStructPtr ; + BindElement *HSM2DPdStructPtr ; + BindElement *HSM2DPgpStructPtr ; + BindElement *HSM2SPgpStructPtr ; + BindElement *HSM2SPsStructPtr ; + BindElement *HSM2SPdpStructPtr ; + BindElement *HSM2GgStructPtr ; + BindElement *HSM2GgpStructPtr ; + BindElement *HSM2GPgStructPtr ; + BindElement *HSM2GdpStructPtr ; + BindElement *HSM2GspStructPtr ; + BindElement *HSM2GbpStructPtr ; + BindElement *HSM2DPdbStructPtr ; + BindElement *HSM2SPsbStructPtr ; + BindElement *HSM2DBdpStructPtr ; + BindElement *HSM2DBdbStructPtr ; + BindElement *HSM2DBbpStructPtr ; + BindElement *HSM2DBbStructPtr ; + BindElement *HSM2BPdbStructPtr ; + BindElement *HSM2BPbStructPtr ; + BindElement *HSM2BPsbStructPtr ; + BindElement *HSM2SBspStructPtr ; + BindElement *HSM2SBbpStructPtr ; + BindElement *HSM2SBbStructPtr ; + BindElement *HSM2SBsbStructPtr ; + BindElement *HSM2BdbStructPtr ; + BindElement *HSM2BbpStructPtr ; + BindElement *HSM2BsbStructPtr ; + BindElement *HSM2BbStructPtr ; +#endif + } HSM2instance ; diff --git a/src/spicelib/devices/hisim2/hsm2ext.h b/src/spicelib/devices/hisim2/hsm2ext.h index ebae516e6..3b4f8e2c7 100644 --- a/src/spicelib/devices/hisim2/hsm2ext.h +++ b/src/spicelib/devices/hisim2/hsm2ext.h @@ -38,3 +38,9 @@ extern int HSM2temp(GENmodel*,CKTcircuit*); extern int HSM2trunc(GENmodel*,CKTcircuit*,double*); extern int HSM2noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int HSM2soaCheck(CKTcircuit *, GENmodel *); + +#ifdef KLU +extern int HSM2bindCSC (GENmodel*, CKTcircuit*) ; +extern int HSM2bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int HSM2bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/hisim2/hsm2init.c b/src/spicelib/devices/hisim2/hsm2init.c index 1eefbd18b..71d4d2100 100644 --- a/src/spicelib/devices/hisim2/hsm2init.c +++ b/src/spicelib/devices/hisim2/hsm2init.c @@ -71,7 +71,13 @@ SPICEdev HSM2info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &HSM2iSize, - /* DEVmodSize */ &HSM2mSize + /* DEVmodSize */ &HSM2mSize, + +#ifdef KLU + /* DEVbindCSC */ HSM2bindCSC, + /* DEVbindCSCComplex */ HSM2bindCSCComplex, + /* DEVbindCSCComplexToReal */ HSM2bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/hisimhv1/Makefile.am b/src/spicelib/devices/hisimhv1/Makefile.am index 44b121f18..84f0f516e 100644 --- a/src/spicelib/devices/hisimhv1/Makefile.am +++ b/src/spicelib/devices/hisimhv1/Makefile.am @@ -32,6 +32,11 @@ libhisimhv1_la_SOURCES = hisimhv.h \ hsmhvtemp_eval.h \ hsmhvtrunc.c + +if KLU_WANTED +libhisimhv1_la_SOURCES += hsmhvbindCSC.c +endif + AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/hisimhv1/hsmhvbindCSC.c b/src/spicelib/devices/hisimhv1/hsmhvbindCSC.c new file mode 100644 index 000000000..09c8b8226 --- /dev/null +++ b/src/spicelib/devices/hisimhv1/hsmhvbindCSC.c @@ -0,0 +1,1353 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "hsmhvdef.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +HSMHVbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + HSMHVmodel *model = (HSMHVmodel *)inModel ; + HSMHVinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the HSMHV models */ + for ( ; model != NULL ; model = model->HSMHVnextModel) + { + /* loop through all the instances of the model */ + for (here = model->HSMHVinstances ; here != NULL ; here = here->HSMHVnextInstance) + { + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVDPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDPbpStructPtr = matched ; + here->HSMHVDPbpPtr = matched->CSC ; + } + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVSPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSPbpStructPtr = matched ; + here->HSMHVSPbpPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVGPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPbpStructPtr = matched ; + here->HSMHVGPbpPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVdNode != 0)) + { + i = here->HSMHVBPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPdStructPtr = matched ; + here->HSMHVBPdPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVsNode != 0)) + { + i = here->HSMHVBPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPsStructPtr = matched ; + here->HSMHVBPsPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + { + i = here->HSMHVBPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPdpStructPtr = matched ; + here->HSMHVBPdpPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + { + i = here->HSMHVBPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPspStructPtr = matched ; + here->HSMHVBPspPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVBPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPgpStructPtr = matched ; + here->HSMHVBPgpPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVBPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPbpStructPtr = matched ; + here->HSMHVBPbpPtr = matched->CSC ; + } + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVdNode != 0)) + { + i = here->HSMHVDdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDdStructPtr = matched ; + here->HSMHVDdPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVGPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPgpStructPtr = matched ; + here->HSMHVGPgpPtr = matched->CSC ; + } + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsNode != 0)) + { + i = here->HSMHVSsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSsStructPtr = matched ; + here->HSMHVSsPtr = matched->CSC ; + } + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + { + i = here->HSMHVDPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDPdpStructPtr = matched ; + here->HSMHVDPdpPtr = matched->CSC ; + } + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + { + i = here->HSMHVSPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSPspStructPtr = matched ; + here->HSMHVSPspPtr = matched->CSC ; + } + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVdNodePrime != 0)) + { + i = here->HSMHVDdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDdpStructPtr = matched ; + here->HSMHVDdpPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + { + i = here->HSMHVGPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPdpStructPtr = matched ; + here->HSMHVGPdpPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + { + i = here->HSMHVGPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPspStructPtr = matched ; + here->HSMHVGPspPtr = matched->CSC ; + } + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsNodePrime != 0)) + { + i = here->HSMHVSspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSspStructPtr = matched ; + here->HSMHVSspPtr = matched->CSC ; + } + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + { + i = here->HSMHVDPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDPspStructPtr = matched ; + here->HSMHVDPspPtr = matched->CSC ; + } + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVdNode != 0)) + { + i = here->HSMHVDPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDPdStructPtr = matched ; + here->HSMHVDPdPtr = matched->CSC ; + } + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVDPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDPgpStructPtr = matched ; + here->HSMHVDPgpPtr = matched->CSC ; + } + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVSPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSPgpStructPtr = matched ; + here->HSMHVSPgpPtr = matched->CSC ; + } + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVsNode != 0)) + { + i = here->HSMHVSPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSPsStructPtr = matched ; + here->HSMHVSPsPtr = matched->CSC ; + } + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + { + i = here->HSMHVSPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSPdpStructPtr = matched ; + here->HSMHVSPdpPtr = matched->CSC ; + } + + if ((here-> HSMHVgNode != 0) && (here-> HSMHVgNode != 0)) + { + i = here->HSMHVGgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGgStructPtr = matched ; + here->HSMHVGgPtr = matched->CSC ; + } + + if ((here-> HSMHVgNode != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVGgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGgpStructPtr = matched ; + here->HSMHVGgpPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVgNode != 0)) + { + i = here->HSMHVGPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPgStructPtr = matched ; + here->HSMHVGPgPtr = matched->CSC ; + } + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVdbNode != 0)) + { + i = here->HSMHVDdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDdbStructPtr = matched ; + here->HSMHVDdbPtr = matched->CSC ; + } + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsbNode != 0)) + { + i = here->HSMHVSsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSsbStructPtr = matched ; + here->HSMHVSsbPtr = matched->CSC ; + } + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVdNode != 0)) + { + i = here->HSMHVDBdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDBdStructPtr = matched ; + here->HSMHVDBdPtr = matched->CSC ; + } + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVdbNode != 0)) + { + i = here->HSMHVDBdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDBdbStructPtr = matched ; + here->HSMHVDBdbPtr = matched->CSC ; + } + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVDBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDBbpStructPtr = matched ; + here->HSMHVDBbpPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVdbNode != 0)) + { + i = here->HSMHVBPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPdbStructPtr = matched ; + here->HSMHVBPdbPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVbNode != 0)) + { + i = here->HSMHVBPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPbStructPtr = matched ; + here->HSMHVBPbPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVsbNode != 0)) + { + i = here->HSMHVBPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPsbStructPtr = matched ; + here->HSMHVBPsbPtr = matched->CSC ; + } + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVsNode != 0)) + { + i = here->HSMHVSBsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSBsStructPtr = matched ; + here->HSMHVSBsPtr = matched->CSC ; + } + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVSBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSBbpStructPtr = matched ; + here->HSMHVSBbpPtr = matched->CSC ; + } + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVsbNode != 0)) + { + i = here->HSMHVSBsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSBsbStructPtr = matched ; + here->HSMHVSBsbPtr = matched->CSC ; + } + + if ((here-> HSMHVbNode != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBbpStructPtr = matched ; + here->HSMHVBbpPtr = matched->CSC ; + } + + if ((here-> HSMHVbNode != 0) && (here-> HSMHVbNode != 0)) + { + i = here->HSMHVBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBbStructPtr = matched ; + here->HSMHVBbPtr = matched->CSC ; + } + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVDgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDgpStructPtr = matched ; + here->HSMHVDgpPtr = matched->CSC ; + } + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVsNode != 0)) + { + i = here->HSMHVDsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDsStructPtr = matched ; + here->HSMHVDsPtr = matched->CSC ; + } + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVDbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDbpStructPtr = matched ; + here->HSMHVDbpPtr = matched->CSC ; + } + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVsNodePrime != 0)) + { + i = here->HSMHVDspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDspStructPtr = matched ; + here->HSMHVDspPtr = matched->CSC ; + } + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVsNode != 0)) + { + i = here->HSMHVDPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDPsStructPtr = matched ; + here->HSMHVDPsPtr = matched->CSC ; + } + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVSgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSgpStructPtr = matched ; + here->HSMHVSgpPtr = matched->CSC ; + } + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVdNode != 0)) + { + i = here->HSMHVSdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSdStructPtr = matched ; + here->HSMHVSdPtr = matched->CSC ; + } + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVSbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSbpStructPtr = matched ; + here->HSMHVSbpPtr = matched->CSC ; + } + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVdNodePrime != 0)) + { + i = here->HSMHVSdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSdpStructPtr = matched ; + here->HSMHVSdpPtr = matched->CSC ; + } + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVdNode != 0)) + { + i = here->HSMHVSPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSPdStructPtr = matched ; + here->HSMHVSPdPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVdNode != 0)) + { + i = here->HSMHVGPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPdStructPtr = matched ; + here->HSMHVGPdPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVsNode != 0)) + { + i = here->HSMHVGPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPsStructPtr = matched ; + here->HSMHVGPsPtr = matched->CSC ; + } + + if ( here->HSMHVsubNode > 0 ) + { + if ((here-> HSMHVdNode != 0) && (here-> HSMHVsubNode != 0)) + { + i = here->HSMHVDsubPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDsubStructPtr = matched ; + here->HSMHVDsubPtr = matched->CSC ; + } + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVsubNode != 0)) + { + i = here->HSMHVDPsubPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDPsubStructPtr = matched ; + here->HSMHVDPsubPtr = matched->CSC ; + } + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsubNode != 0)) + { + i = here->HSMHVSsubPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSsubStructPtr = matched ; + here->HSMHVSsubPtr = matched->CSC ; + } + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVsubNode != 0)) + { + i = here->HSMHVSPsubPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSPsubStructPtr = matched ; + here->HSMHVSPsubPtr = matched->CSC ; + } + + } + if ( here->HSMHV_coselfheat > 0 ) + { + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVTemptempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVTemptempStructPtr = matched ; + here->HSMHVTemptempPtr = matched->CSC ; + } + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVdNode != 0)) + { + i = here->HSMHVTempdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVTempdStructPtr = matched ; + here->HSMHVTempdPtr = matched->CSC ; + } + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVdNodePrime != 0)) + { + i = here->HSMHVTempdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVTempdpStructPtr = matched ; + here->HSMHVTempdpPtr = matched->CSC ; + } + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVsNode != 0)) + { + i = here->HSMHVTempsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVTempsStructPtr = matched ; + here->HSMHVTempsPtr = matched->CSC ; + } + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVsNodePrime != 0)) + { + i = here->HSMHVTempspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVTempspStructPtr = matched ; + here->HSMHVTempspPtr = matched->CSC ; + } + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVDPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDPtempStructPtr = matched ; + here->HSMHVDPtempPtr = matched->CSC ; + } + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVSPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSPtempStructPtr = matched ; + here->HSMHVSPtempPtr = matched->CSC ; + } + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVTempgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVTempgpStructPtr = matched ; + here->HSMHVTempgpPtr = matched->CSC ; + } + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVTempbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVTempbpStructPtr = matched ; + here->HSMHVTempbpPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVGPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPtempStructPtr = matched ; + here->HSMHVGPtempPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVBPtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPtempStructPtr = matched ; + here->HSMHVBPtempPtr = matched->CSC ; + } + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVDBtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDBtempStructPtr = matched ; + here->HSMHVDBtempPtr = matched->CSC ; + } + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVSBtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSBtempStructPtr = matched ; + here->HSMHVSBtempPtr = matched->CSC ; + } + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVDtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDtempStructPtr = matched ; + here->HSMHVDtempPtr = matched->CSC ; + } + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVStempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVStempStructPtr = matched ; + here->HSMHVStempPtr = matched->CSC ; + } + + } + if ( model->HSMHV_conqs ) + { + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVqiNode != 0)) + { + i = here->HSMHVDPqiPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVDPqiStructPtr = matched ; + here->HSMHVDPqiPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVqiNode != 0)) + { + i = here->HSMHVGPqiPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPqiStructPtr = matched ; + here->HSMHVGPqiPtr = matched->CSC ; + } + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVqbNode != 0)) + { + i = here->HSMHVGPqbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVGPqbStructPtr = matched ; + here->HSMHVGPqbPtr = matched->CSC ; + } + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVqiNode != 0)) + { + i = here->HSMHVSPqiPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVSPqiStructPtr = matched ; + here->HSMHVSPqiPtr = matched->CSC ; + } + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVqbNode != 0)) + { + i = here->HSMHVBPqbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVBPqbStructPtr = matched ; + here->HSMHVBPqbPtr = matched->CSC ; + } + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVdNodePrime != 0)) + { + i = here->HSMHVQIdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQIdpStructPtr = matched ; + here->HSMHVQIdpPtr = matched->CSC ; + } + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVQIgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQIgpStructPtr = matched ; + here->HSMHVQIgpPtr = matched->CSC ; + } + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVsNodePrime != 0)) + { + i = here->HSMHVQIspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQIspStructPtr = matched ; + here->HSMHVQIspPtr = matched->CSC ; + } + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVQIbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQIbpStructPtr = matched ; + here->HSMHVQIbpPtr = matched->CSC ; + } + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVqiNode != 0)) + { + i = here->HSMHVQIqiPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQIqiStructPtr = matched ; + here->HSMHVQIqiPtr = matched->CSC ; + } + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVdNodePrime != 0)) + { + i = here->HSMHVQBdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQBdpStructPtr = matched ; + here->HSMHVQBdpPtr = matched->CSC ; + } + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVgNodePrime != 0)) + { + i = here->HSMHVQBgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQBgpStructPtr = matched ; + here->HSMHVQBgpPtr = matched->CSC ; + } + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVsNodePrime != 0)) + { + i = here->HSMHVQBspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQBspStructPtr = matched ; + here->HSMHVQBspPtr = matched->CSC ; + } + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVbNodePrime != 0)) + { + i = here->HSMHVQBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQBbpStructPtr = matched ; + here->HSMHVQBbpPtr = matched->CSC ; + } + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVqbNode != 0)) + { + i = here->HSMHVQBqbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQBqbStructPtr = matched ; + here->HSMHVQBqbPtr = matched->CSC ; + } + + if ( here->HSMHV_coselfheat > 0 ) + { + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVQItempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQItempStructPtr = matched ; + here->HSMHVQItempPtr = matched->CSC ; + } + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVtempNode != 0)) + { + i = here->HSMHVQBtempPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->HSMHVQBtempStructPtr = matched ; + here->HSMHVQBtempPtr = matched->CSC ; + } + + } + } + } + } + + return (OK) ; +} + +int +HSMHVbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + HSMHVmodel *model = (HSMHVmodel *)inModel ; + HSMHVinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the HSMHV models */ + for ( ; model != NULL ; model = model->HSMHVnextModel) + { + /* loop through all the instances of the model */ + for (here = model->HSMHVinstances ; here != NULL ; here = here->HSMHVnextInstance) + { + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVDPbpPtr = here->HSMHVDPbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVSPbpPtr = here->HSMHVSPbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVGPbpPtr = here->HSMHVGPbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVBPdPtr = here->HSMHVBPdStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVBPsPtr = here->HSMHVBPsStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVBPdpPtr = here->HSMHVBPdpStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVBPspPtr = here->HSMHVBPspStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVBPgpPtr = here->HSMHVBPgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVBPbpPtr = here->HSMHVBPbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVDdPtr = here->HSMHVDdStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVGPgpPtr = here->HSMHVGPgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVSsPtr = here->HSMHVSsStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVDPdpPtr = here->HSMHVDPdpStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVSPspPtr = here->HSMHVSPspStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVDdpPtr = here->HSMHVDdpStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVGPdpPtr = here->HSMHVGPdpStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVGPspPtr = here->HSMHVGPspStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVSspPtr = here->HSMHVSspStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVDPspPtr = here->HSMHVDPspStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVDPdPtr = here->HSMHVDPdStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVDPgpPtr = here->HSMHVDPgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVSPgpPtr = here->HSMHVSPgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVSPsPtr = here->HSMHVSPsStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVSPdpPtr = here->HSMHVSPdpStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNode != 0) && (here-> HSMHVgNode != 0)) + here->HSMHVGgPtr = here->HSMHVGgStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVGgpPtr = here->HSMHVGgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVgNode != 0)) + here->HSMHVGPgPtr = here->HSMHVGPgStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVdbNode != 0)) + here->HSMHVDdbPtr = here->HSMHVDdbStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsbNode != 0)) + here->HSMHVSsbPtr = here->HSMHVSsbStructPtr->CSC_Complex ; + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVDBdPtr = here->HSMHVDBdStructPtr->CSC_Complex ; + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVdbNode != 0)) + here->HSMHVDBdbPtr = here->HSMHVDBdbStructPtr->CSC_Complex ; + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVDBbpPtr = here->HSMHVDBbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVdbNode != 0)) + here->HSMHVBPdbPtr = here->HSMHVBPdbStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVbNode != 0)) + here->HSMHVBPbPtr = here->HSMHVBPbStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVsbNode != 0)) + here->HSMHVBPsbPtr = here->HSMHVBPsbStructPtr->CSC_Complex ; + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVSBsPtr = here->HSMHVSBsStructPtr->CSC_Complex ; + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVSBbpPtr = here->HSMHVSBbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVsbNode != 0)) + here->HSMHVSBsbPtr = here->HSMHVSBsbStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVBbpPtr = here->HSMHVBbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNode != 0) && (here-> HSMHVbNode != 0)) + here->HSMHVBbPtr = here->HSMHVBbStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVDgpPtr = here->HSMHVDgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVDsPtr = here->HSMHVDsStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVDbpPtr = here->HSMHVDbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVDspPtr = here->HSMHVDspStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVDPsPtr = here->HSMHVDPsStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVSgpPtr = here->HSMHVSgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVSdPtr = here->HSMHVSdStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVSbpPtr = here->HSMHVSbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVSdpPtr = here->HSMHVSdpStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVSPdPtr = here->HSMHVSPdStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVGPdPtr = here->HSMHVGPdStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVGPsPtr = here->HSMHVGPsStructPtr->CSC_Complex ; + + if ( here->HSMHVsubNode > 0 ) + { + if ((here-> HSMHVdNode != 0) && (here-> HSMHVsubNode != 0)) + here->HSMHVDsubPtr = here->HSMHVDsubStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVsubNode != 0)) + here->HSMHVDPsubPtr = here->HSMHVDPsubStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsubNode != 0)) + here->HSMHVSsubPtr = here->HSMHVSsubStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVsubNode != 0)) + here->HSMHVSPsubPtr = here->HSMHVSPsubStructPtr->CSC_Complex ; + + } + if ( here->HSMHV_coselfheat > 0 ) + { + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVTemptempPtr = here->HSMHVTemptempStructPtr->CSC_Complex ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVTempdPtr = here->HSMHVTempdStructPtr->CSC_Complex ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVTempdpPtr = here->HSMHVTempdpStructPtr->CSC_Complex ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVTempsPtr = here->HSMHVTempsStructPtr->CSC_Complex ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVTempspPtr = here->HSMHVTempspStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVDPtempPtr = here->HSMHVDPtempStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVSPtempPtr = here->HSMHVSPtempStructPtr->CSC_Complex ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVTempgpPtr = here->HSMHVTempgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVTempbpPtr = here->HSMHVTempbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVGPtempPtr = here->HSMHVGPtempStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVBPtempPtr = here->HSMHVBPtempStructPtr->CSC_Complex ; + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVDBtempPtr = here->HSMHVDBtempStructPtr->CSC_Complex ; + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVSBtempPtr = here->HSMHVSBtempStructPtr->CSC_Complex ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVDtempPtr = here->HSMHVDtempStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVStempPtr = here->HSMHVStempStructPtr->CSC_Complex ; + + } + if ( model->HSMHV_conqs ) + { + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVqiNode != 0)) + here->HSMHVDPqiPtr = here->HSMHVDPqiStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVqiNode != 0)) + here->HSMHVGPqiPtr = here->HSMHVGPqiStructPtr->CSC_Complex ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVqbNode != 0)) + here->HSMHVGPqbPtr = here->HSMHVGPqbStructPtr->CSC_Complex ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVqiNode != 0)) + here->HSMHVSPqiPtr = here->HSMHVSPqiStructPtr->CSC_Complex ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVqbNode != 0)) + here->HSMHVBPqbPtr = here->HSMHVBPqbStructPtr->CSC_Complex ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVQIdpPtr = here->HSMHVQIdpStructPtr->CSC_Complex ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVQIgpPtr = here->HSMHVQIgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVQIspPtr = here->HSMHVQIspStructPtr->CSC_Complex ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVQIbpPtr = here->HSMHVQIbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVqiNode != 0)) + here->HSMHVQIqiPtr = here->HSMHVQIqiStructPtr->CSC_Complex ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVQBdpPtr = here->HSMHVQBdpStructPtr->CSC_Complex ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVQBgpPtr = here->HSMHVQBgpStructPtr->CSC_Complex ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVQBspPtr = here->HSMHVQBspStructPtr->CSC_Complex ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVQBbpPtr = here->HSMHVQBbpStructPtr->CSC_Complex ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVqbNode != 0)) + here->HSMHVQBqbPtr = here->HSMHVQBqbStructPtr->CSC_Complex ; + + if ( here->HSMHV_coselfheat > 0 ) + { + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVQItempPtr = here->HSMHVQItempStructPtr->CSC_Complex ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVQBtempPtr = here->HSMHVQBtempStructPtr->CSC_Complex ; + + } + } + } + } + + return (OK) ; +} + +int +HSMHVbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + HSMHVmodel *model = (HSMHVmodel *)inModel ; + HSMHVinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the HSMHV models */ + for ( ; model != NULL ; model = model->HSMHVnextModel) + { + /* loop through all the instances of the model */ + for (here = model->HSMHVinstances ; here != NULL ; here = here->HSMHVnextInstance) + { + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVDPbpPtr = here->HSMHVDPbpStructPtr->CSC ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVSPbpPtr = here->HSMHVSPbpStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVGPbpPtr = here->HSMHVGPbpStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVBPdPtr = here->HSMHVBPdStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVBPsPtr = here->HSMHVBPsStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVBPdpPtr = here->HSMHVBPdpStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVBPspPtr = here->HSMHVBPspStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVBPgpPtr = here->HSMHVBPgpStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVBPbpPtr = here->HSMHVBPbpStructPtr->CSC ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVDdPtr = here->HSMHVDdStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVGPgpPtr = here->HSMHVGPgpStructPtr->CSC ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVSsPtr = here->HSMHVSsStructPtr->CSC ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVDPdpPtr = here->HSMHVDPdpStructPtr->CSC ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVSPspPtr = here->HSMHVSPspStructPtr->CSC ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVDdpPtr = here->HSMHVDdpStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVGPdpPtr = here->HSMHVGPdpStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVGPspPtr = here->HSMHVGPspStructPtr->CSC ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVSspPtr = here->HSMHVSspStructPtr->CSC ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVDPspPtr = here->HSMHVDPspStructPtr->CSC ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVDPdPtr = here->HSMHVDPdStructPtr->CSC ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVDPgpPtr = here->HSMHVDPgpStructPtr->CSC ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVSPgpPtr = here->HSMHVSPgpStructPtr->CSC ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVSPsPtr = here->HSMHVSPsStructPtr->CSC ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVSPdpPtr = here->HSMHVSPdpStructPtr->CSC ; + + if ((here-> HSMHVgNode != 0) && (here-> HSMHVgNode != 0)) + here->HSMHVGgPtr = here->HSMHVGgStructPtr->CSC ; + + if ((here-> HSMHVgNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVGgpPtr = here->HSMHVGgpStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVgNode != 0)) + here->HSMHVGPgPtr = here->HSMHVGPgStructPtr->CSC ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVdbNode != 0)) + here->HSMHVDdbPtr = here->HSMHVDdbStructPtr->CSC ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsbNode != 0)) + here->HSMHVSsbPtr = here->HSMHVSsbStructPtr->CSC ; + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVDBdPtr = here->HSMHVDBdStructPtr->CSC ; + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVdbNode != 0)) + here->HSMHVDBdbPtr = here->HSMHVDBdbStructPtr->CSC ; + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVDBbpPtr = here->HSMHVDBbpStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVdbNode != 0)) + here->HSMHVBPdbPtr = here->HSMHVBPdbStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVbNode != 0)) + here->HSMHVBPbPtr = here->HSMHVBPbStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVsbNode != 0)) + here->HSMHVBPsbPtr = here->HSMHVBPsbStructPtr->CSC ; + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVSBsPtr = here->HSMHVSBsStructPtr->CSC ; + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVSBbpPtr = here->HSMHVSBbpStructPtr->CSC ; + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVsbNode != 0)) + here->HSMHVSBsbPtr = here->HSMHVSBsbStructPtr->CSC ; + + if ((here-> HSMHVbNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVBbpPtr = here->HSMHVBbpStructPtr->CSC ; + + if ((here-> HSMHVbNode != 0) && (here-> HSMHVbNode != 0)) + here->HSMHVBbPtr = here->HSMHVBbStructPtr->CSC ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVDgpPtr = here->HSMHVDgpStructPtr->CSC ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVDsPtr = here->HSMHVDsStructPtr->CSC ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVDbpPtr = here->HSMHVDbpStructPtr->CSC ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVDspPtr = here->HSMHVDspStructPtr->CSC ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVDPsPtr = here->HSMHVDPsStructPtr->CSC ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVSgpPtr = here->HSMHVSgpStructPtr->CSC ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVSdPtr = here->HSMHVSdStructPtr->CSC ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVSbpPtr = here->HSMHVSbpStructPtr->CSC ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVSdpPtr = here->HSMHVSdpStructPtr->CSC ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVSPdPtr = here->HSMHVSPdStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVGPdPtr = here->HSMHVGPdStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVGPsPtr = here->HSMHVGPsStructPtr->CSC ; + + if ( here->HSMHVsubNode > 0 ) + { + if ((here-> HSMHVdNode != 0) && (here-> HSMHVsubNode != 0)) + here->HSMHVDsubPtr = here->HSMHVDsubStructPtr->CSC ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVsubNode != 0)) + here->HSMHVDPsubPtr = here->HSMHVDPsubStructPtr->CSC ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVsubNode != 0)) + here->HSMHVSsubPtr = here->HSMHVSsubStructPtr->CSC ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVsubNode != 0)) + here->HSMHVSPsubPtr = here->HSMHVSPsubStructPtr->CSC ; + + } + if ( here->HSMHV_coselfheat > 0 ) + { + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVTemptempPtr = here->HSMHVTemptempStructPtr->CSC ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVdNode != 0)) + here->HSMHVTempdPtr = here->HSMHVTempdStructPtr->CSC ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVTempdpPtr = here->HSMHVTempdpStructPtr->CSC ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVsNode != 0)) + here->HSMHVTempsPtr = here->HSMHVTempsStructPtr->CSC ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVTempspPtr = here->HSMHVTempspStructPtr->CSC ; + + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVDPtempPtr = here->HSMHVDPtempStructPtr->CSC ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVSPtempPtr = here->HSMHVSPtempStructPtr->CSC ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVTempgpPtr = here->HSMHVTempgpStructPtr->CSC ; + + if ((here-> HSMHVtempNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVTempbpPtr = here->HSMHVTempbpStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVGPtempPtr = here->HSMHVGPtempStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVBPtempPtr = here->HSMHVBPtempStructPtr->CSC ; + + if ((here-> HSMHVdbNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVDBtempPtr = here->HSMHVDBtempStructPtr->CSC ; + + if ((here-> HSMHVsbNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVSBtempPtr = here->HSMHVSBtempStructPtr->CSC ; + + if ((here-> HSMHVdNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVDtempPtr = here->HSMHVDtempStructPtr->CSC ; + + if ((here-> HSMHVsNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVStempPtr = here->HSMHVStempStructPtr->CSC ; + + } + if ( model->HSMHV_conqs ) + { + if ((here-> HSMHVdNodePrime != 0) && (here-> HSMHVqiNode != 0)) + here->HSMHVDPqiPtr = here->HSMHVDPqiStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVqiNode != 0)) + here->HSMHVGPqiPtr = here->HSMHVGPqiStructPtr->CSC ; + + if ((here-> HSMHVgNodePrime != 0) && (here-> HSMHVqbNode != 0)) + here->HSMHVGPqbPtr = here->HSMHVGPqbStructPtr->CSC ; + + if ((here-> HSMHVsNodePrime != 0) && (here-> HSMHVqiNode != 0)) + here->HSMHVSPqiPtr = here->HSMHVSPqiStructPtr->CSC ; + + if ((here-> HSMHVbNodePrime != 0) && (here-> HSMHVqbNode != 0)) + here->HSMHVBPqbPtr = here->HSMHVBPqbStructPtr->CSC ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVQIdpPtr = here->HSMHVQIdpStructPtr->CSC ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVQIgpPtr = here->HSMHVQIgpStructPtr->CSC ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVQIspPtr = here->HSMHVQIspStructPtr->CSC ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVQIbpPtr = here->HSMHVQIbpStructPtr->CSC ; + + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVqiNode != 0)) + here->HSMHVQIqiPtr = here->HSMHVQIqiStructPtr->CSC ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVdNodePrime != 0)) + here->HSMHVQBdpPtr = here->HSMHVQBdpStructPtr->CSC ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVgNodePrime != 0)) + here->HSMHVQBgpPtr = here->HSMHVQBgpStructPtr->CSC ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVsNodePrime != 0)) + here->HSMHVQBspPtr = here->HSMHVQBspStructPtr->CSC ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVbNodePrime != 0)) + here->HSMHVQBbpPtr = here->HSMHVQBbpStructPtr->CSC ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVqbNode != 0)) + here->HSMHVQBqbPtr = here->HSMHVQBqbStructPtr->CSC ; + + if ( here->HSMHV_coselfheat > 0 ) + { + if ((here-> HSMHVqiNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVQItempPtr = here->HSMHVQItempStructPtr->CSC ; + + if ((here-> HSMHVqbNode != 0) && (here-> HSMHVtempNode != 0)) + here->HSMHVQBtempPtr = here->HSMHVQBtempStructPtr->CSC ; + + } + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/hisimhv1/hsmhvdef.h b/src/spicelib/devices/hisimhv1/hsmhvdef.h index 8ddfe40a2..0b7084b9e 100644 --- a/src/spicelib/devices/hisimhv1/hsmhvdef.h +++ b/src/spicelib/devices/hisimhv1/hsmhvdef.h @@ -903,6 +903,97 @@ typedef struct sHSMHVinstance { double **HSMHVnVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *HSMHVDPbpStructPtr ; + BindElement *HSMHVSPbpStructPtr ; + BindElement *HSMHVGPbpStructPtr ; + BindElement *HSMHVBPdStructPtr ; + BindElement *HSMHVBPsStructPtr ; + BindElement *HSMHVBPdpStructPtr ; + BindElement *HSMHVBPspStructPtr ; + BindElement *HSMHVBPgpStructPtr ; + BindElement *HSMHVBPbpStructPtr ; + BindElement *HSMHVDdStructPtr ; + BindElement *HSMHVGPgpStructPtr ; + BindElement *HSMHVSsStructPtr ; + BindElement *HSMHVDPdpStructPtr ; + BindElement *HSMHVSPspStructPtr ; + BindElement *HSMHVDdpStructPtr ; + BindElement *HSMHVGPdpStructPtr ; + BindElement *HSMHVGPspStructPtr ; + BindElement *HSMHVSspStructPtr ; + BindElement *HSMHVDPspStructPtr ; + BindElement *HSMHVDPdStructPtr ; + BindElement *HSMHVDPgpStructPtr ; + BindElement *HSMHVSPgpStructPtr ; + BindElement *HSMHVSPsStructPtr ; + BindElement *HSMHVSPdpStructPtr ; + BindElement *HSMHVGgStructPtr ; + BindElement *HSMHVGgpStructPtr ; + BindElement *HSMHVGPgStructPtr ; + BindElement *HSMHVDdbStructPtr ; + BindElement *HSMHVSsbStructPtr ; + BindElement *HSMHVDBdStructPtr ; + BindElement *HSMHVDBdbStructPtr ; + BindElement *HSMHVDBbpStructPtr ; + BindElement *HSMHVBPdbStructPtr ; + BindElement *HSMHVBPbStructPtr ; + BindElement *HSMHVBPsbStructPtr ; + BindElement *HSMHVSBsStructPtr ; + BindElement *HSMHVSBbpStructPtr ; + BindElement *HSMHVSBsbStructPtr ; + BindElement *HSMHVBbpStructPtr ; + BindElement *HSMHVBbStructPtr ; + BindElement *HSMHVDgpStructPtr ; + BindElement *HSMHVDsStructPtr ; + BindElement *HSMHVDbpStructPtr ; + BindElement *HSMHVDspStructPtr ; + BindElement *HSMHVDPsStructPtr ; + BindElement *HSMHVSgpStructPtr ; + BindElement *HSMHVSdStructPtr ; + BindElement *HSMHVSbpStructPtr ; + BindElement *HSMHVSdpStructPtr ; + BindElement *HSMHVSPdStructPtr ; + BindElement *HSMHVGPdStructPtr ; + BindElement *HSMHVGPsStructPtr ; + BindElement *HSMHVDsubStructPtr ; + BindElement *HSMHVDPsubStructPtr ; + BindElement *HSMHVSsubStructPtr ; + BindElement *HSMHVSPsubStructPtr ; + BindElement *HSMHVTemptempStructPtr ; + BindElement *HSMHVTempdStructPtr ; + BindElement *HSMHVTempdpStructPtr ; + BindElement *HSMHVTempsStructPtr ; + BindElement *HSMHVTempspStructPtr ; + BindElement *HSMHVDPtempStructPtr ; + BindElement *HSMHVSPtempStructPtr ; + BindElement *HSMHVTempgpStructPtr ; + BindElement *HSMHVTempbpStructPtr ; + BindElement *HSMHVGPtempStructPtr ; + BindElement *HSMHVBPtempStructPtr ; + BindElement *HSMHVDBtempStructPtr ; + BindElement *HSMHVSBtempStructPtr ; + BindElement *HSMHVDtempStructPtr ; + BindElement *HSMHVStempStructPtr ; + BindElement *HSMHVDPqiStructPtr ; + BindElement *HSMHVGPqiStructPtr ; + BindElement *HSMHVGPqbStructPtr ; + BindElement *HSMHVSPqiStructPtr ; + BindElement *HSMHVBPqbStructPtr ; + BindElement *HSMHVQIdpStructPtr ; + BindElement *HSMHVQIgpStructPtr ; + BindElement *HSMHVQIspStructPtr ; + BindElement *HSMHVQIbpStructPtr ; + BindElement *HSMHVQIqiStructPtr ; + BindElement *HSMHVQBdpStructPtr ; + BindElement *HSMHVQBgpStructPtr ; + BindElement *HSMHVQBspStructPtr ; + BindElement *HSMHVQBbpStructPtr ; + BindElement *HSMHVQBqbStructPtr ; + BindElement *HSMHVQItempStructPtr ; + BindElement *HSMHVQBtempStructPtr ; +#endif + } HSMHVinstance ; diff --git a/src/spicelib/devices/hisimhv1/hsmhvext.h b/src/spicelib/devices/hisimhv1/hsmhvext.h index 7ba0be7ba..b5f4a3798 100644 --- a/src/spicelib/devices/hisimhv1/hsmhvext.h +++ b/src/spicelib/devices/hisimhv1/hsmhvext.h @@ -38,3 +38,9 @@ extern int HSMHVtemp(GENmodel*,CKTcircuit*); extern int HSMHVtrunc(GENmodel*,CKTcircuit*,double*); extern int HSMHVnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int HSMHVsoaCheck(CKTcircuit *, GENmodel *); + +#ifdef KLU +extern int HSMHVbindCSC (GENmodel*, CKTcircuit*); +extern int HSMHVbindCSCComplex (GENmodel*, CKTcircuit*); +extern int HSMHVbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/hisimhv1/hsmhvinit.c b/src/spicelib/devices/hisimhv1/hsmhvinit.c index 759348afc..be8439aa4 100644 --- a/src/spicelib/devices/hisimhv1/hsmhvinit.c +++ b/src/spicelib/devices/hisimhv1/hsmhvinit.c @@ -71,7 +71,13 @@ SPICEdev HSMHVinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &HSMHViSize, - /* DEVmodSize */ &HSMHVmSize + /* DEVmodSize */ &HSMHVmSize, + +#ifdef KLU + /* DEVbindCSC */ HSMHVbindCSC, + /* DEVbindCSCComplex */ HSMHVbindCSCComplex, + /* DEVbindCSCComplexToReal */ HSMHVbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/ind/Makefile.am b/src/spicelib/devices/ind/Makefile.am index 5a05ee97b..dfbc0442f 100644 --- a/src/spicelib/devices/ind/Makefile.am +++ b/src/spicelib/devices/ind/Makefile.am @@ -40,7 +40,12 @@ libind_la_SOURCES = \ muttemp.c +if KLU_WANTED +libind_la_SOURCES += indbindCSC.c +libind_la_SOURCES += mutbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/ind/indbindCSC.c b/src/spicelib/devices/ind/indbindCSC.c new file mode 100644 index 000000000..7558b1bc3 --- /dev/null +++ b/src/spicelib/devices/ind/indbindCSC.c @@ -0,0 +1,155 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "inddefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +INDbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + INDmodel *model = (INDmodel *)inModel ; + INDinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the IND models */ + for ( ; model != NULL ; model = model->INDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->INDinstances ; here != NULL ; here = here->INDnextInstance) + { + if ((here->INDposNode != 0) && (here->INDbrEq != 0)) + { + i = here->INDposIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->INDposIbrptrStructPtr = matched ; + here->INDposIbrptr = matched->CSC ; + } + + if ((here->INDnegNode != 0) && (here->INDbrEq != 0)) + { + i = here->INDnegIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->INDnegIbrptrStructPtr = matched ; + here->INDnegIbrptr = matched->CSC ; + } + + if ((here->INDbrEq != 0) && (here->INDnegNode != 0)) + { + i = here->INDibrNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->INDibrNegptrStructPtr = matched ; + here->INDibrNegptr = matched->CSC ; + } + + if ((here->INDbrEq != 0) && (here->INDposNode != 0)) + { + i = here->INDibrPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->INDibrPosptrStructPtr = matched ; + here->INDibrPosptr = matched->CSC ; + } + + if ((here->INDbrEq != 0) && (here->INDbrEq != 0)) + { + i = here->INDibrIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->INDibrIbrptrStructPtr = matched ; + here->INDibrIbrptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +INDbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + INDmodel *model = (INDmodel *)inModel ; + INDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the IND models */ + for ( ; model != NULL ; model = model->INDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->INDinstances ; here != NULL ; here = here->INDnextInstance) + { + if ((here->INDposNode != 0) && (here->INDbrEq != 0)) + here->INDposIbrptr = here->INDposIbrptrStructPtr->CSC_Complex ; + + if ((here->INDnegNode != 0) && (here->INDbrEq != 0)) + here->INDnegIbrptr = here->INDnegIbrptrStructPtr->CSC_Complex ; + + if ((here->INDbrEq != 0) && (here->INDnegNode != 0)) + here->INDibrNegptr = here->INDibrNegptrStructPtr->CSC_Complex ; + + if ((here->INDbrEq != 0) && (here->INDposNode != 0)) + here->INDibrPosptr = here->INDibrPosptrStructPtr->CSC_Complex ; + + if ((here->INDbrEq != 0) && (here->INDbrEq != 0)) + here->INDibrIbrptr = here->INDibrIbrptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +INDbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + INDmodel *model = (INDmodel *)inModel ; + INDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the IND models */ + for ( ; model != NULL ; model = model->INDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->INDinstances ; here != NULL ; here = here->INDnextInstance) + { + if ((here->INDposNode != 0) && (here->INDbrEq != 0)) + here->INDposIbrptr = here->INDposIbrptrStructPtr->CSC ; + + if ((here->INDnegNode != 0) && (here->INDbrEq != 0)) + here->INDnegIbrptr = here->INDnegIbrptrStructPtr->CSC ; + + if ((here->INDbrEq != 0) && (here->INDnegNode != 0)) + here->INDibrNegptr = here->INDibrNegptrStructPtr->CSC ; + + if ((here->INDbrEq != 0) && (here->INDposNode != 0)) + here->INDibrPosptr = here->INDibrPosptrStructPtr->CSC ; + + if ((here->INDbrEq != 0) && (here->INDbrEq != 0)) + here->INDibrIbrptr = here->INDibrIbrptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/ind/inddefs.h b/src/spicelib/devices/ind/inddefs.h index d043c4afe..7c79317e5 100644 --- a/src/spicelib/devices/ind/inddefs.h +++ b/src/spicelib/devices/ind/inddefs.h @@ -63,6 +63,14 @@ typedef struct sINDinstance { int INDsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ +#ifdef KLU + BindElement *INDposIbrptrStructPtr ; + BindElement *INDnegIbrptrStructPtr ; + BindElement *INDibrNegptrStructPtr ; + BindElement *INDibrPosptrStructPtr ; + BindElement *INDibrIbrptrStructPtr ; +#endif + } INDinstance ; #define INDflux INDstate /* flux in the inductor */ @@ -131,6 +139,10 @@ unsigned MUTindGiven : 1; /* flag to indicate inductance was specified */ int MUTsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ +#ifdef KLU + BindElement *MUTbr1br2StructPtr ; + BindElement *MUTbr2br1StructPtr ; +#endif } MUTinstance ; diff --git a/src/spicelib/devices/ind/indext.h b/src/spicelib/devices/ind/indext.h index 8d2fa035c..ebed3a35a 100644 --- a/src/spicelib/devices/ind/indext.h +++ b/src/spicelib/devices/ind/indext.h @@ -36,4 +36,14 @@ extern void MUTsPrint(GENmodel*,CKTcircuit*); extern int MUTsSetup(SENstruct*,GENmodel*); extern int MUTsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int MUTtemp(GENmodel *inModel, CKTcircuit *ckt); + +#ifdef KLU +extern int INDbindCSC (GENmodel*, CKTcircuit*) ; +extern int INDbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int INDbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +extern int MUTbindCSC (GENmodel*, CKTcircuit*) ; +extern int MUTbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int MUTbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif + #endif diff --git a/src/spicelib/devices/ind/indinit.c b/src/spicelib/devices/ind/indinit.c index 20c325543..5264d5cb8 100644 --- a/src/spicelib/devices/ind/indinit.c +++ b/src/spicelib/devices/ind/indinit.c @@ -72,7 +72,13 @@ SPICEdev INDinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &INDiSize, - /* DEVmodSize */ &INDmSize + /* DEVmodSize */ &INDmSize, + +#ifdef KLU + /* DEVbindCSC */ INDbindCSC, + /* DEVbindCSCComplex */ INDbindCSCComplex, + /* DEVbindCSCComplexToReal */ INDbindCSCComplexToReal, +#endif }; @@ -143,7 +149,13 @@ SPICEdev MUTinfo = { /* DEVacct */ NULL, #endif &MUTiSize, - &MUTmSize + &MUTmSize, + +#ifdef KLU + /* DEVbindCSC */ MUTbindCSC, + /* DEVbindCSCComplex */ MUTbindCSCComplex, + /* DEVbindCSCComplexToReal */ MUTbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/ind/mutbindCSC.c b/src/spicelib/devices/ind/mutbindCSC.c new file mode 100644 index 000000000..d7124a931 --- /dev/null +++ b/src/spicelib/devices/ind/mutbindCSC.c @@ -0,0 +1,113 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "inddefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +MUTbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + MUTmodel *model = (MUTmodel *)inModel ; + MUTinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the MUT models */ + for ( ; model != NULL ; model = model->MUTnextModel) + { + /* loop through all the instances of the model */ + for (here = model->MUTinstances ; here != NULL ; here = here->MUTnextInstance) + { + if ((here->MUTind1->INDbrEq != 0) && (here->MUTind2->INDbrEq != 0)) + { + i = here->MUTbr1br2 ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MUTbr1br2StructPtr = matched ; + here->MUTbr1br2 = matched->CSC ; + } + + if ((here->MUTind2->INDbrEq != 0) && (here->MUTind1->INDbrEq != 0)) + { + i = here->MUTbr2br1 ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MUTbr2br1StructPtr = matched ; + here->MUTbr2br1 = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +MUTbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + MUTmodel *model = (MUTmodel *)inModel ; + MUTinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MUT models */ + for ( ; model != NULL ; model = model->MUTnextModel) + { + /* loop through all the instances of the model */ + for (here = model->MUTinstances ; here != NULL ; here = here->MUTnextInstance) + { + if ((here->MUTind1->INDbrEq != 0) && (here->MUTind2->INDbrEq != 0)) + here->MUTbr1br2 = here->MUTbr1br2StructPtr->CSC_Complex ; + + if ((here->MUTind2->INDbrEq != 0) && (here->MUTind1->INDbrEq != 0)) + here->MUTbr2br1 = here->MUTbr2br1StructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +MUTbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + MUTmodel *model = (MUTmodel *)inModel ; + MUTinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MUT models */ + for ( ; model != NULL ; model = model->MUTnextModel) + { + /* loop through all the instances of the model */ + for (here = model->MUTinstances ; here != NULL ; here = here->MUTnextInstance) + { + if ((here->MUTind1->INDbrEq != 0) && (here->MUTind2->INDbrEq != 0)) + here->MUTbr1br2 = here->MUTbr1br2StructPtr->CSC ; + + if ((here->MUTind2->INDbrEq != 0) && (here->MUTind1->INDbrEq != 0)) + here->MUTbr2br1 = here->MUTbr2br1StructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/isrc/isrcinit.c b/src/spicelib/devices/isrc/isrcinit.c index 2d02d4ec5..ce528b456 100644 --- a/src/spicelib/devices/isrc/isrcinit.c +++ b/src/spicelib/devices/isrc/isrcinit.c @@ -73,7 +73,14 @@ SPICEdev ISRCinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &ISRCiSize, - /* DEVmodSize */ &ISRCmSize + /* DEVmodSize */ &ISRCmSize, + +#ifdef KLU + /* DEVbindCSC */ NULL, + /* DEVbindCSCComplex */ NULL, + /* DEVbindCSCComplexToReal */ NULL, +#endif + }; diff --git a/src/spicelib/devices/jfet/Makefile.am b/src/spicelib/devices/jfet/Makefile.am index fc4907373..2f7947dfe 100644 --- a/src/spicelib/devices/jfet/Makefile.am +++ b/src/spicelib/devices/jfet/Makefile.am @@ -28,7 +28,11 @@ libjfet_la_SOURCES = \ jfettrun.c +if KLU_WANTED +libjfet_la_SOURCES += jfetbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/jfet/jfetbindCSC.c b/src/spicelib/devices/jfet/jfetbindCSC.c new file mode 100644 index 000000000..f781ab6bd --- /dev/null +++ b/src/spicelib/devices/jfet/jfetbindCSC.c @@ -0,0 +1,295 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "jfetdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +JFETbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + JFETmodel *model = (JFETmodel *)inModel ; + JFETinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the JFET models */ + for ( ; model != NULL ; model = model->JFETnextModel) + { + /* loop through all the instances of the model */ + for (here = model->JFETinstances ; here != NULL ; here = here->JFETnextInstance) + { + if ((here->JFETdrainNode != 0) && (here->JFETdrainPrimeNode != 0)) + { + i = here->JFETdrainDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETdrainDrainPrimeStructPtr = matched ; + here->JFETdrainDrainPrimePtr = matched->CSC ; + } + + if ((here->JFETgateNode != 0) && (here->JFETdrainPrimeNode != 0)) + { + i = here->JFETgateDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETgateDrainPrimeStructPtr = matched ; + here->JFETgateDrainPrimePtr = matched->CSC ; + } + + if ((here->JFETgateNode != 0) && (here->JFETsourcePrimeNode != 0)) + { + i = here->JFETgateSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETgateSourcePrimeStructPtr = matched ; + here->JFETgateSourcePrimePtr = matched->CSC ; + } + + if ((here->JFETsourceNode != 0) && (here->JFETsourcePrimeNode != 0)) + { + i = here->JFETsourceSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETsourceSourcePrimeStructPtr = matched ; + here->JFETsourceSourcePrimePtr = matched->CSC ; + } + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETdrainNode != 0)) + { + i = here->JFETdrainPrimeDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETdrainPrimeDrainStructPtr = matched ; + here->JFETdrainPrimeDrainPtr = matched->CSC ; + } + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETgateNode != 0)) + { + i = here->JFETdrainPrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETdrainPrimeGateStructPtr = matched ; + here->JFETdrainPrimeGatePtr = matched->CSC ; + } + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETsourcePrimeNode != 0)) + { + i = here->JFETdrainPrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETdrainPrimeSourcePrimeStructPtr = matched ; + here->JFETdrainPrimeSourcePrimePtr = matched->CSC ; + } + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETgateNode != 0)) + { + i = here->JFETsourcePrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETsourcePrimeGateStructPtr = matched ; + here->JFETsourcePrimeGatePtr = matched->CSC ; + } + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETsourceNode != 0)) + { + i = here->JFETsourcePrimeSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETsourcePrimeSourceStructPtr = matched ; + here->JFETsourcePrimeSourcePtr = matched->CSC ; + } + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETdrainPrimeNode != 0)) + { + i = here->JFETsourcePrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETsourcePrimeDrainPrimeStructPtr = matched ; + here->JFETsourcePrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->JFETdrainNode != 0) && (here->JFETdrainNode != 0)) + { + i = here->JFETdrainDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETdrainDrainStructPtr = matched ; + here->JFETdrainDrainPtr = matched->CSC ; + } + + if ((here->JFETgateNode != 0) && (here->JFETgateNode != 0)) + { + i = here->JFETgateGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETgateGateStructPtr = matched ; + here->JFETgateGatePtr = matched->CSC ; + } + + if ((here->JFETsourceNode != 0) && (here->JFETsourceNode != 0)) + { + i = here->JFETsourceSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETsourceSourceStructPtr = matched ; + here->JFETsourceSourcePtr = matched->CSC ; + } + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETdrainPrimeNode != 0)) + { + i = here->JFETdrainPrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETdrainPrimeDrainPrimeStructPtr = matched ; + here->JFETdrainPrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETsourcePrimeNode != 0)) + { + i = here->JFETsourcePrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFETsourcePrimeSourcePrimeStructPtr = matched ; + here->JFETsourcePrimeSourcePrimePtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +JFETbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + JFETmodel *model = (JFETmodel *)inModel ; + JFETinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the JFET models */ + for ( ; model != NULL ; model = model->JFETnextModel) + { + /* loop through all the instances of the model */ + for (here = model->JFETinstances ; here != NULL ; here = here->JFETnextInstance) + { + if ((here->JFETdrainNode != 0) && (here->JFETdrainPrimeNode != 0)) + here->JFETdrainDrainPrimePtr = here->JFETdrainDrainPrimeStructPtr->CSC_Complex ; + + if ((here->JFETgateNode != 0) && (here->JFETdrainPrimeNode != 0)) + here->JFETgateDrainPrimePtr = here->JFETgateDrainPrimeStructPtr->CSC_Complex ; + + if ((here->JFETgateNode != 0) && (here->JFETsourcePrimeNode != 0)) + here->JFETgateSourcePrimePtr = here->JFETgateSourcePrimeStructPtr->CSC_Complex ; + + if ((here->JFETsourceNode != 0) && (here->JFETsourcePrimeNode != 0)) + here->JFETsourceSourcePrimePtr = here->JFETsourceSourcePrimeStructPtr->CSC_Complex ; + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETdrainNode != 0)) + here->JFETdrainPrimeDrainPtr = here->JFETdrainPrimeDrainStructPtr->CSC_Complex ; + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETgateNode != 0)) + here->JFETdrainPrimeGatePtr = here->JFETdrainPrimeGateStructPtr->CSC_Complex ; + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETsourcePrimeNode != 0)) + here->JFETdrainPrimeSourcePrimePtr = here->JFETdrainPrimeSourcePrimeStructPtr->CSC_Complex ; + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETgateNode != 0)) + here->JFETsourcePrimeGatePtr = here->JFETsourcePrimeGateStructPtr->CSC_Complex ; + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETsourceNode != 0)) + here->JFETsourcePrimeSourcePtr = here->JFETsourcePrimeSourceStructPtr->CSC_Complex ; + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETdrainPrimeNode != 0)) + here->JFETsourcePrimeDrainPrimePtr = here->JFETsourcePrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->JFETdrainNode != 0) && (here->JFETdrainNode != 0)) + here->JFETdrainDrainPtr = here->JFETdrainDrainStructPtr->CSC_Complex ; + + if ((here->JFETgateNode != 0) && (here->JFETgateNode != 0)) + here->JFETgateGatePtr = here->JFETgateGateStructPtr->CSC_Complex ; + + if ((here->JFETsourceNode != 0) && (here->JFETsourceNode != 0)) + here->JFETsourceSourcePtr = here->JFETsourceSourceStructPtr->CSC_Complex ; + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETdrainPrimeNode != 0)) + here->JFETdrainPrimeDrainPrimePtr = here->JFETdrainPrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETsourcePrimeNode != 0)) + here->JFETsourcePrimeSourcePrimePtr = here->JFETsourcePrimeSourcePrimeStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +JFETbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + JFETmodel *model = (JFETmodel *)inModel ; + JFETinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the JFET models */ + for ( ; model != NULL ; model = model->JFETnextModel) + { + /* loop through all the instances of the model */ + for (here = model->JFETinstances ; here != NULL ; here = here->JFETnextInstance) + { + if ((here->JFETdrainNode != 0) && (here->JFETdrainPrimeNode != 0)) + here->JFETdrainDrainPrimePtr = here->JFETdrainDrainPrimeStructPtr->CSC ; + + if ((here->JFETgateNode != 0) && (here->JFETdrainPrimeNode != 0)) + here->JFETgateDrainPrimePtr = here->JFETgateDrainPrimeStructPtr->CSC ; + + if ((here->JFETgateNode != 0) && (here->JFETsourcePrimeNode != 0)) + here->JFETgateSourcePrimePtr = here->JFETgateSourcePrimeStructPtr->CSC ; + + if ((here->JFETsourceNode != 0) && (here->JFETsourcePrimeNode != 0)) + here->JFETsourceSourcePrimePtr = here->JFETsourceSourcePrimeStructPtr->CSC ; + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETdrainNode != 0)) + here->JFETdrainPrimeDrainPtr = here->JFETdrainPrimeDrainStructPtr->CSC ; + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETgateNode != 0)) + here->JFETdrainPrimeGatePtr = here->JFETdrainPrimeGateStructPtr->CSC ; + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETsourcePrimeNode != 0)) + here->JFETdrainPrimeSourcePrimePtr = here->JFETdrainPrimeSourcePrimeStructPtr->CSC ; + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETgateNode != 0)) + here->JFETsourcePrimeGatePtr = here->JFETsourcePrimeGateStructPtr->CSC ; + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETsourceNode != 0)) + here->JFETsourcePrimeSourcePtr = here->JFETsourcePrimeSourceStructPtr->CSC ; + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETdrainPrimeNode != 0)) + here->JFETsourcePrimeDrainPrimePtr = here->JFETsourcePrimeDrainPrimeStructPtr->CSC ; + + if ((here->JFETdrainNode != 0) && (here->JFETdrainNode != 0)) + here->JFETdrainDrainPtr = here->JFETdrainDrainStructPtr->CSC ; + + if ((here->JFETgateNode != 0) && (here->JFETgateNode != 0)) + here->JFETgateGatePtr = here->JFETgateGateStructPtr->CSC ; + + if ((here->JFETsourceNode != 0) && (here->JFETsourceNode != 0)) + here->JFETsourceSourcePtr = here->JFETsourceSourceStructPtr->CSC ; + + if ((here->JFETdrainPrimeNode != 0) && (here->JFETdrainPrimeNode != 0)) + here->JFETdrainPrimeDrainPrimePtr = here->JFETdrainPrimeDrainPrimeStructPtr->CSC ; + + if ((here->JFETsourcePrimeNode != 0) && (here->JFETsourcePrimeNode != 0)) + here->JFETsourcePrimeSourcePrimePtr = here->JFETsourcePrimeSourcePrimeStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/jfet/jfetdefs.h b/src/spicelib/devices/jfet/jfetdefs.h index 929e43f7e..9fe69007c 100644 --- a/src/spicelib/devices/jfet/jfetdefs.h +++ b/src/spicelib/devices/jfet/jfetdefs.h @@ -149,6 +149,24 @@ typedef struct sJFETinstance { double JFETtThreshold; /* temperature adjusted threshold voltage */ double JFETtBeta; /* temperature adjusted beta */ +#ifdef KLU + BindElement *JFETdrainDrainPrimeStructPtr ; + BindElement *JFETgateDrainPrimeStructPtr ; + BindElement *JFETgateSourcePrimeStructPtr ; + BindElement *JFETsourceSourcePrimeStructPtr ; + BindElement *JFETdrainPrimeDrainStructPtr ; + BindElement *JFETdrainPrimeGateStructPtr ; + BindElement *JFETdrainPrimeSourcePrimeStructPtr ; + BindElement *JFETsourcePrimeGateStructPtr ; + BindElement *JFETsourcePrimeSourceStructPtr ; + BindElement *JFETsourcePrimeDrainPrimeStructPtr ; + BindElement *JFETdrainDrainStructPtr ; + BindElement *JFETgateGateStructPtr ; + BindElement *JFETsourceSourceStructPtr ; + BindElement *JFETdrainPrimeDrainPrimeStructPtr ; + BindElement *JFETsourcePrimeSourcePrimeStructPtr ; +#endif + } JFETinstance ; #define JFETvgs JFETstate diff --git a/src/spicelib/devices/jfet/jfetext.h b/src/spicelib/devices/jfet/jfetext.h index 475bdbe1a..9245019dc 100644 --- a/src/spicelib/devices/jfet/jfetext.h +++ b/src/spicelib/devices/jfet/jfetext.h @@ -22,3 +22,9 @@ extern int JFETtrunc(GENmodel*,CKTcircuit*,double*); extern int JFETdisto(int,GENmodel*,CKTcircuit*); extern int JFETnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int JFETdSetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int JFETbindCSC (GENmodel*, CKTcircuit*) ; +extern int JFETbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int JFETbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/jfet/jfetinit.c b/src/spicelib/devices/jfet/jfetinit.c index 6c31d5fb4..80e20e075 100644 --- a/src/spicelib/devices/jfet/jfetinit.c +++ b/src/spicelib/devices/jfet/jfetinit.c @@ -73,7 +73,13 @@ SPICEdev JFETinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &JFETiSize, - /* DEVmodSize */ &JFETmSize + /* DEVmodSize */ &JFETmSize, + +#ifdef KLU + /* DEVbindCSC */ JFETbindCSC, + /* DEVbindCSCComplex */ JFETbindCSCComplex, + /* DEVbindCSCComplexToReal */ JFETbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/jfet2/Makefile.am b/src/spicelib/devices/jfet2/Makefile.am index f8789cd9b..c0f9dd189 100644 --- a/src/spicelib/devices/jfet2/Makefile.am +++ b/src/spicelib/devices/jfet2/Makefile.am @@ -28,8 +28,11 @@ libjfet2_la_SOURCES = \ psmodel.h - +if KLU_WANTED +libjfet2_la_SOURCES += jfet2bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/jfet2/jfet2bindCSC.c b/src/spicelib/devices/jfet2/jfet2bindCSC.c new file mode 100644 index 000000000..7d5eab516 --- /dev/null +++ b/src/spicelib/devices/jfet2/jfet2bindCSC.c @@ -0,0 +1,295 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "jfet2defs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +JFET2bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + JFET2model *model = (JFET2model *)inModel ; + JFET2instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the JFET2 models */ + for ( ; model != NULL ; model = model->JFET2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->JFET2instances ; here != NULL ; here = here->JFET2nextInstance) + { + if ((here->JFET2drainNode != 0) && (here->JFET2drainPrimeNode != 0)) + { + i = here->JFET2drainDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2drainDrainPrimeStructPtr = matched ; + here->JFET2drainDrainPrimePtr = matched->CSC ; + } + + if ((here->JFET2gateNode != 0) && (here->JFET2drainPrimeNode != 0)) + { + i = here->JFET2gateDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2gateDrainPrimeStructPtr = matched ; + here->JFET2gateDrainPrimePtr = matched->CSC ; + } + + if ((here->JFET2gateNode != 0) && (here->JFET2sourcePrimeNode != 0)) + { + i = here->JFET2gateSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2gateSourcePrimeStructPtr = matched ; + here->JFET2gateSourcePrimePtr = matched->CSC ; + } + + if ((here->JFET2sourceNode != 0) && (here->JFET2sourcePrimeNode != 0)) + { + i = here->JFET2sourceSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2sourceSourcePrimeStructPtr = matched ; + here->JFET2sourceSourcePrimePtr = matched->CSC ; + } + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2drainNode != 0)) + { + i = here->JFET2drainPrimeDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2drainPrimeDrainStructPtr = matched ; + here->JFET2drainPrimeDrainPtr = matched->CSC ; + } + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2gateNode != 0)) + { + i = here->JFET2drainPrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2drainPrimeGateStructPtr = matched ; + here->JFET2drainPrimeGatePtr = matched->CSC ; + } + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2sourcePrimeNode != 0)) + { + i = here->JFET2drainPrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2drainPrimeSourcePrimeStructPtr = matched ; + here->JFET2drainPrimeSourcePrimePtr = matched->CSC ; + } + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2gateNode != 0)) + { + i = here->JFET2sourcePrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2sourcePrimeGateStructPtr = matched ; + here->JFET2sourcePrimeGatePtr = matched->CSC ; + } + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2sourceNode != 0)) + { + i = here->JFET2sourcePrimeSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2sourcePrimeSourceStructPtr = matched ; + here->JFET2sourcePrimeSourcePtr = matched->CSC ; + } + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2drainPrimeNode != 0)) + { + i = here->JFET2sourcePrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2sourcePrimeDrainPrimeStructPtr = matched ; + here->JFET2sourcePrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->JFET2drainNode != 0) && (here->JFET2drainNode != 0)) + { + i = here->JFET2drainDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2drainDrainStructPtr = matched ; + here->JFET2drainDrainPtr = matched->CSC ; + } + + if ((here->JFET2gateNode != 0) && (here->JFET2gateNode != 0)) + { + i = here->JFET2gateGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2gateGateStructPtr = matched ; + here->JFET2gateGatePtr = matched->CSC ; + } + + if ((here->JFET2sourceNode != 0) && (here->JFET2sourceNode != 0)) + { + i = here->JFET2sourceSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2sourceSourceStructPtr = matched ; + here->JFET2sourceSourcePtr = matched->CSC ; + } + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2drainPrimeNode != 0)) + { + i = here->JFET2drainPrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2drainPrimeDrainPrimeStructPtr = matched ; + here->JFET2drainPrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2sourcePrimeNode != 0)) + { + i = here->JFET2sourcePrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->JFET2sourcePrimeSourcePrimeStructPtr = matched ; + here->JFET2sourcePrimeSourcePrimePtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +JFET2bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + JFET2model *model = (JFET2model *)inModel ; + JFET2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the JFET2 models */ + for ( ; model != NULL ; model = model->JFET2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->JFET2instances ; here != NULL ; here = here->JFET2nextInstance) + { + if ((here->JFET2drainNode != 0) && (here->JFET2drainPrimeNode != 0)) + here->JFET2drainDrainPrimePtr = here->JFET2drainDrainPrimeStructPtr->CSC_Complex ; + + if ((here->JFET2gateNode != 0) && (here->JFET2drainPrimeNode != 0)) + here->JFET2gateDrainPrimePtr = here->JFET2gateDrainPrimeStructPtr->CSC_Complex ; + + if ((here->JFET2gateNode != 0) && (here->JFET2sourcePrimeNode != 0)) + here->JFET2gateSourcePrimePtr = here->JFET2gateSourcePrimeStructPtr->CSC_Complex ; + + if ((here->JFET2sourceNode != 0) && (here->JFET2sourcePrimeNode != 0)) + here->JFET2sourceSourcePrimePtr = here->JFET2sourceSourcePrimeStructPtr->CSC_Complex ; + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2drainNode != 0)) + here->JFET2drainPrimeDrainPtr = here->JFET2drainPrimeDrainStructPtr->CSC_Complex ; + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2gateNode != 0)) + here->JFET2drainPrimeGatePtr = here->JFET2drainPrimeGateStructPtr->CSC_Complex ; + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2sourcePrimeNode != 0)) + here->JFET2drainPrimeSourcePrimePtr = here->JFET2drainPrimeSourcePrimeStructPtr->CSC_Complex ; + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2gateNode != 0)) + here->JFET2sourcePrimeGatePtr = here->JFET2sourcePrimeGateStructPtr->CSC_Complex ; + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2sourceNode != 0)) + here->JFET2sourcePrimeSourcePtr = here->JFET2sourcePrimeSourceStructPtr->CSC_Complex ; + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2drainPrimeNode != 0)) + here->JFET2sourcePrimeDrainPrimePtr = here->JFET2sourcePrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->JFET2drainNode != 0) && (here->JFET2drainNode != 0)) + here->JFET2drainDrainPtr = here->JFET2drainDrainStructPtr->CSC_Complex ; + + if ((here->JFET2gateNode != 0) && (here->JFET2gateNode != 0)) + here->JFET2gateGatePtr = here->JFET2gateGateStructPtr->CSC_Complex ; + + if ((here->JFET2sourceNode != 0) && (here->JFET2sourceNode != 0)) + here->JFET2sourceSourcePtr = here->JFET2sourceSourceStructPtr->CSC_Complex ; + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2drainPrimeNode != 0)) + here->JFET2drainPrimeDrainPrimePtr = here->JFET2drainPrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2sourcePrimeNode != 0)) + here->JFET2sourcePrimeSourcePrimePtr = here->JFET2sourcePrimeSourcePrimeStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +JFET2bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + JFET2model *model = (JFET2model *)inModel ; + JFET2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the JFET2 models */ + for ( ; model != NULL ; model = model->JFET2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->JFET2instances ; here != NULL ; here = here->JFET2nextInstance) + { + if ((here->JFET2drainNode != 0) && (here->JFET2drainPrimeNode != 0)) + here->JFET2drainDrainPrimePtr = here->JFET2drainDrainPrimeStructPtr->CSC ; + + if ((here->JFET2gateNode != 0) && (here->JFET2drainPrimeNode != 0)) + here->JFET2gateDrainPrimePtr = here->JFET2gateDrainPrimeStructPtr->CSC ; + + if ((here->JFET2gateNode != 0) && (here->JFET2sourcePrimeNode != 0)) + here->JFET2gateSourcePrimePtr = here->JFET2gateSourcePrimeStructPtr->CSC ; + + if ((here->JFET2sourceNode != 0) && (here->JFET2sourcePrimeNode != 0)) + here->JFET2sourceSourcePrimePtr = here->JFET2sourceSourcePrimeStructPtr->CSC ; + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2drainNode != 0)) + here->JFET2drainPrimeDrainPtr = here->JFET2drainPrimeDrainStructPtr->CSC ; + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2gateNode != 0)) + here->JFET2drainPrimeGatePtr = here->JFET2drainPrimeGateStructPtr->CSC ; + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2sourcePrimeNode != 0)) + here->JFET2drainPrimeSourcePrimePtr = here->JFET2drainPrimeSourcePrimeStructPtr->CSC ; + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2gateNode != 0)) + here->JFET2sourcePrimeGatePtr = here->JFET2sourcePrimeGateStructPtr->CSC ; + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2sourceNode != 0)) + here->JFET2sourcePrimeSourcePtr = here->JFET2sourcePrimeSourceStructPtr->CSC ; + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2drainPrimeNode != 0)) + here->JFET2sourcePrimeDrainPrimePtr = here->JFET2sourcePrimeDrainPrimeStructPtr->CSC ; + + if ((here->JFET2drainNode != 0) && (here->JFET2drainNode != 0)) + here->JFET2drainDrainPtr = here->JFET2drainDrainStructPtr->CSC ; + + if ((here->JFET2gateNode != 0) && (here->JFET2gateNode != 0)) + here->JFET2gateGatePtr = here->JFET2gateGateStructPtr->CSC ; + + if ((here->JFET2sourceNode != 0) && (here->JFET2sourceNode != 0)) + here->JFET2sourceSourcePtr = here->JFET2sourceSourceStructPtr->CSC ; + + if ((here->JFET2drainPrimeNode != 0) && (here->JFET2drainPrimeNode != 0)) + here->JFET2drainPrimeDrainPrimePtr = here->JFET2drainPrimeDrainPrimeStructPtr->CSC ; + + if ((here->JFET2sourcePrimeNode != 0) && (here->JFET2sourcePrimeNode != 0)) + here->JFET2sourcePrimeSourcePrimePtr = here->JFET2sourcePrimeSourcePrimeStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/jfet2/jfet2defs.h b/src/spicelib/devices/jfet2/jfet2defs.h index 572f34b20..0d5205028 100644 --- a/src/spicelib/devices/jfet2/jfet2defs.h +++ b/src/spicelib/devices/jfet2/jfet2defs.h @@ -155,6 +155,24 @@ typedef struct sJFET2instance { double JFET2d3; /* Dual Power-law parameter */ double JFET2alpha; /* capacitance model transition parameter */ +#ifdef KLU + BindElement *JFET2drainDrainPrimeStructPtr ; + BindElement *JFET2gateDrainPrimeStructPtr ; + BindElement *JFET2gateSourcePrimeStructPtr ; + BindElement *JFET2sourceSourcePrimeStructPtr ; + BindElement *JFET2drainPrimeDrainStructPtr ; + BindElement *JFET2drainPrimeGateStructPtr ; + BindElement *JFET2drainPrimeSourcePrimeStructPtr ; + BindElement *JFET2sourcePrimeGateStructPtr ; + BindElement *JFET2sourcePrimeSourceStructPtr ; + BindElement *JFET2sourcePrimeDrainPrimeStructPtr ; + BindElement *JFET2drainDrainStructPtr ; + BindElement *JFET2gateGateStructPtr ; + BindElement *JFET2sourceSourceStructPtr ; + BindElement *JFET2drainPrimeDrainPrimeStructPtr ; + BindElement *JFET2sourcePrimeSourcePrimeStructPtr ; +#endif + } JFET2instance ; #define JFET2vgs JFET2state diff --git a/src/spicelib/devices/jfet2/jfet2ext.h b/src/spicelib/devices/jfet2/jfet2ext.h index fc330fe59..87f4013bf 100644 --- a/src/spicelib/devices/jfet2/jfet2ext.h +++ b/src/spicelib/devices/jfet2/jfet2ext.h @@ -22,3 +22,9 @@ extern int JFET2unsetup(GENmodel*,CKTcircuit*); extern int JFET2temp(GENmodel*,CKTcircuit*); extern int JFET2trunc(GENmodel*,CKTcircuit*,double*); extern int JFET2noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); + +#ifdef KLU +extern int JFET2bindCSC (GENmodel*, CKTcircuit*) ; +extern int JFET2bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int JFET2bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/jfet2/jfet2init.c b/src/spicelib/devices/jfet2/jfet2init.c index 4590c84bf..9120c9439 100644 --- a/src/spicelib/devices/jfet2/jfet2init.c +++ b/src/spicelib/devices/jfet2/jfet2init.c @@ -73,7 +73,13 @@ SPICEdev JFET2info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &JFET2iSize, - /* DEVmodSize */ &JFET2mSize + /* DEVmodSize */ &JFET2mSize, + +#ifdef KLU + /* DEVbindCSC */ JFET2bindCSC, + /* DEVbindCSCComplex */ JFET2bindCSCComplex, + /* DEVbindCSCComplexToReal */ JFET2bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/ltra/Makefile.am b/src/spicelib/devices/ltra/Makefile.am index 42a9c042a..c65eb5fff 100644 --- a/src/spicelib/devices/ltra/Makefile.am +++ b/src/spicelib/devices/ltra/Makefile.am @@ -25,7 +25,11 @@ libltra_la_SOURCES = \ ltratrun.c +if KLU_WANTED +libltra_la_SOURCES += ltrabindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/ltra/ltrabindCSC.c b/src/spicelib/devices/ltra/ltrabindCSC.c new file mode 100644 index 000000000..6693b8f10 --- /dev/null +++ b/src/spicelib/devices/ltra/ltrabindCSC.c @@ -0,0 +1,365 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "ltradefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +LTRAbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + LTRAmodel *model = (LTRAmodel *)inModel ; + LTRAinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the LTRA models */ + for ( ; model != NULL ; model = model->LTRAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->LTRAinstances ; here != NULL ; here = here->LTRAnextInstance) + { + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAposNode1 != 0)) + { + i = here->LTRAibr1Pos1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr1Pos1StructPtr = matched ; + here->LTRAibr1Pos1Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAnegNode1 != 0)) + { + i = here->LTRAibr1Neg1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr1Neg1StructPtr = matched ; + here->LTRAibr1Neg1Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAposNode2 != 0)) + { + i = here->LTRAibr1Pos2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr1Pos2StructPtr = matched ; + here->LTRAibr1Pos2Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAnegNode2 != 0)) + { + i = here->LTRAibr1Neg2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr1Neg2StructPtr = matched ; + here->LTRAibr1Neg2Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAbrEq1 != 0)) + { + i = here->LTRAibr1Ibr1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr1Ibr1StructPtr = matched ; + here->LTRAibr1Ibr1Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAbrEq2 != 0)) + { + i = here->LTRAibr1Ibr2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr1Ibr2StructPtr = matched ; + here->LTRAibr1Ibr2Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAposNode1 != 0)) + { + i = here->LTRAibr2Pos1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr2Pos1StructPtr = matched ; + here->LTRAibr2Pos1Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAnegNode1 != 0)) + { + i = here->LTRAibr2Neg1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr2Neg1StructPtr = matched ; + here->LTRAibr2Neg1Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAposNode2 != 0)) + { + i = here->LTRAibr2Pos2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr2Pos2StructPtr = matched ; + here->LTRAibr2Pos2Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAnegNode2 != 0)) + { + i = here->LTRAibr2Neg2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr2Neg2StructPtr = matched ; + here->LTRAibr2Neg2Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAbrEq1 != 0)) + { + i = here->LTRAibr2Ibr1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr2Ibr1StructPtr = matched ; + here->LTRAibr2Ibr1Ptr = matched->CSC ; + } + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAbrEq2 != 0)) + { + i = here->LTRAibr2Ibr2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAibr2Ibr2StructPtr = matched ; + here->LTRAibr2Ibr2Ptr = matched->CSC ; + } + + if ((here-> LTRAposNode1 != 0) && (here-> LTRAbrEq1 != 0)) + { + i = here->LTRApos1Ibr1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRApos1Ibr1StructPtr = matched ; + here->LTRApos1Ibr1Ptr = matched->CSC ; + } + + if ((here-> LTRAnegNode1 != 0) && (here-> LTRAbrEq1 != 0)) + { + i = here->LTRAneg1Ibr1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAneg1Ibr1StructPtr = matched ; + here->LTRAneg1Ibr1Ptr = matched->CSC ; + } + + if ((here-> LTRAposNode2 != 0) && (here-> LTRAbrEq2 != 0)) + { + i = here->LTRApos2Ibr2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRApos2Ibr2StructPtr = matched ; + here->LTRApos2Ibr2Ptr = matched->CSC ; + } + + if ((here-> LTRAnegNode2 != 0) && (here-> LTRAbrEq2 != 0)) + { + i = here->LTRAneg2Ibr2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAneg2Ibr2StructPtr = matched ; + here->LTRAneg2Ibr2Ptr = matched->CSC ; + } + + if ((here-> LTRAposNode1 != 0) && (here-> LTRAposNode1 != 0)) + { + i = here->LTRApos1Pos1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRApos1Pos1StructPtr = matched ; + here->LTRApos1Pos1Ptr = matched->CSC ; + } + + if ((here-> LTRAnegNode1 != 0) && (here-> LTRAnegNode1 != 0)) + { + i = here->LTRAneg1Neg1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAneg1Neg1StructPtr = matched ; + here->LTRAneg1Neg1Ptr = matched->CSC ; + } + + if ((here-> LTRAposNode2 != 0) && (here-> LTRAposNode2 != 0)) + { + i = here->LTRApos2Pos2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRApos2Pos2StructPtr = matched ; + here->LTRApos2Pos2Ptr = matched->CSC ; + } + + if ((here-> LTRAnegNode2 != 0) && (here-> LTRAnegNode2 != 0)) + { + i = here->LTRAneg2Neg2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->LTRAneg2Neg2StructPtr = matched ; + here->LTRAneg2Neg2Ptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +LTRAbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + LTRAmodel *model = (LTRAmodel *)inModel ; + LTRAinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the LTRA models */ + for ( ; model != NULL ; model = model->LTRAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->LTRAinstances ; here != NULL ; here = here->LTRAnextInstance) + { + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAposNode1 != 0)) + here->LTRAibr1Pos1Ptr = here->LTRAibr1Pos1StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAnegNode1 != 0)) + here->LTRAibr1Neg1Ptr = here->LTRAibr1Neg1StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAposNode2 != 0)) + here->LTRAibr1Pos2Ptr = here->LTRAibr1Pos2StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAnegNode2 != 0)) + here->LTRAibr1Neg2Ptr = here->LTRAibr1Neg2StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAbrEq1 != 0)) + here->LTRAibr1Ibr1Ptr = here->LTRAibr1Ibr1StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAbrEq2 != 0)) + here->LTRAibr1Ibr2Ptr = here->LTRAibr1Ibr2StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAposNode1 != 0)) + here->LTRAibr2Pos1Ptr = here->LTRAibr2Pos1StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAnegNode1 != 0)) + here->LTRAibr2Neg1Ptr = here->LTRAibr2Neg1StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAposNode2 != 0)) + here->LTRAibr2Pos2Ptr = here->LTRAibr2Pos2StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAnegNode2 != 0)) + here->LTRAibr2Neg2Ptr = here->LTRAibr2Neg2StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAbrEq1 != 0)) + here->LTRAibr2Ibr1Ptr = here->LTRAibr2Ibr1StructPtr->CSC_Complex ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAbrEq2 != 0)) + here->LTRAibr2Ibr2Ptr = here->LTRAibr2Ibr2StructPtr->CSC_Complex ; + + if ((here-> LTRAposNode1 != 0) && (here-> LTRAbrEq1 != 0)) + here->LTRApos1Ibr1Ptr = here->LTRApos1Ibr1StructPtr->CSC_Complex ; + + if ((here-> LTRAnegNode1 != 0) && (here-> LTRAbrEq1 != 0)) + here->LTRAneg1Ibr1Ptr = here->LTRAneg1Ibr1StructPtr->CSC_Complex ; + + if ((here-> LTRAposNode2 != 0) && (here-> LTRAbrEq2 != 0)) + here->LTRApos2Ibr2Ptr = here->LTRApos2Ibr2StructPtr->CSC_Complex ; + + if ((here-> LTRAnegNode2 != 0) && (here-> LTRAbrEq2 != 0)) + here->LTRAneg2Ibr2Ptr = here->LTRAneg2Ibr2StructPtr->CSC_Complex ; + + if ((here-> LTRAposNode1 != 0) && (here-> LTRAposNode1 != 0)) + here->LTRApos1Pos1Ptr = here->LTRApos1Pos1StructPtr->CSC_Complex ; + + if ((here-> LTRAnegNode1 != 0) && (here-> LTRAnegNode1 != 0)) + here->LTRAneg1Neg1Ptr = here->LTRAneg1Neg1StructPtr->CSC_Complex ; + + if ((here-> LTRAposNode2 != 0) && (here-> LTRAposNode2 != 0)) + here->LTRApos2Pos2Ptr = here->LTRApos2Pos2StructPtr->CSC_Complex ; + + if ((here-> LTRAnegNode2 != 0) && (here-> LTRAnegNode2 != 0)) + here->LTRAneg2Neg2Ptr = here->LTRAneg2Neg2StructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +LTRAbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + LTRAmodel *model = (LTRAmodel *)inModel ; + LTRAinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the LTRA models */ + for ( ; model != NULL ; model = model->LTRAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->LTRAinstances ; here != NULL ; here = here->LTRAnextInstance) + { + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAposNode1 != 0)) + here->LTRAibr1Pos1Ptr = here->LTRAibr1Pos1StructPtr->CSC ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAnegNode1 != 0)) + here->LTRAibr1Neg1Ptr = here->LTRAibr1Neg1StructPtr->CSC ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAposNode2 != 0)) + here->LTRAibr1Pos2Ptr = here->LTRAibr1Pos2StructPtr->CSC ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAnegNode2 != 0)) + here->LTRAibr1Neg2Ptr = here->LTRAibr1Neg2StructPtr->CSC ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAbrEq1 != 0)) + here->LTRAibr1Ibr1Ptr = here->LTRAibr1Ibr1StructPtr->CSC ; + + if ((here-> LTRAbrEq1 != 0) && (here-> LTRAbrEq2 != 0)) + here->LTRAibr1Ibr2Ptr = here->LTRAibr1Ibr2StructPtr->CSC ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAposNode1 != 0)) + here->LTRAibr2Pos1Ptr = here->LTRAibr2Pos1StructPtr->CSC ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAnegNode1 != 0)) + here->LTRAibr2Neg1Ptr = here->LTRAibr2Neg1StructPtr->CSC ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAposNode2 != 0)) + here->LTRAibr2Pos2Ptr = here->LTRAibr2Pos2StructPtr->CSC ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAnegNode2 != 0)) + here->LTRAibr2Neg2Ptr = here->LTRAibr2Neg2StructPtr->CSC ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAbrEq1 != 0)) + here->LTRAibr2Ibr1Ptr = here->LTRAibr2Ibr1StructPtr->CSC ; + + if ((here-> LTRAbrEq2 != 0) && (here-> LTRAbrEq2 != 0)) + here->LTRAibr2Ibr2Ptr = here->LTRAibr2Ibr2StructPtr->CSC ; + + if ((here-> LTRAposNode1 != 0) && (here-> LTRAbrEq1 != 0)) + here->LTRApos1Ibr1Ptr = here->LTRApos1Ibr1StructPtr->CSC ; + + if ((here-> LTRAnegNode1 != 0) && (here-> LTRAbrEq1 != 0)) + here->LTRAneg1Ibr1Ptr = here->LTRAneg1Ibr1StructPtr->CSC ; + + if ((here-> LTRAposNode2 != 0) && (here-> LTRAbrEq2 != 0)) + here->LTRApos2Ibr2Ptr = here->LTRApos2Ibr2StructPtr->CSC ; + + if ((here-> LTRAnegNode2 != 0) && (here-> LTRAbrEq2 != 0)) + here->LTRAneg2Ibr2Ptr = here->LTRAneg2Ibr2StructPtr->CSC ; + + if ((here-> LTRAposNode1 != 0) && (here-> LTRAposNode1 != 0)) + here->LTRApos1Pos1Ptr = here->LTRApos1Pos1StructPtr->CSC ; + + if ((here-> LTRAnegNode1 != 0) && (here-> LTRAnegNode1 != 0)) + here->LTRAneg1Neg1Ptr = here->LTRAneg1Neg1StructPtr->CSC ; + + if ((here-> LTRAposNode2 != 0) && (here-> LTRAposNode2 != 0)) + here->LTRApos2Pos2Ptr = here->LTRApos2Pos2StructPtr->CSC ; + + if ((here-> LTRAnegNode2 != 0) && (here-> LTRAnegNode2 != 0)) + here->LTRAneg2Neg2Ptr = here->LTRAneg2Neg2StructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/ltra/ltradefs.h b/src/spicelib/devices/ltra/ltradefs.h index 71833ba33..971a196f1 100644 --- a/src/spicelib/devices/ltra/ltradefs.h +++ b/src/spicelib/devices/ltra/ltradefs.h @@ -67,6 +67,30 @@ typedef struct sLTRAinstance { unsigned LTRAicC1Given : 1; /* flag to ind. init. current at port 1 given */ unsigned LTRAicV2Given : 1; /* flag to ind. init. voltage at port 2 given */ unsigned LTRAicC2Given : 1; /* flag to ind. init. current at port 2 given */ + +#ifdef KLU + BindElement *LTRAibr1Pos1StructPtr ; + BindElement *LTRAibr1Neg1StructPtr ; + BindElement *LTRAibr1Pos2StructPtr ; + BindElement *LTRAibr1Neg2StructPtr ; + BindElement *LTRAibr1Ibr1StructPtr ; + BindElement *LTRAibr1Ibr2StructPtr ; + BindElement *LTRAibr2Pos1StructPtr ; + BindElement *LTRAibr2Neg1StructPtr ; + BindElement *LTRAibr2Pos2StructPtr ; + BindElement *LTRAibr2Neg2StructPtr ; + BindElement *LTRAibr2Ibr1StructPtr ; + BindElement *LTRAibr2Ibr2StructPtr ; + BindElement *LTRApos1Ibr1StructPtr ; + BindElement *LTRAneg1Ibr1StructPtr ; + BindElement *LTRApos2Ibr2StructPtr ; + BindElement *LTRAneg2Ibr2StructPtr ; + BindElement *LTRApos1Pos1StructPtr ; + BindElement *LTRAneg1Neg1StructPtr ; + BindElement *LTRApos2Pos2StructPtr ; + BindElement *LTRAneg2Neg2StructPtr ; +#endif + } LTRAinstance ; diff --git a/src/spicelib/devices/ltra/ltraext.h b/src/spicelib/devices/ltra/ltraext.h index 09cc06a8c..365495aab 100644 --- a/src/spicelib/devices/ltra/ltraext.h +++ b/src/spicelib/devices/ltra/ltraext.h @@ -44,3 +44,9 @@ extern double LTRAh3dashCoeffSetup(double*,int,double,double,double,double*,int, extern void LTRArcCoeffsSetup(double*,double*,double*,double*,double*,double*,int,double,double,double,double*,int,double); extern void LTRArlcCoeffsSetup(double*,double*,double*,double*,double*,double*,int,double,double,double,double,double*,int,double,int*); extern int LTRAstraightLineCheck(double,double,double,double,double,double,double,double); + +#ifdef KLU +extern int LTRAbindCSC (GENmodel*, CKTcircuit*) ; +extern int LTRAbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int LTRAbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/ltra/ltrainit.c b/src/spicelib/devices/ltra/ltrainit.c index b2c30b76e..115f39a36 100644 --- a/src/spicelib/devices/ltra/ltrainit.c +++ b/src/spicelib/devices/ltra/ltrainit.c @@ -73,7 +73,13 @@ SPICEdev LTRAinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ <RAiSize, - /* DEVmodSize */ <RAmSize + /* DEVmodSize */ <RAmSize, + +#ifdef KLU + /* DEVbindCSC */ LTRAbindCSC, + /* DEVbindCSCComplex */ LTRAbindCSCComplex, + /* DEVbindCSCComplexToReal */ LTRAbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/mes/Makefile.am b/src/spicelib/devices/mes/Makefile.am index 3d0c3b3d5..adbdfc555 100644 --- a/src/spicelib/devices/mes/Makefile.am +++ b/src/spicelib/devices/mes/Makefile.am @@ -28,7 +28,11 @@ libmes_la_SOURCES = \ mestrunc.c +if KLU_WANTED +libmes_la_SOURCES += mesbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/mes/mesbindCSC.c b/src/spicelib/devices/mes/mesbindCSC.c new file mode 100644 index 000000000..ea9a1c798 --- /dev/null +++ b/src/spicelib/devices/mes/mesbindCSC.c @@ -0,0 +1,295 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "mesdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +MESbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + MESmodel *model = (MESmodel *)inModel ; + MESinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the MES models */ + for ( ; model != NULL ; model = model->MESnextModel) + { + /* loop through all the instances of the model */ + for (here = model->MESinstances ; here != NULL ; here = here->MESnextInstance) + { + if ((here->MESdrainNode != 0) && (here->MESdrainPrimeNode != 0)) + { + i = here->MESdrainDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESdrainDrainPrimeStructPtr = matched ; + here->MESdrainDrainPrimePtr = matched->CSC ; + } + + if ((here->MESgateNode != 0) && (here->MESdrainPrimeNode != 0)) + { + i = here->MESgateDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESgateDrainPrimeStructPtr = matched ; + here->MESgateDrainPrimePtr = matched->CSC ; + } + + if ((here->MESgateNode != 0) && (here->MESsourcePrimeNode != 0)) + { + i = here->MESgateSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESgateSourcePrimeStructPtr = matched ; + here->MESgateSourcePrimePtr = matched->CSC ; + } + + if ((here->MESsourceNode != 0) && (here->MESsourcePrimeNode != 0)) + { + i = here->MESsourceSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESsourceSourcePrimeStructPtr = matched ; + here->MESsourceSourcePrimePtr = matched->CSC ; + } + + if ((here->MESdrainPrimeNode != 0) && (here->MESdrainNode != 0)) + { + i = here->MESdrainPrimeDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESdrainPrimeDrainStructPtr = matched ; + here->MESdrainPrimeDrainPtr = matched->CSC ; + } + + if ((here->MESdrainPrimeNode != 0) && (here->MESgateNode != 0)) + { + i = here->MESdrainPrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESdrainPrimeGateStructPtr = matched ; + here->MESdrainPrimeGatePtr = matched->CSC ; + } + + if ((here->MESdrainPrimeNode != 0) && (here->MESsourcePrimeNode != 0)) + { + i = here->MESdrainPrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESdrainPrimeSourcePrimeStructPtr = matched ; + here->MESdrainPrimeSourcePrimePtr = matched->CSC ; + } + + if ((here->MESsourcePrimeNode != 0) && (here->MESgateNode != 0)) + { + i = here->MESsourcePrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESsourcePrimeGateStructPtr = matched ; + here->MESsourcePrimeGatePtr = matched->CSC ; + } + + if ((here->MESsourcePrimeNode != 0) && (here->MESsourceNode != 0)) + { + i = here->MESsourcePrimeSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESsourcePrimeSourceStructPtr = matched ; + here->MESsourcePrimeSourcePtr = matched->CSC ; + } + + if ((here->MESsourcePrimeNode != 0) && (here->MESdrainPrimeNode != 0)) + { + i = here->MESsourcePrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESsourcePrimeDrainPrimeStructPtr = matched ; + here->MESsourcePrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->MESdrainNode != 0) && (here->MESdrainNode != 0)) + { + i = here->MESdrainDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESdrainDrainStructPtr = matched ; + here->MESdrainDrainPtr = matched->CSC ; + } + + if ((here->MESgateNode != 0) && (here->MESgateNode != 0)) + { + i = here->MESgateGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESgateGateStructPtr = matched ; + here->MESgateGatePtr = matched->CSC ; + } + + if ((here->MESsourceNode != 0) && (here->MESsourceNode != 0)) + { + i = here->MESsourceSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESsourceSourceStructPtr = matched ; + here->MESsourceSourcePtr = matched->CSC ; + } + + if ((here->MESdrainPrimeNode != 0) && (here->MESdrainPrimeNode != 0)) + { + i = here->MESdrainPrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESdrainPrimeDrainPrimeStructPtr = matched ; + here->MESdrainPrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->MESsourcePrimeNode != 0) && (here->MESsourcePrimeNode != 0)) + { + i = here->MESsourcePrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESsourcePrimeSourcePrimeStructPtr = matched ; + here->MESsourcePrimeSourcePrimePtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +MESbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + MESmodel *model = (MESmodel *)inModel ; + MESinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MES models */ + for ( ; model != NULL ; model = model->MESnextModel) + { + /* loop through all the instances of the model */ + for (here = model->MESinstances ; here != NULL ; here = here->MESnextInstance) + { + if ((here->MESdrainNode != 0) && (here->MESdrainPrimeNode != 0)) + here->MESdrainDrainPrimePtr = here->MESdrainDrainPrimeStructPtr->CSC_Complex ; + + if ((here->MESgateNode != 0) && (here->MESdrainPrimeNode != 0)) + here->MESgateDrainPrimePtr = here->MESgateDrainPrimeStructPtr->CSC_Complex ; + + if ((here->MESgateNode != 0) && (here->MESsourcePrimeNode != 0)) + here->MESgateSourcePrimePtr = here->MESgateSourcePrimeStructPtr->CSC_Complex ; + + if ((here->MESsourceNode != 0) && (here->MESsourcePrimeNode != 0)) + here->MESsourceSourcePrimePtr = here->MESsourceSourcePrimeStructPtr->CSC_Complex ; + + if ((here->MESdrainPrimeNode != 0) && (here->MESdrainNode != 0)) + here->MESdrainPrimeDrainPtr = here->MESdrainPrimeDrainStructPtr->CSC_Complex ; + + if ((here->MESdrainPrimeNode != 0) && (here->MESgateNode != 0)) + here->MESdrainPrimeGatePtr = here->MESdrainPrimeGateStructPtr->CSC_Complex ; + + if ((here->MESdrainPrimeNode != 0) && (here->MESsourcePrimeNode != 0)) + here->MESdrainPrimeSourcePrimePtr = here->MESdrainPrimeSourcePrimeStructPtr->CSC_Complex ; + + if ((here->MESsourcePrimeNode != 0) && (here->MESgateNode != 0)) + here->MESsourcePrimeGatePtr = here->MESsourcePrimeGateStructPtr->CSC_Complex ; + + if ((here->MESsourcePrimeNode != 0) && (here->MESsourceNode != 0)) + here->MESsourcePrimeSourcePtr = here->MESsourcePrimeSourceStructPtr->CSC_Complex ; + + if ((here->MESsourcePrimeNode != 0) && (here->MESdrainPrimeNode != 0)) + here->MESsourcePrimeDrainPrimePtr = here->MESsourcePrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->MESdrainNode != 0) && (here->MESdrainNode != 0)) + here->MESdrainDrainPtr = here->MESdrainDrainStructPtr->CSC_Complex ; + + if ((here->MESgateNode != 0) && (here->MESgateNode != 0)) + here->MESgateGatePtr = here->MESgateGateStructPtr->CSC_Complex ; + + if ((here->MESsourceNode != 0) && (here->MESsourceNode != 0)) + here->MESsourceSourcePtr = here->MESsourceSourceStructPtr->CSC_Complex ; + + if ((here->MESdrainPrimeNode != 0) && (here->MESdrainPrimeNode != 0)) + here->MESdrainPrimeDrainPrimePtr = here->MESdrainPrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->MESsourcePrimeNode != 0) && (here->MESsourcePrimeNode != 0)) + here->MESsourcePrimeSourcePrimePtr = here->MESsourcePrimeSourcePrimeStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +MESbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + MESmodel *model = (MESmodel *)inModel ; + MESinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MES models */ + for ( ; model != NULL ; model = model->MESnextModel) + { + /* loop through all the instances of the model */ + for (here = model->MESinstances ; here != NULL ; here = here->MESnextInstance) + { + if ((here->MESdrainNode != 0) && (here->MESdrainPrimeNode != 0)) + here->MESdrainDrainPrimePtr = here->MESdrainDrainPrimeStructPtr->CSC ; + + if ((here->MESgateNode != 0) && (here->MESdrainPrimeNode != 0)) + here->MESgateDrainPrimePtr = here->MESgateDrainPrimeStructPtr->CSC ; + + if ((here->MESgateNode != 0) && (here->MESsourcePrimeNode != 0)) + here->MESgateSourcePrimePtr = here->MESgateSourcePrimeStructPtr->CSC ; + + if ((here->MESsourceNode != 0) && (here->MESsourcePrimeNode != 0)) + here->MESsourceSourcePrimePtr = here->MESsourceSourcePrimeStructPtr->CSC ; + + if ((here->MESdrainPrimeNode != 0) && (here->MESdrainNode != 0)) + here->MESdrainPrimeDrainPtr = here->MESdrainPrimeDrainStructPtr->CSC ; + + if ((here->MESdrainPrimeNode != 0) && (here->MESgateNode != 0)) + here->MESdrainPrimeGatePtr = here->MESdrainPrimeGateStructPtr->CSC ; + + if ((here->MESdrainPrimeNode != 0) && (here->MESsourcePrimeNode != 0)) + here->MESdrainPrimeSourcePrimePtr = here->MESdrainPrimeSourcePrimeStructPtr->CSC ; + + if ((here->MESsourcePrimeNode != 0) && (here->MESgateNode != 0)) + here->MESsourcePrimeGatePtr = here->MESsourcePrimeGateStructPtr->CSC ; + + if ((here->MESsourcePrimeNode != 0) && (here->MESsourceNode != 0)) + here->MESsourcePrimeSourcePtr = here->MESsourcePrimeSourceStructPtr->CSC ; + + if ((here->MESsourcePrimeNode != 0) && (here->MESdrainPrimeNode != 0)) + here->MESsourcePrimeDrainPrimePtr = here->MESsourcePrimeDrainPrimeStructPtr->CSC ; + + if ((here->MESdrainNode != 0) && (here->MESdrainNode != 0)) + here->MESdrainDrainPtr = here->MESdrainDrainStructPtr->CSC ; + + if ((here->MESgateNode != 0) && (here->MESgateNode != 0)) + here->MESgateGatePtr = here->MESgateGateStructPtr->CSC ; + + if ((here->MESsourceNode != 0) && (here->MESsourceNode != 0)) + here->MESsourceSourcePtr = here->MESsourceSourceStructPtr->CSC ; + + if ((here->MESdrainPrimeNode != 0) && (here->MESdrainPrimeNode != 0)) + here->MESdrainPrimeDrainPrimePtr = here->MESdrainPrimeDrainPrimeStructPtr->CSC ; + + if ((here->MESsourcePrimeNode != 0) && (here->MESsourcePrimeNode != 0)) + here->MESsourcePrimeSourcePrimePtr = here->MESsourcePrimeSourcePrimeStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/mes/mesdefs.h b/src/spicelib/devices/mes/mesdefs.h index 316f14b8c..5f8c168f8 100644 --- a/src/spicelib/devices/mes/mesdefs.h +++ b/src/spicelib/devices/mes/mesdefs.h @@ -141,6 +141,24 @@ int MESmode; double **MESnVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *MESdrainDrainPrimeStructPtr ; + BindElement *MESgateDrainPrimeStructPtr ; + BindElement *MESgateSourcePrimeStructPtr ; + BindElement *MESsourceSourcePrimeStructPtr ; + BindElement *MESdrainPrimeDrainStructPtr ; + BindElement *MESdrainPrimeGateStructPtr ; + BindElement *MESdrainPrimeSourcePrimeStructPtr ; + BindElement *MESsourcePrimeGateStructPtr ; + BindElement *MESsourcePrimeSourceStructPtr ; + BindElement *MESsourcePrimeDrainPrimeStructPtr ; + BindElement *MESdrainDrainStructPtr ; + BindElement *MESgateGateStructPtr ; + BindElement *MESsourceSourceStructPtr ; + BindElement *MESdrainPrimeDrainPrimeStructPtr ; + BindElement *MESsourcePrimeSourcePrimeStructPtr ; +#endif + } MESinstance ; #define MESvgs MESstate diff --git a/src/spicelib/devices/mes/mesext.h b/src/spicelib/devices/mes/mesext.h index 7ff419573..bda1f61d0 100644 --- a/src/spicelib/devices/mes/mesext.h +++ b/src/spicelib/devices/mes/mesext.h @@ -23,3 +23,8 @@ extern int MESdisto(int,GENmodel*,CKTcircuit*); extern int MESnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int MESdSetup(GENmodel*,CKTcircuit*); +#ifdef KLU +extern int MESbindCSC (GENmodel*, CKTcircuit*) ; +extern int MESbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int MESbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/mes/mesinit.c b/src/spicelib/devices/mes/mesinit.c index 4eb612a68..50823140a 100644 --- a/src/spicelib/devices/mes/mesinit.c +++ b/src/spicelib/devices/mes/mesinit.c @@ -73,7 +73,13 @@ SPICEdev MESinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &MESiSize, - /* DEVmodSize */ &MESmSize + /* DEVmodSize */ &MESmSize, + +#ifdef KLU + /* DEVbindCSC */ MESbindCSC, + /* DEVbindCSCComplex */ MESbindCSCComplex, + /* DEVbindCSCComplexToReal */ MESbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/mesa/Makefile.am b/src/spicelib/devices/mesa/Makefile.am index 79e6f7555..07218b37b 100644 --- a/src/spicelib/devices/mesa/Makefile.am +++ b/src/spicelib/devices/mesa/Makefile.am @@ -25,7 +25,11 @@ libmesa_la_SOURCES = \ mesatrunc.c +if KLU_WANTED +libmesa_la_SOURCES += mesabindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/mesa/mesabindCSC.c b/src/spicelib/devices/mesa/mesabindCSC.c new file mode 100644 index 000000000..d0e0e27f2 --- /dev/null +++ b/src/spicelib/devices/mesa/mesabindCSC.c @@ -0,0 +1,477 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "mesadefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +MESAbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + MESAmodel *model = (MESAmodel *)inModel ; + MESAinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the MESA models */ + for ( ; model != NULL ; model = model->MESAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->MESAinstances ; here != NULL ; here = here->MESAnextInstance) + { + if ((here->MESAdrainNode != 0) && (here->MESAdrainNode != 0)) + { + i = here->MESAdrainDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainDrainStructPtr = matched ; + here->MESAdrainDrainPtr = matched->CSC ; + } + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAdrainPrimeNode != 0)) + { + i = here->MESAdrainPrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainPrimeDrainPrimeStructPtr = matched ; + here->MESAdrainPrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->MESAdrainPrmPrmNode != 0) && (here->MESAdrainPrmPrmNode != 0)) + { + i = here->MESAdrainPrmPrmDrainPrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainPrmPrmDrainPrmPrmStructPtr = matched ; + here->MESAdrainPrmPrmDrainPrmPrmPtr = matched->CSC ; + } + + if ((here->MESAgateNode != 0) && (here->MESAgateNode != 0)) + { + i = here->MESAgateGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAgateGateStructPtr = matched ; + here->MESAgateGatePtr = matched->CSC ; + } + + if ((here->MESAgatePrimeNode != 0) && (here->MESAgatePrimeNode != 0)) + { + i = here->MESAgatePrimeGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAgatePrimeGatePrimeStructPtr = matched ; + here->MESAgatePrimeGatePrimePtr = matched->CSC ; + } + + if ((here->MESAsourceNode != 0) && (here->MESAsourceNode != 0)) + { + i = here->MESAsourceSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourceSourceStructPtr = matched ; + here->MESAsourceSourcePtr = matched->CSC ; + } + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAsourcePrimeNode != 0)) + { + i = here->MESAsourcePrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourcePrimeSourcePrimeStructPtr = matched ; + here->MESAsourcePrimeSourcePrimePtr = matched->CSC ; + } + + if ((here->MESAsourcePrmPrmNode != 0) && (here->MESAsourcePrmPrmNode != 0)) + { + i = here->MESAsourcePrmPrmSourcePrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourcePrmPrmSourcePrmPrmStructPtr = matched ; + here->MESAsourcePrmPrmSourcePrmPrmPtr = matched->CSC ; + } + + if ((here->MESAdrainNode != 0) && (here->MESAdrainPrimeNode != 0)) + { + i = here->MESAdrainDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainDrainPrimeStructPtr = matched ; + here->MESAdrainDrainPrimePtr = matched->CSC ; + } + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAdrainNode != 0)) + { + i = here->MESAdrainPrimeDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainPrimeDrainStructPtr = matched ; + here->MESAdrainPrimeDrainPtr = matched->CSC ; + } + + if ((here->MESAgatePrimeNode != 0) && (here->MESAdrainPrimeNode != 0)) + { + i = here->MESAgatePrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAgatePrimeDrainPrimeStructPtr = matched ; + here->MESAgatePrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAgatePrimeNode != 0)) + { + i = here->MESAdrainPrimeGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainPrimeGatePrimeStructPtr = matched ; + here->MESAdrainPrimeGatePrimePtr = matched->CSC ; + } + + if ((here->MESAgatePrimeNode != 0) && (here->MESAsourcePrimeNode != 0)) + { + i = here->MESAgatePrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAgatePrimeSourcePrimeStructPtr = matched ; + here->MESAgatePrimeSourcePrimePtr = matched->CSC ; + } + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAgatePrimeNode != 0)) + { + i = here->MESAsourcePrimeGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourcePrimeGatePrimeStructPtr = matched ; + here->MESAsourcePrimeGatePrimePtr = matched->CSC ; + } + + if ((here->MESAsourceNode != 0) && (here->MESAsourcePrimeNode != 0)) + { + i = here->MESAsourceSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourceSourcePrimeStructPtr = matched ; + here->MESAsourceSourcePrimePtr = matched->CSC ; + } + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAsourceNode != 0)) + { + i = here->MESAsourcePrimeSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourcePrimeSourceStructPtr = matched ; + here->MESAsourcePrimeSourcePtr = matched->CSC ; + } + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAsourcePrimeNode != 0)) + { + i = here->MESAdrainPrimeSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainPrimeSourcePrimeStructPtr = matched ; + here->MESAdrainPrimeSourcePrimePtr = matched->CSC ; + } + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAdrainPrimeNode != 0)) + { + i = here->MESAsourcePrimeDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourcePrimeDrainPrimeStructPtr = matched ; + here->MESAsourcePrimeDrainPrimePtr = matched->CSC ; + } + + if ((here->MESAgatePrimeNode != 0) && (here->MESAgateNode != 0)) + { + i = here->MESAgatePrimeGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAgatePrimeGateStructPtr = matched ; + here->MESAgatePrimeGatePtr = matched->CSC ; + } + + if ((here->MESAgateNode != 0) && (here->MESAgatePrimeNode != 0)) + { + i = here->MESAgateGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAgateGatePrimeStructPtr = matched ; + here->MESAgateGatePrimePtr = matched->CSC ; + } + + if ((here->MESAsourcePrmPrmNode != 0) && (here->MESAsourcePrimeNode != 0)) + { + i = here->MESAsourcePrmPrmSourcePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourcePrmPrmSourcePrimeStructPtr = matched ; + here->MESAsourcePrmPrmSourcePrimePtr = matched->CSC ; + } + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAsourcePrmPrmNode != 0)) + { + i = here->MESAsourcePrimeSourcePrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourcePrimeSourcePrmPrmStructPtr = matched ; + here->MESAsourcePrimeSourcePrmPrmPtr = matched->CSC ; + } + + if ((here->MESAsourcePrmPrmNode != 0) && (here->MESAgatePrimeNode != 0)) + { + i = here->MESAsourcePrmPrmGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAsourcePrmPrmGatePrimeStructPtr = matched ; + here->MESAsourcePrmPrmGatePrimePtr = matched->CSC ; + } + + if ((here->MESAgatePrimeNode != 0) && (here->MESAsourcePrmPrmNode != 0)) + { + i = here->MESAgatePrimeSourcePrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAgatePrimeSourcePrmPrmStructPtr = matched ; + here->MESAgatePrimeSourcePrmPrmPtr = matched->CSC ; + } + + if ((here->MESAdrainPrmPrmNode != 0) && (here->MESAdrainPrimeNode != 0)) + { + i = here->MESAdrainPrmPrmDrainPrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainPrmPrmDrainPrimeStructPtr = matched ; + here->MESAdrainPrmPrmDrainPrimePtr = matched->CSC ; + } + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAdrainPrmPrmNode != 0)) + { + i = here->MESAdrainPrimeDrainPrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainPrimeDrainPrmPrmStructPtr = matched ; + here->MESAdrainPrimeDrainPrmPrmPtr = matched->CSC ; + } + + if ((here->MESAdrainPrmPrmNode != 0) && (here->MESAgatePrimeNode != 0)) + { + i = here->MESAdrainPrmPrmGatePrimePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAdrainPrmPrmGatePrimeStructPtr = matched ; + here->MESAdrainPrmPrmGatePrimePtr = matched->CSC ; + } + + if ((here->MESAgatePrimeNode != 0) && (here->MESAdrainPrmPrmNode != 0)) + { + i = here->MESAgatePrimeDrainPrmPrmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MESAgatePrimeDrainPrmPrmStructPtr = matched ; + here->MESAgatePrimeDrainPrmPrmPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +MESAbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + MESAmodel *model = (MESAmodel *)inModel ; + MESAinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MESA models */ + for ( ; model != NULL ; model = model->MESAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->MESAinstances ; here != NULL ; here = here->MESAnextInstance) + { + if ((here->MESAdrainNode != 0) && (here->MESAdrainNode != 0)) + here->MESAdrainDrainPtr = here->MESAdrainDrainStructPtr->CSC_Complex ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAdrainPrimeDrainPrimePtr = here->MESAdrainPrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->MESAdrainPrmPrmNode != 0) && (here->MESAdrainPrmPrmNode != 0)) + here->MESAdrainPrmPrmDrainPrmPrmPtr = here->MESAdrainPrmPrmDrainPrmPrmStructPtr->CSC_Complex ; + + if ((here->MESAgateNode != 0) && (here->MESAgateNode != 0)) + here->MESAgateGatePtr = here->MESAgateGateStructPtr->CSC_Complex ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAgatePrimeGatePrimePtr = here->MESAgatePrimeGatePrimeStructPtr->CSC_Complex ; + + if ((here->MESAsourceNode != 0) && (here->MESAsourceNode != 0)) + here->MESAsourceSourcePtr = here->MESAsourceSourceStructPtr->CSC_Complex ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAsourcePrimeSourcePrimePtr = here->MESAsourcePrimeSourcePrimeStructPtr->CSC_Complex ; + + if ((here->MESAsourcePrmPrmNode != 0) && (here->MESAsourcePrmPrmNode != 0)) + here->MESAsourcePrmPrmSourcePrmPrmPtr = here->MESAsourcePrmPrmSourcePrmPrmStructPtr->CSC_Complex ; + + if ((here->MESAdrainNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAdrainDrainPrimePtr = here->MESAdrainDrainPrimeStructPtr->CSC_Complex ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAdrainNode != 0)) + here->MESAdrainPrimeDrainPtr = here->MESAdrainPrimeDrainStructPtr->CSC_Complex ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAgatePrimeDrainPrimePtr = here->MESAgatePrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAdrainPrimeGatePrimePtr = here->MESAdrainPrimeGatePrimeStructPtr->CSC_Complex ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAgatePrimeSourcePrimePtr = here->MESAgatePrimeSourcePrimeStructPtr->CSC_Complex ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAsourcePrimeGatePrimePtr = here->MESAsourcePrimeGatePrimeStructPtr->CSC_Complex ; + + if ((here->MESAsourceNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAsourceSourcePrimePtr = here->MESAsourceSourcePrimeStructPtr->CSC_Complex ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAsourceNode != 0)) + here->MESAsourcePrimeSourcePtr = here->MESAsourcePrimeSourceStructPtr->CSC_Complex ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAdrainPrimeSourcePrimePtr = here->MESAdrainPrimeSourcePrimeStructPtr->CSC_Complex ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAsourcePrimeDrainPrimePtr = here->MESAsourcePrimeDrainPrimeStructPtr->CSC_Complex ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAgateNode != 0)) + here->MESAgatePrimeGatePtr = here->MESAgatePrimeGateStructPtr->CSC_Complex ; + + if ((here->MESAgateNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAgateGatePrimePtr = here->MESAgateGatePrimeStructPtr->CSC_Complex ; + + if ((here->MESAsourcePrmPrmNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAsourcePrmPrmSourcePrimePtr = here->MESAsourcePrmPrmSourcePrimeStructPtr->CSC_Complex ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAsourcePrmPrmNode != 0)) + here->MESAsourcePrimeSourcePrmPrmPtr = here->MESAsourcePrimeSourcePrmPrmStructPtr->CSC_Complex ; + + if ((here->MESAsourcePrmPrmNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAsourcePrmPrmGatePrimePtr = here->MESAsourcePrmPrmGatePrimeStructPtr->CSC_Complex ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAsourcePrmPrmNode != 0)) + here->MESAgatePrimeSourcePrmPrmPtr = here->MESAgatePrimeSourcePrmPrmStructPtr->CSC_Complex ; + + if ((here->MESAdrainPrmPrmNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAdrainPrmPrmDrainPrimePtr = here->MESAdrainPrmPrmDrainPrimeStructPtr->CSC_Complex ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAdrainPrmPrmNode != 0)) + here->MESAdrainPrimeDrainPrmPrmPtr = here->MESAdrainPrimeDrainPrmPrmStructPtr->CSC_Complex ; + + if ((here->MESAdrainPrmPrmNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAdrainPrmPrmGatePrimePtr = here->MESAdrainPrmPrmGatePrimeStructPtr->CSC_Complex ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAdrainPrmPrmNode != 0)) + here->MESAgatePrimeDrainPrmPrmPtr = here->MESAgatePrimeDrainPrmPrmStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +MESAbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + MESAmodel *model = (MESAmodel *)inModel ; + MESAinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MESA models */ + for ( ; model != NULL ; model = model->MESAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->MESAinstances ; here != NULL ; here = here->MESAnextInstance) + { + if ((here->MESAdrainNode != 0) && (here->MESAdrainNode != 0)) + here->MESAdrainDrainPtr = here->MESAdrainDrainStructPtr->CSC ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAdrainPrimeDrainPrimePtr = here->MESAdrainPrimeDrainPrimeStructPtr->CSC ; + + if ((here->MESAdrainPrmPrmNode != 0) && (here->MESAdrainPrmPrmNode != 0)) + here->MESAdrainPrmPrmDrainPrmPrmPtr = here->MESAdrainPrmPrmDrainPrmPrmStructPtr->CSC ; + + if ((here->MESAgateNode != 0) && (here->MESAgateNode != 0)) + here->MESAgateGatePtr = here->MESAgateGateStructPtr->CSC ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAgatePrimeGatePrimePtr = here->MESAgatePrimeGatePrimeStructPtr->CSC ; + + if ((here->MESAsourceNode != 0) && (here->MESAsourceNode != 0)) + here->MESAsourceSourcePtr = here->MESAsourceSourceStructPtr->CSC ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAsourcePrimeSourcePrimePtr = here->MESAsourcePrimeSourcePrimeStructPtr->CSC ; + + if ((here->MESAsourcePrmPrmNode != 0) && (here->MESAsourcePrmPrmNode != 0)) + here->MESAsourcePrmPrmSourcePrmPrmPtr = here->MESAsourcePrmPrmSourcePrmPrmStructPtr->CSC ; + + if ((here->MESAdrainNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAdrainDrainPrimePtr = here->MESAdrainDrainPrimeStructPtr->CSC ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAdrainNode != 0)) + here->MESAdrainPrimeDrainPtr = here->MESAdrainPrimeDrainStructPtr->CSC ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAgatePrimeDrainPrimePtr = here->MESAgatePrimeDrainPrimeStructPtr->CSC ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAdrainPrimeGatePrimePtr = here->MESAdrainPrimeGatePrimeStructPtr->CSC ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAgatePrimeSourcePrimePtr = here->MESAgatePrimeSourcePrimeStructPtr->CSC ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAsourcePrimeGatePrimePtr = here->MESAsourcePrimeGatePrimeStructPtr->CSC ; + + if ((here->MESAsourceNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAsourceSourcePrimePtr = here->MESAsourceSourcePrimeStructPtr->CSC ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAsourceNode != 0)) + here->MESAsourcePrimeSourcePtr = here->MESAsourcePrimeSourceStructPtr->CSC ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAdrainPrimeSourcePrimePtr = here->MESAdrainPrimeSourcePrimeStructPtr->CSC ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAsourcePrimeDrainPrimePtr = here->MESAsourcePrimeDrainPrimeStructPtr->CSC ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAgateNode != 0)) + here->MESAgatePrimeGatePtr = here->MESAgatePrimeGateStructPtr->CSC ; + + if ((here->MESAgateNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAgateGatePrimePtr = here->MESAgateGatePrimeStructPtr->CSC ; + + if ((here->MESAsourcePrmPrmNode != 0) && (here->MESAsourcePrimeNode != 0)) + here->MESAsourcePrmPrmSourcePrimePtr = here->MESAsourcePrmPrmSourcePrimeStructPtr->CSC ; + + if ((here->MESAsourcePrimeNode != 0) && (here->MESAsourcePrmPrmNode != 0)) + here->MESAsourcePrimeSourcePrmPrmPtr = here->MESAsourcePrimeSourcePrmPrmStructPtr->CSC ; + + if ((here->MESAsourcePrmPrmNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAsourcePrmPrmGatePrimePtr = here->MESAsourcePrmPrmGatePrimeStructPtr->CSC ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAsourcePrmPrmNode != 0)) + here->MESAgatePrimeSourcePrmPrmPtr = here->MESAgatePrimeSourcePrmPrmStructPtr->CSC ; + + if ((here->MESAdrainPrmPrmNode != 0) && (here->MESAdrainPrimeNode != 0)) + here->MESAdrainPrmPrmDrainPrimePtr = here->MESAdrainPrmPrmDrainPrimeStructPtr->CSC ; + + if ((here->MESAdrainPrimeNode != 0) && (here->MESAdrainPrmPrmNode != 0)) + here->MESAdrainPrimeDrainPrmPrmPtr = here->MESAdrainPrimeDrainPrmPrmStructPtr->CSC ; + + if ((here->MESAdrainPrmPrmNode != 0) && (here->MESAgatePrimeNode != 0)) + here->MESAdrainPrmPrmGatePrimePtr = here->MESAdrainPrmPrmGatePrimeStructPtr->CSC ; + + if ((here->MESAgatePrimeNode != 0) && (here->MESAdrainPrmPrmNode != 0)) + here->MESAgatePrimeDrainPrmPrmPtr = here->MESAgatePrimeDrainPrmPrmStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/mesa/mesadefs.h b/src/spicelib/devices/mesa/mesadefs.h index 37fffc4a4..bc47ceabc 100644 --- a/src/spicelib/devices/mesa/mesadefs.h +++ b/src/spicelib/devices/mesa/mesadefs.h @@ -208,6 +208,38 @@ int MESAmode; double MESAnsb0; double MESAvcrits; double MESAvcritd; + +#ifdef KLU + BindElement *MESAdrainDrainStructPtr ; + BindElement *MESAdrainPrimeDrainPrimeStructPtr ; + BindElement *MESAdrainPrmPrmDrainPrmPrmStructPtr ; + BindElement *MESAgateGateStructPtr ; + BindElement *MESAgatePrimeGatePrimeStructPtr ; + BindElement *MESAsourceSourceStructPtr ; + BindElement *MESAsourcePrimeSourcePrimeStructPtr ; + BindElement *MESAsourcePrmPrmSourcePrmPrmStructPtr ; + BindElement *MESAdrainDrainPrimeStructPtr ; + BindElement *MESAdrainPrimeDrainStructPtr ; + BindElement *MESAgatePrimeDrainPrimeStructPtr ; + BindElement *MESAdrainPrimeGatePrimeStructPtr ; + BindElement *MESAgatePrimeSourcePrimeStructPtr ; + BindElement *MESAsourcePrimeGatePrimeStructPtr ; + BindElement *MESAsourceSourcePrimeStructPtr ; + BindElement *MESAsourcePrimeSourceStructPtr ; + BindElement *MESAdrainPrimeSourcePrimeStructPtr ; + BindElement *MESAsourcePrimeDrainPrimeStructPtr ; + BindElement *MESAgatePrimeGateStructPtr ; + BindElement *MESAgateGatePrimeStructPtr ; + BindElement *MESAsourcePrmPrmSourcePrimeStructPtr ; + BindElement *MESAsourcePrimeSourcePrmPrmStructPtr ; + BindElement *MESAsourcePrmPrmGatePrimeStructPtr ; + BindElement *MESAgatePrimeSourcePrmPrmStructPtr ; + BindElement *MESAdrainPrmPrmDrainPrimeStructPtr ; + BindElement *MESAdrainPrimeDrainPrmPrmStructPtr ; + BindElement *MESAdrainPrmPrmGatePrimeStructPtr ; + BindElement *MESAgatePrimeDrainPrmPrmStructPtr ; +#endif + } MESAinstance ; diff --git a/src/spicelib/devices/mesa/mesaext.h b/src/spicelib/devices/mesa/mesaext.h index a1967cf44..b4fc30a4c 100644 --- a/src/spicelib/devices/mesa/mesaext.h +++ b/src/spicelib/devices/mesa/mesaext.h @@ -18,3 +18,9 @@ extern int MESAsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int MESAtemp(GENmodel*,CKTcircuit*); extern int MESAtrunc(GENmodel*,CKTcircuit*,double*); extern int MESAunsetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int MESAbindCSC (GENmodel*, CKTcircuit*) ; +extern int MESAbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int MESAbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/mesa/mesainit.c b/src/spicelib/devices/mesa/mesainit.c index c1a63a43b..1e9ced6fb 100644 --- a/src/spicelib/devices/mesa/mesainit.c +++ b/src/spicelib/devices/mesa/mesainit.c @@ -73,7 +73,13 @@ SPICEdev MESAinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &MESAiSize, - /* DEVmodSize */ &MESAmSize + /* DEVmodSize */ &MESAmSize, + +#ifdef KLU + /* DEVbindCSC */ MESAbindCSC, + /* DEVbindCSCComplex */ MESAbindCSCComplex, + /* DEVbindCSCComplexToReal */ MESAbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/mos1/Makefile.am b/src/spicelib/devices/mos1/Makefile.am index e523c113c..a0e3eff13 100644 --- a/src/spicelib/devices/mos1/Makefile.am +++ b/src/spicelib/devices/mos1/Makefile.am @@ -34,7 +34,11 @@ libmos1_la_SOURCES = \ mos1trun.c +if KLU_WANTED +libmos1_la_SOURCES += mos1bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/mos1/mos1bindCSC.c b/src/spicelib/devices/mos1/mos1bindCSC.c new file mode 100644 index 000000000..fb47779e7 --- /dev/null +++ b/src/spicelib/devices/mos1/mos1bindCSC.c @@ -0,0 +1,393 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "mos1defs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +MOS1bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS1model *model = (MOS1model *)inModel ; + MOS1instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the MOS1 models */ + for ( ; model != NULL ; model = model->MOS1nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS1instances ; here != NULL ; here = here->MOS1nextInstance) + { + if ((here->MOS1dNode != 0) && (here->MOS1dNode != 0)) + { + i = here->MOS1DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1DdStructPtr = matched ; + here->MOS1DdPtr = matched->CSC ; + } + + if ((here->MOS1gNode != 0) && (here->MOS1gNode != 0)) + { + i = here->MOS1GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1GgStructPtr = matched ; + here->MOS1GgPtr = matched->CSC ; + } + + if ((here->MOS1sNode != 0) && (here->MOS1sNode != 0)) + { + i = here->MOS1SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1SsStructPtr = matched ; + here->MOS1SsPtr = matched->CSC ; + } + + if ((here->MOS1bNode != 0) && (here->MOS1bNode != 0)) + { + i = here->MOS1BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1BbStructPtr = matched ; + here->MOS1BbPtr = matched->CSC ; + } + + if ((here->MOS1dNodePrime != 0) && (here->MOS1dNodePrime != 0)) + { + i = here->MOS1DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1DPdpStructPtr = matched ; + here->MOS1DPdpPtr = matched->CSC ; + } + + if ((here->MOS1sNodePrime != 0) && (here->MOS1sNodePrime != 0)) + { + i = here->MOS1SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1SPspStructPtr = matched ; + here->MOS1SPspPtr = matched->CSC ; + } + + if ((here->MOS1dNode != 0) && (here->MOS1dNodePrime != 0)) + { + i = here->MOS1DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1DdpStructPtr = matched ; + here->MOS1DdpPtr = matched->CSC ; + } + + if ((here->MOS1gNode != 0) && (here->MOS1bNode != 0)) + { + i = here->MOS1GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1GbStructPtr = matched ; + here->MOS1GbPtr = matched->CSC ; + } + + if ((here->MOS1gNode != 0) && (here->MOS1dNodePrime != 0)) + { + i = here->MOS1GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1GdpStructPtr = matched ; + here->MOS1GdpPtr = matched->CSC ; + } + + if ((here->MOS1gNode != 0) && (here->MOS1sNodePrime != 0)) + { + i = here->MOS1GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1GspStructPtr = matched ; + here->MOS1GspPtr = matched->CSC ; + } + + if ((here->MOS1sNode != 0) && (here->MOS1sNodePrime != 0)) + { + i = here->MOS1SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1SspStructPtr = matched ; + here->MOS1SspPtr = matched->CSC ; + } + + if ((here->MOS1bNode != 0) && (here->MOS1dNodePrime != 0)) + { + i = here->MOS1BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1BdpStructPtr = matched ; + here->MOS1BdpPtr = matched->CSC ; + } + + if ((here->MOS1bNode != 0) && (here->MOS1sNodePrime != 0)) + { + i = here->MOS1BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1BspStructPtr = matched ; + here->MOS1BspPtr = matched->CSC ; + } + + if ((here->MOS1dNodePrime != 0) && (here->MOS1sNodePrime != 0)) + { + i = here->MOS1DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1DPspStructPtr = matched ; + here->MOS1DPspPtr = matched->CSC ; + } + + if ((here->MOS1dNodePrime != 0) && (here->MOS1dNode != 0)) + { + i = here->MOS1DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1DPdStructPtr = matched ; + here->MOS1DPdPtr = matched->CSC ; + } + + if ((here->MOS1bNode != 0) && (here->MOS1gNode != 0)) + { + i = here->MOS1BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1BgStructPtr = matched ; + here->MOS1BgPtr = matched->CSC ; + } + + if ((here->MOS1dNodePrime != 0) && (here->MOS1gNode != 0)) + { + i = here->MOS1DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1DPgStructPtr = matched ; + here->MOS1DPgPtr = matched->CSC ; + } + + if ((here->MOS1sNodePrime != 0) && (here->MOS1gNode != 0)) + { + i = here->MOS1SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1SPgStructPtr = matched ; + here->MOS1SPgPtr = matched->CSC ; + } + + if ((here->MOS1sNodePrime != 0) && (here->MOS1sNode != 0)) + { + i = here->MOS1SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1SPsStructPtr = matched ; + here->MOS1SPsPtr = matched->CSC ; + } + + if ((here->MOS1dNodePrime != 0) && (here->MOS1bNode != 0)) + { + i = here->MOS1DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1DPbStructPtr = matched ; + here->MOS1DPbPtr = matched->CSC ; + } + + if ((here->MOS1sNodePrime != 0) && (here->MOS1bNode != 0)) + { + i = here->MOS1SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1SPbStructPtr = matched ; + here->MOS1SPbPtr = matched->CSC ; + } + + if ((here->MOS1sNodePrime != 0) && (here->MOS1dNodePrime != 0)) + { + i = here->MOS1SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS1SPdpStructPtr = matched ; + here->MOS1SPdpPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +MOS1bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS1model *model = (MOS1model *)inModel ; + MOS1instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS1 models */ + for ( ; model != NULL ; model = model->MOS1nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS1instances ; here != NULL ; here = here->MOS1nextInstance) + { + if ((here->MOS1dNode != 0) && (here->MOS1dNode != 0)) + here->MOS1DdPtr = here->MOS1DdStructPtr->CSC_Complex ; + + if ((here->MOS1gNode != 0) && (here->MOS1gNode != 0)) + here->MOS1GgPtr = here->MOS1GgStructPtr->CSC_Complex ; + + if ((here->MOS1sNode != 0) && (here->MOS1sNode != 0)) + here->MOS1SsPtr = here->MOS1SsStructPtr->CSC_Complex ; + + if ((here->MOS1bNode != 0) && (here->MOS1bNode != 0)) + here->MOS1BbPtr = here->MOS1BbStructPtr->CSC_Complex ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1DPdpPtr = here->MOS1DPdpStructPtr->CSC_Complex ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1SPspPtr = here->MOS1SPspStructPtr->CSC_Complex ; + + if ((here->MOS1dNode != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1DdpPtr = here->MOS1DdpStructPtr->CSC_Complex ; + + if ((here->MOS1gNode != 0) && (here->MOS1bNode != 0)) + here->MOS1GbPtr = here->MOS1GbStructPtr->CSC_Complex ; + + if ((here->MOS1gNode != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1GdpPtr = here->MOS1GdpStructPtr->CSC_Complex ; + + if ((here->MOS1gNode != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1GspPtr = here->MOS1GspStructPtr->CSC_Complex ; + + if ((here->MOS1sNode != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1SspPtr = here->MOS1SspStructPtr->CSC_Complex ; + + if ((here->MOS1bNode != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1BdpPtr = here->MOS1BdpStructPtr->CSC_Complex ; + + if ((here->MOS1bNode != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1BspPtr = here->MOS1BspStructPtr->CSC_Complex ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1DPspPtr = here->MOS1DPspStructPtr->CSC_Complex ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1dNode != 0)) + here->MOS1DPdPtr = here->MOS1DPdStructPtr->CSC_Complex ; + + if ((here->MOS1bNode != 0) && (here->MOS1gNode != 0)) + here->MOS1BgPtr = here->MOS1BgStructPtr->CSC_Complex ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1gNode != 0)) + here->MOS1DPgPtr = here->MOS1DPgStructPtr->CSC_Complex ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1gNode != 0)) + here->MOS1SPgPtr = here->MOS1SPgStructPtr->CSC_Complex ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1sNode != 0)) + here->MOS1SPsPtr = here->MOS1SPsStructPtr->CSC_Complex ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1bNode != 0)) + here->MOS1DPbPtr = here->MOS1DPbStructPtr->CSC_Complex ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1bNode != 0)) + here->MOS1SPbPtr = here->MOS1SPbStructPtr->CSC_Complex ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1SPdpPtr = here->MOS1SPdpStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +MOS1bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS1model *model = (MOS1model *)inModel ; + MOS1instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS1 models */ + for ( ; model != NULL ; model = model->MOS1nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS1instances ; here != NULL ; here = here->MOS1nextInstance) + { + if ((here->MOS1dNode != 0) && (here->MOS1dNode != 0)) + here->MOS1DdPtr = here->MOS1DdStructPtr->CSC ; + + if ((here->MOS1gNode != 0) && (here->MOS1gNode != 0)) + here->MOS1GgPtr = here->MOS1GgStructPtr->CSC ; + + if ((here->MOS1sNode != 0) && (here->MOS1sNode != 0)) + here->MOS1SsPtr = here->MOS1SsStructPtr->CSC ; + + if ((here->MOS1bNode != 0) && (here->MOS1bNode != 0)) + here->MOS1BbPtr = here->MOS1BbStructPtr->CSC ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1DPdpPtr = here->MOS1DPdpStructPtr->CSC ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1SPspPtr = here->MOS1SPspStructPtr->CSC ; + + if ((here->MOS1dNode != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1DdpPtr = here->MOS1DdpStructPtr->CSC ; + + if ((here->MOS1gNode != 0) && (here->MOS1bNode != 0)) + here->MOS1GbPtr = here->MOS1GbStructPtr->CSC ; + + if ((here->MOS1gNode != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1GdpPtr = here->MOS1GdpStructPtr->CSC ; + + if ((here->MOS1gNode != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1GspPtr = here->MOS1GspStructPtr->CSC ; + + if ((here->MOS1sNode != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1SspPtr = here->MOS1SspStructPtr->CSC ; + + if ((here->MOS1bNode != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1BdpPtr = here->MOS1BdpStructPtr->CSC ; + + if ((here->MOS1bNode != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1BspPtr = here->MOS1BspStructPtr->CSC ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1sNodePrime != 0)) + here->MOS1DPspPtr = here->MOS1DPspStructPtr->CSC ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1dNode != 0)) + here->MOS1DPdPtr = here->MOS1DPdStructPtr->CSC ; + + if ((here->MOS1bNode != 0) && (here->MOS1gNode != 0)) + here->MOS1BgPtr = here->MOS1BgStructPtr->CSC ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1gNode != 0)) + here->MOS1DPgPtr = here->MOS1DPgStructPtr->CSC ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1gNode != 0)) + here->MOS1SPgPtr = here->MOS1SPgStructPtr->CSC ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1sNode != 0)) + here->MOS1SPsPtr = here->MOS1SPsStructPtr->CSC ; + + if ((here->MOS1dNodePrime != 0) && (here->MOS1bNode != 0)) + here->MOS1DPbPtr = here->MOS1DPbStructPtr->CSC ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1bNode != 0)) + here->MOS1SPbPtr = here->MOS1SPbStructPtr->CSC ; + + if ((here->MOS1sNodePrime != 0) && (here->MOS1dNodePrime != 0)) + here->MOS1SPdpPtr = here->MOS1SPdpStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/mos1/mos1defs.h b/src/spicelib/devices/mos1/mos1defs.h index c51cc2eb9..dcc31ad58 100644 --- a/src/spicelib/devices/mos1/mos1defs.h +++ b/src/spicelib/devices/mos1/mos1defs.h @@ -264,6 +264,31 @@ typedef struct sMOS1instance { #define MOS1dphibs_dw MOS1sens + 68 #define MOS1dphibd_dw MOS1sens + 69 +#ifdef KLU + BindElement *MOS1DdStructPtr ; + BindElement *MOS1GgStructPtr ; + BindElement *MOS1SsStructPtr ; + BindElement *MOS1BbStructPtr ; + BindElement *MOS1DPdpStructPtr ; + BindElement *MOS1SPspStructPtr ; + BindElement *MOS1DdpStructPtr ; + BindElement *MOS1GbStructPtr ; + BindElement *MOS1GdpStructPtr ; + BindElement *MOS1GspStructPtr ; + BindElement *MOS1SspStructPtr ; + BindElement *MOS1BdpStructPtr ; + BindElement *MOS1BspStructPtr ; + BindElement *MOS1DPspStructPtr ; + BindElement *MOS1DPdStructPtr ; + BindElement *MOS1BgStructPtr ; + BindElement *MOS1DPgStructPtr ; + BindElement *MOS1SPgStructPtr ; + BindElement *MOS1SPsStructPtr ; + BindElement *MOS1DPbStructPtr ; + BindElement *MOS1SPbStructPtr ; + BindElement *MOS1SPdpStructPtr ; +#endif + } MOS1instance ; #define MOS1vbd MOS1states+ 0 /* bulk-drain voltage */ diff --git a/src/spicelib/devices/mos1/mos1ext.h b/src/spicelib/devices/mos1/mos1ext.h index b1ed69d52..4521e6d35 100644 --- a/src/spicelib/devices/mos1/mos1ext.h +++ b/src/spicelib/devices/mos1/mos1ext.h @@ -28,3 +28,9 @@ extern int MOS1convTest(GENmodel*,CKTcircuit*); extern int MOS1disto(int,GENmodel*,CKTcircuit*); extern int MOS1noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int MOS1dSetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int MOS1bindCSC (GENmodel*, CKTcircuit*) ; +extern int MOS1bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int MOS1bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/mos1/mos1init.c b/src/spicelib/devices/mos1/mos1init.c index a537f411c..3d26953c8 100644 --- a/src/spicelib/devices/mos1/mos1init.c +++ b/src/spicelib/devices/mos1/mos1init.c @@ -73,7 +73,14 @@ SPICEdev MOS1info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &MOS1iSize, - /* DEVmodSize */ &MOS1mSize + /* DEVmodSize */ &MOS1mSize, + +#ifdef KLU + /* DEVbindCSC */ MOS1bindCSC, + /* DEVbindCSCComplex */ MOS1bindCSCComplex, + /* DEVbindCSCComplexToReal */ MOS1bindCSCComplexToReal, +#endif + }; diff --git a/src/spicelib/devices/mos2/Makefile.am b/src/spicelib/devices/mos2/Makefile.am index a27ddc9d2..a3d439759 100644 --- a/src/spicelib/devices/mos2/Makefile.am +++ b/src/spicelib/devices/mos2/Makefile.am @@ -33,7 +33,11 @@ libmos2_la_SOURCES = \ mos2temp.c \ mos2trun.c +if KLU_WANTED +libmos2_la_SOURCES += mos2bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/mos2/mos2bindCSC.c b/src/spicelib/devices/mos2/mos2bindCSC.c new file mode 100644 index 000000000..e0dd4c869 --- /dev/null +++ b/src/spicelib/devices/mos2/mos2bindCSC.c @@ -0,0 +1,393 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "mos2defs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +MOS2bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS2model *model = (MOS2model *)inModel ; + MOS2instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the MOS2 models */ + for ( ; model != NULL ; model = model->MOS2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS2instances ; here != NULL ; here = here->MOS2nextInstance) + { + if ((here-> MOS2dNode != 0) && (here-> MOS2dNode != 0)) + { + i = here->MOS2DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2DdStructPtr = matched ; + here->MOS2DdPtr = matched->CSC ; + } + + if ((here-> MOS2gNode != 0) && (here-> MOS2gNode != 0)) + { + i = here->MOS2GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2GgStructPtr = matched ; + here->MOS2GgPtr = matched->CSC ; + } + + if ((here-> MOS2sNode != 0) && (here-> MOS2sNode != 0)) + { + i = here->MOS2SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2SsStructPtr = matched ; + here->MOS2SsPtr = matched->CSC ; + } + + if ((here-> MOS2bNode != 0) && (here-> MOS2bNode != 0)) + { + i = here->MOS2BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2BbStructPtr = matched ; + here->MOS2BbPtr = matched->CSC ; + } + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2dNodePrime != 0)) + { + i = here->MOS2DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2DPdpStructPtr = matched ; + here->MOS2DPdpPtr = matched->CSC ; + } + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2sNodePrime != 0)) + { + i = here->MOS2SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2SPspStructPtr = matched ; + here->MOS2SPspPtr = matched->CSC ; + } + + if ((here-> MOS2dNode != 0) && (here-> MOS2dNodePrime != 0)) + { + i = here->MOS2DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2DdpStructPtr = matched ; + here->MOS2DdpPtr = matched->CSC ; + } + + if ((here-> MOS2gNode != 0) && (here-> MOS2bNode != 0)) + { + i = here->MOS2GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2GbStructPtr = matched ; + here->MOS2GbPtr = matched->CSC ; + } + + if ((here-> MOS2gNode != 0) && (here-> MOS2dNodePrime != 0)) + { + i = here->MOS2GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2GdpStructPtr = matched ; + here->MOS2GdpPtr = matched->CSC ; + } + + if ((here-> MOS2gNode != 0) && (here-> MOS2sNodePrime != 0)) + { + i = here->MOS2GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2GspStructPtr = matched ; + here->MOS2GspPtr = matched->CSC ; + } + + if ((here-> MOS2sNode != 0) && (here-> MOS2sNodePrime != 0)) + { + i = here->MOS2SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2SspStructPtr = matched ; + here->MOS2SspPtr = matched->CSC ; + } + + if ((here-> MOS2bNode != 0) && (here-> MOS2dNodePrime != 0)) + { + i = here->MOS2BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2BdpStructPtr = matched ; + here->MOS2BdpPtr = matched->CSC ; + } + + if ((here-> MOS2bNode != 0) && (here-> MOS2sNodePrime != 0)) + { + i = here->MOS2BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2BspStructPtr = matched ; + here->MOS2BspPtr = matched->CSC ; + } + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2sNodePrime != 0)) + { + i = here->MOS2DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2DPspStructPtr = matched ; + here->MOS2DPspPtr = matched->CSC ; + } + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2dNode != 0)) + { + i = here->MOS2DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2DPdStructPtr = matched ; + here->MOS2DPdPtr = matched->CSC ; + } + + if ((here-> MOS2bNode != 0) && (here-> MOS2gNode != 0)) + { + i = here->MOS2BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2BgStructPtr = matched ; + here->MOS2BgPtr = matched->CSC ; + } + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2gNode != 0)) + { + i = here->MOS2DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2DPgStructPtr = matched ; + here->MOS2DPgPtr = matched->CSC ; + } + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2gNode != 0)) + { + i = here->MOS2SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2SPgStructPtr = matched ; + here->MOS2SPgPtr = matched->CSC ; + } + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2sNode != 0)) + { + i = here->MOS2SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2SPsStructPtr = matched ; + here->MOS2SPsPtr = matched->CSC ; + } + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2bNode != 0)) + { + i = here->MOS2DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2DPbStructPtr = matched ; + here->MOS2DPbPtr = matched->CSC ; + } + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2bNode != 0)) + { + i = here->MOS2SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2SPbStructPtr = matched ; + here->MOS2SPbPtr = matched->CSC ; + } + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2dNodePrime != 0)) + { + i = here->MOS2SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS2SPdpStructPtr = matched ; + here->MOS2SPdpPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +MOS2bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS2model *model = (MOS2model *)inModel ; + MOS2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS2 models */ + for ( ; model != NULL ; model = model->MOS2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS2instances ; here != NULL ; here = here->MOS2nextInstance) + { + if ((here-> MOS2dNode != 0) && (here-> MOS2dNode != 0)) + here->MOS2DdPtr = here->MOS2DdStructPtr->CSC_Complex ; + + if ((here-> MOS2gNode != 0) && (here-> MOS2gNode != 0)) + here->MOS2GgPtr = here->MOS2GgStructPtr->CSC_Complex ; + + if ((here-> MOS2sNode != 0) && (here-> MOS2sNode != 0)) + here->MOS2SsPtr = here->MOS2SsStructPtr->CSC_Complex ; + + if ((here-> MOS2bNode != 0) && (here-> MOS2bNode != 0)) + here->MOS2BbPtr = here->MOS2BbStructPtr->CSC_Complex ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2DPdpPtr = here->MOS2DPdpStructPtr->CSC_Complex ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2SPspPtr = here->MOS2SPspStructPtr->CSC_Complex ; + + if ((here-> MOS2dNode != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2DdpPtr = here->MOS2DdpStructPtr->CSC_Complex ; + + if ((here-> MOS2gNode != 0) && (here-> MOS2bNode != 0)) + here->MOS2GbPtr = here->MOS2GbStructPtr->CSC_Complex ; + + if ((here-> MOS2gNode != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2GdpPtr = here->MOS2GdpStructPtr->CSC_Complex ; + + if ((here-> MOS2gNode != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2GspPtr = here->MOS2GspStructPtr->CSC_Complex ; + + if ((here-> MOS2sNode != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2SspPtr = here->MOS2SspStructPtr->CSC_Complex ; + + if ((here-> MOS2bNode != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2BdpPtr = here->MOS2BdpStructPtr->CSC_Complex ; + + if ((here-> MOS2bNode != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2BspPtr = here->MOS2BspStructPtr->CSC_Complex ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2DPspPtr = here->MOS2DPspStructPtr->CSC_Complex ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2dNode != 0)) + here->MOS2DPdPtr = here->MOS2DPdStructPtr->CSC_Complex ; + + if ((here-> MOS2bNode != 0) && (here-> MOS2gNode != 0)) + here->MOS2BgPtr = here->MOS2BgStructPtr->CSC_Complex ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2gNode != 0)) + here->MOS2DPgPtr = here->MOS2DPgStructPtr->CSC_Complex ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2gNode != 0)) + here->MOS2SPgPtr = here->MOS2SPgStructPtr->CSC_Complex ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2sNode != 0)) + here->MOS2SPsPtr = here->MOS2SPsStructPtr->CSC_Complex ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2bNode != 0)) + here->MOS2DPbPtr = here->MOS2DPbStructPtr->CSC_Complex ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2bNode != 0)) + here->MOS2SPbPtr = here->MOS2SPbStructPtr->CSC_Complex ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2SPdpPtr = here->MOS2SPdpStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +MOS2bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS2model *model = (MOS2model *)inModel ; + MOS2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS2 models */ + for ( ; model != NULL ; model = model->MOS2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS2instances ; here != NULL ; here = here->MOS2nextInstance) + { + if ((here-> MOS2dNode != 0) && (here-> MOS2dNode != 0)) + here->MOS2DdPtr = here->MOS2DdStructPtr->CSC ; + + if ((here-> MOS2gNode != 0) && (here-> MOS2gNode != 0)) + here->MOS2GgPtr = here->MOS2GgStructPtr->CSC ; + + if ((here-> MOS2sNode != 0) && (here-> MOS2sNode != 0)) + here->MOS2SsPtr = here->MOS2SsStructPtr->CSC ; + + if ((here-> MOS2bNode != 0) && (here-> MOS2bNode != 0)) + here->MOS2BbPtr = here->MOS2BbStructPtr->CSC ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2DPdpPtr = here->MOS2DPdpStructPtr->CSC ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2SPspPtr = here->MOS2SPspStructPtr->CSC ; + + if ((here-> MOS2dNode != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2DdpPtr = here->MOS2DdpStructPtr->CSC ; + + if ((here-> MOS2gNode != 0) && (here-> MOS2bNode != 0)) + here->MOS2GbPtr = here->MOS2GbStructPtr->CSC ; + + if ((here-> MOS2gNode != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2GdpPtr = here->MOS2GdpStructPtr->CSC ; + + if ((here-> MOS2gNode != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2GspPtr = here->MOS2GspStructPtr->CSC ; + + if ((here-> MOS2sNode != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2SspPtr = here->MOS2SspStructPtr->CSC ; + + if ((here-> MOS2bNode != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2BdpPtr = here->MOS2BdpStructPtr->CSC ; + + if ((here-> MOS2bNode != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2BspPtr = here->MOS2BspStructPtr->CSC ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2sNodePrime != 0)) + here->MOS2DPspPtr = here->MOS2DPspStructPtr->CSC ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2dNode != 0)) + here->MOS2DPdPtr = here->MOS2DPdStructPtr->CSC ; + + if ((here-> MOS2bNode != 0) && (here-> MOS2gNode != 0)) + here->MOS2BgPtr = here->MOS2BgStructPtr->CSC ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2gNode != 0)) + here->MOS2DPgPtr = here->MOS2DPgStructPtr->CSC ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2gNode != 0)) + here->MOS2SPgPtr = here->MOS2SPgStructPtr->CSC ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2sNode != 0)) + here->MOS2SPsPtr = here->MOS2SPsStructPtr->CSC ; + + if ((here-> MOS2dNodePrime != 0) && (here-> MOS2bNode != 0)) + here->MOS2DPbPtr = here->MOS2DPbStructPtr->CSC ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2bNode != 0)) + here->MOS2SPbPtr = here->MOS2SPbStructPtr->CSC ; + + if ((here-> MOS2sNodePrime != 0) && (here-> MOS2dNodePrime != 0)) + here->MOS2SPdpPtr = here->MOS2SPdpStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/mos2/mos2defs.h b/src/spicelib/devices/mos2/mos2defs.h index 6d42d8eee..8dd3532d9 100644 --- a/src/spicelib/devices/mos2/mos2defs.h +++ b/src/spicelib/devices/mos2/mos2defs.h @@ -267,7 +267,30 @@ typedef struct sMOS2instance { double **MOS2nVar; #endif /* NONOISE */ - +#ifdef KLU + BindElement *MOS2DdStructPtr ; + BindElement *MOS2GgStructPtr ; + BindElement *MOS2SsStructPtr ; + BindElement *MOS2BbStructPtr ; + BindElement *MOS2DPdpStructPtr ; + BindElement *MOS2SPspStructPtr ; + BindElement *MOS2DdpStructPtr ; + BindElement *MOS2GbStructPtr ; + BindElement *MOS2GdpStructPtr ; + BindElement *MOS2GspStructPtr ; + BindElement *MOS2SspStructPtr ; + BindElement *MOS2BdpStructPtr ; + BindElement *MOS2BspStructPtr ; + BindElement *MOS2DPspStructPtr ; + BindElement *MOS2DPdStructPtr ; + BindElement *MOS2BgStructPtr ; + BindElement *MOS2DPgStructPtr ; + BindElement *MOS2SPgStructPtr ; + BindElement *MOS2SPsStructPtr ; + BindElement *MOS2DPbStructPtr ; + BindElement *MOS2SPbStructPtr ; + BindElement *MOS2SPdpStructPtr ; +#endif } MOS2instance ; diff --git a/src/spicelib/devices/mos2/mos2ext.h b/src/spicelib/devices/mos2/mos2ext.h index 46a8a3e38..f87f7ea7d 100644 --- a/src/spicelib/devices/mos2/mos2ext.h +++ b/src/spicelib/devices/mos2/mos2ext.h @@ -29,3 +29,9 @@ extern int MOS2disto(int,GENmodel*,CKTcircuit*); extern int MOS2noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int MOS2dSetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int MOS2bindCSC (GENmodel*, CKTcircuit*) ; +extern int MOS2bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int MOS2bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/mos2/mos2init.c b/src/spicelib/devices/mos2/mos2init.c index 1a6c9afbe..05c50fdd5 100644 --- a/src/spicelib/devices/mos2/mos2init.c +++ b/src/spicelib/devices/mos2/mos2init.c @@ -73,7 +73,14 @@ SPICEdev MOS2info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &MOS2iSize, - /* DEVmodSize */ &MOS2mSize + /* DEVmodSize */ &MOS2mSize, + +#ifdef KLU + /* DEVbindCSC */ MOS2bindCSC, + /* DEVbindCSCComplex */ MOS2bindCSCComplex, + /* DEVbindCSCComplexToReal */ MOS2bindCSCComplexToReal, +#endif + }; diff --git a/src/spicelib/devices/mos3/Makefile.am b/src/spicelib/devices/mos3/Makefile.am index 7419051a9..cf08841e1 100644 --- a/src/spicelib/devices/mos3/Makefile.am +++ b/src/spicelib/devices/mos3/Makefile.am @@ -33,7 +33,11 @@ libmos3_la_SOURCES = \ mos3temp.c \ mos3trun.c +if KLU_WANTED +libmos3_la_SOURCES += mos3bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/mos3/mos3bindCSC.c b/src/spicelib/devices/mos3/mos3bindCSC.c new file mode 100644 index 000000000..b0c5ce0d5 --- /dev/null +++ b/src/spicelib/devices/mos3/mos3bindCSC.c @@ -0,0 +1,393 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "mos3defs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +MOS3bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS3model *model = (MOS3model *)inModel ; + MOS3instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the MOS3 models */ + for ( ; model != NULL ; model = model->MOS3nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS3instances ; here != NULL ; here = here->MOS3nextInstance) + { + if ((here-> MOS3dNode != 0) && (here-> MOS3dNode != 0)) + { + i = here->MOS3DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3DdStructPtr = matched ; + here->MOS3DdPtr = matched->CSC ; + } + + if ((here-> MOS3gNode != 0) && (here-> MOS3gNode != 0)) + { + i = here->MOS3GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3GgStructPtr = matched ; + here->MOS3GgPtr = matched->CSC ; + } + + if ((here-> MOS3sNode != 0) && (here-> MOS3sNode != 0)) + { + i = here->MOS3SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3SsStructPtr = matched ; + here->MOS3SsPtr = matched->CSC ; + } + + if ((here-> MOS3bNode != 0) && (here-> MOS3bNode != 0)) + { + i = here->MOS3BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3BbStructPtr = matched ; + here->MOS3BbPtr = matched->CSC ; + } + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3dNodePrime != 0)) + { + i = here->MOS3DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3DPdpStructPtr = matched ; + here->MOS3DPdpPtr = matched->CSC ; + } + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3sNodePrime != 0)) + { + i = here->MOS3SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3SPspStructPtr = matched ; + here->MOS3SPspPtr = matched->CSC ; + } + + if ((here-> MOS3dNode != 0) && (here-> MOS3dNodePrime != 0)) + { + i = here->MOS3DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3DdpStructPtr = matched ; + here->MOS3DdpPtr = matched->CSC ; + } + + if ((here-> MOS3gNode != 0) && (here-> MOS3bNode != 0)) + { + i = here->MOS3GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3GbStructPtr = matched ; + here->MOS3GbPtr = matched->CSC ; + } + + if ((here-> MOS3gNode != 0) && (here-> MOS3dNodePrime != 0)) + { + i = here->MOS3GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3GdpStructPtr = matched ; + here->MOS3GdpPtr = matched->CSC ; + } + + if ((here-> MOS3gNode != 0) && (here-> MOS3sNodePrime != 0)) + { + i = here->MOS3GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3GspStructPtr = matched ; + here->MOS3GspPtr = matched->CSC ; + } + + if ((here-> MOS3sNode != 0) && (here-> MOS3sNodePrime != 0)) + { + i = here->MOS3SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3SspStructPtr = matched ; + here->MOS3SspPtr = matched->CSC ; + } + + if ((here-> MOS3bNode != 0) && (here-> MOS3dNodePrime != 0)) + { + i = here->MOS3BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3BdpStructPtr = matched ; + here->MOS3BdpPtr = matched->CSC ; + } + + if ((here-> MOS3bNode != 0) && (here-> MOS3sNodePrime != 0)) + { + i = here->MOS3BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3BspStructPtr = matched ; + here->MOS3BspPtr = matched->CSC ; + } + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3sNodePrime != 0)) + { + i = here->MOS3DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3DPspStructPtr = matched ; + here->MOS3DPspPtr = matched->CSC ; + } + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3dNode != 0)) + { + i = here->MOS3DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3DPdStructPtr = matched ; + here->MOS3DPdPtr = matched->CSC ; + } + + if ((here-> MOS3bNode != 0) && (here-> MOS3gNode != 0)) + { + i = here->MOS3BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3BgStructPtr = matched ; + here->MOS3BgPtr = matched->CSC ; + } + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3gNode != 0)) + { + i = here->MOS3DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3DPgStructPtr = matched ; + here->MOS3DPgPtr = matched->CSC ; + } + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3gNode != 0)) + { + i = here->MOS3SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3SPgStructPtr = matched ; + here->MOS3SPgPtr = matched->CSC ; + } + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3sNode != 0)) + { + i = here->MOS3SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3SPsStructPtr = matched ; + here->MOS3SPsPtr = matched->CSC ; + } + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3bNode != 0)) + { + i = here->MOS3DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3DPbStructPtr = matched ; + here->MOS3DPbPtr = matched->CSC ; + } + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3bNode != 0)) + { + i = here->MOS3SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3SPbStructPtr = matched ; + here->MOS3SPbPtr = matched->CSC ; + } + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3dNodePrime != 0)) + { + i = here->MOS3SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS3SPdpStructPtr = matched ; + here->MOS3SPdpPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +MOS3bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS3model *model = (MOS3model *)inModel ; + MOS3instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS3 models */ + for ( ; model != NULL ; model = model->MOS3nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS3instances ; here != NULL ; here = here->MOS3nextInstance) + { + if ((here-> MOS3dNode != 0) && (here-> MOS3dNode != 0)) + here->MOS3DdPtr = here->MOS3DdStructPtr->CSC_Complex ; + + if ((here-> MOS3gNode != 0) && (here-> MOS3gNode != 0)) + here->MOS3GgPtr = here->MOS3GgStructPtr->CSC_Complex ; + + if ((here-> MOS3sNode != 0) && (here-> MOS3sNode != 0)) + here->MOS3SsPtr = here->MOS3SsStructPtr->CSC_Complex ; + + if ((here-> MOS3bNode != 0) && (here-> MOS3bNode != 0)) + here->MOS3BbPtr = here->MOS3BbStructPtr->CSC_Complex ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3DPdpPtr = here->MOS3DPdpStructPtr->CSC_Complex ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3SPspPtr = here->MOS3SPspStructPtr->CSC_Complex ; + + if ((here-> MOS3dNode != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3DdpPtr = here->MOS3DdpStructPtr->CSC_Complex ; + + if ((here-> MOS3gNode != 0) && (here-> MOS3bNode != 0)) + here->MOS3GbPtr = here->MOS3GbStructPtr->CSC_Complex ; + + if ((here-> MOS3gNode != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3GdpPtr = here->MOS3GdpStructPtr->CSC_Complex ; + + if ((here-> MOS3gNode != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3GspPtr = here->MOS3GspStructPtr->CSC_Complex ; + + if ((here-> MOS3sNode != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3SspPtr = here->MOS3SspStructPtr->CSC_Complex ; + + if ((here-> MOS3bNode != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3BdpPtr = here->MOS3BdpStructPtr->CSC_Complex ; + + if ((here-> MOS3bNode != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3BspPtr = here->MOS3BspStructPtr->CSC_Complex ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3DPspPtr = here->MOS3DPspStructPtr->CSC_Complex ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3dNode != 0)) + here->MOS3DPdPtr = here->MOS3DPdStructPtr->CSC_Complex ; + + if ((here-> MOS3bNode != 0) && (here-> MOS3gNode != 0)) + here->MOS3BgPtr = here->MOS3BgStructPtr->CSC_Complex ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3gNode != 0)) + here->MOS3DPgPtr = here->MOS3DPgStructPtr->CSC_Complex ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3gNode != 0)) + here->MOS3SPgPtr = here->MOS3SPgStructPtr->CSC_Complex ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3sNode != 0)) + here->MOS3SPsPtr = here->MOS3SPsStructPtr->CSC_Complex ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3bNode != 0)) + here->MOS3DPbPtr = here->MOS3DPbStructPtr->CSC_Complex ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3bNode != 0)) + here->MOS3SPbPtr = here->MOS3SPbStructPtr->CSC_Complex ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3SPdpPtr = here->MOS3SPdpStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +MOS3bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS3model *model = (MOS3model *)inModel ; + MOS3instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS3 models */ + for ( ; model != NULL ; model = model->MOS3nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS3instances ; here != NULL ; here = here->MOS3nextInstance) + { + if ((here-> MOS3dNode != 0) && (here-> MOS3dNode != 0)) + here->MOS3DdPtr = here->MOS3DdStructPtr->CSC ; + + if ((here-> MOS3gNode != 0) && (here-> MOS3gNode != 0)) + here->MOS3GgPtr = here->MOS3GgStructPtr->CSC ; + + if ((here-> MOS3sNode != 0) && (here-> MOS3sNode != 0)) + here->MOS3SsPtr = here->MOS3SsStructPtr->CSC ; + + if ((here-> MOS3bNode != 0) && (here-> MOS3bNode != 0)) + here->MOS3BbPtr = here->MOS3BbStructPtr->CSC ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3DPdpPtr = here->MOS3DPdpStructPtr->CSC ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3SPspPtr = here->MOS3SPspStructPtr->CSC ; + + if ((here-> MOS3dNode != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3DdpPtr = here->MOS3DdpStructPtr->CSC ; + + if ((here-> MOS3gNode != 0) && (here-> MOS3bNode != 0)) + here->MOS3GbPtr = here->MOS3GbStructPtr->CSC ; + + if ((here-> MOS3gNode != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3GdpPtr = here->MOS3GdpStructPtr->CSC ; + + if ((here-> MOS3gNode != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3GspPtr = here->MOS3GspStructPtr->CSC ; + + if ((here-> MOS3sNode != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3SspPtr = here->MOS3SspStructPtr->CSC ; + + if ((here-> MOS3bNode != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3BdpPtr = here->MOS3BdpStructPtr->CSC ; + + if ((here-> MOS3bNode != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3BspPtr = here->MOS3BspStructPtr->CSC ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3sNodePrime != 0)) + here->MOS3DPspPtr = here->MOS3DPspStructPtr->CSC ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3dNode != 0)) + here->MOS3DPdPtr = here->MOS3DPdStructPtr->CSC ; + + if ((here-> MOS3bNode != 0) && (here-> MOS3gNode != 0)) + here->MOS3BgPtr = here->MOS3BgStructPtr->CSC ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3gNode != 0)) + here->MOS3DPgPtr = here->MOS3DPgStructPtr->CSC ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3gNode != 0)) + here->MOS3SPgPtr = here->MOS3SPgStructPtr->CSC ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3sNode != 0)) + here->MOS3SPsPtr = here->MOS3SPsStructPtr->CSC ; + + if ((here-> MOS3dNodePrime != 0) && (here-> MOS3bNode != 0)) + here->MOS3DPbPtr = here->MOS3DPbStructPtr->CSC ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3bNode != 0)) + here->MOS3SPbPtr = here->MOS3SPbStructPtr->CSC ; + + if ((here-> MOS3sNodePrime != 0) && (here-> MOS3dNodePrime != 0)) + here->MOS3SPdpPtr = here->MOS3SPdpStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/mos3/mos3defs.h b/src/spicelib/devices/mos3/mos3defs.h index 51fe799a7..d9765e39e 100644 --- a/src/spicelib/devices/mos3/mos3defs.h +++ b/src/spicelib/devices/mos3/mos3defs.h @@ -266,6 +266,31 @@ typedef struct sMOS3instance { double **MOS3nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *MOS3DdStructPtr ; + BindElement *MOS3GgStructPtr ; + BindElement *MOS3SsStructPtr ; + BindElement *MOS3BbStructPtr ; + BindElement *MOS3DPdpStructPtr ; + BindElement *MOS3SPspStructPtr ; + BindElement *MOS3DdpStructPtr ; + BindElement *MOS3GbStructPtr ; + BindElement *MOS3GdpStructPtr ; + BindElement *MOS3GspStructPtr ; + BindElement *MOS3SspStructPtr ; + BindElement *MOS3BdpStructPtr ; + BindElement *MOS3BspStructPtr ; + BindElement *MOS3DPspStructPtr ; + BindElement *MOS3DPdStructPtr ; + BindElement *MOS3BgStructPtr ; + BindElement *MOS3DPgStructPtr ; + BindElement *MOS3SPgStructPtr ; + BindElement *MOS3SPsStructPtr ; + BindElement *MOS3DPbStructPtr ; + BindElement *MOS3SPbStructPtr ; + BindElement *MOS3SPdpStructPtr ; +#endif + } MOS3instance ; #define MOS3vbd MOS3states+ 0 diff --git a/src/spicelib/devices/mos3/mos3ext.h b/src/spicelib/devices/mos3/mos3ext.h index 843d68329..bffcd8b6e 100644 --- a/src/spicelib/devices/mos3/mos3ext.h +++ b/src/spicelib/devices/mos3/mos3ext.h @@ -28,3 +28,9 @@ extern int MOS3trunc(GENmodel*,CKTcircuit*,double*); extern int MOS3disto(int,GENmodel*,CKTcircuit*); extern int MOS3noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int MOS3dSetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int MOS3bindCSC (GENmodel*, CKTcircuit*) ; +extern int MOS3bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int MOS3bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/mos3/mos3init.c b/src/spicelib/devices/mos3/mos3init.c index bd3e8c26a..b2d88fcae 100644 --- a/src/spicelib/devices/mos3/mos3init.c +++ b/src/spicelib/devices/mos3/mos3init.c @@ -73,7 +73,13 @@ SPICEdev MOS3info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &MOS3iSize, - /* DEVmodSize */ &MOS3mSize + /* DEVmodSize */ &MOS3mSize, + +#ifdef KLU + /* DEVbindCSC */ MOS3bindCSC, + /* DEVbindCSCComplex */ MOS3bindCSCComplex, + /* DEVbindCSCComplexToReal */ MOS3bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/mos6/Makefile.am b/src/spicelib/devices/mos6/Makefile.am index 5161dbac3..b41fc460e 100644 --- a/src/spicelib/devices/mos6/Makefile.am +++ b/src/spicelib/devices/mos6/Makefile.am @@ -22,7 +22,11 @@ libmos6_la_SOURCES = \ mos6trun.c +if KLU_WANTED +libmos6_la_SOURCES += mos6bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/mos6/mos6bindCSC.c b/src/spicelib/devices/mos6/mos6bindCSC.c new file mode 100644 index 000000000..942ecbad5 --- /dev/null +++ b/src/spicelib/devices/mos6/mos6bindCSC.c @@ -0,0 +1,390 @@ +/********** +Author: 2012 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "mos6defs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +MOS6bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS6model *model = (MOS6model *)inModel ; + MOS6instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the MOS6 models */ + for ( ; model != NULL ; model = model->MOS6nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS6instances ; here != NULL ; here = here->MOS6nextInstance) + { + if ((here->MOS6dNode != 0) && (here->MOS6dNode != 0)) + { + i = here->MOS6DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6DdStructPtr = matched ; + here->MOS6DdPtr = matched->CSC ; + } + + if ((here->MOS6gNode != 0) && (here->MOS6gNode != 0)) + { + i = here->MOS6GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6GgStructPtr = matched ; + here->MOS6GgPtr = matched->CSC ; + } + + if ((here->MOS6sNode != 0) && (here->MOS6sNode != 0)) + { + i = here->MOS6SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6SsStructPtr = matched ; + here->MOS6SsPtr = matched->CSC ; + } + + if ((here->MOS6bNode != 0) && (here->MOS6bNode != 0)) + { + i = here->MOS6BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6BbStructPtr = matched ; + here->MOS6BbPtr = matched->CSC ; + } + + if ((here->MOS6dNodePrime != 0) && (here->MOS6dNodePrime != 0)) + { + i = here->MOS6DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6DPdpStructPtr = matched ; + here->MOS6DPdpPtr = matched->CSC ; + } + + if ((here->MOS6sNodePrime != 0) && (here->MOS6sNodePrime != 0)) + { + i = here->MOS6SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6SPspStructPtr = matched ; + here->MOS6SPspPtr = matched->CSC ; + } + + if ((here->MOS6dNode != 0) && (here->MOS6dNodePrime != 0)) + { + i = here->MOS6DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6DdpStructPtr = matched ; + here->MOS6DdpPtr = matched->CSC ; + } + + if ((here->MOS6gNode != 0) && (here->MOS6bNode != 0)) + { + i = here->MOS6GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6GbStructPtr = matched ; + here->MOS6GbPtr = matched->CSC ; + } + + if ((here->MOS6gNode != 0) && (here->MOS6dNodePrime != 0)) + { + i = here->MOS6GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6GdpStructPtr = matched ; + here->MOS6GdpPtr = matched->CSC ; + } + + if ((here->MOS6gNode != 0) && (here->MOS6sNodePrime != 0)) + { + i = here->MOS6GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6GspStructPtr = matched ; + here->MOS6GspPtr = matched->CSC ; + } + + if ((here->MOS6sNode != 0) && (here->MOS6sNodePrime != 0)) + { + i = here->MOS6SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6SspStructPtr = matched ; + here->MOS6SspPtr = matched->CSC ; + } + + if ((here->MOS6bNode != 0) && (here->MOS6dNodePrime != 0)) + { + i = here->MOS6BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6BdpStructPtr = matched ; + here->MOS6BdpPtr = matched->CSC ; + } + + if ((here->MOS6bNode != 0) && (here->MOS6sNodePrime != 0)) + { + i = here->MOS6BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6BspStructPtr = matched ; + here->MOS6BspPtr = matched->CSC ; + } + + if ((here->MOS6dNodePrime != 0) && (here->MOS6sNodePrime != 0)) + { + i = here->MOS6DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6DPspStructPtr = matched ; + here->MOS6DPspPtr = matched->CSC ; + } + + if ((here->MOS6dNodePrime != 0) && (here->MOS6dNode != 0)) + { + i = here->MOS6DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6DPdStructPtr = matched ; + here->MOS6DPdPtr = matched->CSC ; + } + + if ((here->MOS6bNode != 0) && (here->MOS6gNode != 0)) + { + i = here->MOS6BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6BgStructPtr = matched ; + here->MOS6BgPtr = matched->CSC ; + } + + if ((here->MOS6dNodePrime != 0) && (here->MOS6gNode != 0)) + { + i = here->MOS6DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6DPgStructPtr = matched ; + here->MOS6DPgPtr = matched->CSC ; + } + + if ((here->MOS6sNodePrime != 0) && (here->MOS6gNode != 0)) + { + i = here->MOS6SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6SPgStructPtr = matched ; + here->MOS6SPgPtr = matched->CSC ; + } + + if ((here->MOS6sNodePrime != 0) && (here->MOS6sNode != 0)) + { + i = here->MOS6SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6SPsStructPtr = matched ; + here->MOS6SPsPtr = matched->CSC ; + } + + if ((here->MOS6dNodePrime != 0) && (here->MOS6bNode != 0)) + { + i = here->MOS6DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6DPbStructPtr = matched ; + here->MOS6DPbPtr = matched->CSC ; + } + + if ((here->MOS6sNodePrime != 0) && (here->MOS6bNode != 0)) + { + i = here->MOS6SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6SPbStructPtr = matched ; + here->MOS6SPbPtr = matched->CSC ; + } + + if ((here->MOS6sNodePrime != 0) && (here->MOS6dNodePrime != 0)) + { + i = here->MOS6SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS6SPdpStructPtr = matched ; + here->MOS6SPdpPtr = matched->CSC ; + } + } + } + + return (OK) ; +} + +int +MOS6bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS6model *model = (MOS6model *)inModel ; + MOS6instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS6 models */ + for ( ; model != NULL ; model = model->MOS6nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS6instances ; here != NULL ; here = here->MOS6nextInstance) + { + if ((here->MOS6dNode != 0) && (here->MOS6dNode != 0)) + here->MOS6DdPtr = here->MOS6DdStructPtr->CSC_Complex ; + + if ((here->MOS6gNode != 0) && (here->MOS6gNode != 0)) + here->MOS6GgPtr = here->MOS6GgStructPtr->CSC_Complex ; + + if ((here->MOS6sNode != 0) && (here->MOS6sNode != 0)) + here->MOS6SsPtr = here->MOS6SsStructPtr->CSC_Complex ; + + if ((here->MOS6bNode != 0) && (here->MOS6bNode != 0)) + here->MOS6BbPtr = here->MOS6BbStructPtr->CSC_Complex ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6DPdpPtr = here->MOS6DPdpStructPtr->CSC_Complex ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6SPspPtr = here->MOS6SPspStructPtr->CSC_Complex ; + + if ((here->MOS6dNode != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6DdpPtr = here->MOS6DdpStructPtr->CSC_Complex ; + + if ((here->MOS6gNode != 0) && (here->MOS6bNode != 0)) + here->MOS6GbPtr = here->MOS6GbStructPtr->CSC_Complex ; + + if ((here->MOS6gNode != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6GdpPtr = here->MOS6GdpStructPtr->CSC_Complex ; + + if ((here->MOS6gNode != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6GspPtr = here->MOS6GspStructPtr->CSC_Complex ; + + if ((here->MOS6sNode != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6SspPtr = here->MOS6SspStructPtr->CSC_Complex ; + + if ((here->MOS6bNode != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6BdpPtr = here->MOS6BdpStructPtr->CSC_Complex ; + + if ((here->MOS6bNode != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6BspPtr = here->MOS6BspStructPtr->CSC_Complex ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6DPspPtr = here->MOS6DPspStructPtr->CSC_Complex ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6dNode != 0)) + here->MOS6DPdPtr = here->MOS6DPdStructPtr->CSC_Complex ; + + if ((here->MOS6bNode != 0) && (here->MOS6gNode != 0)) + here->MOS6BgPtr = here->MOS6BgStructPtr->CSC_Complex ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6gNode != 0)) + here->MOS6DPgPtr = here->MOS6DPgStructPtr->CSC_Complex ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6gNode != 0)) + here->MOS6SPgPtr = here->MOS6SPgStructPtr->CSC_Complex ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6sNode != 0)) + here->MOS6SPsPtr = here->MOS6SPsStructPtr->CSC_Complex ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6bNode != 0)) + here->MOS6DPbPtr = here->MOS6DPbStructPtr->CSC_Complex ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6bNode != 0)) + here->MOS6SPbPtr = here->MOS6SPbStructPtr->CSC_Complex ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6SPdpPtr = here->MOS6SPdpStructPtr->CSC_Complex ; + } + } + + return (OK) ; +} + +int +MOS6bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS6model *model = (MOS6model *)inModel ; + MOS6instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS6 models */ + for ( ; model != NULL ; model = model->MOS6nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS6instances ; here != NULL ; here = here->MOS6nextInstance) + { + if ((here->MOS6dNode != 0) && (here->MOS6dNode != 0)) + here->MOS6DdPtr = here->MOS6DdStructPtr->CSC ; + + if ((here->MOS6gNode != 0) && (here->MOS6gNode != 0)) + here->MOS6GgPtr = here->MOS6GgStructPtr->CSC ; + + if ((here->MOS6sNode != 0) && (here->MOS6sNode != 0)) + here->MOS6SsPtr = here->MOS6SsStructPtr->CSC ; + + if ((here->MOS6bNode != 0) && (here->MOS6bNode != 0)) + here->MOS6BbPtr = here->MOS6BbStructPtr->CSC ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6DPdpPtr = here->MOS6DPdpStructPtr->CSC ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6SPspPtr = here->MOS6SPspStructPtr->CSC ; + + if ((here->MOS6dNode != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6DdpPtr = here->MOS6DdpStructPtr->CSC ; + + if ((here->MOS6gNode != 0) && (here->MOS6bNode != 0)) + here->MOS6GbPtr = here->MOS6GbStructPtr->CSC ; + + if ((here->MOS6gNode != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6GdpPtr = here->MOS6GdpStructPtr->CSC ; + + if ((here->MOS6gNode != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6GspPtr = here->MOS6GspStructPtr->CSC ; + + if ((here->MOS6sNode != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6SspPtr = here->MOS6SspStructPtr->CSC ; + + if ((here->MOS6bNode != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6BdpPtr = here->MOS6BdpStructPtr->CSC ; + + if ((here->MOS6bNode != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6BspPtr = here->MOS6BspStructPtr->CSC ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6sNodePrime != 0)) + here->MOS6DPspPtr = here->MOS6DPspStructPtr->CSC ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6dNode != 0)) + here->MOS6DPdPtr = here->MOS6DPdStructPtr->CSC ; + + if ((here->MOS6bNode != 0) && (here->MOS6gNode != 0)) + here->MOS6BgPtr = here->MOS6BgStructPtr->CSC ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6gNode != 0)) + here->MOS6DPgPtr = here->MOS6DPgStructPtr->CSC ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6gNode != 0)) + here->MOS6SPgPtr = here->MOS6SPgStructPtr->CSC ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6sNode != 0)) + here->MOS6SPsPtr = here->MOS6SPsStructPtr->CSC ; + + if ((here->MOS6dNodePrime != 0) && (here->MOS6bNode != 0)) + here->MOS6DPbPtr = here->MOS6DPbStructPtr->CSC ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6bNode != 0)) + here->MOS6SPbPtr = here->MOS6SPbStructPtr->CSC ; + + if ((here->MOS6sNodePrime != 0) && (here->MOS6dNodePrime != 0)) + here->MOS6SPdpPtr = here->MOS6SPdpStructPtr->CSC ; + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/mos6/mos6defs.h b/src/spicelib/devices/mos6/mos6defs.h index af1ad82ac..81bbec353 100644 --- a/src/spicelib/devices/mos6/mos6defs.h +++ b/src/spicelib/devices/mos6/mos6defs.h @@ -195,6 +195,31 @@ typedef struct sMOS6instance { #define MOS6dphibs_dw MOS6sens + 68 #define MOS6dphibd_dw MOS6sens + 69 +#ifdef KLU + BindElement *MOS6DdStructPtr ; + BindElement *MOS6GgStructPtr ; + BindElement *MOS6SsStructPtr ; + BindElement *MOS6BbStructPtr ; + BindElement *MOS6DPdpStructPtr ; + BindElement *MOS6SPspStructPtr ; + BindElement *MOS6DdpStructPtr ; + BindElement *MOS6GbStructPtr ; + BindElement *MOS6GdpStructPtr ; + BindElement *MOS6GspStructPtr ; + BindElement *MOS6SspStructPtr ; + BindElement *MOS6BdpStructPtr ; + BindElement *MOS6BspStructPtr ; + BindElement *MOS6DPspStructPtr ; + BindElement *MOS6DPdStructPtr ; + BindElement *MOS6BgStructPtr ; + BindElement *MOS6DPgStructPtr ; + BindElement *MOS6SPgStructPtr ; + BindElement *MOS6SPsStructPtr ; + BindElement *MOS6DPbStructPtr ; + BindElement *MOS6SPbStructPtr ; + BindElement *MOS6SPdpStructPtr ; +#endif + } MOS6instance ; #define MOS6vbd MOS6states+ 0 /* bulk-drain voltage */ diff --git a/src/spicelib/devices/mos6/mos6ext.h b/src/spicelib/devices/mos6/mos6ext.h index e5d203145..d666425be 100644 --- a/src/spicelib/devices/mos6/mos6ext.h +++ b/src/spicelib/devices/mos6/mos6ext.h @@ -19,3 +19,9 @@ extern int MOS6unsetup(GENmodel*,CKTcircuit*); extern int MOS6temp(GENmodel*,CKTcircuit*); extern int MOS6trunc(GENmodel*,CKTcircuit*,double*); extern int MOS6convTest(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int MOS6bindCSC (GENmodel*, CKTcircuit*) ; +extern int MOS6bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int MOS6bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/mos6/mos6init.c b/src/spicelib/devices/mos6/mos6init.c index 65df0328c..7bec9858a 100644 --- a/src/spicelib/devices/mos6/mos6init.c +++ b/src/spicelib/devices/mos6/mos6init.c @@ -73,7 +73,14 @@ SPICEdev MOS6info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &MOS6iSize, - /* DEVmodSize */ &MOS6mSize + /* DEVmodSize */ &MOS6mSize, + +#ifdef KLU + /* DEVbindCSC */ MOS6bindCSC, + /* DEVbindCSCComplex */ MOS6bindCSCComplex, + /* DEVbindCSCComplexToReal */ MOS6bindCSCComplexToReal, +#endif + }; diff --git a/src/spicelib/devices/mos9/Makefile.am b/src/spicelib/devices/mos9/Makefile.am index 5db83e4c0..564835c93 100644 --- a/src/spicelib/devices/mos9/Makefile.am +++ b/src/spicelib/devices/mos9/Makefile.am @@ -34,7 +34,11 @@ libmos9_la_SOURCES = \ mos9trun.c +if KLU_WANTED +libmos9_la_SOURCES += mos9bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/mos9/mos9bindCSC.c b/src/spicelib/devices/mos9/mos9bindCSC.c new file mode 100644 index 000000000..7c8a6694a --- /dev/null +++ b/src/spicelib/devices/mos9/mos9bindCSC.c @@ -0,0 +1,393 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "mos9defs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +MOS9bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS9model *model = (MOS9model *)inModel ; + MOS9instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the MOS9 models */ + for ( ; model != NULL ; model = model->MOS9nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS9instances ; here != NULL ; here = here->MOS9nextInstance) + { + if ((here-> MOS9dNode != 0) && (here-> MOS9dNode != 0)) + { + i = here->MOS9DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9DdStructPtr = matched ; + here->MOS9DdPtr = matched->CSC ; + } + + if ((here-> MOS9gNode != 0) && (here-> MOS9gNode != 0)) + { + i = here->MOS9GgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9GgStructPtr = matched ; + here->MOS9GgPtr = matched->CSC ; + } + + if ((here-> MOS9sNode != 0) && (here-> MOS9sNode != 0)) + { + i = here->MOS9SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9SsStructPtr = matched ; + here->MOS9SsPtr = matched->CSC ; + } + + if ((here-> MOS9bNode != 0) && (here-> MOS9bNode != 0)) + { + i = here->MOS9BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9BbStructPtr = matched ; + here->MOS9BbPtr = matched->CSC ; + } + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9dNodePrime != 0)) + { + i = here->MOS9DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9DPdpStructPtr = matched ; + here->MOS9DPdpPtr = matched->CSC ; + } + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9sNodePrime != 0)) + { + i = here->MOS9SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9SPspStructPtr = matched ; + here->MOS9SPspPtr = matched->CSC ; + } + + if ((here-> MOS9dNode != 0) && (here-> MOS9dNodePrime != 0)) + { + i = here->MOS9DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9DdpStructPtr = matched ; + here->MOS9DdpPtr = matched->CSC ; + } + + if ((here-> MOS9gNode != 0) && (here-> MOS9bNode != 0)) + { + i = here->MOS9GbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9GbStructPtr = matched ; + here->MOS9GbPtr = matched->CSC ; + } + + if ((here-> MOS9gNode != 0) && (here-> MOS9dNodePrime != 0)) + { + i = here->MOS9GdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9GdpStructPtr = matched ; + here->MOS9GdpPtr = matched->CSC ; + } + + if ((here-> MOS9gNode != 0) && (here-> MOS9sNodePrime != 0)) + { + i = here->MOS9GspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9GspStructPtr = matched ; + here->MOS9GspPtr = matched->CSC ; + } + + if ((here-> MOS9sNode != 0) && (here-> MOS9sNodePrime != 0)) + { + i = here->MOS9SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9SspStructPtr = matched ; + here->MOS9SspPtr = matched->CSC ; + } + + if ((here-> MOS9bNode != 0) && (here-> MOS9dNodePrime != 0)) + { + i = here->MOS9BdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9BdpStructPtr = matched ; + here->MOS9BdpPtr = matched->CSC ; + } + + if ((here-> MOS9bNode != 0) && (here-> MOS9sNodePrime != 0)) + { + i = here->MOS9BspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9BspStructPtr = matched ; + here->MOS9BspPtr = matched->CSC ; + } + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9sNodePrime != 0)) + { + i = here->MOS9DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9DPspStructPtr = matched ; + here->MOS9DPspPtr = matched->CSC ; + } + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9dNode != 0)) + { + i = here->MOS9DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9DPdStructPtr = matched ; + here->MOS9DPdPtr = matched->CSC ; + } + + if ((here-> MOS9bNode != 0) && (here-> MOS9gNode != 0)) + { + i = here->MOS9BgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9BgStructPtr = matched ; + here->MOS9BgPtr = matched->CSC ; + } + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9gNode != 0)) + { + i = here->MOS9DPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9DPgStructPtr = matched ; + here->MOS9DPgPtr = matched->CSC ; + } + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9gNode != 0)) + { + i = here->MOS9SPgPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9SPgStructPtr = matched ; + here->MOS9SPgPtr = matched->CSC ; + } + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9sNode != 0)) + { + i = here->MOS9SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9SPsStructPtr = matched ; + here->MOS9SPsPtr = matched->CSC ; + } + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9bNode != 0)) + { + i = here->MOS9DPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9DPbStructPtr = matched ; + here->MOS9DPbPtr = matched->CSC ; + } + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9bNode != 0)) + { + i = here->MOS9SPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9SPbStructPtr = matched ; + here->MOS9SPbPtr = matched->CSC ; + } + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9dNodePrime != 0)) + { + i = here->MOS9SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->MOS9SPdpStructPtr = matched ; + here->MOS9SPdpPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +MOS9bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS9model *model = (MOS9model *)inModel ; + MOS9instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS9 models */ + for ( ; model != NULL ; model = model->MOS9nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS9instances ; here != NULL ; here = here->MOS9nextInstance) + { + if ((here-> MOS9dNode != 0) && (here-> MOS9dNode != 0)) + here->MOS9DdPtr = here->MOS9DdStructPtr->CSC_Complex ; + + if ((here-> MOS9gNode != 0) && (here-> MOS9gNode != 0)) + here->MOS9GgPtr = here->MOS9GgStructPtr->CSC_Complex ; + + if ((here-> MOS9sNode != 0) && (here-> MOS9sNode != 0)) + here->MOS9SsPtr = here->MOS9SsStructPtr->CSC_Complex ; + + if ((here-> MOS9bNode != 0) && (here-> MOS9bNode != 0)) + here->MOS9BbPtr = here->MOS9BbStructPtr->CSC_Complex ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9DPdpPtr = here->MOS9DPdpStructPtr->CSC_Complex ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9SPspPtr = here->MOS9SPspStructPtr->CSC_Complex ; + + if ((here-> MOS9dNode != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9DdpPtr = here->MOS9DdpStructPtr->CSC_Complex ; + + if ((here-> MOS9gNode != 0) && (here-> MOS9bNode != 0)) + here->MOS9GbPtr = here->MOS9GbStructPtr->CSC_Complex ; + + if ((here-> MOS9gNode != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9GdpPtr = here->MOS9GdpStructPtr->CSC_Complex ; + + if ((here-> MOS9gNode != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9GspPtr = here->MOS9GspStructPtr->CSC_Complex ; + + if ((here-> MOS9sNode != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9SspPtr = here->MOS9SspStructPtr->CSC_Complex ; + + if ((here-> MOS9bNode != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9BdpPtr = here->MOS9BdpStructPtr->CSC_Complex ; + + if ((here-> MOS9bNode != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9BspPtr = here->MOS9BspStructPtr->CSC_Complex ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9DPspPtr = here->MOS9DPspStructPtr->CSC_Complex ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9dNode != 0)) + here->MOS9DPdPtr = here->MOS9DPdStructPtr->CSC_Complex ; + + if ((here-> MOS9bNode != 0) && (here-> MOS9gNode != 0)) + here->MOS9BgPtr = here->MOS9BgStructPtr->CSC_Complex ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9gNode != 0)) + here->MOS9DPgPtr = here->MOS9DPgStructPtr->CSC_Complex ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9gNode != 0)) + here->MOS9SPgPtr = here->MOS9SPgStructPtr->CSC_Complex ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9sNode != 0)) + here->MOS9SPsPtr = here->MOS9SPsStructPtr->CSC_Complex ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9bNode != 0)) + here->MOS9DPbPtr = here->MOS9DPbStructPtr->CSC_Complex ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9bNode != 0)) + here->MOS9SPbPtr = here->MOS9SPbStructPtr->CSC_Complex ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9SPdpPtr = here->MOS9SPdpStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +MOS9bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + MOS9model *model = (MOS9model *)inModel ; + MOS9instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the MOS9 models */ + for ( ; model != NULL ; model = model->MOS9nextModel) + { + /* loop through all the instances of the model */ + for (here = model->MOS9instances ; here != NULL ; here = here->MOS9nextInstance) + { + if ((here-> MOS9dNode != 0) && (here-> MOS9dNode != 0)) + here->MOS9DdPtr = here->MOS9DdStructPtr->CSC ; + + if ((here-> MOS9gNode != 0) && (here-> MOS9gNode != 0)) + here->MOS9GgPtr = here->MOS9GgStructPtr->CSC ; + + if ((here-> MOS9sNode != 0) && (here-> MOS9sNode != 0)) + here->MOS9SsPtr = here->MOS9SsStructPtr->CSC ; + + if ((here-> MOS9bNode != 0) && (here-> MOS9bNode != 0)) + here->MOS9BbPtr = here->MOS9BbStructPtr->CSC ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9DPdpPtr = here->MOS9DPdpStructPtr->CSC ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9SPspPtr = here->MOS9SPspStructPtr->CSC ; + + if ((here-> MOS9dNode != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9DdpPtr = here->MOS9DdpStructPtr->CSC ; + + if ((here-> MOS9gNode != 0) && (here-> MOS9bNode != 0)) + here->MOS9GbPtr = here->MOS9GbStructPtr->CSC ; + + if ((here-> MOS9gNode != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9GdpPtr = here->MOS9GdpStructPtr->CSC ; + + if ((here-> MOS9gNode != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9GspPtr = here->MOS9GspStructPtr->CSC ; + + if ((here-> MOS9sNode != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9SspPtr = here->MOS9SspStructPtr->CSC ; + + if ((here-> MOS9bNode != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9BdpPtr = here->MOS9BdpStructPtr->CSC ; + + if ((here-> MOS9bNode != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9BspPtr = here->MOS9BspStructPtr->CSC ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9sNodePrime != 0)) + here->MOS9DPspPtr = here->MOS9DPspStructPtr->CSC ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9dNode != 0)) + here->MOS9DPdPtr = here->MOS9DPdStructPtr->CSC ; + + if ((here-> MOS9bNode != 0) && (here-> MOS9gNode != 0)) + here->MOS9BgPtr = here->MOS9BgStructPtr->CSC ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9gNode != 0)) + here->MOS9DPgPtr = here->MOS9DPgStructPtr->CSC ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9gNode != 0)) + here->MOS9SPgPtr = here->MOS9SPgStructPtr->CSC ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9sNode != 0)) + here->MOS9SPsPtr = here->MOS9SPsStructPtr->CSC ; + + if ((here-> MOS9dNodePrime != 0) && (here-> MOS9bNode != 0)) + here->MOS9DPbPtr = here->MOS9DPbStructPtr->CSC ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9bNode != 0)) + here->MOS9SPbPtr = here->MOS9SPbStructPtr->CSC ; + + if ((here-> MOS9sNodePrime != 0) && (here-> MOS9dNodePrime != 0)) + here->MOS9SPdpPtr = here->MOS9SPdpStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/mos9/mos9defs.h b/src/spicelib/devices/mos9/mos9defs.h index 2a863c25d..e1f1a6306 100644 --- a/src/spicelib/devices/mos9/mos9defs.h +++ b/src/spicelib/devices/mos9/mos9defs.h @@ -268,6 +268,31 @@ typedef struct sMOS9instance { double **MOS9nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *MOS9DdStructPtr ; + BindElement *MOS9GgStructPtr ; + BindElement *MOS9SsStructPtr ; + BindElement *MOS9BbStructPtr ; + BindElement *MOS9DPdpStructPtr ; + BindElement *MOS9SPspStructPtr ; + BindElement *MOS9DdpStructPtr ; + BindElement *MOS9GbStructPtr ; + BindElement *MOS9GdpStructPtr ; + BindElement *MOS9GspStructPtr ; + BindElement *MOS9SspStructPtr ; + BindElement *MOS9BdpStructPtr ; + BindElement *MOS9BspStructPtr ; + BindElement *MOS9DPspStructPtr ; + BindElement *MOS9DPdStructPtr ; + BindElement *MOS9BgStructPtr ; + BindElement *MOS9DPgStructPtr ; + BindElement *MOS9SPgStructPtr ; + BindElement *MOS9SPsStructPtr ; + BindElement *MOS9DPbStructPtr ; + BindElement *MOS9SPbStructPtr ; + BindElement *MOS9SPdpStructPtr ; +#endif + } MOS9instance ; #define MOS9vbd MOS9states+ 0 diff --git a/src/spicelib/devices/mos9/mos9ext.h b/src/spicelib/devices/mos9/mos9ext.h index c2af0a136..73383b3dd 100644 --- a/src/spicelib/devices/mos9/mos9ext.h +++ b/src/spicelib/devices/mos9/mos9ext.h @@ -28,3 +28,9 @@ extern int MOS9trunc(GENmodel*,CKTcircuit*,double*); extern int MOS9disto(int,GENmodel*,CKTcircuit*); extern int MOS9noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int MOS9dSetup(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int MOS9bindCSC (GENmodel*, CKTcircuit*) ; +extern int MOS9bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int MOS9bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/mos9/mos9init.c b/src/spicelib/devices/mos9/mos9init.c index 9d0ab50bf..bbfb8f032 100644 --- a/src/spicelib/devices/mos9/mos9init.c +++ b/src/spicelib/devices/mos9/mos9init.c @@ -73,7 +73,13 @@ SPICEdev MOS9info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &MOS9iSize, - /* DEVmodSize */ &MOS9mSize + /* DEVmodSize */ &MOS9mSize, + +#ifdef KLU + /* DEVbindCSC */ MOS9bindCSC, + /* DEVbindCSCComplex */ MOS9bindCSCComplex, + /* DEVbindCSCComplexToReal */ MOS9bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/nbjt/Makefile.am b/src/spicelib/devices/nbjt/Makefile.am index 4a5c3ee8a..7f18d5b19 100644 --- a/src/spicelib/devices/nbjt/Makefile.am +++ b/src/spicelib/devices/nbjt/Makefile.am @@ -24,6 +24,9 @@ libnbjt_la_SOURCES = \ nbjttrun.c +if KLU_WANTED +libnbjt_la_SOURCES += nbjtbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/nbjt/nbjtbindCSC.c b/src/spicelib/devices/nbjt/nbjtbindCSC.c new file mode 100644 index 000000000..c910971ab --- /dev/null +++ b/src/spicelib/devices/nbjt/nbjtbindCSC.c @@ -0,0 +1,211 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "nbjtdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +NBJTbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + NBJTmodel *model = (NBJTmodel *)inModel ; + NBJTinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the NBJT models */ + for ( ; model != NULL ; model = model->NBJTnextModel) + { + /* loop through all the instances of the model */ + for (here = model->NBJTinstances ; here != NULL ; here = here->NBJTnextInstance) + { + if ((here-> NBJTcolNode != 0) && (here-> NBJTcolNode != 0)) + { + i = here->NBJTcolColPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJTcolColStructPtr = matched ; + here->NBJTcolColPtr = matched->CSC ; + } + + if ((here-> NBJTbaseNode != 0) && (here-> NBJTbaseNode != 0)) + { + i = here->NBJTbaseBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJTbaseBaseStructPtr = matched ; + here->NBJTbaseBasePtr = matched->CSC ; + } + + if ((here-> NBJTemitNode != 0) && (here-> NBJTemitNode != 0)) + { + i = here->NBJTemitEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJTemitEmitStructPtr = matched ; + here->NBJTemitEmitPtr = matched->CSC ; + } + + if ((here-> NBJTcolNode != 0) && (here-> NBJTbaseNode != 0)) + { + i = here->NBJTcolBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJTcolBaseStructPtr = matched ; + here->NBJTcolBasePtr = matched->CSC ; + } + + if ((here-> NBJTcolNode != 0) && (here-> NBJTemitNode != 0)) + { + i = here->NBJTcolEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJTcolEmitStructPtr = matched ; + here->NBJTcolEmitPtr = matched->CSC ; + } + + if ((here-> NBJTbaseNode != 0) && (here-> NBJTcolNode != 0)) + { + i = here->NBJTbaseColPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJTbaseColStructPtr = matched ; + here->NBJTbaseColPtr = matched->CSC ; + } + + if ((here-> NBJTbaseNode != 0) && (here-> NBJTemitNode != 0)) + { + i = here->NBJTbaseEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJTbaseEmitStructPtr = matched ; + here->NBJTbaseEmitPtr = matched->CSC ; + } + + if ((here-> NBJTemitNode != 0) && (here-> NBJTcolNode != 0)) + { + i = here->NBJTemitColPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJTemitColStructPtr = matched ; + here->NBJTemitColPtr = matched->CSC ; + } + + if ((here-> NBJTemitNode != 0) && (here-> NBJTbaseNode != 0)) + { + i = here->NBJTemitBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJTemitBaseStructPtr = matched ; + here->NBJTemitBasePtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +NBJTbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + NBJTmodel *model = (NBJTmodel *)inModel ; + NBJTinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NBJT models */ + for ( ; model != NULL ; model = model->NBJTnextModel) + { + /* loop through all the instances of the model */ + for (here = model->NBJTinstances ; here != NULL ; here = here->NBJTnextInstance) + { + if ((here-> NBJTcolNode != 0) && (here-> NBJTcolNode != 0)) + here->NBJTcolColPtr = here->NBJTcolColStructPtr->CSC_Complex ; + + if ((here-> NBJTbaseNode != 0) && (here-> NBJTbaseNode != 0)) + here->NBJTbaseBasePtr = here->NBJTbaseBaseStructPtr->CSC_Complex ; + + if ((here-> NBJTemitNode != 0) && (here-> NBJTemitNode != 0)) + here->NBJTemitEmitPtr = here->NBJTemitEmitStructPtr->CSC_Complex ; + + if ((here-> NBJTcolNode != 0) && (here-> NBJTbaseNode != 0)) + here->NBJTcolBasePtr = here->NBJTcolBaseStructPtr->CSC_Complex ; + + if ((here-> NBJTcolNode != 0) && (here-> NBJTemitNode != 0)) + here->NBJTcolEmitPtr = here->NBJTcolEmitStructPtr->CSC_Complex ; + + if ((here-> NBJTbaseNode != 0) && (here-> NBJTcolNode != 0)) + here->NBJTbaseColPtr = here->NBJTbaseColStructPtr->CSC_Complex ; + + if ((here-> NBJTbaseNode != 0) && (here-> NBJTemitNode != 0)) + here->NBJTbaseEmitPtr = here->NBJTbaseEmitStructPtr->CSC_Complex ; + + if ((here-> NBJTemitNode != 0) && (here-> NBJTcolNode != 0)) + here->NBJTemitColPtr = here->NBJTemitColStructPtr->CSC_Complex ; + + if ((here-> NBJTemitNode != 0) && (here-> NBJTbaseNode != 0)) + here->NBJTemitBasePtr = here->NBJTemitBaseStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +NBJTbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + NBJTmodel *model = (NBJTmodel *)inModel ; + NBJTinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NBJT models */ + for ( ; model != NULL ; model = model->NBJTnextModel) + { + /* loop through all the instances of the model */ + for (here = model->NBJTinstances ; here != NULL ; here = here->NBJTnextInstance) + { + if ((here-> NBJTcolNode != 0) && (here-> NBJTcolNode != 0)) + here->NBJTcolColPtr = here->NBJTcolColStructPtr->CSC ; + + if ((here-> NBJTbaseNode != 0) && (here-> NBJTbaseNode != 0)) + here->NBJTbaseBasePtr = here->NBJTbaseBaseStructPtr->CSC ; + + if ((here-> NBJTemitNode != 0) && (here-> NBJTemitNode != 0)) + here->NBJTemitEmitPtr = here->NBJTemitEmitStructPtr->CSC ; + + if ((here-> NBJTcolNode != 0) && (here-> NBJTbaseNode != 0)) + here->NBJTcolBasePtr = here->NBJTcolBaseStructPtr->CSC ; + + if ((here-> NBJTcolNode != 0) && (here-> NBJTemitNode != 0)) + here->NBJTcolEmitPtr = here->NBJTcolEmitStructPtr->CSC ; + + if ((here-> NBJTbaseNode != 0) && (here-> NBJTcolNode != 0)) + here->NBJTbaseColPtr = here->NBJTbaseColStructPtr->CSC ; + + if ((here-> NBJTbaseNode != 0) && (here-> NBJTemitNode != 0)) + here->NBJTbaseEmitPtr = here->NBJTbaseEmitStructPtr->CSC ; + + if ((here-> NBJTemitNode != 0) && (here-> NBJTcolNode != 0)) + here->NBJTemitColPtr = here->NBJTemitColStructPtr->CSC ; + + if ((here-> NBJTemitNode != 0) && (here-> NBJTbaseNode != 0)) + here->NBJTemitBasePtr = here->NBJTemitBaseStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/nbjt/nbjtdefs.h b/src/spicelib/devices/nbjt/nbjtdefs.h index 911dac696..aefd8d673 100644 --- a/src/spicelib/devices/nbjt/nbjtdefs.h +++ b/src/spicelib/devices/nbjt/nbjtdefs.h @@ -83,6 +83,19 @@ typedef struct sNBJTinstance { unsigned NBJTicFileGiven:1; /* flag to indicate init. cond. file given */ unsigned NBJTprintGiven:1; /* flag to indicate if print was given */ unsigned NBJTtempGiven:1; /* flag to indicate if temp was given */ + +#ifdef KLU + BindElement *NBJTcolColStructPtr ; + BindElement *NBJTbaseBaseStructPtr ; + BindElement *NBJTemitEmitStructPtr ; + BindElement *NBJTcolBaseStructPtr ; + BindElement *NBJTcolEmitStructPtr ; + BindElement *NBJTbaseColStructPtr ; + BindElement *NBJTbaseEmitStructPtr ; + BindElement *NBJTemitColStructPtr ; + BindElement *NBJTemitBaseStructPtr ; +#endif + } NBJTinstance; /* per model data */ diff --git a/src/spicelib/devices/nbjt/nbjtext.h b/src/spicelib/devices/nbjt/nbjtext.h index b9d0a980c..cb446f9f6 100644 --- a/src/spicelib/devices/nbjt/nbjtext.h +++ b/src/spicelib/devices/nbjt/nbjtext.h @@ -23,5 +23,10 @@ extern int NBJTtrunc(GENmodel *, CKTcircuit *, double *); extern void NBJTdump(GENmodel *, CKTcircuit *); extern void NBJTacct(GENmodel *, CKTcircuit *, FILE *); +#ifdef KLU +extern int NBJTbindCSC (GENmodel*, CKTcircuit*) ; +extern int NBJTbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int NBJTbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif #endif /* NBJT_H */ diff --git a/src/spicelib/devices/nbjt/nbjtinit.c b/src/spicelib/devices/nbjt/nbjtinit.c index 45a9dbee0..a7c25f33b 100644 --- a/src/spicelib/devices/nbjt/nbjtinit.c +++ b/src/spicelib/devices/nbjt/nbjtinit.c @@ -74,7 +74,13 @@ SPICEdev NBJTinfo = { #endif /* DEVinstSize */ &NBJTiSize, - /* DEVmodSize */ &NBJTmSize + /* DEVmodSize */ &NBJTmSize, + +#ifdef KLU + /* DEVbindCSC */ NBJTbindCSC, + /* DEVbindCSCComplex */ NBJTbindCSCComplex, + /* DEVbindCSCComplexToReal */ NBJTbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/nbjt2/Makefile.am b/src/spicelib/devices/nbjt2/Makefile.am index 08ed45a07..22e262578 100644 --- a/src/spicelib/devices/nbjt2/Makefile.am +++ b/src/spicelib/devices/nbjt2/Makefile.am @@ -24,6 +24,9 @@ libnbjt2_la_SOURCES = \ nbt2trun.c +if KLU_WANTED +libnbjt2_la_SOURCES += nbjt2bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/nbjt2/nbjt2bindCSC.c b/src/spicelib/devices/nbjt2/nbjt2bindCSC.c new file mode 100644 index 000000000..0b635ed67 --- /dev/null +++ b/src/spicelib/devices/nbjt2/nbjt2bindCSC.c @@ -0,0 +1,211 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "nbjt2def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +NBJT2bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + NBJT2model *model = (NBJT2model *)inModel ; + NBJT2instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the NBJT2 models */ + for ( ; model != NULL ; model = model->NBJT2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->NBJT2instances ; here != NULL ; here = here->NBJT2nextInstance) + { + if ((here-> NBJT2colNode != 0) && (here-> NBJT2colNode != 0)) + { + i = here->NBJT2colColPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJT2colColStructPtr = matched ; + here->NBJT2colColPtr = matched->CSC ; + } + + if ((here-> NBJT2colNode != 0) && (here-> NBJT2baseNode != 0)) + { + i = here->NBJT2colBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJT2colBaseStructPtr = matched ; + here->NBJT2colBasePtr = matched->CSC ; + } + + if ((here-> NBJT2colNode != 0) && (here-> NBJT2emitNode != 0)) + { + i = here->NBJT2colEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJT2colEmitStructPtr = matched ; + here->NBJT2colEmitPtr = matched->CSC ; + } + + if ((here-> NBJT2baseNode != 0) && (here-> NBJT2colNode != 0)) + { + i = here->NBJT2baseColPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJT2baseColStructPtr = matched ; + here->NBJT2baseColPtr = matched->CSC ; + } + + if ((here-> NBJT2baseNode != 0) && (here-> NBJT2baseNode != 0)) + { + i = here->NBJT2baseBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJT2baseBaseStructPtr = matched ; + here->NBJT2baseBasePtr = matched->CSC ; + } + + if ((here-> NBJT2baseNode != 0) && (here-> NBJT2emitNode != 0)) + { + i = here->NBJT2baseEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJT2baseEmitStructPtr = matched ; + here->NBJT2baseEmitPtr = matched->CSC ; + } + + if ((here-> NBJT2emitNode != 0) && (here-> NBJT2colNode != 0)) + { + i = here->NBJT2emitColPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJT2emitColStructPtr = matched ; + here->NBJT2emitColPtr = matched->CSC ; + } + + if ((here-> NBJT2emitNode != 0) && (here-> NBJT2baseNode != 0)) + { + i = here->NBJT2emitBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJT2emitBaseStructPtr = matched ; + here->NBJT2emitBasePtr = matched->CSC ; + } + + if ((here-> NBJT2emitNode != 0) && (here-> NBJT2emitNode != 0)) + { + i = here->NBJT2emitEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NBJT2emitEmitStructPtr = matched ; + here->NBJT2emitEmitPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +NBJT2bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + NBJT2model *model = (NBJT2model *)inModel ; + NBJT2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NBJT2 models */ + for ( ; model != NULL ; model = model->NBJT2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->NBJT2instances ; here != NULL ; here = here->NBJT2nextInstance) + { + if ((here-> NBJT2colNode != 0) && (here-> NBJT2colNode != 0)) + here->NBJT2colColPtr = here->NBJT2colColStructPtr->CSC_Complex ; + + if ((here-> NBJT2colNode != 0) && (here-> NBJT2baseNode != 0)) + here->NBJT2colBasePtr = here->NBJT2colBaseStructPtr->CSC_Complex ; + + if ((here-> NBJT2colNode != 0) && (here-> NBJT2emitNode != 0)) + here->NBJT2colEmitPtr = here->NBJT2colEmitStructPtr->CSC_Complex ; + + if ((here-> NBJT2baseNode != 0) && (here-> NBJT2colNode != 0)) + here->NBJT2baseColPtr = here->NBJT2baseColStructPtr->CSC_Complex ; + + if ((here-> NBJT2baseNode != 0) && (here-> NBJT2baseNode != 0)) + here->NBJT2baseBasePtr = here->NBJT2baseBaseStructPtr->CSC_Complex ; + + if ((here-> NBJT2baseNode != 0) && (here-> NBJT2emitNode != 0)) + here->NBJT2baseEmitPtr = here->NBJT2baseEmitStructPtr->CSC_Complex ; + + if ((here-> NBJT2emitNode != 0) && (here-> NBJT2colNode != 0)) + here->NBJT2emitColPtr = here->NBJT2emitColStructPtr->CSC_Complex ; + + if ((here-> NBJT2emitNode != 0) && (here-> NBJT2baseNode != 0)) + here->NBJT2emitBasePtr = here->NBJT2emitBaseStructPtr->CSC_Complex ; + + if ((here-> NBJT2emitNode != 0) && (here-> NBJT2emitNode != 0)) + here->NBJT2emitEmitPtr = here->NBJT2emitEmitStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +NBJT2bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + NBJT2model *model = (NBJT2model *)inModel ; + NBJT2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NBJT2 models */ + for ( ; model != NULL ; model = model->NBJT2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->NBJT2instances ; here != NULL ; here = here->NBJT2nextInstance) + { + if ((here-> NBJT2colNode != 0) && (here-> NBJT2colNode != 0)) + here->NBJT2colColPtr = here->NBJT2colColStructPtr->CSC ; + + if ((here-> NBJT2colNode != 0) && (here-> NBJT2baseNode != 0)) + here->NBJT2colBasePtr = here->NBJT2colBaseStructPtr->CSC ; + + if ((here-> NBJT2colNode != 0) && (here-> NBJT2emitNode != 0)) + here->NBJT2colEmitPtr = here->NBJT2colEmitStructPtr->CSC ; + + if ((here-> NBJT2baseNode != 0) && (here-> NBJT2colNode != 0)) + here->NBJT2baseColPtr = here->NBJT2baseColStructPtr->CSC ; + + if ((here-> NBJT2baseNode != 0) && (here-> NBJT2baseNode != 0)) + here->NBJT2baseBasePtr = here->NBJT2baseBaseStructPtr->CSC ; + + if ((here-> NBJT2baseNode != 0) && (here-> NBJT2emitNode != 0)) + here->NBJT2baseEmitPtr = here->NBJT2baseEmitStructPtr->CSC ; + + if ((here-> NBJT2emitNode != 0) && (here-> NBJT2colNode != 0)) + here->NBJT2emitColPtr = here->NBJT2emitColStructPtr->CSC ; + + if ((here-> NBJT2emitNode != 0) && (here-> NBJT2baseNode != 0)) + here->NBJT2emitBasePtr = here->NBJT2emitBaseStructPtr->CSC ; + + if ((here-> NBJT2emitNode != 0) && (here-> NBJT2emitNode != 0)) + here->NBJT2emitEmitPtr = here->NBJT2emitEmitStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/nbjt2/nbjt2def.h b/src/spicelib/devices/nbjt2/nbjt2def.h index c66ac191a..3ff9e40ed 100644 --- a/src/spicelib/devices/nbjt2/nbjt2def.h +++ b/src/spicelib/devices/nbjt2/nbjt2def.h @@ -85,6 +85,19 @@ typedef struct sNBJT2instance { unsigned NBJT2icFileGiven:1; /* flag to indicate init. cond. file given */ unsigned NBJT2printGiven:1; /* flag to indicate print given */ unsigned NBJT2tempGiven:1; /* flag to indicate temp given */ + +#ifdef KLU + BindElement *NBJT2colColStructPtr ; + BindElement *NBJT2colBaseStructPtr ; + BindElement *NBJT2colEmitStructPtr ; + BindElement *NBJT2baseColStructPtr ; + BindElement *NBJT2baseBaseStructPtr ; + BindElement *NBJT2baseEmitStructPtr ; + BindElement *NBJT2emitColStructPtr ; + BindElement *NBJT2emitBaseStructPtr ; + BindElement *NBJT2emitEmitStructPtr ; +#endif + } NBJT2instance; /* per model data */ diff --git a/src/spicelib/devices/nbjt2/nbjt2ext.h b/src/spicelib/devices/nbjt2/nbjt2ext.h index 7448e637d..9a77394de 100644 --- a/src/spicelib/devices/nbjt2/nbjt2ext.h +++ b/src/spicelib/devices/nbjt2/nbjt2ext.h @@ -24,4 +24,10 @@ extern int NBJT2trunc(GENmodel *, CKTcircuit *, double *); extern void NBJT2dump(GENmodel *, CKTcircuit *); extern void NBJT2acct(GENmodel *, CKTcircuit *, FILE *); +#ifdef KLU +extern int NBJT2bindCSC (GENmodel*, CKTcircuit*) ; +extern int NBJT2bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int NBJT2bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif + #endif /* NBJT2EXT_H */ diff --git a/src/spicelib/devices/nbjt2/nbt2init.c b/src/spicelib/devices/nbjt2/nbt2init.c index 39eab292f..aa23f4bc2 100644 --- a/src/spicelib/devices/nbjt2/nbt2init.c +++ b/src/spicelib/devices/nbjt2/nbt2init.c @@ -74,7 +74,13 @@ SPICEdev NBJT2info = { #endif /* DEVinstSize */ &NBJT2iSize, - /* DEVmodSize */ &NBJT2mSize + /* DEVmodSize */ &NBJT2mSize, + +#ifdef KLU + /* DEVbindCSC */ NBJT2bindCSC, + /* DEVbindCSCComplex */ NBJT2bindCSCComplex, + /* DEVbindCSCComplexToReal */ NBJT2bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/ndev/ndevinit.c b/src/spicelib/devices/ndev/ndevinit.c index 4a855c69c..f6df726ab 100644 --- a/src/spicelib/devices/ndev/ndevinit.c +++ b/src/spicelib/devices/ndev/ndevinit.c @@ -74,7 +74,13 @@ SPICEdev NDEVinfo = { #endif /* DEVinstSize */ &NDEViSize, - /* DEVmodSize */ &NDEVmSize + /* DEVmodSize */ &NDEVmSize, + +#ifdef KLU + /* DEVbindCSC */ NULL, + /* DEVbindCSCComplex */ NULL, + /* DEVbindCSCComplexToReal */ NULL, +#endif }; diff --git a/src/spicelib/devices/numd/Makefile.am b/src/spicelib/devices/numd/Makefile.am index a9c263e89..9f6b19510 100644 --- a/src/spicelib/devices/numd/Makefile.am +++ b/src/spicelib/devices/numd/Makefile.am @@ -24,6 +24,10 @@ libnumd_la_SOURCES = \ numdtrun.c +if KLU_WANTED +libnumd_la_SOURCES += numdbindCSC.c +endif + AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/numd/numdbindCSC.c b/src/spicelib/devices/numd/numdbindCSC.c new file mode 100644 index 000000000..dfb0ef8d4 --- /dev/null +++ b/src/spicelib/devices/numd/numdbindCSC.c @@ -0,0 +1,141 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "numddefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +NUMDbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + NUMDmodel *model = (NUMDmodel *)inModel ; + NUMDinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the NUMD models */ + for ( ; model != NULL ; model = model->NUMDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->NUMDinstances ; here != NULL ; here = here->NUMDnextInstance) + { + if ((here-> NUMDposNode != 0) && (here-> NUMDposNode != 0)) + { + i = here->NUMDposPosPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMDposPosStructPtr = matched ; + here->NUMDposPosPtr = matched->CSC ; + } + + if ((here-> NUMDnegNode != 0) && (here-> NUMDnegNode != 0)) + { + i = here->NUMDnegNegPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMDnegNegStructPtr = matched ; + here->NUMDnegNegPtr = matched->CSC ; + } + + if ((here-> NUMDnegNode != 0) && (here-> NUMDposNode != 0)) + { + i = here->NUMDnegPosPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMDnegPosStructPtr = matched ; + here->NUMDnegPosPtr = matched->CSC ; + } + + if ((here-> NUMDposNode != 0) && (here-> NUMDnegNode != 0)) + { + i = here->NUMDposNegPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMDposNegStructPtr = matched ; + here->NUMDposNegPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +NUMDbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + NUMDmodel *model = (NUMDmodel *)inModel ; + NUMDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NUMD models */ + for ( ; model != NULL ; model = model->NUMDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->NUMDinstances ; here != NULL ; here = here->NUMDnextInstance) + { + if ((here-> NUMDposNode != 0) && (here-> NUMDposNode != 0)) + here->NUMDposPosPtr = here->NUMDposPosStructPtr->CSC_Complex ; + + if ((here-> NUMDnegNode != 0) && (here-> NUMDnegNode != 0)) + here->NUMDnegNegPtr = here->NUMDnegNegStructPtr->CSC_Complex ; + + if ((here-> NUMDnegNode != 0) && (here-> NUMDposNode != 0)) + here->NUMDnegPosPtr = here->NUMDnegPosStructPtr->CSC_Complex ; + + if ((here-> NUMDposNode != 0) && (here-> NUMDnegNode != 0)) + here->NUMDposNegPtr = here->NUMDposNegStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +NUMDbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + NUMDmodel *model = (NUMDmodel *)inModel ; + NUMDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NUMD models */ + for ( ; model != NULL ; model = model->NUMDnextModel) + { + /* loop through all the instances of the model */ + for (here = model->NUMDinstances ; here != NULL ; here = here->NUMDnextInstance) + { + if ((here-> NUMDposNode != 0) && (here-> NUMDposNode != 0)) + here->NUMDposPosPtr = here->NUMDposPosStructPtr->CSC ; + + if ((here-> NUMDnegNode != 0) && (here-> NUMDnegNode != 0)) + here->NUMDnegNegPtr = here->NUMDnegNegStructPtr->CSC ; + + if ((here-> NUMDnegNode != 0) && (here-> NUMDposNode != 0)) + here->NUMDnegPosPtr = here->NUMDnegPosStructPtr->CSC ; + + if ((here-> NUMDposNode != 0) && (here-> NUMDnegNode != 0)) + here->NUMDposNegPtr = here->NUMDposNegStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/numd/numddefs.h b/src/spicelib/devices/numd/numddefs.h index c24dd358d..81542b563 100644 --- a/src/spicelib/devices/numd/numddefs.h +++ b/src/spicelib/devices/numd/numddefs.h @@ -62,6 +62,14 @@ typedef struct sNUMDinstance { unsigned NUMDicFileGiven:1; /* flag to indicate init. cond. file given */ unsigned NUMDtempGiven:1; /* flag to indicate temp was specified */ unsigned NUMDprintGiven:1; /* flag to indicate if print was specified */ + +#ifdef KLU + BindElement *NUMDposPosStructPtr ; + BindElement *NUMDnegNegStructPtr ; + BindElement *NUMDnegPosStructPtr ; + BindElement *NUMDposNegStructPtr ; +#endif + } NUMDinstance; diff --git a/src/spicelib/devices/numd/numdext.h b/src/spicelib/devices/numd/numdext.h index bf98dcd48..3542e0ace 100644 --- a/src/spicelib/devices/numd/numdext.h +++ b/src/spicelib/devices/numd/numdext.h @@ -24,4 +24,10 @@ extern int NUMDtrunc(GENmodel *, CKTcircuit *, double *); extern void NUMDdump(GENmodel *, CKTcircuit *); extern void NUMDacct(GENmodel *, CKTcircuit *, FILE *); +#ifdef KLU +extern int NUMDbindCSC (GENmodel*, CKTcircuit*) ; +extern int NUMDbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int NUMDbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif + #endif /* NUMDEXT_H */ diff --git a/src/spicelib/devices/numd/numdinit.c b/src/spicelib/devices/numd/numdinit.c index cd78dee31..d6ea1cc76 100644 --- a/src/spicelib/devices/numd/numdinit.c +++ b/src/spicelib/devices/numd/numdinit.c @@ -74,7 +74,13 @@ SPICEdev NUMDinfo = { #endif /* DEVinstSize */ &NUMDiSize, - /* DEVmodSize */ &NUMDmSize + /* DEVmodSize */ &NUMDmSize, + +#ifdef KLU + /* DEVbindCSC */ NUMDbindCSC, + /* DEVbindCSCComplex */ NUMDbindCSCComplex, + /* DEVbindCSCComplexToReal */ NUMDbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/numd2/Makefile.am b/src/spicelib/devices/numd2/Makefile.am index d4734642b..bd0dd1cf2 100644 --- a/src/spicelib/devices/numd2/Makefile.am +++ b/src/spicelib/devices/numd2/Makefile.am @@ -24,6 +24,9 @@ libnumd2_la_SOURCES = \ nud2trun.c +if KLU_WANTED +libnumd2_la_SOURCES += numd2bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/numd2/numd2bindCSC.c b/src/spicelib/devices/numd2/numd2bindCSC.c new file mode 100644 index 000000000..88e1aecea --- /dev/null +++ b/src/spicelib/devices/numd2/numd2bindCSC.c @@ -0,0 +1,141 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "numd2def.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +NUMD2bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + NUMD2model *model = (NUMD2model *)inModel ; + NUMD2instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the NUMD2 models */ + for ( ; model != NULL ; model = model->NUMD2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->NUMD2instances ; here != NULL ; here = here->NUMD2nextInstance) + { + if ((here-> NUMD2posNode != 0) && (here-> NUMD2posNode != 0)) + { + i = here->NUMD2posPosPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMD2posPosStructPtr = matched ; + here->NUMD2posPosPtr = matched->CSC ; + } + + if ((here-> NUMD2negNode != 0) && (here-> NUMD2negNode != 0)) + { + i = here->NUMD2negNegPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMD2negNegStructPtr = matched ; + here->NUMD2negNegPtr = matched->CSC ; + } + + if ((here-> NUMD2negNode != 0) && (here-> NUMD2posNode != 0)) + { + i = here->NUMD2negPosPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMD2negPosStructPtr = matched ; + here->NUMD2negPosPtr = matched->CSC ; + } + + if ((here-> NUMD2posNode != 0) && (here-> NUMD2negNode != 0)) + { + i = here->NUMD2posNegPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMD2posNegStructPtr = matched ; + here->NUMD2posNegPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +NUMD2bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + NUMD2model *model = (NUMD2model *)inModel ; + NUMD2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NUMD2 models */ + for ( ; model != NULL ; model = model->NUMD2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->NUMD2instances ; here != NULL ; here = here->NUMD2nextInstance) + { + if ((here-> NUMD2posNode != 0) && (here-> NUMD2posNode != 0)) + here->NUMD2posPosPtr = here->NUMD2posPosStructPtr->CSC_Complex ; + + if ((here-> NUMD2negNode != 0) && (here-> NUMD2negNode != 0)) + here->NUMD2negNegPtr = here->NUMD2negNegStructPtr->CSC_Complex ; + + if ((here-> NUMD2negNode != 0) && (here-> NUMD2posNode != 0)) + here->NUMD2negPosPtr = here->NUMD2negPosStructPtr->CSC_Complex ; + + if ((here-> NUMD2posNode != 0) && (here-> NUMD2negNode != 0)) + here->NUMD2posNegPtr = here->NUMD2posNegStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +NUMD2bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + NUMD2model *model = (NUMD2model *)inModel ; + NUMD2instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NUMD2 models */ + for ( ; model != NULL ; model = model->NUMD2nextModel) + { + /* loop through all the instances of the model */ + for (here = model->NUMD2instances ; here != NULL ; here = here->NUMD2nextInstance) + { + if ((here-> NUMD2posNode != 0) && (here-> NUMD2posNode != 0)) + here->NUMD2posPosPtr = here->NUMD2posPosStructPtr->CSC ; + + if ((here-> NUMD2negNode != 0) && (here-> NUMD2negNode != 0)) + here->NUMD2negNegPtr = here->NUMD2negNegStructPtr->CSC ; + + if ((here-> NUMD2negNode != 0) && (here-> NUMD2posNode != 0)) + here->NUMD2negPosPtr = here->NUMD2negPosStructPtr->CSC ; + + if ((here-> NUMD2posNode != 0) && (here-> NUMD2negNode != 0)) + here->NUMD2posNegPtr = here->NUMD2posNegStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/numd2/numd2def.h b/src/spicelib/devices/numd2/numd2def.h index 46017446f..07b8f89e1 100644 --- a/src/spicelib/devices/numd2/numd2def.h +++ b/src/spicelib/devices/numd2/numd2def.h @@ -64,6 +64,14 @@ typedef struct sNUMD2instance { unsigned NUMD2icFileGiven:1; /* flag to indicate init. cond. file given */ unsigned NUMD2tempGiven:1; /* flag to indicate temp was specified */ unsigned NUMD2printGiven:1; /* flag to indicate if print was specified */ + +#ifdef KLU + BindElement *NUMD2posPosStructPtr ; + BindElement *NUMD2negNegStructPtr ; + BindElement *NUMD2negPosStructPtr ; + BindElement *NUMD2posNegStructPtr ; +#endif + } NUMD2instance; diff --git a/src/spicelib/devices/numd2/numd2ext.h b/src/spicelib/devices/numd2/numd2ext.h index a23cd1169..99a9b6331 100644 --- a/src/spicelib/devices/numd2/numd2ext.h +++ b/src/spicelib/devices/numd2/numd2ext.h @@ -24,5 +24,10 @@ extern int NUMD2trunc(GENmodel *, CKTcircuit *, double *); extern void NUMD2dump(GENmodel *, CKTcircuit *); extern void NUMD2acct(GENmodel *, CKTcircuit *, FILE *); +#ifdef KLU +extern int NUMD2bindCSC (GENmodel*, CKTcircuit*) ; +extern int NUMD2bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int NUMD2bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif #endif /* NUMD2EXT_H */ diff --git a/src/spicelib/devices/numd2/numd2init.c b/src/spicelib/devices/numd2/numd2init.c index dec78e566..55a268c37 100644 --- a/src/spicelib/devices/numd2/numd2init.c +++ b/src/spicelib/devices/numd2/numd2init.c @@ -74,7 +74,13 @@ SPICEdev NUMD2info = { #endif /* DEVinstSize */ &NUMD2iSize, - /* DEVmodSize */ &NUMD2mSize + /* DEVmodSize */ &NUMD2mSize, + +#ifdef KLU + /* DEVbindCSC */ NUMD2bindCSC, + /* DEVbindCSCComplex */ NUMD2bindCSCComplex, + /* DEVbindCSCComplexToReal */ NUMD2bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/numos/Makefile.am b/src/spicelib/devices/numos/Makefile.am index 0517f2552..4f7c315c8 100644 --- a/src/spicelib/devices/numos/Makefile.am +++ b/src/spicelib/devices/numos/Makefile.am @@ -24,6 +24,9 @@ libnumos_la_SOURCES = \ nummtrun.c +if KLU_WANTED +libnumos_la_SOURCES += numosbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/numos/numosbindCSC.c b/src/spicelib/devices/numos/numosbindCSC.c new file mode 100644 index 000000000..decfdcbb8 --- /dev/null +++ b/src/spicelib/devices/numos/numosbindCSC.c @@ -0,0 +1,309 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "numosdef.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +NUMOSbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + NUMOSmodel *model = (NUMOSmodel *)inModel ; + NUMOSinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the NUMOS models */ + for ( ; model != NULL ; model = model->NUMOSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->NUMOSinstances ; here != NULL ; here = here->NUMOSnextInstance) + { + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSdrainNode != 0)) + { + i = here->NUMOSdrainDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSdrainDrainStructPtr = matched ; + here->NUMOSdrainDrainPtr = matched->CSC ; + } + + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSsourceNode != 0)) + { + i = here->NUMOSdrainSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSdrainSourceStructPtr = matched ; + here->NUMOSdrainSourcePtr = matched->CSC ; + } + + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSgateNode != 0)) + { + i = here->NUMOSdrainGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSdrainGateStructPtr = matched ; + here->NUMOSdrainGatePtr = matched->CSC ; + } + + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSbulkNode != 0)) + { + i = here->NUMOSdrainBulkPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSdrainBulkStructPtr = matched ; + here->NUMOSdrainBulkPtr = matched->CSC ; + } + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSdrainNode != 0)) + { + i = here->NUMOSsourceDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSsourceDrainStructPtr = matched ; + here->NUMOSsourceDrainPtr = matched->CSC ; + } + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSsourceNode != 0)) + { + i = here->NUMOSsourceSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSsourceSourceStructPtr = matched ; + here->NUMOSsourceSourcePtr = matched->CSC ; + } + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSgateNode != 0)) + { + i = here->NUMOSsourceGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSsourceGateStructPtr = matched ; + here->NUMOSsourceGatePtr = matched->CSC ; + } + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSbulkNode != 0)) + { + i = here->NUMOSsourceBulkPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSsourceBulkStructPtr = matched ; + here->NUMOSsourceBulkPtr = matched->CSC ; + } + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSdrainNode != 0)) + { + i = here->NUMOSgateDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSgateDrainStructPtr = matched ; + here->NUMOSgateDrainPtr = matched->CSC ; + } + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSsourceNode != 0)) + { + i = here->NUMOSgateSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSgateSourceStructPtr = matched ; + here->NUMOSgateSourcePtr = matched->CSC ; + } + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSgateNode != 0)) + { + i = here->NUMOSgateGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSgateGateStructPtr = matched ; + here->NUMOSgateGatePtr = matched->CSC ; + } + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSbulkNode != 0)) + { + i = here->NUMOSgateBulkPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSgateBulkStructPtr = matched ; + here->NUMOSgateBulkPtr = matched->CSC ; + } + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSdrainNode != 0)) + { + i = here->NUMOSbulkDrainPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSbulkDrainStructPtr = matched ; + here->NUMOSbulkDrainPtr = matched->CSC ; + } + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSsourceNode != 0)) + { + i = here->NUMOSbulkSourcePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSbulkSourceStructPtr = matched ; + here->NUMOSbulkSourcePtr = matched->CSC ; + } + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSgateNode != 0)) + { + i = here->NUMOSbulkGatePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSbulkGateStructPtr = matched ; + here->NUMOSbulkGatePtr = matched->CSC ; + } + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSbulkNode != 0)) + { + i = here->NUMOSbulkBulkPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->NUMOSbulkBulkStructPtr = matched ; + here->NUMOSbulkBulkPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +NUMOSbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + NUMOSmodel *model = (NUMOSmodel *)inModel ; + NUMOSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NUMOS models */ + for ( ; model != NULL ; model = model->NUMOSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->NUMOSinstances ; here != NULL ; here = here->NUMOSnextInstance) + { + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSdrainNode != 0)) + here->NUMOSdrainDrainPtr = here->NUMOSdrainDrainStructPtr->CSC_Complex ; + + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSsourceNode != 0)) + here->NUMOSdrainSourcePtr = here->NUMOSdrainSourceStructPtr->CSC_Complex ; + + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSgateNode != 0)) + here->NUMOSdrainGatePtr = here->NUMOSdrainGateStructPtr->CSC_Complex ; + + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSbulkNode != 0)) + here->NUMOSdrainBulkPtr = here->NUMOSdrainBulkStructPtr->CSC_Complex ; + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSdrainNode != 0)) + here->NUMOSsourceDrainPtr = here->NUMOSsourceDrainStructPtr->CSC_Complex ; + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSsourceNode != 0)) + here->NUMOSsourceSourcePtr = here->NUMOSsourceSourceStructPtr->CSC_Complex ; + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSgateNode != 0)) + here->NUMOSsourceGatePtr = here->NUMOSsourceGateStructPtr->CSC_Complex ; + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSbulkNode != 0)) + here->NUMOSsourceBulkPtr = here->NUMOSsourceBulkStructPtr->CSC_Complex ; + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSdrainNode != 0)) + here->NUMOSgateDrainPtr = here->NUMOSgateDrainStructPtr->CSC_Complex ; + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSsourceNode != 0)) + here->NUMOSgateSourcePtr = here->NUMOSgateSourceStructPtr->CSC_Complex ; + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSgateNode != 0)) + here->NUMOSgateGatePtr = here->NUMOSgateGateStructPtr->CSC_Complex ; + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSbulkNode != 0)) + here->NUMOSgateBulkPtr = here->NUMOSgateBulkStructPtr->CSC_Complex ; + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSdrainNode != 0)) + here->NUMOSbulkDrainPtr = here->NUMOSbulkDrainStructPtr->CSC_Complex ; + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSsourceNode != 0)) + here->NUMOSbulkSourcePtr = here->NUMOSbulkSourceStructPtr->CSC_Complex ; + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSgateNode != 0)) + here->NUMOSbulkGatePtr = here->NUMOSbulkGateStructPtr->CSC_Complex ; + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSbulkNode != 0)) + here->NUMOSbulkBulkPtr = here->NUMOSbulkBulkStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +NUMOSbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + NUMOSmodel *model = (NUMOSmodel *)inModel ; + NUMOSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the NUMOS models */ + for ( ; model != NULL ; model = model->NUMOSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->NUMOSinstances ; here != NULL ; here = here->NUMOSnextInstance) + { + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSdrainNode != 0)) + here->NUMOSdrainDrainPtr = here->NUMOSdrainDrainStructPtr->CSC ; + + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSsourceNode != 0)) + here->NUMOSdrainSourcePtr = here->NUMOSdrainSourceStructPtr->CSC ; + + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSgateNode != 0)) + here->NUMOSdrainGatePtr = here->NUMOSdrainGateStructPtr->CSC ; + + if ((here-> NUMOSdrainNode != 0) && (here-> NUMOSbulkNode != 0)) + here->NUMOSdrainBulkPtr = here->NUMOSdrainBulkStructPtr->CSC ; + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSdrainNode != 0)) + here->NUMOSsourceDrainPtr = here->NUMOSsourceDrainStructPtr->CSC ; + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSsourceNode != 0)) + here->NUMOSsourceSourcePtr = here->NUMOSsourceSourceStructPtr->CSC ; + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSgateNode != 0)) + here->NUMOSsourceGatePtr = here->NUMOSsourceGateStructPtr->CSC ; + + if ((here-> NUMOSsourceNode != 0) && (here-> NUMOSbulkNode != 0)) + here->NUMOSsourceBulkPtr = here->NUMOSsourceBulkStructPtr->CSC ; + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSdrainNode != 0)) + here->NUMOSgateDrainPtr = here->NUMOSgateDrainStructPtr->CSC ; + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSsourceNode != 0)) + here->NUMOSgateSourcePtr = here->NUMOSgateSourceStructPtr->CSC ; + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSgateNode != 0)) + here->NUMOSgateGatePtr = here->NUMOSgateGateStructPtr->CSC ; + + if ((here-> NUMOSgateNode != 0) && (here-> NUMOSbulkNode != 0)) + here->NUMOSgateBulkPtr = here->NUMOSgateBulkStructPtr->CSC ; + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSdrainNode != 0)) + here->NUMOSbulkDrainPtr = here->NUMOSbulkDrainStructPtr->CSC ; + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSsourceNode != 0)) + here->NUMOSbulkSourcePtr = here->NUMOSbulkSourceStructPtr->CSC ; + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSgateNode != 0)) + here->NUMOSbulkGatePtr = here->NUMOSbulkGateStructPtr->CSC ; + + if ((here-> NUMOSbulkNode != 0) && (here-> NUMOSbulkNode != 0)) + here->NUMOSbulkBulkPtr = here->NUMOSbulkBulkStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/numos/numosdef.h b/src/spicelib/devices/numos/numosdef.h index 6bcad9fc8..5b3db8402 100644 --- a/src/spicelib/devices/numos/numosdef.h +++ b/src/spicelib/devices/numos/numosdef.h @@ -114,6 +114,26 @@ typedef struct sNUMOSinstance { unsigned NUMOSicFileGiven:1; /* flag to indicate init. cond. file given */ unsigned NUMOSprintGiven:1; /* flag to indicate print was given */ unsigned NUMOStempGiven:1; /* flag to indicate temp was given */ + +#ifdef KLU + BindElement *NUMOSdrainDrainStructPtr ; + BindElement *NUMOSdrainSourceStructPtr ; + BindElement *NUMOSdrainGateStructPtr ; + BindElement *NUMOSdrainBulkStructPtr ; + BindElement *NUMOSsourceDrainStructPtr ; + BindElement *NUMOSsourceSourceStructPtr ; + BindElement *NUMOSsourceGateStructPtr ; + BindElement *NUMOSsourceBulkStructPtr ; + BindElement *NUMOSgateDrainStructPtr ; + BindElement *NUMOSgateSourceStructPtr ; + BindElement *NUMOSgateGateStructPtr ; + BindElement *NUMOSgateBulkStructPtr ; + BindElement *NUMOSbulkDrainStructPtr ; + BindElement *NUMOSbulkSourceStructPtr ; + BindElement *NUMOSbulkGateStructPtr ; + BindElement *NUMOSbulkBulkStructPtr ; +#endif + } NUMOSinstance; /* per model data */ diff --git a/src/spicelib/devices/numos/numosext.h b/src/spicelib/devices/numos/numosext.h index 411c5b03b..ced7b27a0 100644 --- a/src/spicelib/devices/numos/numosext.h +++ b/src/spicelib/devices/numos/numosext.h @@ -24,4 +24,10 @@ extern int NUMOStrunc(GENmodel *, CKTcircuit *, double *); extern void NUMOSdump(GENmodel *, CKTcircuit *); extern void NUMOSacct(GENmodel *, CKTcircuit *, FILE *); +#ifdef KLU +extern int NUMOSbindCSC (GENmodel*, CKTcircuit*) ; +extern int NUMOSbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int NUMOSbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif + #endif /* NUMOSEXT_H */ diff --git a/src/spicelib/devices/numos/numosinit.c b/src/spicelib/devices/numos/numosinit.c index 851685906..ee68aab3a 100644 --- a/src/spicelib/devices/numos/numosinit.c +++ b/src/spicelib/devices/numos/numosinit.c @@ -74,7 +74,13 @@ SPICEdev NUMOSinfo = { #endif /* DEVinstSize */ &NUMOSiSize, - /* DEVmodSize */ &NUMOSmSize + /* DEVmodSize */ &NUMOSmSize, + +#ifdef KLU + /* DEVbindCSC */ NUMOSbindCSC, + /* DEVbindCSCComplex */ NUMOSbindCSCComplex, + /* DEVbindCSCComplexToReal */ NUMOSbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/res/Makefile.am b/src/spicelib/devices/res/Makefile.am index ab746263d..c2fd893d9 100644 --- a/src/spicelib/devices/res/Makefile.am +++ b/src/spicelib/devices/res/Makefile.am @@ -28,7 +28,11 @@ libres_la_SOURCES = \ restemp.c +if KLU_WANTED +libres_la_SOURCES += resbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/res/resbindCSC.c b/src/spicelib/devices/res/resbindCSC.c new file mode 100644 index 000000000..f22214141 --- /dev/null +++ b/src/spicelib/devices/res/resbindCSC.c @@ -0,0 +1,141 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "resdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +RESbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + RESmodel *model = (RESmodel *)inModel ; + RESinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the RES models */ + for ( ; model != NULL ; model = model->RESnextModel) + { + /* loop through all the instances of the model */ + for (here = model->RESinstances ; here != NULL ; here = here->RESnextInstance) + { + if ((here-> RESposNode != 0) && (here-> RESposNode != 0)) + { + i = here->RESposPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->RESposPosptrStructPtr = matched ; + here->RESposPosptr = matched->CSC ; + } + + if ((here-> RESnegNode != 0) && (here-> RESnegNode != 0)) + { + i = here->RESnegNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->RESnegNegptrStructPtr = matched ; + here->RESnegNegptr = matched->CSC ; + } + + if ((here-> RESposNode != 0) && (here-> RESnegNode != 0)) + { + i = here->RESposNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->RESposNegptrStructPtr = matched ; + here->RESposNegptr = matched->CSC ; + } + + if ((here-> RESnegNode != 0) && (here-> RESposNode != 0)) + { + i = here->RESnegPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->RESnegPosptrStructPtr = matched ; + here->RESnegPosptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +RESbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + RESmodel *model = (RESmodel *)inModel ; + RESinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the RES models */ + for ( ; model != NULL ; model = model->RESnextModel) + { + /* loop through all the instances of the model */ + for (here = model->RESinstances ; here != NULL ; here = here->RESnextInstance) + { + if ((here-> RESposNode != 0) && (here-> RESposNode != 0)) + here->RESposPosptr = here->RESposPosptrStructPtr->CSC_Complex ; + + if ((here-> RESnegNode != 0) && (here-> RESnegNode != 0)) + here->RESnegNegptr = here->RESnegNegptrStructPtr->CSC_Complex ; + + if ((here-> RESposNode != 0) && (here-> RESnegNode != 0)) + here->RESposNegptr = here->RESposNegptrStructPtr->CSC_Complex ; + + if ((here-> RESnegNode != 0) && (here-> RESposNode != 0)) + here->RESnegPosptr = here->RESnegPosptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +RESbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + RESmodel *model = (RESmodel *)inModel ; + RESinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the RES models */ + for ( ; model != NULL ; model = model->RESnextModel) + { + /* loop through all the instances of the model */ + for (here = model->RESinstances ; here != NULL ; here = here->RESnextInstance) + { + if ((here-> RESposNode != 0) && (here-> RESposNode != 0)) + here->RESposPosptr = here->RESposPosptrStructPtr->CSC ; + + if ((here-> RESnegNode != 0) && (here-> RESnegNode != 0)) + here->RESnegNegptr = here->RESnegNegptrStructPtr->CSC ; + + if ((here-> RESposNode != 0) && (here-> RESnegNode != 0)) + here->RESposNegptr = here->RESposNegptrStructPtr->CSC ; + + if ((here-> RESnegNode != 0) && (here-> RESposNode != 0)) + here->RESnegPosptr = here->RESnegPosptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/res/resdefs.h b/src/spicelib/devices/res/resdefs.h index 8b8f4d54a..318a9f1f2 100644 --- a/src/spicelib/devices/res/resdefs.h +++ b/src/spicelib/devices/res/resdefs.h @@ -86,6 +86,13 @@ typedef struct sRESinstance { double **RESnVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *RESposPosptrStructPtr ; + BindElement *RESnegNegptrStructPtr ; + BindElement *RESposNegptrStructPtr ; + BindElement *RESnegPosptrStructPtr ; +#endif + } RESinstance ; diff --git a/src/spicelib/devices/res/resext.h b/src/spicelib/devices/res/resext.h index 148d1d222..87f4f17f6 100644 --- a/src/spicelib/devices/res/resext.h +++ b/src/spicelib/devices/res/resext.h @@ -21,3 +21,9 @@ extern int RESsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int REStemp(GENmodel*,CKTcircuit*); extern int RESnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int RESsoaCheck(CKTcircuit *, GENmodel *); + +#ifdef KLU +extern int RESbindCSC (GENmodel*, CKTcircuit*) ; +extern int RESbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int RESbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/res/resinit.c b/src/spicelib/devices/res/resinit.c index d4096de8d..2265a7e15 100644 --- a/src/spicelib/devices/res/resinit.c +++ b/src/spicelib/devices/res/resinit.c @@ -73,7 +73,13 @@ SPICEdev RESinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &RESiSize, - /* DEVmodSize */ &RESmSize + /* DEVmodSize */ &RESmSize, + +#ifdef KLU + /* DEVbindCSC */ RESbindCSC, + /* DEVbindCSCComplex */ RESbindCSCComplex, + /* DEVbindCSCComplexToReal */ RESbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/soi3/Makefile.am b/src/spicelib/devices/soi3/Makefile.am index 09b1591dd..4081c33fe 100644 --- a/src/spicelib/devices/soi3/Makefile.am +++ b/src/spicelib/devices/soi3/Makefile.am @@ -27,7 +27,11 @@ libsoi3_la_SOURCES = \ soi3trun.c +if KLU_WANTED +libsoi3_la_SOURCES += soi3bindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/soi3/soi3bindCSC.c b/src/spicelib/devices/soi3/soi3bindCSC.c new file mode 100644 index 000000000..e1b110e88 --- /dev/null +++ b/src/spicelib/devices/soi3/soi3bindCSC.c @@ -0,0 +1,937 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "soi3defs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +SOI3bindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + SOI3model *model = (SOI3model *)inModel ; + SOI3instance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the SOI3 models */ + for ( ; model != NULL ; model = model->SOI3nextModel) + { + /* loop through all the instances of the model */ + for (here = model->SOI3instances ; here != NULL ; here = here->SOI3nextInstance) + { + if ((here->SOI3dNode != 0) && (here->SOI3dNode != 0)) + { + i = here->SOI3D_dPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3D_dStructPtr = matched ; + here->SOI3D_dPtr = matched->CSC ; + } + + if ((here->SOI3dNode != 0) && (here->SOI3dNodePrime != 0)) + { + i = here->SOI3D_dpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3D_dpStructPtr = matched ; + here->SOI3D_dpPtr = matched->CSC ; + } + + if ((here->SOI3dNodePrime != 0) && (here->SOI3dNode != 0)) + { + i = here->SOI3DP_dPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3DP_dStructPtr = matched ; + here->SOI3DP_dPtr = matched->CSC ; + } + + if ((here->SOI3sNode != 0) && (here->SOI3sNode != 0)) + { + i = here->SOI3S_sPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3S_sStructPtr = matched ; + here->SOI3S_sPtr = matched->CSC ; + } + + if ((here->SOI3sNode != 0) && (here->SOI3sNodePrime != 0)) + { + i = here->SOI3S_spPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3S_spStructPtr = matched ; + here->SOI3S_spPtr = matched->CSC ; + } + + if ((here->SOI3sNodePrime != 0) && (here->SOI3sNode != 0)) + { + i = here->SOI3SP_sPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3SP_sStructPtr = matched ; + here->SOI3SP_sPtr = matched->CSC ; + } + + if ((here->SOI3gfNode != 0) && (here->SOI3gfNode != 0)) + { + i = here->SOI3GF_gfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GF_gfStructPtr = matched ; + here->SOI3GF_gfPtr = matched->CSC ; + } + + if ((here->SOI3gfNode != 0) && (here->SOI3gbNode != 0)) + { + i = here->SOI3GF_gbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GF_gbStructPtr = matched ; + here->SOI3GF_gbPtr = matched->CSC ; + } + + if ((here->SOI3gfNode != 0) && (here->SOI3dNodePrime != 0)) + { + i = here->SOI3GF_dpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GF_dpStructPtr = matched ; + here->SOI3GF_dpPtr = matched->CSC ; + } + + if ((here->SOI3gfNode != 0) && (here->SOI3sNodePrime != 0)) + { + i = here->SOI3GF_spPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GF_spStructPtr = matched ; + here->SOI3GF_spPtr = matched->CSC ; + } + + if ((here->SOI3gfNode != 0) && (here->SOI3bNode != 0)) + { + i = here->SOI3GF_bPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GF_bStructPtr = matched ; + here->SOI3GF_bPtr = matched->CSC ; + } + + if ((here->SOI3gbNode != 0) && (here->SOI3gfNode != 0)) + { + i = here->SOI3GB_gfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GB_gfStructPtr = matched ; + here->SOI3GB_gfPtr = matched->CSC ; + } + + if ((here->SOI3gbNode != 0) && (here->SOI3gbNode != 0)) + { + i = here->SOI3GB_gbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GB_gbStructPtr = matched ; + here->SOI3GB_gbPtr = matched->CSC ; + } + + if ((here->SOI3gbNode != 0) && (here->SOI3dNodePrime != 0)) + { + i = here->SOI3GB_dpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GB_dpStructPtr = matched ; + here->SOI3GB_dpPtr = matched->CSC ; + } + + if ((here->SOI3gbNode != 0) && (here->SOI3sNodePrime != 0)) + { + i = here->SOI3GB_spPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GB_spStructPtr = matched ; + here->SOI3GB_spPtr = matched->CSC ; + } + + if ((here->SOI3gbNode != 0) && (here->SOI3bNode != 0)) + { + i = here->SOI3GB_bPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GB_bStructPtr = matched ; + here->SOI3GB_bPtr = matched->CSC ; + } + + if ((here->SOI3bNode != 0) && (here->SOI3gfNode != 0)) + { + i = here->SOI3B_gfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3B_gfStructPtr = matched ; + here->SOI3B_gfPtr = matched->CSC ; + } + + if ((here->SOI3bNode != 0) && (here->SOI3gbNode != 0)) + { + i = here->SOI3B_gbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3B_gbStructPtr = matched ; + here->SOI3B_gbPtr = matched->CSC ; + } + + if ((here->SOI3bNode != 0) && (here->SOI3dNodePrime != 0)) + { + i = here->SOI3B_dpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3B_dpStructPtr = matched ; + here->SOI3B_dpPtr = matched->CSC ; + } + + if ((here->SOI3bNode != 0) && (here->SOI3sNodePrime != 0)) + { + i = here->SOI3B_spPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3B_spStructPtr = matched ; + here->SOI3B_spPtr = matched->CSC ; + } + + if ((here->SOI3bNode != 0) && (here->SOI3bNode != 0)) + { + i = here->SOI3B_bPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3B_bStructPtr = matched ; + here->SOI3B_bPtr = matched->CSC ; + } + + if ((here->SOI3dNodePrime != 0) && (here->SOI3gfNode != 0)) + { + i = here->SOI3DP_gfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3DP_gfStructPtr = matched ; + here->SOI3DP_gfPtr = matched->CSC ; + } + + if ((here->SOI3dNodePrime != 0) && (here->SOI3gbNode != 0)) + { + i = here->SOI3DP_gbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3DP_gbStructPtr = matched ; + here->SOI3DP_gbPtr = matched->CSC ; + } + + if ((here->SOI3dNodePrime != 0) && (here->SOI3dNodePrime != 0)) + { + i = here->SOI3DP_dpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3DP_dpStructPtr = matched ; + here->SOI3DP_dpPtr = matched->CSC ; + } + + if ((here->SOI3dNodePrime != 0) && (here->SOI3sNodePrime != 0)) + { + i = here->SOI3DP_spPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3DP_spStructPtr = matched ; + here->SOI3DP_spPtr = matched->CSC ; + } + + if ((here->SOI3dNodePrime != 0) && (here->SOI3bNode != 0)) + { + i = here->SOI3DP_bPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3DP_bStructPtr = matched ; + here->SOI3DP_bPtr = matched->CSC ; + } + + if ((here->SOI3sNodePrime != 0) && (here->SOI3gfNode != 0)) + { + i = here->SOI3SP_gfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3SP_gfStructPtr = matched ; + here->SOI3SP_gfPtr = matched->CSC ; + } + + if ((here->SOI3sNodePrime != 0) && (here->SOI3gbNode != 0)) + { + i = here->SOI3SP_gbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3SP_gbStructPtr = matched ; + here->SOI3SP_gbPtr = matched->CSC ; + } + + if ((here->SOI3sNodePrime != 0) && (here->SOI3dNodePrime != 0)) + { + i = here->SOI3SP_dpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3SP_dpStructPtr = matched ; + here->SOI3SP_dpPtr = matched->CSC ; + } + + if ((here->SOI3sNodePrime != 0) && (here->SOI3sNodePrime != 0)) + { + i = here->SOI3SP_spPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3SP_spStructPtr = matched ; + here->SOI3SP_spPtr = matched->CSC ; + } + + if ((here->SOI3sNodePrime != 0) && (here->SOI3bNode != 0)) + { + i = here->SOI3SP_bPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3SP_bStructPtr = matched ; + here->SOI3SP_bPtr = matched->CSC ; + } + + if (here->SOI3rt == 0) + { + if ((here->SOI3toutNode != 0) && (here->SOI3branch != 0)) + { + i = here->SOI3TOUT_ibrPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT_ibrStructPtr = matched ; + here->SOI3TOUT_ibrPtr = matched->CSC ; + } + + if ((here->SOI3branch != 0) && (here->SOI3toutNode != 0)) + { + i = here->SOI3IBR_toutPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3IBR_toutStructPtr = matched ; + here->SOI3IBR_toutPtr = matched->CSC ; + } + + } + else + { + if ((here->SOI3toutNode != 0) && (here->SOI3toutNode != 0)) + { + i = here->SOI3TOUT_toutPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT_toutStructPtr = matched ; + here->SOI3TOUT_toutPtr = matched->CSC ; + } + + if (here->SOI3numThermalNodes > 1) + { + if ((here->SOI3toutNode != 0) && (here->SOI3tout1Node != 0)) + { + i = here->SOI3TOUT_tout1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT_tout1StructPtr = matched ; + here->SOI3TOUT_tout1Ptr = matched->CSC ; + } + + if ((here->SOI3tout1Node != 0) && (here->SOI3toutNode != 0)) + { + i = here->SOI3TOUT1_toutPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT1_toutStructPtr = matched ; + here->SOI3TOUT1_toutPtr = matched->CSC ; + } + + if ((here->SOI3tout1Node != 0) && (here->SOI3tout1Node != 0)) + { + i = here->SOI3TOUT1_tout1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT1_tout1StructPtr = matched ; + here->SOI3TOUT1_tout1Ptr = matched->CSC ; + } + + } + if (here->SOI3numThermalNodes > 2) + { + if ((here->SOI3tout1Node != 0) && (here->SOI3tout2Node != 0)) + { + i = here->SOI3TOUT1_tout2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT1_tout2StructPtr = matched ; + here->SOI3TOUT1_tout2Ptr = matched->CSC ; + } + + if ((here->SOI3tout2Node != 0) && (here->SOI3tout1Node != 0)) + { + i = here->SOI3TOUT2_tout1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT2_tout1StructPtr = matched ; + here->SOI3TOUT2_tout1Ptr = matched->CSC ; + } + + if ((here->SOI3tout2Node != 0) && (here->SOI3tout2Node != 0)) + { + i = here->SOI3TOUT2_tout2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT2_tout2StructPtr = matched ; + here->SOI3TOUT2_tout2Ptr = matched->CSC ; + } + + } + if (here->SOI3numThermalNodes > 3) + { + if ((here->SOI3tout2Node != 0) && (here->SOI3tout3Node != 0)) + { + i = here->SOI3TOUT2_tout3Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT2_tout3StructPtr = matched ; + here->SOI3TOUT2_tout3Ptr = matched->CSC ; + } + + if ((here->SOI3tout3Node != 0) && (here->SOI3tout2Node != 0)) + { + i = here->SOI3TOUT3_tout2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT3_tout2StructPtr = matched ; + here->SOI3TOUT3_tout2Ptr = matched->CSC ; + } + + if ((here->SOI3tout3Node != 0) && (here->SOI3tout3Node != 0)) + { + i = here->SOI3TOUT3_tout3Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT3_tout3StructPtr = matched ; + here->SOI3TOUT3_tout3Ptr = matched->CSC ; + } + + } + if (here->SOI3numThermalNodes > 4) + { + if ((here->SOI3tout3Node != 0) && (here->SOI3tout4Node != 0)) + { + i = here->SOI3TOUT3_tout4Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT3_tout4StructPtr = matched ; + here->SOI3TOUT3_tout4Ptr = matched->CSC ; + } + + if ((here->SOI3tout4Node != 0) && (here->SOI3tout3Node != 0)) + { + i = here->SOI3TOUT4_tout3Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT4_tout3StructPtr = matched ; + here->SOI3TOUT4_tout3Ptr = matched->CSC ; + } + + if ((here->SOI3tout4Node != 0) && (here->SOI3tout4Node != 0)) + { + i = here->SOI3TOUT4_tout4Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT4_tout4StructPtr = matched ; + here->SOI3TOUT4_tout4Ptr = matched->CSC ; + } + + } + if ((here->SOI3toutNode != 0) && (here->SOI3toutNode != 0)) + { + i = here->SOI3TOUT_toutPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT_toutStructPtr = matched ; + here->SOI3TOUT_toutPtr = matched->CSC ; + } + + if ((here->SOI3toutNode != 0) && (here->SOI3gfNode != 0)) + { + i = here->SOI3TOUT_gfPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT_gfStructPtr = matched ; + here->SOI3TOUT_gfPtr = matched->CSC ; + } + + if ((here->SOI3toutNode != 0) && (here->SOI3gbNode != 0)) + { + i = here->SOI3TOUT_gbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT_gbStructPtr = matched ; + here->SOI3TOUT_gbPtr = matched->CSC ; + } + + if ((here->SOI3toutNode != 0) && (here->SOI3dNodePrime != 0)) + { + i = here->SOI3TOUT_dpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT_dpStructPtr = matched ; + here->SOI3TOUT_dpPtr = matched->CSC ; + } + + if ((here->SOI3toutNode != 0) && (here->SOI3sNodePrime != 0)) + { + i = here->SOI3TOUT_spPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT_spStructPtr = matched ; + here->SOI3TOUT_spPtr = matched->CSC ; + } + + if ((here->SOI3toutNode != 0) && (here->SOI3bNode != 0)) + { + i = here->SOI3TOUT_bPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3TOUT_bStructPtr = matched ; + here->SOI3TOUT_bPtr = matched->CSC ; + } + + if ((here->SOI3gfNode != 0) && (here->SOI3toutNode != 0)) + { + i = here->SOI3GF_toutPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GF_toutStructPtr = matched ; + here->SOI3GF_toutPtr = matched->CSC ; + } + + if ((here->SOI3gbNode != 0) && (here->SOI3toutNode != 0)) + { + i = here->SOI3GB_toutPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3GB_toutStructPtr = matched ; + here->SOI3GB_toutPtr = matched->CSC ; + } + + if ((here->SOI3dNodePrime != 0) && (here->SOI3toutNode != 0)) + { + i = here->SOI3DP_toutPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3DP_toutStructPtr = matched ; + here->SOI3DP_toutPtr = matched->CSC ; + } + + if ((here->SOI3sNodePrime != 0) && (here->SOI3toutNode != 0)) + { + i = here->SOI3SP_toutPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3SP_toutStructPtr = matched ; + here->SOI3SP_toutPtr = matched->CSC ; + } + + if ((here->SOI3bNode != 0) && (here->SOI3toutNode != 0)) + { + i = here->SOI3B_toutPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SOI3B_toutStructPtr = matched ; + here->SOI3B_toutPtr = matched->CSC ; + } + + } + } + } + + return (OK) ; +} + +int +SOI3bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + SOI3model *model = (SOI3model *)inModel ; + SOI3instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the SOI3 models */ + for ( ; model != NULL ; model = model->SOI3nextModel) + { + /* loop through all the instances of the model */ + for (here = model->SOI3instances ; here != NULL ; here = here->SOI3nextInstance) + { + if ((here->SOI3dNode != 0) && (here->SOI3dNode != 0)) + here->SOI3D_dPtr = here->SOI3D_dStructPtr->CSC_Complex ; + + if ((here->SOI3dNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3D_dpPtr = here->SOI3D_dpStructPtr->CSC_Complex ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3dNode != 0)) + here->SOI3DP_dPtr = here->SOI3DP_dStructPtr->CSC_Complex ; + + if ((here->SOI3sNode != 0) && (here->SOI3sNode != 0)) + here->SOI3S_sPtr = here->SOI3S_sStructPtr->CSC_Complex ; + + if ((here->SOI3sNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3S_spPtr = here->SOI3S_spStructPtr->CSC_Complex ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3sNode != 0)) + here->SOI3SP_sPtr = here->SOI3SP_sStructPtr->CSC_Complex ; + + if ((here->SOI3gfNode != 0) && (here->SOI3gfNode != 0)) + here->SOI3GF_gfPtr = here->SOI3GF_gfStructPtr->CSC_Complex ; + + if ((here->SOI3gfNode != 0) && (here->SOI3gbNode != 0)) + here->SOI3GF_gbPtr = here->SOI3GF_gbStructPtr->CSC_Complex ; + + if ((here->SOI3gfNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3GF_dpPtr = here->SOI3GF_dpStructPtr->CSC_Complex ; + + if ((here->SOI3gfNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3GF_spPtr = here->SOI3GF_spStructPtr->CSC_Complex ; + + if ((here->SOI3gfNode != 0) && (here->SOI3bNode != 0)) + here->SOI3GF_bPtr = here->SOI3GF_bStructPtr->CSC_Complex ; + + if ((here->SOI3gbNode != 0) && (here->SOI3gfNode != 0)) + here->SOI3GB_gfPtr = here->SOI3GB_gfStructPtr->CSC_Complex ; + + if ((here->SOI3gbNode != 0) && (here->SOI3gbNode != 0)) + here->SOI3GB_gbPtr = here->SOI3GB_gbStructPtr->CSC_Complex ; + + if ((here->SOI3gbNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3GB_dpPtr = here->SOI3GB_dpStructPtr->CSC_Complex ; + + if ((here->SOI3gbNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3GB_spPtr = here->SOI3GB_spStructPtr->CSC_Complex ; + + if ((here->SOI3gbNode != 0) && (here->SOI3bNode != 0)) + here->SOI3GB_bPtr = here->SOI3GB_bStructPtr->CSC_Complex ; + + if ((here->SOI3bNode != 0) && (here->SOI3gfNode != 0)) + here->SOI3B_gfPtr = here->SOI3B_gfStructPtr->CSC_Complex ; + + if ((here->SOI3bNode != 0) && (here->SOI3gbNode != 0)) + here->SOI3B_gbPtr = here->SOI3B_gbStructPtr->CSC_Complex ; + + if ((here->SOI3bNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3B_dpPtr = here->SOI3B_dpStructPtr->CSC_Complex ; + + if ((here->SOI3bNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3B_spPtr = here->SOI3B_spStructPtr->CSC_Complex ; + + if ((here->SOI3bNode != 0) && (here->SOI3bNode != 0)) + here->SOI3B_bPtr = here->SOI3B_bStructPtr->CSC_Complex ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3gfNode != 0)) + here->SOI3DP_gfPtr = here->SOI3DP_gfStructPtr->CSC_Complex ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3gbNode != 0)) + here->SOI3DP_gbPtr = here->SOI3DP_gbStructPtr->CSC_Complex ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3DP_dpPtr = here->SOI3DP_dpStructPtr->CSC_Complex ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3DP_spPtr = here->SOI3DP_spStructPtr->CSC_Complex ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3bNode != 0)) + here->SOI3DP_bPtr = here->SOI3DP_bStructPtr->CSC_Complex ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3gfNode != 0)) + here->SOI3SP_gfPtr = here->SOI3SP_gfStructPtr->CSC_Complex ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3gbNode != 0)) + here->SOI3SP_gbPtr = here->SOI3SP_gbStructPtr->CSC_Complex ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3SP_dpPtr = here->SOI3SP_dpStructPtr->CSC_Complex ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3SP_spPtr = here->SOI3SP_spStructPtr->CSC_Complex ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3bNode != 0)) + here->SOI3SP_bPtr = here->SOI3SP_bStructPtr->CSC_Complex ; + + if (here->SOI3rt == 0) + { + if ((here->SOI3toutNode != 0) && (here->SOI3branch != 0)) + here->SOI3TOUT_ibrPtr = here->SOI3TOUT_ibrStructPtr->CSC_Complex ; + + if ((here->SOI3branch != 0) && (here->SOI3toutNode != 0)) + here->SOI3IBR_toutPtr = here->SOI3IBR_toutStructPtr->CSC_Complex ; + + } + else + { + if ((here->SOI3toutNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3TOUT_toutPtr = here->SOI3TOUT_toutStructPtr->CSC_Complex ; + + if (here->SOI3numThermalNodes > 1) + { + if ((here->SOI3toutNode != 0) && (here->SOI3tout1Node != 0)) + here->SOI3TOUT_tout1Ptr = here->SOI3TOUT_tout1StructPtr->CSC_Complex ; + + if ((here->SOI3tout1Node != 0) && (here->SOI3toutNode != 0)) + here->SOI3TOUT1_toutPtr = here->SOI3TOUT1_toutStructPtr->CSC_Complex ; + + if ((here->SOI3tout1Node != 0) && (here->SOI3tout1Node != 0)) + here->SOI3TOUT1_tout1Ptr = here->SOI3TOUT1_tout1StructPtr->CSC_Complex ; + + } + if (here->SOI3numThermalNodes > 2) + { + if ((here->SOI3tout1Node != 0) && (here->SOI3tout2Node != 0)) + here->SOI3TOUT1_tout2Ptr = here->SOI3TOUT1_tout2StructPtr->CSC_Complex ; + + if ((here->SOI3tout2Node != 0) && (here->SOI3tout1Node != 0)) + here->SOI3TOUT2_tout1Ptr = here->SOI3TOUT2_tout1StructPtr->CSC_Complex ; + + if ((here->SOI3tout2Node != 0) && (here->SOI3tout2Node != 0)) + here->SOI3TOUT2_tout2Ptr = here->SOI3TOUT2_tout2StructPtr->CSC_Complex ; + + } + if (here->SOI3numThermalNodes > 3) + { + if ((here->SOI3tout2Node != 0) && (here->SOI3tout3Node != 0)) + here->SOI3TOUT2_tout3Ptr = here->SOI3TOUT2_tout3StructPtr->CSC_Complex ; + + if ((here->SOI3tout3Node != 0) && (here->SOI3tout2Node != 0)) + here->SOI3TOUT3_tout2Ptr = here->SOI3TOUT3_tout2StructPtr->CSC_Complex ; + + if ((here->SOI3tout3Node != 0) && (here->SOI3tout3Node != 0)) + here->SOI3TOUT3_tout3Ptr = here->SOI3TOUT3_tout3StructPtr->CSC_Complex ; + + } + if (here->SOI3numThermalNodes > 4) + { + if ((here->SOI3tout3Node != 0) && (here->SOI3tout4Node != 0)) + here->SOI3TOUT3_tout4Ptr = here->SOI3TOUT3_tout4StructPtr->CSC_Complex ; + + if ((here->SOI3tout4Node != 0) && (here->SOI3tout3Node != 0)) + here->SOI3TOUT4_tout3Ptr = here->SOI3TOUT4_tout3StructPtr->CSC_Complex ; + + if ((here->SOI3tout4Node != 0) && (here->SOI3tout4Node != 0)) + here->SOI3TOUT4_tout4Ptr = here->SOI3TOUT4_tout4StructPtr->CSC_Complex ; + + } + if ((here->SOI3toutNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3TOUT_toutPtr = here->SOI3TOUT_toutStructPtr->CSC_Complex ; + + if ((here->SOI3toutNode != 0) && (here->SOI3gfNode != 0)) + here->SOI3TOUT_gfPtr = here->SOI3TOUT_gfStructPtr->CSC_Complex ; + + if ((here->SOI3toutNode != 0) && (here->SOI3gbNode != 0)) + here->SOI3TOUT_gbPtr = here->SOI3TOUT_gbStructPtr->CSC_Complex ; + + if ((here->SOI3toutNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3TOUT_dpPtr = here->SOI3TOUT_dpStructPtr->CSC_Complex ; + + if ((here->SOI3toutNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3TOUT_spPtr = here->SOI3TOUT_spStructPtr->CSC_Complex ; + + if ((here->SOI3toutNode != 0) && (here->SOI3bNode != 0)) + here->SOI3TOUT_bPtr = here->SOI3TOUT_bStructPtr->CSC_Complex ; + + if ((here->SOI3gfNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3GF_toutPtr = here->SOI3GF_toutStructPtr->CSC_Complex ; + + if ((here->SOI3gbNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3GB_toutPtr = here->SOI3GB_toutStructPtr->CSC_Complex ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3toutNode != 0)) + here->SOI3DP_toutPtr = here->SOI3DP_toutStructPtr->CSC_Complex ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3toutNode != 0)) + here->SOI3SP_toutPtr = here->SOI3SP_toutStructPtr->CSC_Complex ; + + if ((here->SOI3bNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3B_toutPtr = here->SOI3B_toutStructPtr->CSC_Complex ; + + } + } + } + + return (OK) ; +} + +int +SOI3bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + SOI3model *model = (SOI3model *)inModel ; + SOI3instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the SOI3 models */ + for ( ; model != NULL ; model = model->SOI3nextModel) + { + /* loop through all the instances of the model */ + for (here = model->SOI3instances ; here != NULL ; here = here->SOI3nextInstance) + { + if ((here->SOI3dNode != 0) && (here->SOI3dNode != 0)) + here->SOI3D_dPtr = here->SOI3D_dStructPtr->CSC ; + + if ((here->SOI3dNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3D_dpPtr = here->SOI3D_dpStructPtr->CSC ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3dNode != 0)) + here->SOI3DP_dPtr = here->SOI3DP_dStructPtr->CSC ; + + if ((here->SOI3sNode != 0) && (here->SOI3sNode != 0)) + here->SOI3S_sPtr = here->SOI3S_sStructPtr->CSC ; + + if ((here->SOI3sNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3S_spPtr = here->SOI3S_spStructPtr->CSC ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3sNode != 0)) + here->SOI3SP_sPtr = here->SOI3SP_sStructPtr->CSC ; + + if ((here->SOI3gfNode != 0) && (here->SOI3gfNode != 0)) + here->SOI3GF_gfPtr = here->SOI3GF_gfStructPtr->CSC ; + + if ((here->SOI3gfNode != 0) && (here->SOI3gbNode != 0)) + here->SOI3GF_gbPtr = here->SOI3GF_gbStructPtr->CSC ; + + if ((here->SOI3gfNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3GF_dpPtr = here->SOI3GF_dpStructPtr->CSC ; + + if ((here->SOI3gfNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3GF_spPtr = here->SOI3GF_spStructPtr->CSC ; + + if ((here->SOI3gfNode != 0) && (here->SOI3bNode != 0)) + here->SOI3GF_bPtr = here->SOI3GF_bStructPtr->CSC ; + + if ((here->SOI3gbNode != 0) && (here->SOI3gfNode != 0)) + here->SOI3GB_gfPtr = here->SOI3GB_gfStructPtr->CSC ; + + if ((here->SOI3gbNode != 0) && (here->SOI3gbNode != 0)) + here->SOI3GB_gbPtr = here->SOI3GB_gbStructPtr->CSC ; + + if ((here->SOI3gbNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3GB_dpPtr = here->SOI3GB_dpStructPtr->CSC ; + + if ((here->SOI3gbNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3GB_spPtr = here->SOI3GB_spStructPtr->CSC ; + + if ((here->SOI3gbNode != 0) && (here->SOI3bNode != 0)) + here->SOI3GB_bPtr = here->SOI3GB_bStructPtr->CSC ; + + if ((here->SOI3bNode != 0) && (here->SOI3gfNode != 0)) + here->SOI3B_gfPtr = here->SOI3B_gfStructPtr->CSC ; + + if ((here->SOI3bNode != 0) && (here->SOI3gbNode != 0)) + here->SOI3B_gbPtr = here->SOI3B_gbStructPtr->CSC ; + + if ((here->SOI3bNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3B_dpPtr = here->SOI3B_dpStructPtr->CSC ; + + if ((here->SOI3bNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3B_spPtr = here->SOI3B_spStructPtr->CSC ; + + if ((here->SOI3bNode != 0) && (here->SOI3bNode != 0)) + here->SOI3B_bPtr = here->SOI3B_bStructPtr->CSC ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3gfNode != 0)) + here->SOI3DP_gfPtr = here->SOI3DP_gfStructPtr->CSC ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3gbNode != 0)) + here->SOI3DP_gbPtr = here->SOI3DP_gbStructPtr->CSC ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3DP_dpPtr = here->SOI3DP_dpStructPtr->CSC ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3DP_spPtr = here->SOI3DP_spStructPtr->CSC ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3bNode != 0)) + here->SOI3DP_bPtr = here->SOI3DP_bStructPtr->CSC ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3gfNode != 0)) + here->SOI3SP_gfPtr = here->SOI3SP_gfStructPtr->CSC ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3gbNode != 0)) + here->SOI3SP_gbPtr = here->SOI3SP_gbStructPtr->CSC ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3SP_dpPtr = here->SOI3SP_dpStructPtr->CSC ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3SP_spPtr = here->SOI3SP_spStructPtr->CSC ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3bNode != 0)) + here->SOI3SP_bPtr = here->SOI3SP_bStructPtr->CSC ; + + if (here->SOI3rt == 0) + { + if ((here->SOI3toutNode != 0) && (here->SOI3branch != 0)) + here->SOI3TOUT_ibrPtr = here->SOI3TOUT_ibrStructPtr->CSC ; + + if ((here->SOI3branch != 0) && (here->SOI3toutNode != 0)) + here->SOI3IBR_toutPtr = here->SOI3IBR_toutStructPtr->CSC ; + + } + else + { + if ((here->SOI3toutNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3TOUT_toutPtr = here->SOI3TOUT_toutStructPtr->CSC ; + + if (here->SOI3numThermalNodes > 1) + { + if ((here->SOI3toutNode != 0) && (here->SOI3tout1Node != 0)) + here->SOI3TOUT_tout1Ptr = here->SOI3TOUT_tout1StructPtr->CSC ; + + if ((here->SOI3tout1Node != 0) && (here->SOI3toutNode != 0)) + here->SOI3TOUT1_toutPtr = here->SOI3TOUT1_toutStructPtr->CSC ; + + if ((here->SOI3tout1Node != 0) && (here->SOI3tout1Node != 0)) + here->SOI3TOUT1_tout1Ptr = here->SOI3TOUT1_tout1StructPtr->CSC ; + + } + if (here->SOI3numThermalNodes > 2) + { + if ((here->SOI3tout1Node != 0) && (here->SOI3tout2Node != 0)) + here->SOI3TOUT1_tout2Ptr = here->SOI3TOUT1_tout2StructPtr->CSC ; + + if ((here->SOI3tout2Node != 0) && (here->SOI3tout1Node != 0)) + here->SOI3TOUT2_tout1Ptr = here->SOI3TOUT2_tout1StructPtr->CSC ; + + if ((here->SOI3tout2Node != 0) && (here->SOI3tout2Node != 0)) + here->SOI3TOUT2_tout2Ptr = here->SOI3TOUT2_tout2StructPtr->CSC ; + + } + if (here->SOI3numThermalNodes > 3) + { + if ((here->SOI3tout2Node != 0) && (here->SOI3tout3Node != 0)) + here->SOI3TOUT2_tout3Ptr = here->SOI3TOUT2_tout3StructPtr->CSC ; + + if ((here->SOI3tout3Node != 0) && (here->SOI3tout2Node != 0)) + here->SOI3TOUT3_tout2Ptr = here->SOI3TOUT3_tout2StructPtr->CSC ; + + if ((here->SOI3tout3Node != 0) && (here->SOI3tout3Node != 0)) + here->SOI3TOUT3_tout3Ptr = here->SOI3TOUT3_tout3StructPtr->CSC ; + + } + if (here->SOI3numThermalNodes > 4) + { + if ((here->SOI3tout3Node != 0) && (here->SOI3tout4Node != 0)) + here->SOI3TOUT3_tout4Ptr = here->SOI3TOUT3_tout4StructPtr->CSC ; + + if ((here->SOI3tout4Node != 0) && (here->SOI3tout3Node != 0)) + here->SOI3TOUT4_tout3Ptr = here->SOI3TOUT4_tout3StructPtr->CSC ; + + if ((here->SOI3tout4Node != 0) && (here->SOI3tout4Node != 0)) + here->SOI3TOUT4_tout4Ptr = here->SOI3TOUT4_tout4StructPtr->CSC ; + + } + if ((here->SOI3toutNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3TOUT_toutPtr = here->SOI3TOUT_toutStructPtr->CSC ; + + if ((here->SOI3toutNode != 0) && (here->SOI3gfNode != 0)) + here->SOI3TOUT_gfPtr = here->SOI3TOUT_gfStructPtr->CSC ; + + if ((here->SOI3toutNode != 0) && (here->SOI3gbNode != 0)) + here->SOI3TOUT_gbPtr = here->SOI3TOUT_gbStructPtr->CSC ; + + if ((here->SOI3toutNode != 0) && (here->SOI3dNodePrime != 0)) + here->SOI3TOUT_dpPtr = here->SOI3TOUT_dpStructPtr->CSC ; + + if ((here->SOI3toutNode != 0) && (here->SOI3sNodePrime != 0)) + here->SOI3TOUT_spPtr = here->SOI3TOUT_spStructPtr->CSC ; + + if ((here->SOI3toutNode != 0) && (here->SOI3bNode != 0)) + here->SOI3TOUT_bPtr = here->SOI3TOUT_bStructPtr->CSC ; + + if ((here->SOI3gfNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3GF_toutPtr = here->SOI3GF_toutStructPtr->CSC ; + + if ((here->SOI3gbNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3GB_toutPtr = here->SOI3GB_toutStructPtr->CSC ; + + if ((here->SOI3dNodePrime != 0) && (here->SOI3toutNode != 0)) + here->SOI3DP_toutPtr = here->SOI3DP_toutStructPtr->CSC ; + + if ((here->SOI3sNodePrime != 0) && (here->SOI3toutNode != 0)) + here->SOI3SP_toutPtr = here->SOI3SP_toutStructPtr->CSC ; + + if ((here->SOI3bNode != 0) && (here->SOI3toutNode != 0)) + here->SOI3B_toutPtr = here->SOI3B_toutStructPtr->CSC ; + + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/soi3/soi3defs.h b/src/spicelib/devices/soi3/soi3defs.h index 4d7dba923..a2fa91d84 100644 --- a/src/spicelib/devices/soi3/soi3defs.h +++ b/src/spicelib/devices/soi3/soi3defs.h @@ -321,6 +321,65 @@ typedef struct sSOI3instance { double **SOI3nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *SOI3D_dStructPtr ; + BindElement *SOI3D_dpStructPtr ; + BindElement *SOI3DP_dStructPtr ; + BindElement *SOI3S_sStructPtr ; + BindElement *SOI3S_spStructPtr ; + BindElement *SOI3SP_sStructPtr ; + BindElement *SOI3GF_gfStructPtr ; + BindElement *SOI3GF_gbStructPtr ; + BindElement *SOI3GF_dpStructPtr ; + BindElement *SOI3GF_spStructPtr ; + BindElement *SOI3GF_bStructPtr ; + BindElement *SOI3GB_gfStructPtr ; + BindElement *SOI3GB_gbStructPtr ; + BindElement *SOI3GB_dpStructPtr ; + BindElement *SOI3GB_spStructPtr ; + BindElement *SOI3GB_bStructPtr ; + BindElement *SOI3B_gfStructPtr ; + BindElement *SOI3B_gbStructPtr ; + BindElement *SOI3B_dpStructPtr ; + BindElement *SOI3B_spStructPtr ; + BindElement *SOI3B_bStructPtr ; + BindElement *SOI3DP_gfStructPtr ; + BindElement *SOI3DP_gbStructPtr ; + BindElement *SOI3DP_dpStructPtr ; + BindElement *SOI3DP_spStructPtr ; + BindElement *SOI3DP_bStructPtr ; + BindElement *SOI3SP_gfStructPtr ; + BindElement *SOI3SP_gbStructPtr ; + BindElement *SOI3SP_dpStructPtr ; + BindElement *SOI3SP_spStructPtr ; + BindElement *SOI3SP_bStructPtr ; + BindElement *SOI3TOUT_ibrStructPtr ; + BindElement *SOI3IBR_toutStructPtr ; + BindElement *SOI3TOUT_toutStructPtr ; + BindElement *SOI3TOUT_tout1StructPtr ; + BindElement *SOI3TOUT1_toutStructPtr ; + BindElement *SOI3TOUT1_tout1StructPtr ; + BindElement *SOI3TOUT1_tout2StructPtr ; + BindElement *SOI3TOUT2_tout1StructPtr ; + BindElement *SOI3TOUT2_tout2StructPtr ; + BindElement *SOI3TOUT2_tout3StructPtr ; + BindElement *SOI3TOUT3_tout2StructPtr ; + BindElement *SOI3TOUT3_tout3StructPtr ; + BindElement *SOI3TOUT3_tout4StructPtr ; + BindElement *SOI3TOUT4_tout3StructPtr ; + BindElement *SOI3TOUT4_tout4StructPtr ; + BindElement *SOI3TOUT_gfStructPtr ; + BindElement *SOI3TOUT_gbStructPtr ; + BindElement *SOI3TOUT_dpStructPtr ; + BindElement *SOI3TOUT_spStructPtr ; + BindElement *SOI3TOUT_bStructPtr ; + BindElement *SOI3GF_toutStructPtr ; + BindElement *SOI3GB_toutStructPtr ; + BindElement *SOI3DP_toutStructPtr ; + BindElement *SOI3SP_toutStructPtr ; + BindElement *SOI3B_toutStructPtr ; +#endif + } SOI3instance ; #define SOI3vbd SOI3states+ 0 /* bulk-drain voltage */ diff --git a/src/spicelib/devices/soi3/soi3ext.h b/src/spicelib/devices/soi3/soi3ext.h index c7e194acd..c43174c0c 100644 --- a/src/spicelib/devices/soi3/soi3ext.h +++ b/src/spicelib/devices/soi3/soi3ext.h @@ -65,3 +65,9 @@ extern int SOI3convTest(GENmodel*,CKTcircuit*); /* extern int SOI3disto(int,GENmodel*,CKTcircuit*); */ extern int SOI3noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); + +#ifdef KLU +extern int SOI3bindCSC (GENmodel*, CKTcircuit*) ; +extern int SOI3bindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int SOI3bindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/soi3/soi3init.c b/src/spicelib/devices/soi3/soi3init.c index 8d07f800f..a940c99f0 100644 --- a/src/spicelib/devices/soi3/soi3init.c +++ b/src/spicelib/devices/soi3/soi3init.c @@ -73,7 +73,13 @@ SPICEdev SOI3info = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &SOI3iSize, - /* DEVmodSize */ &SOI3mSize + /* DEVmodSize */ &SOI3mSize, + +#ifdef KLU + /* DEVbindCSC */ SOI3bindCSC, + /* DEVbindCSCComplex */ SOI3bindCSCComplex, + /* DEVbindCSCComplexToReal */ SOI3bindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/sw/Makefile.am b/src/spicelib/devices/sw/Makefile.am index 445c1a790..6451924ba 100644 --- a/src/spicelib/devices/sw/Makefile.am +++ b/src/spicelib/devices/sw/Makefile.am @@ -24,7 +24,11 @@ libsw_la_SOURCES = \ swtrunc.c +if KLU_WANTED +libsw_la_SOURCES += swbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/sw/swbindCSC.c b/src/spicelib/devices/sw/swbindCSC.c new file mode 100644 index 000000000..590cb535b --- /dev/null +++ b/src/spicelib/devices/sw/swbindCSC.c @@ -0,0 +1,141 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "swdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +SWbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + SWmodel *model = (SWmodel *)inModel ; + SWinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the SW models */ + for ( ; model != NULL ; model = model->SWnextModel) + { + /* loop through all the instances of the model */ + for (here = model->SWinstances ; here != NULL ; here = here->SWnextInstance) + { + if ((here-> SWposNode != 0) && (here-> SWposNode != 0)) + { + i = here->SWposPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SWposPosptrStructPtr = matched ; + here->SWposPosptr = matched->CSC ; + } + + if ((here-> SWposNode != 0) && (here-> SWnegNode != 0)) + { + i = here->SWposNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SWposNegptrStructPtr = matched ; + here->SWposNegptr = matched->CSC ; + } + + if ((here-> SWnegNode != 0) && (here-> SWposNode != 0)) + { + i = here->SWnegPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SWnegPosptrStructPtr = matched ; + here->SWnegPosptr = matched->CSC ; + } + + if ((here-> SWnegNode != 0) && (here-> SWnegNode != 0)) + { + i = here->SWnegNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->SWnegNegptrStructPtr = matched ; + here->SWnegNegptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +SWbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + SWmodel *model = (SWmodel *)inModel ; + SWinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the SW models */ + for ( ; model != NULL ; model = model->SWnextModel) + { + /* loop through all the instances of the model */ + for (here = model->SWinstances ; here != NULL ; here = here->SWnextInstance) + { + if ((here-> SWposNode != 0) && (here-> SWposNode != 0)) + here->SWposPosptr = here->SWposPosptrStructPtr->CSC_Complex ; + + if ((here-> SWposNode != 0) && (here-> SWnegNode != 0)) + here->SWposNegptr = here->SWposNegptrStructPtr->CSC_Complex ; + + if ((here-> SWnegNode != 0) && (here-> SWposNode != 0)) + here->SWnegPosptr = here->SWnegPosptrStructPtr->CSC_Complex ; + + if ((here-> SWnegNode != 0) && (here-> SWnegNode != 0)) + here->SWnegNegptr = here->SWnegNegptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +SWbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + SWmodel *model = (SWmodel *)inModel ; + SWinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the SW models */ + for ( ; model != NULL ; model = model->SWnextModel) + { + /* loop through all the instances of the model */ + for (here = model->SWinstances ; here != NULL ; here = here->SWnextInstance) + { + if ((here-> SWposNode != 0) && (here-> SWposNode != 0)) + here->SWposPosptr = here->SWposPosptrStructPtr->CSC ; + + if ((here-> SWposNode != 0) && (here-> SWnegNode != 0)) + here->SWposNegptr = here->SWposNegptrStructPtr->CSC ; + + if ((here-> SWnegNode != 0) && (here-> SWposNode != 0)) + here->SWnegPosptr = here->SWnegPosptrStructPtr->CSC ; + + if ((here-> SWnegNode != 0) && (here-> SWnegNode != 0)) + here->SWnegNegptr = here->SWnegNegptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/sw/swdefs.h b/src/spicelib/devices/sw/swdefs.h index 0a97c984e..0eecbdd08 100644 --- a/src/spicelib/devices/sw/swdefs.h +++ b/src/spicelib/devices/sw/swdefs.h @@ -47,6 +47,14 @@ typedef struct sSWinstance { #else /* NONOISE */ double *SWnVar; #endif /* NONOISE */ + +#ifdef KLU + BindElement *SWposPosptrStructPtr ; + BindElement *SWposNegptrStructPtr ; + BindElement *SWnegPosptrStructPtr ; + BindElement *SWnegNegptrStructPtr ; +#endif + } SWinstance ; /* data per model */ diff --git a/src/spicelib/devices/sw/swext.h b/src/spicelib/devices/sw/swext.h index ee447e7a9..bf86d278a 100644 --- a/src/spicelib/devices/sw/swext.h +++ b/src/spicelib/devices/sw/swext.h @@ -17,3 +17,9 @@ extern int SWpzLoad(GENmodel*,CKTcircuit*,SPcomplex*); extern int SWsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int SWnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int SWtrunc(GENmodel*,CKTcircuit*,double*); + +#ifdef KLU +extern int SWbindCSC (GENmodel*, CKTcircuit*) ; +extern int SWbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int SWbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/sw/swinit.c b/src/spicelib/devices/sw/swinit.c index 34b3ebc4c..5858018f9 100644 --- a/src/spicelib/devices/sw/swinit.c +++ b/src/spicelib/devices/sw/swinit.c @@ -74,7 +74,13 @@ SPICEdev SWinfo = { /* DEVacct */ NULL, #endif /* CIDER */ /* DEVinstSize */ &SWiSize, - /* DEVmodSize */ &SWmSize + /* DEVmodSize */ &SWmSize, + +#ifdef KLU + /* DEVbindCSC */ SWbindCSC, + /* DEVbindCSCComplex */ SWbindCSCComplex, + /* DEVbindCSCComplexToReal */ SWbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/tra/Makefile.am b/src/spicelib/devices/tra/Makefile.am index de708838f..5fb0a2eeb 100644 --- a/src/spicelib/devices/tra/Makefile.am +++ b/src/spicelib/devices/tra/Makefile.am @@ -22,6 +22,11 @@ libtra_la_SOURCES = \ tratrunc.c +if KLU_WANTED +libtra_la_SOURCES += trabindCSC.c +endif + AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/tra/trabindCSC.c b/src/spicelib/devices/tra/trabindCSC.c new file mode 100644 index 000000000..106c56991 --- /dev/null +++ b/src/spicelib/devices/tra/trabindCSC.c @@ -0,0 +1,393 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "tradefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +TRAbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + TRAmodel *model = (TRAmodel *)inModel ; + TRAinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the TRA models */ + for ( ; model != NULL ; model = model->TRAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->TRAinstances ; here != NULL ; here = here->TRAnextInstance) + { + if ((here-> TRAbrEq1 != 0) && (here-> TRAbrEq2 != 0)) + { + i = here->TRAibr1Ibr2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr1Ibr2StructPtr = matched ; + here->TRAibr1Ibr2Ptr = matched->CSC ; + } + + if ((here-> TRAbrEq1 != 0) && (here-> TRAintNode1 != 0)) + { + i = here->TRAibr1Int1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr1Int1StructPtr = matched ; + here->TRAibr1Int1Ptr = matched->CSC ; + } + + if ((here-> TRAbrEq1 != 0) && (here-> TRAnegNode1 != 0)) + { + i = here->TRAibr1Neg1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr1Neg1StructPtr = matched ; + here->TRAibr1Neg1Ptr = matched->CSC ; + } + + if ((here-> TRAbrEq1 != 0) && (here-> TRAnegNode2 != 0)) + { + i = here->TRAibr1Neg2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr1Neg2StructPtr = matched ; + here->TRAibr1Neg2Ptr = matched->CSC ; + } + + if ((here-> TRAbrEq1 != 0) && (here-> TRAposNode2 != 0)) + { + i = here->TRAibr1Pos2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr1Pos2StructPtr = matched ; + here->TRAibr1Pos2Ptr = matched->CSC ; + } + + if ((here-> TRAbrEq2 != 0) && (here-> TRAbrEq1 != 0)) + { + i = here->TRAibr2Ibr1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr2Ibr1StructPtr = matched ; + here->TRAibr2Ibr1Ptr = matched->CSC ; + } + + if ((here-> TRAbrEq2 != 0) && (here-> TRAintNode2 != 0)) + { + i = here->TRAibr2Int2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr2Int2StructPtr = matched ; + here->TRAibr2Int2Ptr = matched->CSC ; + } + + if ((here-> TRAbrEq2 != 0) && (here-> TRAnegNode1 != 0)) + { + i = here->TRAibr2Neg1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr2Neg1StructPtr = matched ; + here->TRAibr2Neg1Ptr = matched->CSC ; + } + + if ((here-> TRAbrEq2 != 0) && (here-> TRAnegNode2 != 0)) + { + i = here->TRAibr2Neg2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr2Neg2StructPtr = matched ; + here->TRAibr2Neg2Ptr = matched->CSC ; + } + + if ((here-> TRAbrEq2 != 0) && (here-> TRAposNode1 != 0)) + { + i = here->TRAibr2Pos1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAibr2Pos1StructPtr = matched ; + here->TRAibr2Pos1Ptr = matched->CSC ; + } + + if ((here-> TRAintNode1 != 0) && (here-> TRAbrEq1 != 0)) + { + i = here->TRAint1Ibr1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAint1Ibr1StructPtr = matched ; + here->TRAint1Ibr1Ptr = matched->CSC ; + } + + if ((here-> TRAintNode1 != 0) && (here-> TRAintNode1 != 0)) + { + i = here->TRAint1Int1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAint1Int1StructPtr = matched ; + here->TRAint1Int1Ptr = matched->CSC ; + } + + if ((here-> TRAintNode1 != 0) && (here-> TRAposNode1 != 0)) + { + i = here->TRAint1Pos1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAint1Pos1StructPtr = matched ; + here->TRAint1Pos1Ptr = matched->CSC ; + } + + if ((here-> TRAintNode2 != 0) && (here-> TRAbrEq2 != 0)) + { + i = here->TRAint2Ibr2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAint2Ibr2StructPtr = matched ; + here->TRAint2Ibr2Ptr = matched->CSC ; + } + + if ((here-> TRAintNode2 != 0) && (here-> TRAintNode2 != 0)) + { + i = here->TRAint2Int2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAint2Int2StructPtr = matched ; + here->TRAint2Int2Ptr = matched->CSC ; + } + + if ((here-> TRAintNode2 != 0) && (here-> TRAposNode2 != 0)) + { + i = here->TRAint2Pos2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAint2Pos2StructPtr = matched ; + here->TRAint2Pos2Ptr = matched->CSC ; + } + + if ((here-> TRAnegNode1 != 0) && (here-> TRAbrEq1 != 0)) + { + i = here->TRAneg1Ibr1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAneg1Ibr1StructPtr = matched ; + here->TRAneg1Ibr1Ptr = matched->CSC ; + } + + if ((here-> TRAnegNode2 != 0) && (here-> TRAbrEq2 != 0)) + { + i = here->TRAneg2Ibr2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRAneg2Ibr2StructPtr = matched ; + here->TRAneg2Ibr2Ptr = matched->CSC ; + } + + if ((here-> TRAposNode1 != 0) && (here-> TRAintNode1 != 0)) + { + i = here->TRApos1Int1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRApos1Int1StructPtr = matched ; + here->TRApos1Int1Ptr = matched->CSC ; + } + + if ((here-> TRAposNode1 != 0) && (here-> TRAposNode1 != 0)) + { + i = here->TRApos1Pos1Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRApos1Pos1StructPtr = matched ; + here->TRApos1Pos1Ptr = matched->CSC ; + } + + if ((here-> TRAposNode2 != 0) && (here-> TRAintNode2 != 0)) + { + i = here->TRApos2Int2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRApos2Int2StructPtr = matched ; + here->TRApos2Int2Ptr = matched->CSC ; + } + + if ((here-> TRAposNode2 != 0) && (here-> TRAposNode2 != 0)) + { + i = here->TRApos2Pos2Ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TRApos2Pos2StructPtr = matched ; + here->TRApos2Pos2Ptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +TRAbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + TRAmodel *model = (TRAmodel *)inModel ; + TRAinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the TRA models */ + for ( ; model != NULL ; model = model->TRAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->TRAinstances ; here != NULL ; here = here->TRAnextInstance) + { + if ((here-> TRAbrEq1 != 0) && (here-> TRAbrEq2 != 0)) + here->TRAibr1Ibr2Ptr = here->TRAibr1Ibr2StructPtr->CSC_Complex ; + + if ((here-> TRAbrEq1 != 0) && (here-> TRAintNode1 != 0)) + here->TRAibr1Int1Ptr = here->TRAibr1Int1StructPtr->CSC_Complex ; + + if ((here-> TRAbrEq1 != 0) && (here-> TRAnegNode1 != 0)) + here->TRAibr1Neg1Ptr = here->TRAibr1Neg1StructPtr->CSC_Complex ; + + if ((here-> TRAbrEq1 != 0) && (here-> TRAnegNode2 != 0)) + here->TRAibr1Neg2Ptr = here->TRAibr1Neg2StructPtr->CSC_Complex ; + + if ((here-> TRAbrEq1 != 0) && (here-> TRAposNode2 != 0)) + here->TRAibr1Pos2Ptr = here->TRAibr1Pos2StructPtr->CSC_Complex ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAbrEq1 != 0)) + here->TRAibr2Ibr1Ptr = here->TRAibr2Ibr1StructPtr->CSC_Complex ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAintNode2 != 0)) + here->TRAibr2Int2Ptr = here->TRAibr2Int2StructPtr->CSC_Complex ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAnegNode1 != 0)) + here->TRAibr2Neg1Ptr = here->TRAibr2Neg1StructPtr->CSC_Complex ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAnegNode2 != 0)) + here->TRAibr2Neg2Ptr = here->TRAibr2Neg2StructPtr->CSC_Complex ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAposNode1 != 0)) + here->TRAibr2Pos1Ptr = here->TRAibr2Pos1StructPtr->CSC_Complex ; + + if ((here-> TRAintNode1 != 0) && (here-> TRAbrEq1 != 0)) + here->TRAint1Ibr1Ptr = here->TRAint1Ibr1StructPtr->CSC_Complex ; + + if ((here-> TRAintNode1 != 0) && (here-> TRAintNode1 != 0)) + here->TRAint1Int1Ptr = here->TRAint1Int1StructPtr->CSC_Complex ; + + if ((here-> TRAintNode1 != 0) && (here-> TRAposNode1 != 0)) + here->TRAint1Pos1Ptr = here->TRAint1Pos1StructPtr->CSC_Complex ; + + if ((here-> TRAintNode2 != 0) && (here-> TRAbrEq2 != 0)) + here->TRAint2Ibr2Ptr = here->TRAint2Ibr2StructPtr->CSC_Complex ; + + if ((here-> TRAintNode2 != 0) && (here-> TRAintNode2 != 0)) + here->TRAint2Int2Ptr = here->TRAint2Int2StructPtr->CSC_Complex ; + + if ((here-> TRAintNode2 != 0) && (here-> TRAposNode2 != 0)) + here->TRAint2Pos2Ptr = here->TRAint2Pos2StructPtr->CSC_Complex ; + + if ((here-> TRAnegNode1 != 0) && (here-> TRAbrEq1 != 0)) + here->TRAneg1Ibr1Ptr = here->TRAneg1Ibr1StructPtr->CSC_Complex ; + + if ((here-> TRAnegNode2 != 0) && (here-> TRAbrEq2 != 0)) + here->TRAneg2Ibr2Ptr = here->TRAneg2Ibr2StructPtr->CSC_Complex ; + + if ((here-> TRAposNode1 != 0) && (here-> TRAintNode1 != 0)) + here->TRApos1Int1Ptr = here->TRApos1Int1StructPtr->CSC_Complex ; + + if ((here-> TRAposNode1 != 0) && (here-> TRAposNode1 != 0)) + here->TRApos1Pos1Ptr = here->TRApos1Pos1StructPtr->CSC_Complex ; + + if ((here-> TRAposNode2 != 0) && (here-> TRAintNode2 != 0)) + here->TRApos2Int2Ptr = here->TRApos2Int2StructPtr->CSC_Complex ; + + if ((here-> TRAposNode2 != 0) && (here-> TRAposNode2 != 0)) + here->TRApos2Pos2Ptr = here->TRApos2Pos2StructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +TRAbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + TRAmodel *model = (TRAmodel *)inModel ; + TRAinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the TRA models */ + for ( ; model != NULL ; model = model->TRAnextModel) + { + /* loop through all the instances of the model */ + for (here = model->TRAinstances ; here != NULL ; here = here->TRAnextInstance) + { + if ((here-> TRAbrEq1 != 0) && (here-> TRAbrEq2 != 0)) + here->TRAibr1Ibr2Ptr = here->TRAibr1Ibr2StructPtr->CSC ; + + if ((here-> TRAbrEq1 != 0) && (here-> TRAintNode1 != 0)) + here->TRAibr1Int1Ptr = here->TRAibr1Int1StructPtr->CSC ; + + if ((here-> TRAbrEq1 != 0) && (here-> TRAnegNode1 != 0)) + here->TRAibr1Neg1Ptr = here->TRAibr1Neg1StructPtr->CSC ; + + if ((here-> TRAbrEq1 != 0) && (here-> TRAnegNode2 != 0)) + here->TRAibr1Neg2Ptr = here->TRAibr1Neg2StructPtr->CSC ; + + if ((here-> TRAbrEq1 != 0) && (here-> TRAposNode2 != 0)) + here->TRAibr1Pos2Ptr = here->TRAibr1Pos2StructPtr->CSC ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAbrEq1 != 0)) + here->TRAibr2Ibr1Ptr = here->TRAibr2Ibr1StructPtr->CSC ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAintNode2 != 0)) + here->TRAibr2Int2Ptr = here->TRAibr2Int2StructPtr->CSC ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAnegNode1 != 0)) + here->TRAibr2Neg1Ptr = here->TRAibr2Neg1StructPtr->CSC ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAnegNode2 != 0)) + here->TRAibr2Neg2Ptr = here->TRAibr2Neg2StructPtr->CSC ; + + if ((here-> TRAbrEq2 != 0) && (here-> TRAposNode1 != 0)) + here->TRAibr2Pos1Ptr = here->TRAibr2Pos1StructPtr->CSC ; + + if ((here-> TRAintNode1 != 0) && (here-> TRAbrEq1 != 0)) + here->TRAint1Ibr1Ptr = here->TRAint1Ibr1StructPtr->CSC ; + + if ((here-> TRAintNode1 != 0) && (here-> TRAintNode1 != 0)) + here->TRAint1Int1Ptr = here->TRAint1Int1StructPtr->CSC ; + + if ((here-> TRAintNode1 != 0) && (here-> TRAposNode1 != 0)) + here->TRAint1Pos1Ptr = here->TRAint1Pos1StructPtr->CSC ; + + if ((here-> TRAintNode2 != 0) && (here-> TRAbrEq2 != 0)) + here->TRAint2Ibr2Ptr = here->TRAint2Ibr2StructPtr->CSC ; + + if ((here-> TRAintNode2 != 0) && (here-> TRAintNode2 != 0)) + here->TRAint2Int2Ptr = here->TRAint2Int2StructPtr->CSC ; + + if ((here-> TRAintNode2 != 0) && (here-> TRAposNode2 != 0)) + here->TRAint2Pos2Ptr = here->TRAint2Pos2StructPtr->CSC ; + + if ((here-> TRAnegNode1 != 0) && (here-> TRAbrEq1 != 0)) + here->TRAneg1Ibr1Ptr = here->TRAneg1Ibr1StructPtr->CSC ; + + if ((here-> TRAnegNode2 != 0) && (here-> TRAbrEq2 != 0)) + here->TRAneg2Ibr2Ptr = here->TRAneg2Ibr2StructPtr->CSC ; + + if ((here-> TRAposNode1 != 0) && (here-> TRAintNode1 != 0)) + here->TRApos1Int1Ptr = here->TRApos1Int1StructPtr->CSC ; + + if ((here-> TRAposNode1 != 0) && (here-> TRAposNode1 != 0)) + here->TRApos1Pos1Ptr = here->TRApos1Pos1StructPtr->CSC ; + + if ((here-> TRAposNode2 != 0) && (here-> TRAintNode2 != 0)) + here->TRApos2Int2Ptr = here->TRApos2Int2StructPtr->CSC ; + + if ((here-> TRAposNode2 != 0) && (here-> TRAposNode2 != 0)) + here->TRApos2Pos2Ptr = here->TRApos2Pos2StructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/tra/tradefs.h b/src/spicelib/devices/tra/tradefs.h index 17b158c1e..aaa844015 100644 --- a/src/spicelib/devices/tra/tradefs.h +++ b/src/spicelib/devices/tra/tradefs.h @@ -80,6 +80,32 @@ typedef struct sTRAinstance { unsigned TRAicC2Given : 1; /* flag to ind. init. current at port 2 given */ unsigned TRAreltolGiven:1; /* flag to ind. relative deriv. tol. given */ unsigned TRAabstolGiven:1; /* flag to ind. absolute deriv. tol. given */ + +#ifdef KLU + BindElement *TRAibr1Ibr2StructPtr ; + BindElement *TRAibr1Int1StructPtr ; + BindElement *TRAibr1Neg1StructPtr ; + BindElement *TRAibr1Neg2StructPtr ; + BindElement *TRAibr1Pos2StructPtr ; + BindElement *TRAibr2Ibr1StructPtr ; + BindElement *TRAibr2Int2StructPtr ; + BindElement *TRAibr2Neg1StructPtr ; + BindElement *TRAibr2Neg2StructPtr ; + BindElement *TRAibr2Pos1StructPtr ; + BindElement *TRAint1Ibr1StructPtr ; + BindElement *TRAint1Int1StructPtr ; + BindElement *TRAint1Pos1StructPtr ; + BindElement *TRAint2Ibr2StructPtr ; + BindElement *TRAint2Int2StructPtr ; + BindElement *TRAint2Pos2StructPtr ; + BindElement *TRAneg1Ibr1StructPtr ; + BindElement *TRAneg2Ibr2StructPtr ; + BindElement *TRApos1Int1StructPtr ; + BindElement *TRApos1Pos1StructPtr ; + BindElement *TRApos2Int2StructPtr ; + BindElement *TRApos2Pos2StructPtr ; +#endif + } TRAinstance ; diff --git a/src/spicelib/devices/tra/traext.h b/src/spicelib/devices/tra/traext.h index 95a1d2b25..ab47ed5c8 100644 --- a/src/spicelib/devices/tra/traext.h +++ b/src/spicelib/devices/tra/traext.h @@ -16,3 +16,9 @@ extern int TRAsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int TRAunsetup(GENmodel*,CKTcircuit*); extern int TRAtemp(GENmodel*,CKTcircuit*); extern int TRAtrunc(GENmodel*,CKTcircuit*,double*); + +#ifdef KLU +extern int TRAbindCSC (GENmodel*, CKTcircuit*) ; +extern int TRAbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int TRAbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/tra/trainit.c b/src/spicelib/devices/tra/trainit.c index 8543f08da..769a22c1f 100644 --- a/src/spicelib/devices/tra/trainit.c +++ b/src/spicelib/devices/tra/trainit.c @@ -73,7 +73,13 @@ SPICEdev TRAinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &TRAiSize, - /* DEVmodSize */ &TRAmSize + /* DEVmodSize */ &TRAmSize, + +#ifdef KLU + /* DEVbindCSC */ TRAbindCSC, + /* DEVbindCSCComplex */ TRAbindCSCComplex, + /* DEVbindCSCComplexToReal */ TRAbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/txl/Makefile.am b/src/spicelib/devices/txl/Makefile.am index 0e07d1a38..25e7c4d9a 100644 --- a/src/spicelib/devices/txl/Makefile.am +++ b/src/spicelib/devices/txl/Makefile.am @@ -21,6 +21,11 @@ libtxl_la_SOURCES = \ txlsetup.c \ txlinit.c + +if KLU_WANTED +libtxl_la_SOURCES += txlbindCSC.c +endif + AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/txl/txlbindCSC.c b/src/spicelib/devices/txl/txlbindCSC.c new file mode 100644 index 000000000..0be160b0a --- /dev/null +++ b/src/spicelib/devices/txl/txlbindCSC.c @@ -0,0 +1,281 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "txldefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +TXLbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + TXLmodel *model = (TXLmodel *)inModel ; + TXLinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the TXL models */ + for ( ; model != NULL ; model = model->TXLnextModel) + { + /* loop through all the instances of the model */ + for (here = model->TXLinstances ; here != NULL ; here = here->TXLnextInstance) + { + if ((here-> TXLposNode != 0) && (here-> TXLposNode != 0)) + { + i = here->TXLposPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLposPosptrStructPtr = matched ; + here->TXLposPosptr = matched->CSC ; + } + + if ((here-> TXLposNode != 0) && (here-> TXLnegNode != 0)) + { + i = here->TXLposNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLposNegptrStructPtr = matched ; + here->TXLposNegptr = matched->CSC ; + } + + if ((here-> TXLnegNode != 0) && (here-> TXLposNode != 0)) + { + i = here->TXLnegPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLnegPosptrStructPtr = matched ; + here->TXLnegPosptr = matched->CSC ; + } + + if ((here-> TXLnegNode != 0) && (here-> TXLnegNode != 0)) + { + i = here->TXLnegNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLnegNegptrStructPtr = matched ; + here->TXLnegNegptr = matched->CSC ; + } + + if ((here-> TXLibr1 != 0) && (here-> TXLposNode != 0)) + { + i = here->TXLibr1Posptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr1PosptrStructPtr = matched ; + here->TXLibr1Posptr = matched->CSC ; + } + + if ((here-> TXLibr2 != 0) && (here-> TXLnegNode != 0)) + { + i = here->TXLibr2Negptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr2NegptrStructPtr = matched ; + here->TXLibr2Negptr = matched->CSC ; + } + + if ((here-> TXLnegNode != 0) && (here-> TXLibr2 != 0)) + { + i = here->TXLnegIbr2ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLnegIbr2ptrStructPtr = matched ; + here->TXLnegIbr2ptr = matched->CSC ; + } + + if ((here-> TXLposNode != 0) && (here-> TXLibr1 != 0)) + { + i = here->TXLposIbr1ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLposIbr1ptrStructPtr = matched ; + here->TXLposIbr1ptr = matched->CSC ; + } + + if ((here-> TXLibr1 != 0) && (here-> TXLibr1 != 0)) + { + i = here->TXLibr1Ibr1ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr1Ibr1ptrStructPtr = matched ; + here->TXLibr1Ibr1ptr = matched->CSC ; + } + + if ((here-> TXLibr2 != 0) && (here-> TXLibr2 != 0)) + { + i = here->TXLibr2Ibr2ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr2Ibr2ptrStructPtr = matched ; + here->TXLibr2Ibr2ptr = matched->CSC ; + } + + if ((here-> TXLibr1 != 0) && (here-> TXLnegNode != 0)) + { + i = here->TXLibr1Negptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr1NegptrStructPtr = matched ; + here->TXLibr1Negptr = matched->CSC ; + } + + if ((here-> TXLibr2 != 0) && (here-> TXLposNode != 0)) + { + i = here->TXLibr2Posptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr2PosptrStructPtr = matched ; + here->TXLibr2Posptr = matched->CSC ; + } + + if ((here-> TXLibr1 != 0) && (here-> TXLibr2 != 0)) + { + i = here->TXLibr1Ibr2ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr1Ibr2ptrStructPtr = matched ; + here->TXLibr1Ibr2ptr = matched->CSC ; + } + + if ((here-> TXLibr2 != 0) && (here-> TXLibr1 != 0)) + { + i = here->TXLibr2Ibr1ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr2Ibr1ptrStructPtr = matched ; + here->TXLibr2Ibr1ptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +TXLbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + TXLmodel *model = (TXLmodel *)inModel ; + TXLinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the TXL models */ + for ( ; model != NULL ; model = model->TXLnextModel) + { + /* loop through all the instances of the model */ + for (here = model->TXLinstances ; here != NULL ; here = here->TXLnextInstance) + { + if ((here-> TXLposNode != 0) && (here-> TXLposNode != 0)) + here->TXLposPosptr = here->TXLposPosptrStructPtr->CSC_Complex ; + + if ((here-> TXLposNode != 0) && (here-> TXLnegNode != 0)) + here->TXLposNegptr = here->TXLposNegptrStructPtr->CSC_Complex ; + + if ((here-> TXLnegNode != 0) && (here-> TXLposNode != 0)) + here->TXLnegPosptr = here->TXLnegPosptrStructPtr->CSC_Complex ; + + if ((here-> TXLnegNode != 0) && (here-> TXLnegNode != 0)) + here->TXLnegNegptr = here->TXLnegNegptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr1 != 0) && (here-> TXLposNode != 0)) + here->TXLibr1Posptr = here->TXLibr1PosptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr2 != 0) && (here-> TXLnegNode != 0)) + here->TXLibr2Negptr = here->TXLibr2NegptrStructPtr->CSC_Complex ; + + if ((here-> TXLnegNode != 0) && (here-> TXLibr2 != 0)) + here->TXLnegIbr2ptr = here->TXLnegIbr2ptrStructPtr->CSC_Complex ; + + if ((here-> TXLposNode != 0) && (here-> TXLibr1 != 0)) + here->TXLposIbr1ptr = here->TXLposIbr1ptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr1 != 0) && (here-> TXLibr1 != 0)) + here->TXLibr1Ibr1ptr = here->TXLibr1Ibr1ptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr2 != 0) && (here-> TXLibr2 != 0)) + here->TXLibr2Ibr2ptr = here->TXLibr2Ibr2ptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr1 != 0) && (here-> TXLnegNode != 0)) + here->TXLibr1Negptr = here->TXLibr1NegptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr2 != 0) && (here-> TXLposNode != 0)) + here->TXLibr2Posptr = here->TXLibr2PosptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr1 != 0) && (here-> TXLibr2 != 0)) + here->TXLibr1Ibr2ptr = here->TXLibr1Ibr2ptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr2 != 0) && (here-> TXLibr1 != 0)) + here->TXLibr2Ibr1ptr = here->TXLibr2Ibr1ptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +TXLbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + TXLmodel *model = (TXLmodel *)inModel ; + TXLinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the TXL models */ + for ( ; model != NULL ; model = model->TXLnextModel) + { + /* loop through all the instances of the model */ + for (here = model->TXLinstances ; here != NULL ; here = here->TXLnextInstance) + { + if ((here-> TXLposNode != 0) && (here-> TXLposNode != 0)) + here->TXLposPosptr = here->TXLposPosptrStructPtr->CSC ; + + if ((here-> TXLposNode != 0) && (here-> TXLnegNode != 0)) + here->TXLposNegptr = here->TXLposNegptrStructPtr->CSC ; + + if ((here-> TXLnegNode != 0) && (here-> TXLposNode != 0)) + here->TXLnegPosptr = here->TXLnegPosptrStructPtr->CSC ; + + if ((here-> TXLnegNode != 0) && (here-> TXLnegNode != 0)) + here->TXLnegNegptr = here->TXLnegNegptrStructPtr->CSC ; + + if ((here-> TXLibr1 != 0) && (here-> TXLposNode != 0)) + here->TXLibr1Posptr = here->TXLibr1PosptrStructPtr->CSC ; + + if ((here-> TXLibr2 != 0) && (here-> TXLnegNode != 0)) + here->TXLibr2Negptr = here->TXLibr2NegptrStructPtr->CSC ; + + if ((here-> TXLnegNode != 0) && (here-> TXLibr2 != 0)) + here->TXLnegIbr2ptr = here->TXLnegIbr2ptrStructPtr->CSC ; + + if ((here-> TXLposNode != 0) && (here-> TXLibr1 != 0)) + here->TXLposIbr1ptr = here->TXLposIbr1ptrStructPtr->CSC ; + + if ((here-> TXLibr1 != 0) && (here-> TXLibr1 != 0)) + here->TXLibr1Ibr1ptr = here->TXLibr1Ibr1ptrStructPtr->CSC ; + + if ((here-> TXLibr2 != 0) && (here-> TXLibr2 != 0)) + here->TXLibr2Ibr2ptr = here->TXLibr2Ibr2ptrStructPtr->CSC ; + + if ((here-> TXLibr1 != 0) && (here-> TXLnegNode != 0)) + here->TXLibr1Negptr = here->TXLibr1NegptrStructPtr->CSC ; + + if ((here-> TXLibr2 != 0) && (here-> TXLposNode != 0)) + here->TXLibr2Posptr = here->TXLibr2PosptrStructPtr->CSC ; + + if ((here-> TXLibr1 != 0) && (here-> TXLibr2 != 0)) + here->TXLibr1Ibr2ptr = here->TXLibr1Ibr2ptrStructPtr->CSC ; + + if ((here-> TXLibr2 != 0) && (here-> TXLibr1 != 0)) + here->TXLibr2Ibr1ptr = here->TXLibr2Ibr1ptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/txl/txldefs.h b/src/spicelib/devices/txl/txldefs.h index 7452ea385..df3b71e87 100644 --- a/src/spicelib/devices/txl/txldefs.h +++ b/src/spicelib/devices/txl/txldefs.h @@ -49,6 +49,23 @@ typedef struct sTXLinstance { unsigned TXLdcGiven : 1; unsigned TXLlengthgiven : 1; /* flag to indicate that instance parameter len is specified */ +#ifdef KLU + BindElement *TXLposPosptrStructPtr ; + BindElement *TXLposNegptrStructPtr ; + BindElement *TXLnegPosptrStructPtr ; + BindElement *TXLnegNegptrStructPtr ; + BindElement *TXLibr1PosptrStructPtr ; + BindElement *TXLibr2NegptrStructPtr ; + BindElement *TXLnegIbr2ptrStructPtr ; + BindElement *TXLposIbr1ptrStructPtr ; + BindElement *TXLibr1Ibr1ptrStructPtr ; + BindElement *TXLibr2Ibr2ptrStructPtr ; + BindElement *TXLibr1NegptrStructPtr ; + BindElement *TXLibr2PosptrStructPtr ; + BindElement *TXLibr1Ibr2ptrStructPtr ; + BindElement *TXLibr2Ibr1ptrStructPtr ; +#endif + } TXLinstance ; diff --git a/src/spicelib/devices/txl/txlext.h b/src/spicelib/devices/txl/txlext.h index 1211b71d0..0d24c1119 100644 --- a/src/spicelib/devices/txl/txlext.h +++ b/src/spicelib/devices/txl/txlext.h @@ -12,3 +12,9 @@ extern int TXLmParam(int,IFvalue*,GENmodel*); extern int TXLparam(int,IFvalue*,GENinstance*,IFvalue*); extern int TXLsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int TXLunsetup(GENmodel*, CKTcircuit*); + +#ifdef KLU +extern int TXLbindCSC (GENmodel*, CKTcircuit*) ; +extern int TXLbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int TXLbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/txl/txlinit.c b/src/spicelib/devices/txl/txlinit.c index 4c4e6d3f3..13ba4c16e 100644 --- a/src/spicelib/devices/txl/txlinit.c +++ b/src/spicelib/devices/txl/txlinit.c @@ -78,7 +78,13 @@ SPICEdev TXLinfo = { /* DEVacct */ NULL, #endif &TXLiSize, - &TXLmSize + &TXLmSize, + +#ifdef KLU + /* DEVbindCSC */ TXLbindCSC, + /* DEVbindCSCComplex */ TXLbindCSCComplex, + /* DEVbindCSCComplexToReal */ TXLbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/urc/urcinit.c b/src/spicelib/devices/urc/urcinit.c index 0211d14a0..8950ab0ac 100644 --- a/src/spicelib/devices/urc/urcinit.c +++ b/src/spicelib/devices/urc/urcinit.c @@ -73,7 +73,13 @@ SPICEdev URCinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &URCiSize, - /* DEVmodSize */ &URCmSize + /* DEVmodSize */ &URCmSize, + +#ifdef KLU + /* DEVbindCSC */ NULL, + /* DEVbindCSCComplex */ NULL, + /* DEVbindCSCComplexToReal */ NULL, +#endif }; diff --git a/src/spicelib/devices/vbic/Makefile.am b/src/spicelib/devices/vbic/Makefile.am index a0aee2cb8..189cdb458 100644 --- a/src/spicelib/devices/vbic/Makefile.am +++ b/src/spicelib/devices/vbic/Makefile.am @@ -28,6 +28,9 @@ libvbic_la_SOURCES = \ vbictrunc.c +if KLU_WANTED +libvbic_la_SOURCES += vbicbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/vbic/vbicbindCSC.c b/src/spicelib/devices/vbic/vbicbindCSC.c new file mode 100644 index 000000000..9697909dc --- /dev/null +++ b/src/spicelib/devices/vbic/vbicbindCSC.c @@ -0,0 +1,799 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "vbicdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +VBICbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + VBICmodel *model = (VBICmodel *)inModel ; + VBICinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the VBIC models */ + for ( ; model != NULL ; model = model->VBICnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VBICinstances ; here != NULL ; here = here->VBICnextInstance) + { + if ((here->VBICcollNode != 0) && (here->VBICcollNode != 0)) + { + i = here->VBICcollCollPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCollStructPtr = matched ; + here->VBICcollCollPtr = matched->CSC ; + } + + if ((here->VBICbaseNode != 0) && (here->VBICbaseNode != 0)) + { + i = here->VBICbaseBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBaseStructPtr = matched ; + here->VBICbaseBasePtr = matched->CSC ; + } + + if ((here->VBICemitNode != 0) && (here->VBICemitNode != 0)) + { + i = here->VBICemitEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICemitEmitStructPtr = matched ; + here->VBICemitEmitPtr = matched->CSC ; + } + + if ((here->VBICsubsNode != 0) && (here->VBICsubsNode != 0)) + { + i = here->VBICsubsSubsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICsubsSubsStructPtr = matched ; + here->VBICsubsSubsPtr = matched->CSC ; + } + + if ((here->VBICcollCXNode != 0) && (here->VBICcollCXNode != 0)) + { + i = here->VBICcollCXCollCXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCXCollCXStructPtr = matched ; + here->VBICcollCXCollCXPtr = matched->CSC ; + } + + if ((here->VBICcollCINode != 0) && (here->VBICcollCINode != 0)) + { + i = here->VBICcollCICollCIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCICollCIStructPtr = matched ; + here->VBICcollCICollCIPtr = matched->CSC ; + } + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseBXNode != 0)) + { + i = here->VBICbaseBXBaseBXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBXBaseBXStructPtr = matched ; + here->VBICbaseBXBaseBXPtr = matched->CSC ; + } + + if ((here->VBICbaseBINode != 0) && (here->VBICbaseBINode != 0)) + { + i = here->VBICbaseBIBaseBIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBIBaseBIStructPtr = matched ; + here->VBICbaseBIBaseBIPtr = matched->CSC ; + } + + if ((here->VBICemitEINode != 0) && (here->VBICemitEINode != 0)) + { + i = here->VBICemitEIEmitEIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICemitEIEmitEIStructPtr = matched ; + here->VBICemitEIEmitEIPtr = matched->CSC ; + } + + if ((here->VBICbaseBPNode != 0) && (here->VBICbaseBPNode != 0)) + { + i = here->VBICbaseBPBaseBPPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBPBaseBPStructPtr = matched ; + here->VBICbaseBPBaseBPPtr = matched->CSC ; + } + + if ((here->VBICsubsSINode != 0) && (here->VBICsubsSINode != 0)) + { + i = here->VBICsubsSISubsSIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICsubsSISubsSIStructPtr = matched ; + here->VBICsubsSISubsSIPtr = matched->CSC ; + } + + if ((here->VBICbaseNode != 0) && (here->VBICemitNode != 0)) + { + i = here->VBICbaseEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseEmitStructPtr = matched ; + here->VBICbaseEmitPtr = matched->CSC ; + } + + if ((here->VBICemitNode != 0) && (here->VBICbaseNode != 0)) + { + i = here->VBICemitBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICemitBaseStructPtr = matched ; + here->VBICemitBasePtr = matched->CSC ; + } + + if ((here->VBICbaseNode != 0) && (here->VBICcollNode != 0)) + { + i = here->VBICbaseCollPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseCollStructPtr = matched ; + here->VBICbaseCollPtr = matched->CSC ; + } + + if ((here->VBICcollNode != 0) && (here->VBICbaseNode != 0)) + { + i = here->VBICcollBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollBaseStructPtr = matched ; + here->VBICcollBasePtr = matched->CSC ; + } + + if ((here->VBICcollNode != 0) && (here->VBICcollCXNode != 0)) + { + i = here->VBICcollCollCXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCollCXStructPtr = matched ; + here->VBICcollCollCXPtr = matched->CSC ; + } + + if ((here->VBICbaseNode != 0) && (here->VBICbaseBXNode != 0)) + { + i = here->VBICbaseBaseBXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBaseBXStructPtr = matched ; + here->VBICbaseBaseBXPtr = matched->CSC ; + } + + if ((here->VBICemitNode != 0) && (here->VBICemitEINode != 0)) + { + i = here->VBICemitEmitEIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICemitEmitEIStructPtr = matched ; + here->VBICemitEmitEIPtr = matched->CSC ; + } + + if ((here->VBICsubsNode != 0) && (here->VBICsubsSINode != 0)) + { + i = here->VBICsubsSubsSIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICsubsSubsSIStructPtr = matched ; + here->VBICsubsSubsSIPtr = matched->CSC ; + } + + if ((here->VBICcollCXNode != 0) && (here->VBICcollCINode != 0)) + { + i = here->VBICcollCXCollCIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCXCollCIStructPtr = matched ; + here->VBICcollCXCollCIPtr = matched->CSC ; + } + + if ((here->VBICcollCXNode != 0) && (here->VBICbaseBXNode != 0)) + { + i = here->VBICcollCXBaseBXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCXBaseBXStructPtr = matched ; + here->VBICcollCXBaseBXPtr = matched->CSC ; + } + + if ((here->VBICcollCXNode != 0) && (here->VBICbaseBINode != 0)) + { + i = here->VBICcollCXBaseBIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCXBaseBIStructPtr = matched ; + here->VBICcollCXBaseBIPtr = matched->CSC ; + } + + if ((here->VBICcollCXNode != 0) && (here->VBICbaseBPNode != 0)) + { + i = here->VBICcollCXBaseBPPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCXBaseBPStructPtr = matched ; + here->VBICcollCXBaseBPPtr = matched->CSC ; + } + + if ((here->VBICcollCINode != 0) && (here->VBICbaseBINode != 0)) + { + i = here->VBICcollCIBaseBIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCIBaseBIStructPtr = matched ; + here->VBICcollCIBaseBIPtr = matched->CSC ; + } + + if ((here->VBICcollCINode != 0) && (here->VBICemitEINode != 0)) + { + i = here->VBICcollCIEmitEIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCIEmitEIStructPtr = matched ; + here->VBICcollCIEmitEIPtr = matched->CSC ; + } + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseBINode != 0)) + { + i = here->VBICbaseBXBaseBIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBXBaseBIStructPtr = matched ; + here->VBICbaseBXBaseBIPtr = matched->CSC ; + } + + if ((here->VBICbaseBXNode != 0) && (here->VBICemitEINode != 0)) + { + i = here->VBICbaseBXEmitEIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBXEmitEIStructPtr = matched ; + here->VBICbaseBXEmitEIPtr = matched->CSC ; + } + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseBPNode != 0)) + { + i = here->VBICbaseBXBaseBPPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBXBaseBPStructPtr = matched ; + here->VBICbaseBXBaseBPPtr = matched->CSC ; + } + + if ((here->VBICbaseBXNode != 0) && (here->VBICsubsSINode != 0)) + { + i = here->VBICbaseBXSubsSIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBXSubsSIStructPtr = matched ; + here->VBICbaseBXSubsSIPtr = matched->CSC ; + } + + if ((here->VBICbaseBINode != 0) && (here->VBICemitEINode != 0)) + { + i = here->VBICbaseBIEmitEIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBIEmitEIStructPtr = matched ; + here->VBICbaseBIEmitEIPtr = matched->CSC ; + } + + if ((here->VBICbaseBPNode != 0) && (here->VBICsubsSINode != 0)) + { + i = here->VBICbaseBPSubsSIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBPSubsSIStructPtr = matched ; + here->VBICbaseBPSubsSIPtr = matched->CSC ; + } + + if ((here->VBICcollCXNode != 0) && (here->VBICcollNode != 0)) + { + i = here->VBICcollCXCollPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCXCollStructPtr = matched ; + here->VBICcollCXCollPtr = matched->CSC ; + } + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseNode != 0)) + { + i = here->VBICbaseBXBasePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBXBaseStructPtr = matched ; + here->VBICbaseBXBasePtr = matched->CSC ; + } + + if ((here->VBICemitEINode != 0) && (here->VBICemitNode != 0)) + { + i = here->VBICemitEIEmitPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICemitEIEmitStructPtr = matched ; + here->VBICemitEIEmitPtr = matched->CSC ; + } + + if ((here->VBICsubsSINode != 0) && (here->VBICsubsNode != 0)) + { + i = here->VBICsubsSISubsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICsubsSISubsStructPtr = matched ; + here->VBICsubsSISubsPtr = matched->CSC ; + } + + if ((here->VBICcollCINode != 0) && (here->VBICcollCXNode != 0)) + { + i = here->VBICcollCICollCXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICcollCICollCXStructPtr = matched ; + here->VBICcollCICollCXPtr = matched->CSC ; + } + + if ((here->VBICbaseBINode != 0) && (here->VBICcollCXNode != 0)) + { + i = here->VBICbaseBICollCXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBICollCXStructPtr = matched ; + here->VBICbaseBICollCXPtr = matched->CSC ; + } + + if ((here->VBICbaseBPNode != 0) && (here->VBICcollCXNode != 0)) + { + i = here->VBICbaseBPCollCXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBPCollCXStructPtr = matched ; + here->VBICbaseBPCollCXPtr = matched->CSC ; + } + + if ((here->VBICbaseBXNode != 0) && (here->VBICcollCINode != 0)) + { + i = here->VBICbaseBXCollCIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBXCollCIStructPtr = matched ; + here->VBICbaseBXCollCIPtr = matched->CSC ; + } + + if ((here->VBICbaseBINode != 0) && (here->VBICcollCINode != 0)) + { + i = here->VBICbaseBICollCIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBICollCIStructPtr = matched ; + here->VBICbaseBICollCIPtr = matched->CSC ; + } + + if ((here->VBICemitEINode != 0) && (here->VBICcollCINode != 0)) + { + i = here->VBICemitEICollCIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICemitEICollCIStructPtr = matched ; + here->VBICemitEICollCIPtr = matched->CSC ; + } + + if ((here->VBICbaseBPNode != 0) && (here->VBICcollCINode != 0)) + { + i = here->VBICbaseBPCollCIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBPCollCIStructPtr = matched ; + here->VBICbaseBPCollCIPtr = matched->CSC ; + } + + if ((here->VBICbaseBINode != 0) && (here->VBICbaseBXNode != 0)) + { + i = here->VBICbaseBIBaseBXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBIBaseBXStructPtr = matched ; + here->VBICbaseBIBaseBXPtr = matched->CSC ; + } + + if ((here->VBICemitEINode != 0) && (here->VBICbaseBXNode != 0)) + { + i = here->VBICemitEIBaseBXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICemitEIBaseBXStructPtr = matched ; + here->VBICemitEIBaseBXPtr = matched->CSC ; + } + + if ((here->VBICbaseBPNode != 0) && (here->VBICbaseBXNode != 0)) + { + i = here->VBICbaseBPBaseBXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBPBaseBXStructPtr = matched ; + here->VBICbaseBPBaseBXPtr = matched->CSC ; + } + + if ((here->VBICsubsSINode != 0) && (here->VBICbaseBXNode != 0)) + { + i = here->VBICsubsSIBaseBXPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICsubsSIBaseBXStructPtr = matched ; + here->VBICsubsSIBaseBXPtr = matched->CSC ; + } + + if ((here->VBICemitEINode != 0) && (here->VBICbaseBINode != 0)) + { + i = here->VBICemitEIBaseBIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICemitEIBaseBIStructPtr = matched ; + here->VBICemitEIBaseBIPtr = matched->CSC ; + } + + if ((here->VBICbaseBPNode != 0) && (here->VBICbaseBINode != 0)) + { + i = here->VBICbaseBPBaseBIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICbaseBPBaseBIStructPtr = matched ; + here->VBICbaseBPBaseBIPtr = matched->CSC ; + } + + if ((here->VBICsubsSINode != 0) && (here->VBICcollCINode != 0)) + { + i = here->VBICsubsSICollCIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICsubsSICollCIStructPtr = matched ; + here->VBICsubsSICollCIPtr = matched->CSC ; + } + + if ((here->VBICsubsSINode != 0) && (here->VBICbaseBINode != 0)) + { + i = here->VBICsubsSIBaseBIPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICsubsSIBaseBIStructPtr = matched ; + here->VBICsubsSIBaseBIPtr = matched->CSC ; + } + + if ((here->VBICsubsSINode != 0) && (here->VBICbaseBPNode != 0)) + { + i = here->VBICsubsSIBaseBPPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VBICsubsSIBaseBPStructPtr = matched ; + here->VBICsubsSIBaseBPPtr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +VBICbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + VBICmodel *model = (VBICmodel *)inModel ; + VBICinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the VBIC models */ + for ( ; model != NULL ; model = model->VBICnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VBICinstances ; here != NULL ; here = here->VBICnextInstance) + { + if ((here->VBICcollNode != 0) && (here->VBICcollNode != 0)) + here->VBICcollCollPtr = here->VBICcollCollStructPtr->CSC_Complex ; + + if ((here->VBICbaseNode != 0) && (here->VBICbaseNode != 0)) + here->VBICbaseBasePtr = here->VBICbaseBaseStructPtr->CSC_Complex ; + + if ((here->VBICemitNode != 0) && (here->VBICemitNode != 0)) + here->VBICemitEmitPtr = here->VBICemitEmitStructPtr->CSC_Complex ; + + if ((here->VBICsubsNode != 0) && (here->VBICsubsNode != 0)) + here->VBICsubsSubsPtr = here->VBICsubsSubsStructPtr->CSC_Complex ; + + if ((here->VBICcollCXNode != 0) && (here->VBICcollCXNode != 0)) + here->VBICcollCXCollCXPtr = here->VBICcollCXCollCXStructPtr->CSC_Complex ; + + if ((here->VBICcollCINode != 0) && (here->VBICcollCINode != 0)) + here->VBICcollCICollCIPtr = here->VBICcollCICollCIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICbaseBXBaseBXPtr = here->VBICbaseBXBaseBXStructPtr->CSC_Complex ; + + if ((here->VBICbaseBINode != 0) && (here->VBICbaseBINode != 0)) + here->VBICbaseBIBaseBIPtr = here->VBICbaseBIBaseBIStructPtr->CSC_Complex ; + + if ((here->VBICemitEINode != 0) && (here->VBICemitEINode != 0)) + here->VBICemitEIEmitEIPtr = here->VBICemitEIEmitEIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICbaseBPNode != 0)) + here->VBICbaseBPBaseBPPtr = here->VBICbaseBPBaseBPStructPtr->CSC_Complex ; + + if ((here->VBICsubsSINode != 0) && (here->VBICsubsSINode != 0)) + here->VBICsubsSISubsSIPtr = here->VBICsubsSISubsSIStructPtr->CSC_Complex ; + + if ((here->VBICbaseNode != 0) && (here->VBICemitNode != 0)) + here->VBICbaseEmitPtr = here->VBICbaseEmitStructPtr->CSC_Complex ; + + if ((here->VBICemitNode != 0) && (here->VBICbaseNode != 0)) + here->VBICemitBasePtr = here->VBICemitBaseStructPtr->CSC_Complex ; + + if ((here->VBICbaseNode != 0) && (here->VBICcollNode != 0)) + here->VBICbaseCollPtr = here->VBICbaseCollStructPtr->CSC_Complex ; + + if ((here->VBICcollNode != 0) && (here->VBICbaseNode != 0)) + here->VBICcollBasePtr = here->VBICcollBaseStructPtr->CSC_Complex ; + + if ((here->VBICcollNode != 0) && (here->VBICcollCXNode != 0)) + here->VBICcollCollCXPtr = here->VBICcollCollCXStructPtr->CSC_Complex ; + + if ((here->VBICbaseNode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICbaseBaseBXPtr = here->VBICbaseBaseBXStructPtr->CSC_Complex ; + + if ((here->VBICemitNode != 0) && (here->VBICemitEINode != 0)) + here->VBICemitEmitEIPtr = here->VBICemitEmitEIStructPtr->CSC_Complex ; + + if ((here->VBICsubsNode != 0) && (here->VBICsubsSINode != 0)) + here->VBICsubsSubsSIPtr = here->VBICsubsSubsSIStructPtr->CSC_Complex ; + + if ((here->VBICcollCXNode != 0) && (here->VBICcollCINode != 0)) + here->VBICcollCXCollCIPtr = here->VBICcollCXCollCIStructPtr->CSC_Complex ; + + if ((here->VBICcollCXNode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICcollCXBaseBXPtr = here->VBICcollCXBaseBXStructPtr->CSC_Complex ; + + if ((here->VBICcollCXNode != 0) && (here->VBICbaseBINode != 0)) + here->VBICcollCXBaseBIPtr = here->VBICcollCXBaseBIStructPtr->CSC_Complex ; + + if ((here->VBICcollCXNode != 0) && (here->VBICbaseBPNode != 0)) + here->VBICcollCXBaseBPPtr = here->VBICcollCXBaseBPStructPtr->CSC_Complex ; + + if ((here->VBICcollCINode != 0) && (here->VBICbaseBINode != 0)) + here->VBICcollCIBaseBIPtr = here->VBICcollCIBaseBIStructPtr->CSC_Complex ; + + if ((here->VBICcollCINode != 0) && (here->VBICemitEINode != 0)) + here->VBICcollCIEmitEIPtr = here->VBICcollCIEmitEIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseBINode != 0)) + here->VBICbaseBXBaseBIPtr = here->VBICbaseBXBaseBIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICemitEINode != 0)) + here->VBICbaseBXEmitEIPtr = here->VBICbaseBXEmitEIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseBPNode != 0)) + here->VBICbaseBXBaseBPPtr = here->VBICbaseBXBaseBPStructPtr->CSC_Complex ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICsubsSINode != 0)) + here->VBICbaseBXSubsSIPtr = here->VBICbaseBXSubsSIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBINode != 0) && (here->VBICemitEINode != 0)) + here->VBICbaseBIEmitEIPtr = here->VBICbaseBIEmitEIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICsubsSINode != 0)) + here->VBICbaseBPSubsSIPtr = here->VBICbaseBPSubsSIStructPtr->CSC_Complex ; + + if ((here->VBICcollCXNode != 0) && (here->VBICcollNode != 0)) + here->VBICcollCXCollPtr = here->VBICcollCXCollStructPtr->CSC_Complex ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseNode != 0)) + here->VBICbaseBXBasePtr = here->VBICbaseBXBaseStructPtr->CSC_Complex ; + + if ((here->VBICemitEINode != 0) && (here->VBICemitNode != 0)) + here->VBICemitEIEmitPtr = here->VBICemitEIEmitStructPtr->CSC_Complex ; + + if ((here->VBICsubsSINode != 0) && (here->VBICsubsNode != 0)) + here->VBICsubsSISubsPtr = here->VBICsubsSISubsStructPtr->CSC_Complex ; + + if ((here->VBICcollCINode != 0) && (here->VBICcollCXNode != 0)) + here->VBICcollCICollCXPtr = here->VBICcollCICollCXStructPtr->CSC_Complex ; + + if ((here->VBICbaseBINode != 0) && (here->VBICcollCXNode != 0)) + here->VBICbaseBICollCXPtr = here->VBICbaseBICollCXStructPtr->CSC_Complex ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICcollCXNode != 0)) + here->VBICbaseBPCollCXPtr = here->VBICbaseBPCollCXStructPtr->CSC_Complex ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICcollCINode != 0)) + here->VBICbaseBXCollCIPtr = here->VBICbaseBXCollCIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBINode != 0) && (here->VBICcollCINode != 0)) + here->VBICbaseBICollCIPtr = here->VBICbaseBICollCIStructPtr->CSC_Complex ; + + if ((here->VBICemitEINode != 0) && (here->VBICcollCINode != 0)) + here->VBICemitEICollCIPtr = here->VBICemitEICollCIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICcollCINode != 0)) + here->VBICbaseBPCollCIPtr = here->VBICbaseBPCollCIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBINode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICbaseBIBaseBXPtr = here->VBICbaseBIBaseBXStructPtr->CSC_Complex ; + + if ((here->VBICemitEINode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICemitEIBaseBXPtr = here->VBICemitEIBaseBXStructPtr->CSC_Complex ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICbaseBPBaseBXPtr = here->VBICbaseBPBaseBXStructPtr->CSC_Complex ; + + if ((here->VBICsubsSINode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICsubsSIBaseBXPtr = here->VBICsubsSIBaseBXStructPtr->CSC_Complex ; + + if ((here->VBICemitEINode != 0) && (here->VBICbaseBINode != 0)) + here->VBICemitEIBaseBIPtr = here->VBICemitEIBaseBIStructPtr->CSC_Complex ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICbaseBINode != 0)) + here->VBICbaseBPBaseBIPtr = here->VBICbaseBPBaseBIStructPtr->CSC_Complex ; + + if ((here->VBICsubsSINode != 0) && (here->VBICcollCINode != 0)) + here->VBICsubsSICollCIPtr = here->VBICsubsSICollCIStructPtr->CSC_Complex ; + + if ((here->VBICsubsSINode != 0) && (here->VBICbaseBINode != 0)) + here->VBICsubsSIBaseBIPtr = here->VBICsubsSIBaseBIStructPtr->CSC_Complex ; + + if ((here->VBICsubsSINode != 0) && (here->VBICbaseBPNode != 0)) + here->VBICsubsSIBaseBPPtr = here->VBICsubsSIBaseBPStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +VBICbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + VBICmodel *model = (VBICmodel *)inModel ; + VBICinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the VBIC models */ + for ( ; model != NULL ; model = model->VBICnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VBICinstances ; here != NULL ; here = here->VBICnextInstance) + { + if ((here->VBICcollNode != 0) && (here->VBICcollNode != 0)) + here->VBICcollCollPtr = here->VBICcollCollStructPtr->CSC ; + + if ((here->VBICbaseNode != 0) && (here->VBICbaseNode != 0)) + here->VBICbaseBasePtr = here->VBICbaseBaseStructPtr->CSC ; + + if ((here->VBICemitNode != 0) && (here->VBICemitNode != 0)) + here->VBICemitEmitPtr = here->VBICemitEmitStructPtr->CSC ; + + if ((here->VBICsubsNode != 0) && (here->VBICsubsNode != 0)) + here->VBICsubsSubsPtr = here->VBICsubsSubsStructPtr->CSC ; + + if ((here->VBICcollCXNode != 0) && (here->VBICcollCXNode != 0)) + here->VBICcollCXCollCXPtr = here->VBICcollCXCollCXStructPtr->CSC ; + + if ((here->VBICcollCINode != 0) && (here->VBICcollCINode != 0)) + here->VBICcollCICollCIPtr = here->VBICcollCICollCIStructPtr->CSC ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICbaseBXBaseBXPtr = here->VBICbaseBXBaseBXStructPtr->CSC ; + + if ((here->VBICbaseBINode != 0) && (here->VBICbaseBINode != 0)) + here->VBICbaseBIBaseBIPtr = here->VBICbaseBIBaseBIStructPtr->CSC ; + + if ((here->VBICemitEINode != 0) && (here->VBICemitEINode != 0)) + here->VBICemitEIEmitEIPtr = here->VBICemitEIEmitEIStructPtr->CSC ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICbaseBPNode != 0)) + here->VBICbaseBPBaseBPPtr = here->VBICbaseBPBaseBPStructPtr->CSC ; + + if ((here->VBICsubsSINode != 0) && (here->VBICsubsSINode != 0)) + here->VBICsubsSISubsSIPtr = here->VBICsubsSISubsSIStructPtr->CSC ; + + if ((here->VBICbaseNode != 0) && (here->VBICemitNode != 0)) + here->VBICbaseEmitPtr = here->VBICbaseEmitStructPtr->CSC ; + + if ((here->VBICemitNode != 0) && (here->VBICbaseNode != 0)) + here->VBICemitBasePtr = here->VBICemitBaseStructPtr->CSC ; + + if ((here->VBICbaseNode != 0) && (here->VBICcollNode != 0)) + here->VBICbaseCollPtr = here->VBICbaseCollStructPtr->CSC ; + + if ((here->VBICcollNode != 0) && (here->VBICbaseNode != 0)) + here->VBICcollBasePtr = here->VBICcollBaseStructPtr->CSC ; + + if ((here->VBICcollNode != 0) && (here->VBICcollCXNode != 0)) + here->VBICcollCollCXPtr = here->VBICcollCollCXStructPtr->CSC ; + + if ((here->VBICbaseNode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICbaseBaseBXPtr = here->VBICbaseBaseBXStructPtr->CSC ; + + if ((here->VBICemitNode != 0) && (here->VBICemitEINode != 0)) + here->VBICemitEmitEIPtr = here->VBICemitEmitEIStructPtr->CSC ; + + if ((here->VBICsubsNode != 0) && (here->VBICsubsSINode != 0)) + here->VBICsubsSubsSIPtr = here->VBICsubsSubsSIStructPtr->CSC ; + + if ((here->VBICcollCXNode != 0) && (here->VBICcollCINode != 0)) + here->VBICcollCXCollCIPtr = here->VBICcollCXCollCIStructPtr->CSC ; + + if ((here->VBICcollCXNode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICcollCXBaseBXPtr = here->VBICcollCXBaseBXStructPtr->CSC ; + + if ((here->VBICcollCXNode != 0) && (here->VBICbaseBINode != 0)) + here->VBICcollCXBaseBIPtr = here->VBICcollCXBaseBIStructPtr->CSC ; + + if ((here->VBICcollCXNode != 0) && (here->VBICbaseBPNode != 0)) + here->VBICcollCXBaseBPPtr = here->VBICcollCXBaseBPStructPtr->CSC ; + + if ((here->VBICcollCINode != 0) && (here->VBICbaseBINode != 0)) + here->VBICcollCIBaseBIPtr = here->VBICcollCIBaseBIStructPtr->CSC ; + + if ((here->VBICcollCINode != 0) && (here->VBICemitEINode != 0)) + here->VBICcollCIEmitEIPtr = here->VBICcollCIEmitEIStructPtr->CSC ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseBINode != 0)) + here->VBICbaseBXBaseBIPtr = here->VBICbaseBXBaseBIStructPtr->CSC ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICemitEINode != 0)) + here->VBICbaseBXEmitEIPtr = here->VBICbaseBXEmitEIStructPtr->CSC ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseBPNode != 0)) + here->VBICbaseBXBaseBPPtr = here->VBICbaseBXBaseBPStructPtr->CSC ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICsubsSINode != 0)) + here->VBICbaseBXSubsSIPtr = here->VBICbaseBXSubsSIStructPtr->CSC ; + + if ((here->VBICbaseBINode != 0) && (here->VBICemitEINode != 0)) + here->VBICbaseBIEmitEIPtr = here->VBICbaseBIEmitEIStructPtr->CSC ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICsubsSINode != 0)) + here->VBICbaseBPSubsSIPtr = here->VBICbaseBPSubsSIStructPtr->CSC ; + + if ((here->VBICcollCXNode != 0) && (here->VBICcollNode != 0)) + here->VBICcollCXCollPtr = here->VBICcollCXCollStructPtr->CSC ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICbaseNode != 0)) + here->VBICbaseBXBasePtr = here->VBICbaseBXBaseStructPtr->CSC ; + + if ((here->VBICemitEINode != 0) && (here->VBICemitNode != 0)) + here->VBICemitEIEmitPtr = here->VBICemitEIEmitStructPtr->CSC ; + + if ((here->VBICsubsSINode != 0) && (here->VBICsubsNode != 0)) + here->VBICsubsSISubsPtr = here->VBICsubsSISubsStructPtr->CSC ; + + if ((here->VBICcollCINode != 0) && (here->VBICcollCXNode != 0)) + here->VBICcollCICollCXPtr = here->VBICcollCICollCXStructPtr->CSC ; + + if ((here->VBICbaseBINode != 0) && (here->VBICcollCXNode != 0)) + here->VBICbaseBICollCXPtr = here->VBICbaseBICollCXStructPtr->CSC ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICcollCXNode != 0)) + here->VBICbaseBPCollCXPtr = here->VBICbaseBPCollCXStructPtr->CSC ; + + if ((here->VBICbaseBXNode != 0) && (here->VBICcollCINode != 0)) + here->VBICbaseBXCollCIPtr = here->VBICbaseBXCollCIStructPtr->CSC ; + + if ((here->VBICbaseBINode != 0) && (here->VBICcollCINode != 0)) + here->VBICbaseBICollCIPtr = here->VBICbaseBICollCIStructPtr->CSC ; + + if ((here->VBICemitEINode != 0) && (here->VBICcollCINode != 0)) + here->VBICemitEICollCIPtr = here->VBICemitEICollCIStructPtr->CSC ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICcollCINode != 0)) + here->VBICbaseBPCollCIPtr = here->VBICbaseBPCollCIStructPtr->CSC ; + + if ((here->VBICbaseBINode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICbaseBIBaseBXPtr = here->VBICbaseBIBaseBXStructPtr->CSC ; + + if ((here->VBICemitEINode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICemitEIBaseBXPtr = here->VBICemitEIBaseBXStructPtr->CSC ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICbaseBPBaseBXPtr = here->VBICbaseBPBaseBXStructPtr->CSC ; + + if ((here->VBICsubsSINode != 0) && (here->VBICbaseBXNode != 0)) + here->VBICsubsSIBaseBXPtr = here->VBICsubsSIBaseBXStructPtr->CSC ; + + if ((here->VBICemitEINode != 0) && (here->VBICbaseBINode != 0)) + here->VBICemitEIBaseBIPtr = here->VBICemitEIBaseBIStructPtr->CSC ; + + if ((here->VBICbaseBPNode != 0) && (here->VBICbaseBINode != 0)) + here->VBICbaseBPBaseBIPtr = here->VBICbaseBPBaseBIStructPtr->CSC ; + + if ((here->VBICsubsSINode != 0) && (here->VBICcollCINode != 0)) + here->VBICsubsSICollCIPtr = here->VBICsubsSICollCIStructPtr->CSC ; + + if ((here->VBICsubsSINode != 0) && (here->VBICbaseBINode != 0)) + here->VBICsubsSIBaseBIPtr = here->VBICsubsSIBaseBIStructPtr->CSC ; + + if ((here->VBICsubsSINode != 0) && (here->VBICbaseBPNode != 0)) + here->VBICsubsSIBaseBPPtr = here->VBICsubsSIBaseBPStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/vbic/vbicdefs.h b/src/spicelib/devices/vbic/vbicdefs.h index 4f7078567..182ebd6a5 100644 --- a/src/spicelib/devices/vbic/vbicdefs.h +++ b/src/spicelib/devices/vbic/vbicdefs.h @@ -243,6 +243,60 @@ typedef struct sVBICinstance { #endif /*NONOISE*/ /* the above to avoid allocating memory when it is not needed */ +#ifdef KLU + BindElement *VBICcollCollStructPtr ; + BindElement *VBICbaseBaseStructPtr ; + BindElement *VBICemitEmitStructPtr ; + BindElement *VBICsubsSubsStructPtr ; + BindElement *VBICcollCXCollCXStructPtr ; + BindElement *VBICcollCICollCIStructPtr ; + BindElement *VBICbaseBXBaseBXStructPtr ; + BindElement *VBICbaseBIBaseBIStructPtr ; + BindElement *VBICemitEIEmitEIStructPtr ; + BindElement *VBICbaseBPBaseBPStructPtr ; + BindElement *VBICsubsSISubsSIStructPtr ; + BindElement *VBICbaseEmitStructPtr ; + BindElement *VBICemitBaseStructPtr ; + BindElement *VBICbaseCollStructPtr ; + BindElement *VBICcollBaseStructPtr ; + BindElement *VBICcollCollCXStructPtr ; + BindElement *VBICbaseBaseBXStructPtr ; + BindElement *VBICemitEmitEIStructPtr ; + BindElement *VBICsubsSubsSIStructPtr ; + BindElement *VBICcollCXCollCIStructPtr ; + BindElement *VBICcollCXBaseBXStructPtr ; + BindElement *VBICcollCXBaseBIStructPtr ; + BindElement *VBICcollCXBaseBPStructPtr ; + BindElement *VBICcollCIBaseBIStructPtr ; + BindElement *VBICcollCIEmitEIStructPtr ; + BindElement *VBICbaseBXBaseBIStructPtr ; + BindElement *VBICbaseBXEmitEIStructPtr ; + BindElement *VBICbaseBXBaseBPStructPtr ; + BindElement *VBICbaseBXSubsSIStructPtr ; + BindElement *VBICbaseBIEmitEIStructPtr ; + BindElement *VBICbaseBPSubsSIStructPtr ; + BindElement *VBICcollCXCollStructPtr ; + BindElement *VBICbaseBXBaseStructPtr ; + BindElement *VBICemitEIEmitStructPtr ; + BindElement *VBICsubsSISubsStructPtr ; + BindElement *VBICcollCICollCXStructPtr ; + BindElement *VBICbaseBICollCXStructPtr ; + BindElement *VBICbaseBPCollCXStructPtr ; + BindElement *VBICbaseBXCollCIStructPtr ; + BindElement *VBICbaseBICollCIStructPtr ; + BindElement *VBICemitEICollCIStructPtr ; + BindElement *VBICbaseBPCollCIStructPtr ; + BindElement *VBICbaseBIBaseBXStructPtr ; + BindElement *VBICemitEIBaseBXStructPtr ; + BindElement *VBICbaseBPBaseBXStructPtr ; + BindElement *VBICsubsSIBaseBXStructPtr ; + BindElement *VBICemitEIBaseBIStructPtr ; + BindElement *VBICbaseBPBaseBIStructPtr ; + BindElement *VBICsubsSICollCIStructPtr ; + BindElement *VBICsubsSIBaseBIStructPtr ; + BindElement *VBICsubsSIBaseBPStructPtr ; +#endif + } VBICinstance ; /* entries in the state vector for vbic: */ diff --git a/src/spicelib/devices/vbic/vbicext.h b/src/spicelib/devices/vbic/vbicext.h index c0e0ff943..f2831a749 100644 --- a/src/spicelib/devices/vbic/vbicext.h +++ b/src/spicelib/devices/vbic/vbicext.h @@ -27,4 +27,10 @@ extern int VBICtrunc(GENmodel*,CKTcircuit*,double*); extern int VBICnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*); extern int VBICsoaCheck(CKTcircuit *, GENmodel *); +#ifdef KLU +extern int VBICbindCSC (GENmodel*, CKTcircuit*) ; +extern int VBICbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int VBICbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif + #endif diff --git a/src/spicelib/devices/vbic/vbicinit.c b/src/spicelib/devices/vbic/vbicinit.c index 9abc37049..bb9fd5eb8 100644 --- a/src/spicelib/devices/vbic/vbicinit.c +++ b/src/spicelib/devices/vbic/vbicinit.c @@ -78,7 +78,13 @@ SPICEdev VBICinfo = { NULL, /* DEVacct */ #endif &VBICiSize, /* DEVinstSize */ - &VBICmSize /* DEVmodSize */ + &VBICmSize, /* DEVmodSize */ + +#ifdef KLU + VBICbindCSC, /* DEVbindCSC */ + VBICbindCSCComplex, /* DEVbindCSCComplex */ + VBICbindCSCComplexToReal, /* DEVbindCSCComplexToReal */ +#endif }; diff --git a/src/spicelib/devices/vccs/Makefile.am b/src/spicelib/devices/vccs/Makefile.am index 145693195..eae86acd7 100644 --- a/src/spicelib/devices/vccs/Makefile.am +++ b/src/spicelib/devices/vccs/Makefile.am @@ -23,7 +23,11 @@ libvccs_la_SOURCES = \ vccssset.c +if KLU_WANTED +libvccs_la_SOURCES += vccsbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/vccs/vccsbindCSC.c b/src/spicelib/devices/vccs/vccsbindCSC.c new file mode 100644 index 000000000..aed5b9112 --- /dev/null +++ b/src/spicelib/devices/vccs/vccsbindCSC.c @@ -0,0 +1,141 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "vccsdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +VCCSbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + VCCSmodel *model = (VCCSmodel *)inModel ; + VCCSinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the VCCS models */ + for ( ; model != NULL ; model = model->VCCSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VCCSinstances ; here != NULL ; here = here->VCCSnextInstance) + { + if ((here-> VCCSposNode != 0) && (here-> VCCScontPosNode != 0)) + { + i = here->VCCSposContPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCCSposContPosptrStructPtr = matched ; + here->VCCSposContPosptr = matched->CSC ; + } + + if ((here-> VCCSposNode != 0) && (here-> VCCScontNegNode != 0)) + { + i = here->VCCSposContNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCCSposContNegptrStructPtr = matched ; + here->VCCSposContNegptr = matched->CSC ; + } + + if ((here-> VCCSnegNode != 0) && (here-> VCCScontPosNode != 0)) + { + i = here->VCCSnegContPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCCSnegContPosptrStructPtr = matched ; + here->VCCSnegContPosptr = matched->CSC ; + } + + if ((here-> VCCSnegNode != 0) && (here-> VCCScontNegNode != 0)) + { + i = here->VCCSnegContNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCCSnegContNegptrStructPtr = matched ; + here->VCCSnegContNegptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +VCCSbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + VCCSmodel *model = (VCCSmodel *)inModel ; + VCCSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the VCCS models */ + for ( ; model != NULL ; model = model->VCCSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VCCSinstances ; here != NULL ; here = here->VCCSnextInstance) + { + if ((here-> VCCSposNode != 0) && (here-> VCCScontPosNode != 0)) + here->VCCSposContPosptr = here->VCCSposContPosptrStructPtr->CSC_Complex ; + + if ((here-> VCCSposNode != 0) && (here-> VCCScontNegNode != 0)) + here->VCCSposContNegptr = here->VCCSposContNegptrStructPtr->CSC_Complex ; + + if ((here-> VCCSnegNode != 0) && (here-> VCCScontPosNode != 0)) + here->VCCSnegContPosptr = here->VCCSnegContPosptrStructPtr->CSC_Complex ; + + if ((here-> VCCSnegNode != 0) && (here-> VCCScontNegNode != 0)) + here->VCCSnegContNegptr = here->VCCSnegContNegptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +VCCSbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + VCCSmodel *model = (VCCSmodel *)inModel ; + VCCSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the VCCS models */ + for ( ; model != NULL ; model = model->VCCSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VCCSinstances ; here != NULL ; here = here->VCCSnextInstance) + { + if ((here-> VCCSposNode != 0) && (here-> VCCScontPosNode != 0)) + here->VCCSposContPosptr = here->VCCSposContPosptrStructPtr->CSC ; + + if ((here-> VCCSposNode != 0) && (here-> VCCScontNegNode != 0)) + here->VCCSposContNegptr = here->VCCSposContNegptrStructPtr->CSC ; + + if ((here-> VCCSnegNode != 0) && (here-> VCCScontPosNode != 0)) + here->VCCSnegContPosptr = here->VCCSnegContPosptrStructPtr->CSC ; + + if ((here-> VCCSnegNode != 0) && (here-> VCCScontNegNode != 0)) + here->VCCSnegContNegptr = here->VCCSnegContNegptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/vccs/vccsdefs.h b/src/spicelib/devices/vccs/vccsdefs.h index 13eb94aa1..9dcdc4545 100644 --- a/src/spicelib/devices/vccs/vccsdefs.h +++ b/src/spicelib/devices/vccs/vccsdefs.h @@ -47,6 +47,13 @@ typedef struct sVCCSinstance { int VCCSsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ +#ifdef KLU + BindElement *VCCSposContPosptrStructPtr ; + BindElement *VCCSposContNegptrStructPtr ; + BindElement *VCCSnegContPosptrStructPtr ; + BindElement *VCCSnegContNegptrStructPtr ; +#endif + } VCCSinstance ; #define VCCSvOld VCCSstates diff --git a/src/spicelib/devices/vccs/vccsext.h b/src/spicelib/devices/vccs/vccsext.h index 464020523..29e18cb25 100644 --- a/src/spicelib/devices/vccs/vccsext.h +++ b/src/spicelib/devices/vccs/vccsext.h @@ -15,3 +15,9 @@ extern int VCCSsLoad(GENmodel*,CKTcircuit*); extern int VCCSsSetup(SENstruct*,GENmodel*); extern void VCCSsPrint(GENmodel*,CKTcircuit*); extern int VCCSsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); + +#ifdef KLU +extern int VCCSbindCSC (GENmodel*, CKTcircuit*) ; +extern int VCCSbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int VCCSbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/vccs/vccsinit.c b/src/spicelib/devices/vccs/vccsinit.c index cdfa3c8dd..69d6178e8 100644 --- a/src/spicelib/devices/vccs/vccsinit.c +++ b/src/spicelib/devices/vccs/vccsinit.c @@ -73,8 +73,13 @@ SPICEdev VCCSinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &VCCSiSize, - /* DEVmodSize */ &VCCSmSize + /* DEVmodSize */ &VCCSmSize, +#ifdef KLU + /* DEVbindCSC */ VCCSbindCSC, + /* DEVbindCSCComplex */ VCCSbindCSCComplex, + /* DEVbindCSCComplexToReal */ VCCSbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/vcvs/Makefile.am b/src/spicelib/devices/vcvs/Makefile.am index 8ad37e37b..9f9c548ad 100644 --- a/src/spicelib/devices/vcvs/Makefile.am +++ b/src/spicelib/devices/vcvs/Makefile.am @@ -24,7 +24,11 @@ libvcvs_la_SOURCES = \ vcvssset.c +if KLU_WANTED +libvcvs_la_SOURCES += vcvsbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) + MAINTAINERCLEANFILES = Makefile.in diff --git a/src/spicelib/devices/vcvs/vcvsbindCSC.c b/src/spicelib/devices/vcvs/vcvsbindCSC.c new file mode 100644 index 000000000..1f844f911 --- /dev/null +++ b/src/spicelib/devices/vcvs/vcvsbindCSC.c @@ -0,0 +1,169 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "vcvsdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +VCVSbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + VCVSmodel *model = (VCVSmodel *)inModel ; + VCVSinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the VCVS models */ + for ( ; model != NULL ; model = model->VCVSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VCVSinstances ; here != NULL ; here = here->VCVSnextInstance) + { + if ((here-> VCVSposNode != 0) && (here-> VCVSbranch != 0)) + { + i = here->VCVSposIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCVSposIbrptrStructPtr = matched ; + here->VCVSposIbrptr = matched->CSC ; + } + + if ((here-> VCVSnegNode != 0) && (here-> VCVSbranch != 0)) + { + i = here->VCVSnegIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCVSnegIbrptrStructPtr = matched ; + here->VCVSnegIbrptr = matched->CSC ; + } + + if ((here-> VCVSbranch != 0) && (here-> VCVSnegNode != 0)) + { + i = here->VCVSibrNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCVSibrNegptrStructPtr = matched ; + here->VCVSibrNegptr = matched->CSC ; + } + + if ((here-> VCVSbranch != 0) && (here-> VCVSposNode != 0)) + { + i = here->VCVSibrPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCVSibrPosptrStructPtr = matched ; + here->VCVSibrPosptr = matched->CSC ; + } + + if ((here-> VCVSbranch != 0) && (here-> VCVScontPosNode != 0)) + { + i = here->VCVSibrContPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCVSibrContPosptrStructPtr = matched ; + here->VCVSibrContPosptr = matched->CSC ; + } + + if ((here-> VCVSbranch != 0) && (here-> VCVScontNegNode != 0)) + { + i = here->VCVSibrContNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VCVSibrContNegptrStructPtr = matched ; + here->VCVSibrContNegptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +VCVSbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + VCVSmodel *model = (VCVSmodel *)inModel ; + VCVSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the VCVS models */ + for ( ; model != NULL ; model = model->VCVSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VCVSinstances ; here != NULL ; here = here->VCVSnextInstance) + { + if ((here-> VCVSposNode != 0) && (here-> VCVSbranch != 0)) + here->VCVSposIbrptr = here->VCVSposIbrptrStructPtr->CSC_Complex ; + + if ((here-> VCVSnegNode != 0) && (here-> VCVSbranch != 0)) + here->VCVSnegIbrptr = here->VCVSnegIbrptrStructPtr->CSC_Complex ; + + if ((here-> VCVSbranch != 0) && (here-> VCVSnegNode != 0)) + here->VCVSibrNegptr = here->VCVSibrNegptrStructPtr->CSC_Complex ; + + if ((here-> VCVSbranch != 0) && (here-> VCVSposNode != 0)) + here->VCVSibrPosptr = here->VCVSibrPosptrStructPtr->CSC_Complex ; + + if ((here-> VCVSbranch != 0) && (here-> VCVScontPosNode != 0)) + here->VCVSibrContPosptr = here->VCVSibrContPosptrStructPtr->CSC_Complex ; + + if ((here-> VCVSbranch != 0) && (here-> VCVScontNegNode != 0)) + here->VCVSibrContNegptr = here->VCVSibrContNegptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +VCVSbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + VCVSmodel *model = (VCVSmodel *)inModel ; + VCVSinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the VCVS models */ + for ( ; model != NULL ; model = model->VCVSnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VCVSinstances ; here != NULL ; here = here->VCVSnextInstance) + { + if ((here-> VCVSposNode != 0) && (here-> VCVSbranch != 0)) + here->VCVSposIbrptr = here->VCVSposIbrptrStructPtr->CSC ; + + if ((here-> VCVSnegNode != 0) && (here-> VCVSbranch != 0)) + here->VCVSnegIbrptr = here->VCVSnegIbrptrStructPtr->CSC ; + + if ((here-> VCVSbranch != 0) && (here-> VCVSnegNode != 0)) + here->VCVSibrNegptr = here->VCVSibrNegptrStructPtr->CSC ; + + if ((here-> VCVSbranch != 0) && (here-> VCVSposNode != 0)) + here->VCVSibrPosptr = here->VCVSibrPosptrStructPtr->CSC ; + + if ((here-> VCVSbranch != 0) && (here-> VCVScontPosNode != 0)) + here->VCVSibrContPosptr = here->VCVSibrContPosptrStructPtr->CSC ; + + if ((here-> VCVSbranch != 0) && (here-> VCVScontNegNode != 0)) + here->VCVSibrContNegptr = here->VCVSibrContNegptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/vcvs/vcvsdefs.h b/src/spicelib/devices/vcvs/vcvsdefs.h index b1d6045f4..e4187a612 100644 --- a/src/spicelib/devices/vcvs/vcvsdefs.h +++ b/src/spicelib/devices/vcvs/vcvsdefs.h @@ -51,6 +51,15 @@ typedef struct sVCVSinstance { int VCVSsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ +#ifdef KLU + BindElement *VCVSposIbrptrStructPtr ; + BindElement *VCVSnegIbrptrStructPtr ; + BindElement *VCVSibrNegptrStructPtr ; + BindElement *VCVSibrPosptrStructPtr ; + BindElement *VCVSibrContPosptrStructPtr ; + BindElement *VCVSibrContNegptrStructPtr ; +#endif + } VCVSinstance ; #define VCVSvOld VCVSstates diff --git a/src/spicelib/devices/vcvs/vcvsext.h b/src/spicelib/devices/vcvs/vcvsext.h index 3d3858273..40c18dabd 100644 --- a/src/spicelib/devices/vcvs/vcvsext.h +++ b/src/spicelib/devices/vcvs/vcvsext.h @@ -18,3 +18,8 @@ extern void VCVSsPrint(GENmodel*,CKTcircuit*); extern int VCVSsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int VCVSunsetup(GENmodel*,CKTcircuit*); +#ifdef KLU +extern int VCVSbindCSC (GENmodel*, CKTcircuit*) ; +extern int VCVSbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int VCVSbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/vcvs/vcvsinit.c b/src/spicelib/devices/vcvs/vcvsinit.c index 5b16cbc1a..1c15bb776 100644 --- a/src/spicelib/devices/vcvs/vcvsinit.c +++ b/src/spicelib/devices/vcvs/vcvsinit.c @@ -73,7 +73,13 @@ SPICEdev VCVSinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &VCVSiSize, - /* DEVmodSize */ &VCVSmSize + /* DEVmodSize */ &VCVSmSize, + +#ifdef KLU + /* DEVbindCSC */ VCVSbindCSC, + /* DEVbindCSCComplex */ VCVSbindCSCComplex, + /* DEVbindCSCComplexToReal */ VCVSbindCSCComplexToReal, +#endif }; diff --git a/src/spicelib/devices/vsrc/Makefile.am b/src/spicelib/devices/vsrc/Makefile.am index 28d5fb38b..9800efa14 100644 --- a/src/spicelib/devices/vsrc/Makefile.am +++ b/src/spicelib/devices/vsrc/Makefile.am @@ -24,6 +24,9 @@ libvsrc_la_SOURCES = \ vsrctemp.c +if KLU_WANTED +libvsrc_la_SOURCES += vsrcbindCSC.c +endif AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include AM_CFLAGS = $(STATIC) diff --git a/src/spicelib/devices/vsrc/vsrcbindCSC.c b/src/spicelib/devices/vsrc/vsrcbindCSC.c new file mode 100644 index 000000000..adbade9f3 --- /dev/null +++ b/src/spicelib/devices/vsrc/vsrcbindCSC.c @@ -0,0 +1,141 @@ +/********** +Author: 2013 Francesco Lannutti +**********/ + +#include "ngspice/ngspice.h" +#include "ngspice/cktdefs.h" +#include "vsrcdefs.h" +#include "ngspice/sperror.h" + +#include + +static +int +BindCompare (const void *a, const void *b) +{ + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; + + return ((int)(A->Sparse - B->Sparse)) ; +} + +int +VSRCbindCSC (GENmodel *inModel, CKTcircuit *ckt) +{ + VSRCmodel *model = (VSRCmodel *)inModel ; + VSRCinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; + + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the VSRC models */ + for ( ; model != NULL ; model = model->VSRCnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VSRCinstances ; here != NULL ; here = here->VSRCnextInstance) + { + if ((here-> VSRCposNode != 0) && (here-> VSRCbranch != 0)) + { + i = here->VSRCposIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VSRCposIbrptrStructPtr = matched ; + here->VSRCposIbrptr = matched->CSC ; + } + + if ((here-> VSRCnegNode != 0) && (here-> VSRCbranch != 0)) + { + i = here->VSRCnegIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VSRCnegIbrptrStructPtr = matched ; + here->VSRCnegIbrptr = matched->CSC ; + } + + if ((here-> VSRCbranch != 0) && (here-> VSRCnegNode != 0)) + { + i = here->VSRCibrNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VSRCibrNegptrStructPtr = matched ; + here->VSRCibrNegptr = matched->CSC ; + } + + if ((here-> VSRCbranch != 0) && (here-> VSRCposNode != 0)) + { + i = here->VSRCibrPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VSRCibrPosptrStructPtr = matched ; + here->VSRCibrPosptr = matched->CSC ; + } + + } + } + + return (OK) ; +} + +int +VSRCbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + VSRCmodel *model = (VSRCmodel *)inModel ; + VSRCinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the VSRC models */ + for ( ; model != NULL ; model = model->VSRCnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VSRCinstances ; here != NULL ; here = here->VSRCnextInstance) + { + if ((here-> VSRCposNode != 0) && (here-> VSRCbranch != 0)) + here->VSRCposIbrptr = here->VSRCposIbrptrStructPtr->CSC_Complex ; + + if ((here-> VSRCnegNode != 0) && (here-> VSRCbranch != 0)) + here->VSRCnegIbrptr = here->VSRCnegIbrptrStructPtr->CSC_Complex ; + + if ((here-> VSRCbranch != 0) && (here-> VSRCnegNode != 0)) + here->VSRCibrNegptr = here->VSRCibrNegptrStructPtr->CSC_Complex ; + + if ((here-> VSRCbranch != 0) && (here-> VSRCposNode != 0)) + here->VSRCibrPosptr = here->VSRCibrPosptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; +} + +int +VSRCbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + VSRCmodel *model = (VSRCmodel *)inModel ; + VSRCinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the VSRC models */ + for ( ; model != NULL ; model = model->VSRCnextModel) + { + /* loop through all the instances of the model */ + for (here = model->VSRCinstances ; here != NULL ; here = here->VSRCnextInstance) + { + if ((here-> VSRCposNode != 0) && (here-> VSRCbranch != 0)) + here->VSRCposIbrptr = here->VSRCposIbrptrStructPtr->CSC ; + + if ((here-> VSRCnegNode != 0) && (here-> VSRCbranch != 0)) + here->VSRCnegIbrptr = here->VSRCnegIbrptrStructPtr->CSC ; + + if ((here-> VSRCbranch != 0) && (here-> VSRCnegNode != 0)) + here->VSRCibrNegptr = here->VSRCibrNegptrStructPtr->CSC ; + + if ((here-> VSRCbranch != 0) && (here-> VSRCposNode != 0)) + here->VSRCibrPosptr = here->VSRCibrPosptrStructPtr->CSC ; + + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/vsrc/vsrcdefs.h b/src/spicelib/devices/vsrc/vsrcdefs.h index 82736daa6..5190d901c 100644 --- a/src/spicelib/devices/vsrc/vsrcdefs.h +++ b/src/spicelib/devices/vsrc/vsrcdefs.h @@ -75,6 +75,14 @@ typedef struct sVSRCinstance { unsigned VSRCdF1given :1 ; /* flag to indicate source is an f1 distortion input */ unsigned VSRCdF2given :1 ; /* flag to indicate source is an f2 distortion input */ unsigned VSRCrGiven :1 ; /* flag to indicate repeating pwl */ + +#ifdef KLU + BindElement *VSRCposIbrptrStructPtr ; + BindElement *VSRCnegIbrptrStructPtr ; + BindElement *VSRCibrNegptrStructPtr ; + BindElement *VSRCibrPosptrStructPtr ; +#endif + } VSRCinstance ; diff --git a/src/spicelib/devices/vsrc/vsrcext.h b/src/spicelib/devices/vsrc/vsrcext.h index 980efbf8e..8c27f8b3d 100644 --- a/src/spicelib/devices/vsrc/vsrcext.h +++ b/src/spicelib/devices/vsrc/vsrcext.h @@ -18,3 +18,9 @@ extern int VSRCsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int VSRCunsetup(GENmodel*,CKTcircuit*); extern int VSRCpzSetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*); extern int VSRCtemp(GENmodel*,CKTcircuit*); + +#ifdef KLU +extern int VSRCbindCSC (GENmodel*, CKTcircuit*) ; +extern int VSRCbindCSCComplex (GENmodel*, CKTcircuit*) ; +extern int VSRCbindCSCComplexToReal (GENmodel*, CKTcircuit*) ; +#endif diff --git a/src/spicelib/devices/vsrc/vsrcinit.c b/src/spicelib/devices/vsrc/vsrcinit.c index 3c8285851..29bb44e73 100644 --- a/src/spicelib/devices/vsrc/vsrcinit.c +++ b/src/spicelib/devices/vsrc/vsrcinit.c @@ -73,7 +73,14 @@ SPICEdev VSRCinfo = { /* DEVacct */ NULL, #endif /* DEVinstSize */ &VSRCiSize, - /* DEVmodSize */ &VSRCmSize + /* DEVmodSize */ &VSRCmSize, + +#ifdef KLU + /* DEVbindCSC */ VSRCbindCSC, + /* DEVbindCSCComplex */ VSRCbindCSCComplex, + /* DEVbindCSCComplexToReal */ VSRCbindCSCComplexToReal, +#endif + };