From 38947fb651adfa5205fddda76914df14ab6e37ce Mon Sep 17 00:00:00 2001 From: Francesco Lannutti Date: Sun, 4 Nov 2012 13:50:36 +0100 Subject: [PATCH] Experimental changes: Introduced new binding scheme for RES, CAP, IND, VSRC, (ISRC), BSIM4 models to improve speed The old method will not work anymore, so please use KLU only if you have these models in your circuit and nothing more! --- src/include/ngspice/smpdefs.h | 10 +- src/include/ngspice/spmatrix.h | 23 +- src/maths/KLU/klusmp.c | 2 +- src/maths/ni/niinit.c | 1 + src/maths/sparse/spCSC.c | 13 +- src/spicelib/analysis/acan.c | 22 +- src/spicelib/analysis/cktsetup.c | 57 +- src/spicelib/devices/bsim4/b4bindCSC.c | 2176 +++++++++------------- src/spicelib/devices/bsim4/bsim4def.h | 85 + src/spicelib/devices/cap/capbindCSC.c | 156 +- src/spicelib/devices/cap/capdefs.h | 7 + src/spicelib/devices/ind/indMUTbindCSC.c | 318 ++-- src/spicelib/devices/ind/inddefs.h | 12 + src/spicelib/devices/res/resbindCSC.c | 180 +- src/spicelib/devices/res/resdefs.h | 7 + src/spicelib/devices/vsrc/vsrcbindCSC.c | 180 +- src/spicelib/devices/vsrc/vsrcdefs.h | 8 + 17 files changed, 1544 insertions(+), 1713 deletions(-) diff --git a/src/include/ngspice/smpdefs.h b/src/include/ngspice/smpdefs.h index efb8c345a..4646d3a19 100644 --- a/src/include/ngspice/smpdefs.h +++ b/src/include/ngspice/smpdefs.h @@ -20,13 +20,15 @@ Modified: 2000 AlansFixes #if defined(KLU) #include "ngspice/klu.h" +#include "ngspice/spmatrix.h" #elif defined(SuperLU) #include "ngspice/slu_ddefs.h" #elif defined(UMFPACK) #include "ngspice/umfpack.h" #endif -struct SMPmatrix { +/* SMPmatrix structure - Francesco Lannutti (2012-02) */ +typedef struct sSMPmatrix { MatrixFrame *SPmatrix ; /* pointer to sparse matrix */ #if defined(KLU) @@ -45,6 +47,7 @@ struct SMPmatrix { double **CKTbind_Sparse ; /* KLU Sparse original element position */ double **CKTbind_CSC ; /* KLU new element position */ double **CKTbind_CSC_Complex ; /* KLU new element position in Complex analysis */ + BindElement *CKTbindStruct ; /* KLU - Sparse Binding Structure */ double **CKTdiag_CSC ; /* KLU pointer to diagonal element to perform Gmin */ int CKTkluN ; /* KLU N, copied */ int CKTklunz ; /* KLU nz, copied for AC Analysis */ @@ -97,10 +100,7 @@ struct SMPmatrix { #define CKTumfpackOFF 0 /* UMFPACK MODE OFF definition */ #endif -}; - -/* SMPmatrix structure alias - Francesco Lannutti (2012-02) */ -typedef struct SMPmatrix SMPmatrix ; +} SMPmatrix ; #if defined(KLU) || defined(SuperLU) || defined(UMFPACK) diff --git a/src/include/ngspice/spmatrix.h b/src/include/ngspice/spmatrix.h index 68e0890ec..b3ceabfb3 100644 --- a/src/include/ngspice/spmatrix.h +++ b/src/include/ngspice/spmatrix.h @@ -35,6 +35,8 @@ */ +/* Francesco Lannutti 2012-09 - NGSPICE Configuration File Inclusion */ +#include "ngspice/config.h" #ifndef spOKAY @@ -294,10 +296,21 @@ extern void spMultTransposed(MatrixPtr,spREAL*,spREAL*,spREAL*,spREAL*); extern void spSolve( MatrixPtr, spREAL*, spREAL*, spREAL*, spREAL* ); extern void spSolveTransposed(MatrixPtr,spREAL*,spREAL*,spREAL*,spREAL*); -extern int WriteCol_original(MatrixPtr, int, spREAL *, int *, spREAL **, spREAL **, spREAL **); -extern int WriteCol_original_dump(MatrixPtr, int, spREAL *, int *); -extern void spMatrix_CSC(MatrixPtr, int *, int *, double *, int, double **, double **, double **); -extern void spMatrix_CSC_dump(MatrixPtr, char *); -extern void spRHS_CSC_dump(spREAL *, char *, MatrixPtr); + +/* Francesco Lannutti - CSC Data Structure Conversion */ +#ifdef KLU +typedef struct sBindElement { + double *Sparse ; + double *CSC ; + double *CSC_Complex ; +} BindElement ; + +extern int WriteCol_original (MatrixPtr, int, spREAL *, spREAL *, int *, BindElement *, spREAL **) ; +extern int WriteCol_original_dump (MatrixPtr, int, spREAL *, int *) ; +extern void spMatrix_CSC (MatrixPtr, int *, int *, double *, double *, int, BindElement *, double **) ; +extern void spMatrix_CSC_dump (MatrixPtr, char *) ; +extern void spRHS_CSC_dump (spREAL *, char *, MatrixPtr) ; +#endif +/* ------------------------------------------------------ */ #endif /* spOKAY */ diff --git a/src/maths/KLU/klusmp.c b/src/maths/KLU/klusmp.c index 0bc56d488..18f51bc62 100644 --- a/src/maths/KLU/klusmp.c +++ b/src/maths/KLU/klusmp.c @@ -115,7 +115,7 @@ void SMPmatrix_CSC (SMPmatrix *Matrix) { spMatrix_CSC (Matrix->SPmatrix, Matrix->CKTkluAp, Matrix->CKTkluAi, Matrix->CKTkluAx, - Matrix->CKTkluN, Matrix->CKTbind_Sparse, Matrix->CKTbind_CSC, Matrix->CKTdiag_CSC) ; + Matrix->CKTkluAx_Complex, Matrix->CKTkluN, Matrix->CKTbindStruct, Matrix->CKTdiag_CSC) ; return ; } diff --git a/src/maths/ni/niinit.c b/src/maths/ni/niinit.c index f5dbbdc5d..2433c545e 100644 --- a/src/maths/ni/niinit.c +++ b/src/maths/ni/niinit.c @@ -44,6 +44,7 @@ NIinit(CKTcircuit *ckt) ckt->CKTmatrix->CKTbind_Sparse = NULL ; ckt->CKTmatrix->CKTbind_CSC = NULL ; ckt->CKTmatrix->CKTbind_CSC_Complex = NULL ; + ckt->CKTmatrix->CKTbindStruct = NULL ; ckt->CKTmatrix->CKTdiag_CSC = NULL ; ckt->CKTmatrix->CKTkluN = 0 ; ckt->CKTmatrix->CKTklunz = 0 ; diff --git a/src/maths/sparse/spCSC.c b/src/maths/sparse/spCSC.c index 3055c1b58..2d7cd704e 100644 --- a/src/maths/sparse/spCSC.c +++ b/src/maths/sparse/spCSC.c @@ -21,7 +21,7 @@ /* Body */ int -WriteCol_original (MatrixPtr Matrix, int Col, spREAL *CSC_Element, int *CSC_Row, spREAL **bind_Sparse, spREAL **bind_KLU, spREAL **diag) +WriteCol_original (MatrixPtr Matrix, int Col, spREAL *CSC_Element, spREAL *CSC_Element_Complex, int *CSC_Row, BindElement *BindSparseCSC, spREAL **diag) { int i ; ElementPtr current ; @@ -30,8 +30,9 @@ WriteCol_original (MatrixPtr Matrix, int Col, spREAL *CSC_Element, int *CSC_Row, current = Matrix->FirstInCol [Col] ; while (current != NULL) { - bind_Sparse [i] = (double *)current ; - bind_KLU [i] = &(CSC_Element [i]) ; + BindSparseCSC [i].Sparse = (double *)current ; + BindSparseCSC [i].CSC = &(CSC_Element [i]) ; + BindSparseCSC [i].CSC_Complex = &(CSC_Element_Complex [2 * i]) ; CSC_Row [i] = (current->Row) - 1 ; if (CSC_Row [i] == Col - 1) diag [0] = &(CSC_Element [i]) ; @@ -61,15 +62,15 @@ WriteCol_original_dump (MatrixPtr Matrix, int Col, spREAL *CSC_Element, int *CSC } void -spMatrix_CSC (MatrixPtr Matrix, int *Ap, int *Ai, double *Ax, int n, double **bind_Sparse, double **bind_KLU, double **diag) +spMatrix_CSC (MatrixPtr Matrix, int *Ap, int *Ai, double *Ax, double *Ax_Complex, int n, BindElement *BindSparseCSC, double **diag) { int offset, i ; offset = 0 ; Ap[0] = offset ; for (i = 1 ; i <= n ; i++) { - offset += WriteCol_original (Matrix, i, (spREAL *)(Ax + offset), (int *)(Ai + offset), (spREAL **)(bind_Sparse + offset), - (spREAL **)(bind_KLU + offset), (spREAL **)(diag + (i - 1))) ; + offset += WriteCol_original (Matrix, i, (spREAL *)(Ax + offset), (spREAL *)(Ax_Complex + 2 * offset), + (int *)(Ai + offset), BindSparseCSC + offset, (spREAL **)(diag + (i - 1))) ; Ap[i] = offset ; } diff --git a/src/spicelib/analysis/acan.c b/src/spicelib/analysis/acan.c index 5ecf7c30c..fe87c68d5 100644 --- a/src/spicelib/analysis/acan.c +++ b/src/spicelib/analysis/acan.c @@ -243,25 +243,15 @@ ACan(CKTcircuit *ckt, int restart) ckt->CKTcurrentAnalysis = DOING_AC; #ifdef KLU - int i, m ; + int i ; if (ckt->CKTmatrix->CKTkluMODE) { + /* Conversion from Real Matrix to Complex Matrix */ if (!ckt->CKTmatrix->CKTkluMatrixIsComplex) { - ckt->CKTmatrix->CKTkluAx_Complex = TMALLOC (double, 2 * ckt->CKTmatrix->CKTklunz) ; - ckt->CKTmatrix->CKTbind_CSC_Complex = TMALLOC (double *, ckt->CKTmatrix->CKTklunz) ; - ckt->CKTmatrix->CKTkluIntermediate_Complex = TMALLOC (double, 2 * ckt->CKTmatrix->CKTkluN) ; - - m = 0 ; - for (i = 0 ; i < ckt->CKTmatrix->CKTklunz ; i++) - { - ckt->CKTmatrix->CKTbind_CSC_Complex [i] = &(ckt->CKTmatrix->CKTkluAx_Complex [m]) ; - m += 2 ; - } - for (i = 0 ; i < DEVmaxnum ; i++) - if (DEVices [i] && DEVices [i]->DEVbindCSCComplex) + if (DEVices [i] && DEVices [i]->DEVbindCSCComplex && ckt->CKThead [i]) DEVices [i]->DEVbindCSCComplex (ckt->CKThead [i], ckt) ; ckt->CKTmatrix->CKTkluMatrixIsComplex = CKTkluMatrixComplex ; @@ -286,7 +276,7 @@ ACan(CKTcircuit *ckt, int restart) { /* Conversion from Complex Matrix to Real Matrix */ for (i = 0 ; i < DEVmaxnum ; i++) - if (DEVices [i] && DEVices [i]->DEVbindCSCComplexToReal) + if (DEVices [i] && DEVices [i]->DEVbindCSCComplexToReal && ckt->CKThead [i]) DEVices [i]->DEVbindCSCComplexToReal (ckt->CKThead [i], ckt) ; ckt->CKTmatrix->CKTkluMatrixIsComplex = CKTkluMatrixReal ; @@ -326,7 +316,7 @@ ACan(CKTcircuit *ckt, int restart) { /* Conversion from Real Matrix to Complex Matrix */ for (i = 0 ; i < DEVmaxnum ; i++) - if (DEVices [i] && DEVices [i]->DEVbindCSCComplex) + if (DEVices [i] && DEVices [i]->DEVbindCSCComplex && ckt->CKThead [i]) DEVices [i]->DEVbindCSCComplex (ckt->CKThead [i], ckt) ; ckt->CKTmatrix->CKTkluMatrixIsComplex = CKTkluMatrixComplex ; @@ -438,7 +428,7 @@ endsweep: { /* Conversion from Complex Matrix to Real Matrix */ for (i = 0 ; i < DEVmaxnum ; i++) - if (DEVices [i] && DEVices [i]->DEVbindCSCComplexToReal) + if (DEVices [i] && DEVices [i]->DEVbindCSCComplexToReal && ckt->CKThead [i]) DEVices [i]->DEVbindCSCComplexToReal (ckt->CKThead [i], ckt) ; ckt->CKTmatrix->CKTkluMatrixIsComplex = CKTkluMatrixReal ; diff --git a/src/spicelib/analysis/cktsetup.c b/src/spicelib/analysis/cktsetup.c index 81eb7116a..8a1e3bf1d 100644 --- a/src/spicelib/analysis/cktsetup.c +++ b/src/spicelib/analysis/cktsetup.c @@ -26,6 +26,24 @@ int nthreads; return(E_NOMEM);\ } +#ifdef HAS_WINDOWS +extern void SetAnalyse( char * Analyse, int Percent); +#endif + +#ifdef KLU +#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)) ; +} +#endif int CKTsetup(CKTcircuit *ckt) @@ -103,14 +121,23 @@ CKTsetup(CKTcircuit *ckt) ckt->CKTmatrix->CKTkluAx = TMALLOC (double, nz) ; ckt->CKTmatrix->CKTkluIntermediate = TMALLOC (double, n) ; - ckt->CKTmatrix->CKTbind_Sparse = TMALLOC (double *, nz) ; - ckt->CKTmatrix->CKTbind_CSC = TMALLOC (double *, nz) ; +// ckt->CKTmatrix->CKTbind_Sparse = TMALLOC (double *, nz) ; +// ckt->CKTmatrix->CKTbind_CSC = TMALLOC (double *, nz) ; + ckt->CKTmatrix->CKTbindStruct = TMALLOC (BindElement, nz) ; ckt->CKTmatrix->CKTdiag_CSC = TMALLOC (double *, n) ; - /* Binding Table Sparse-KLU creation */ + /* Complex Stuff needed for AC Analysis */ + ckt->CKTmatrix->CKTkluAx_Complex = TMALLOC (double, 2 * nz) ; + ckt->CKTmatrix->CKTkluIntermediate_Complex = TMALLOC (double, 2 * n) ; + + /* Binding Table from Sparse to CSC Format Creation */ SMPmatrix_CSC (ckt->CKTmatrix) ; + /* Binding Table Sorting */ + qsort (ckt->CKTmatrix->CKTbindStruct, (size_t)nz, sizeof(BindElement), BindCompare) ; + + /* KLU Pointers Assignment */ for (i = 0 ; i < DEVmaxnum ; i++) if (DEVices [i] && DEVices [i]->DEVbindCSC && ckt->CKThead [i]) DEVices [i]->DEVbindCSC (ckt->CKThead [i], ckt) ; @@ -135,14 +162,19 @@ CKTsetup(CKTcircuit *ckt) ckt->CKTmatrix->CKTsuperluIntermediate = TMALLOC (double, n) ; - ckt->CKTmatrix->CKTbind_Sparse = TMALLOC (double *, nz) ; - ckt->CKTmatrix->CKTbind_CSC = TMALLOC (double *, nz) ; +// ckt->CKTmatrix->CKTbind_Sparse = TMALLOC (double *, nz) ; +// ckt->CKTmatrix->CKTbind_CSC = TMALLOC (double *, nz) ; + ckt->CKTmatrix->CKTbindStruct = TMALLOC (BindElement, nz) ; ckt->CKTmatrix->CKTdiag_CSC = TMALLOC (double *, n) ; - /* Binding Table Sparse-KLU creation */ + /* Binding Table from Sparse to CSC Format Creation */ SMPmatrix_CSC (ckt->CKTmatrix) ; + /* Binding Table Sorting */ + qsort (ckt->CKTmatrix->CKTbindStruct, (size_t)nz, sizeof(BindElement), BindCompare) ; + + dCreate_CompCol_Matrix (&(ckt->CKTmatrix->CKTsuperluA), n, n, nz, ckt->CKTmatrix->CKTsuperluAx, ckt->CKTmatrix->CKTsuperluAi, ckt->CKTmatrix->CKTsuperluAp, SLU_NC, SLU_D, SLU_GE) ; dCreate_Dense_Matrix (&(ckt->CKTmatrix->CKTsuperluI), n, 1, ckt->CKTmatrix->CKTsuperluIntermediate, @@ -172,13 +204,18 @@ CKTsetup(CKTcircuit *ckt) ckt->CKTmatrix->CKTumfpackX = TMALLOC (double, n) ; - ckt->CKTmatrix->CKTbind_Sparse = TMALLOC (double *, nz) ; - ckt->CKTmatrix->CKTbind_CSC = TMALLOC (double *, nz) ; +// ckt->CKTmatrix->CKTbind_Sparse = TMALLOC (double *, nz) ; +// ckt->CKTmatrix->CKTbind_CSC = TMALLOC (double *, nz) ; + ckt->CKTmatrix->CKTbindStruct = TMALLOC (BindElement, nz) ; ckt->CKTmatrix->CKTdiag_CSC = TMALLOC (double *, n) ; - /* Binding Table Sparse-KLU creation */ - SMPmatrix_CSC (ckt->CKTmatrix) ; + /* Binding Table from Sparse to CSC Format Creation */ + SMPmatrix_CSC (ckt->CKTmatrix) ; + + /* Binding Table Sorting */ + qsort (ckt->CKTmatrix->CKTbindStruct, (size_t)nz, sizeof(BindElement), BindCompare) ; + for (i = 0 ; i < DEVmaxnum ; i++) if (DEVices [i] && DEVices [i]->DEVbindCSC && ckt->CKThead [i]) diff --git a/src/spicelib/devices/bsim4/b4bindCSC.c b/src/spicelib/devices/bsim4/b4bindCSC.c index 39f69eb04..a5e4cce30 100644 --- a/src/spicelib/devices/bsim4/b4bindCSC.c +++ b/src/spicelib/devices/bsim4/b4bindCSC.c @@ -7,1404 +7,1082 @@ Author: 2012 Francesco Lannutti #include "bsim4def.h" #include "ngspice/sperror.h" +#include + +static int -BSIM4bindCSC(GENmodel *inModel, CKTcircuit *ckt) +BindCompare (const void *a, const void *b) { - BSIM4model *model = (BSIM4model *)inModel; - int i ; + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; - /* loop through all the b4 models */ - for( ; model != NULL; model = model->BSIM4nextModel ) { - BSIM4instance *here; - - /* loop through all the instances of the model */ - for (here = model->BSIM4instances; here != NULL ; - here = here->BSIM4nextInstance) { - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4DPbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DPbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4GPbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GPbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4SPbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SPbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4BPdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BPdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4BPgpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BPgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4BPspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BPspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4BPbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BPbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4dNode != 0)) { - while (here->BSIM4DdPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DdPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4GPgpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GPgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4sNode != 0)) { - while (here->BSIM4SsPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SsPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4DPdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DPdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4SPspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SPspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4DdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4GPdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GPdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4GPspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GPspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4SspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4DPspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DPspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4dNode != 0)) { - while (here->BSIM4DPdPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DPdPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4DPgpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DPgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4SPgpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SPgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4sNode != 0)) { - while (here->BSIM4SPsPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SPsPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4SPdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SPdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4qNode != 0)) { - while (here->BSIM4QqPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4QqPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4QbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4QbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4QdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4QdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4QspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4QspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4QgpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4QgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4qNode != 0)) { - while (here->BSIM4DPqPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DPqPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4qNode != 0)) { - while (here->BSIM4SPqPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SPqPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4qNode != 0)) { - while (here->BSIM4GPqPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GPqPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - if (here->BSIM4rgateMod != 0) { - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4gNodeExt != 0)) { - while (here->BSIM4GEgePtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GEgePtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4GEgpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GEgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4gNodeExt != 0)) { - while (here->BSIM4GPgePtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GPgePtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4GEdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GEdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4GEspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GEspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4GEbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GEbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4GMdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GMdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4GMgpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GMgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4GMgmPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GMgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4gNodeExt != 0)) { - while (here->BSIM4GMgePtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GMgePtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4GMspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GMspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4GMbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GMbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4DPgmPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DPgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4GPgmPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GPgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4GEgmPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4GEgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4SPgmPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SPgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4BPgmPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BPgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - } /* IF */ - - if ((here->BSIM4rbodyMod ==1) || (here->BSIM4rbodyMod ==2)) { - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4dbNode != 0)) { - while (here->BSIM4DPdbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DPdbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4sbNode != 0)) { - while (here->BSIM4SPsbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SPsbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dbNode != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4DBdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DBdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dbNode != 0) && (here-> BSIM4dbNode != 0)) { - while (here->BSIM4DBdbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DBdbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dbNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4DBbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DBbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dbNode != 0) && (here-> BSIM4bNode != 0)) { - while (here->BSIM4DBbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DBbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4dbNode != 0)) { - while (here->BSIM4BPdbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BPdbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4bNode != 0)) { - while (here->BSIM4BPbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BPbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4sbNode != 0)) { - while (here->BSIM4BPsbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BPsbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sbNode != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4SBspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SBspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sbNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4SBbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SBbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sbNode != 0) && (here-> BSIM4bNode != 0)) { - while (here->BSIM4SBbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SBbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sbNode != 0) && (here-> BSIM4sbNode != 0)) { - while (here->BSIM4SBsbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SBsbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNode != 0) && (here-> BSIM4dbNode != 0)) { - while (here->BSIM4BdbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BdbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4BbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNode != 0) && (here-> BSIM4sbNode != 0)) { - while (here->BSIM4BsbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BsbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNode != 0) && (here-> BSIM4bNode != 0)) { - while (here->BSIM4BbPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4BbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - } /* IF */ - - if (model->BSIM4rdsMod) { - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4DgpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4DspPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4DbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4DbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4SdpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4SgpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4SbpPtr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->BSIM4SbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - } /* IF */ - } - } - return(OK); + return ((int)(A->Sparse - B->Sparse)) ; } int -BSIM4bindCSCComplex(GENmodel *inModel, CKTcircuit *ckt) -{ - BSIM4model *model = (BSIM4model *)inModel; - int i ; - - /* loop through all the b4 models */ - for( ; model != NULL; model = model->BSIM4nextModel ) { - BSIM4instance *here; - - /* loop through all the instances of the model */ - for (here = model->BSIM4instances; here != NULL ; - here = here->BSIM4nextInstance) { - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4DPbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DPbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4GPbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GPbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4SPbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SPbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4BPdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BPdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4BPgpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BPgpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4BPspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BPspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4BPbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BPbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4dNode != 0)) { - while (here->BSIM4DdPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DdPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4GPgpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GPgpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4sNode != 0)) { - while (here->BSIM4SsPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SsPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4DPdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DPdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4SPspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SPspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4DdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4GPdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GPdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4GPspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GPspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4SspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4DPspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DPspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4dNode != 0)) { - while (here->BSIM4DPdPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DPdPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4DPgpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DPgpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4SPgpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SPgpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4sNode != 0)) { - while (here->BSIM4SPsPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SPsPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4SPdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SPdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4qNode != 0)) { - while (here->BSIM4QqPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4QqPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4QbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4QbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4QdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4QdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4QspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4QspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4qNode != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4QgpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4QgpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4qNode != 0)) { - while (here->BSIM4DPqPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DPqPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4qNode != 0)) { - while (here->BSIM4SPqPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SPqPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4qNode != 0)) { - while (here->BSIM4GPqPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GPqPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - if (here->BSIM4rgateMod != 0) { - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4gNodeExt != 0)) { - while (here->BSIM4GEgePtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GEgePtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4GEgpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GEgpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4gNodeExt != 0)) { - while (here->BSIM4GPgePtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GPgePtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4GEdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GEdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4GEspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GEspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4GEbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GEbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4GMdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GMdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4GMgpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GMgpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4GMgmPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GMgmPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4gNodeExt != 0)) { - while (here->BSIM4GMgePtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GMgePtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4GMspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GMspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeMid != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4GMbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GMbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4DPgmPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DPgmPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodePrime != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4GPgmPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GPgmPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4gNodeExt != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4GEgmPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4GEgmPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4SPgmPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SPgmPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4gNodeMid != 0)) { - while (here->BSIM4BPgmPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BPgmPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - } /* IF */ - - if ((here->BSIM4rbodyMod ==1) || (here->BSIM4rbodyMod ==2)) { - - i = 0 ; - if ((here-> BSIM4dNodePrime != 0) && (here-> BSIM4dbNode != 0)) { - while (here->BSIM4DPdbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DPdbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNodePrime != 0) && (here-> BSIM4sbNode != 0)) { - while (here->BSIM4SPsbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SPsbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dbNode != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4DBdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DBdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dbNode != 0) && (here-> BSIM4dbNode != 0)) { - while (here->BSIM4DBdbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DBdbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dbNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4DBbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DBbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dbNode != 0) && (here-> BSIM4bNode != 0)) { - while (here->BSIM4DBbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DBbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4dbNode != 0)) { - while (here->BSIM4BPdbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BPdbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4bNode != 0)) { - while (here->BSIM4BPbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BPbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNodePrime != 0) && (here-> BSIM4sbNode != 0)) { - while (here->BSIM4BPsbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BPsbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sbNode != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4SBspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SBspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sbNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4SBbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SBbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sbNode != 0) && (here-> BSIM4bNode != 0)) { - while (here->BSIM4SBbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SBbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sbNode != 0) && (here-> BSIM4sbNode != 0)) { - while (here->BSIM4SBsbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SBsbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNode != 0) && (here-> BSIM4dbNode != 0)) { - while (here->BSIM4BdbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BdbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4BbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNode != 0) && (here-> BSIM4sbNode != 0)) { - while (here->BSIM4BsbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BsbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4bNode != 0) && (here-> BSIM4bNode != 0)) { - while (here->BSIM4BbPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4BbPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - } /* IF */ - - if (model->BSIM4rdsMod) { - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4DgpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DgpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4sNodePrime != 0)) { - while (here->BSIM4DspPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DspPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4dNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4DbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4DbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4dNodePrime != 0)) { - while (here->BSIM4SdpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SdpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4gNodePrime != 0)) { - while (here->BSIM4SgpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SgpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here-> BSIM4sNode != 0) && (here-> BSIM4bNodePrime != 0)) { - while (here->BSIM4SbpPtr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->BSIM4SbpPtr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - } /* IF */ - } - } - return(OK); -} - -int -BSIM4bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +BSIM4bindCSC (GENmodel *inModel, CKTcircuit *ckt) { BSIM4model *model = (BSIM4model *)inModel ; BSIM4instance *here ; - int i ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; - /* loop through all the bsim4 models */ + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the BSIM4 models */ for ( ; model != NULL ; model = model->BSIM4nextModel) { /* loop through all the instances of the model */ for (here = model->BSIM4instances ; here != NULL ; here = here->BSIM4nextInstance) { - i = 0 ; if ((here->BSIM4dNodePrime != 0) && (here->BSIM4bNodePrime != 0)) { - while (here->BSIM4DPbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DPbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4DPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DPbpStructPtr = matched ; + here->BSIM4DPbpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4gNodePrime != 0) && (here->BSIM4bNodePrime != 0)) { - while (here->BSIM4GPbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GPbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4GPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GPbpStructPtr = matched ; + here->BSIM4GPbpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4sNodePrime != 0) && (here->BSIM4bNodePrime != 0)) { - while (here->BSIM4SPbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SPbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4SPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SPbpStructPtr = matched ; + here->BSIM4SPbpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4bNodePrime != 0) && (here->BSIM4dNodePrime != 0)) { - while (here->BSIM4BPdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BPdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4BPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BPdpStructPtr = matched ; + here->BSIM4BPdpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4bNodePrime != 0) && (here->BSIM4gNodePrime != 0)) { - while (here->BSIM4BPgpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BPgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4BPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BPgpStructPtr = matched ; + here->BSIM4BPgpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4bNodePrime != 0) && (here->BSIM4sNodePrime != 0)) { - while (here->BSIM4BPspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BPspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4BPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BPspStructPtr = matched ; + here->BSIM4BPspPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4bNodePrime != 0) && (here->BSIM4bNodePrime != 0)) { - while (here->BSIM4BPbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BPbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4BPbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BPbpStructPtr = matched ; + here->BSIM4BPbpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4dNode != 0) && (here->BSIM4dNode != 0)) { - while (here->BSIM4DdPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DdPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4DdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DdStructPtr = matched ; + here->BSIM4DdPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodePrime != 0)) { - while (here->BSIM4GPgpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GPgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4GPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GPgpStructPtr = matched ; + here->BSIM4GPgpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4sNode != 0) && (here->BSIM4sNode != 0)) { - while (here->BSIM4SsPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SsPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4SsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SsStructPtr = matched ; + here->BSIM4SsPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dNodePrime != 0)) { - while (here->BSIM4DPdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DPdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4DPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DPdpStructPtr = matched ; + here->BSIM4DPdpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sNodePrime != 0)) { - while (here->BSIM4SPspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SPspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4SPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SPspStructPtr = matched ; + here->BSIM4SPspPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4dNode != 0) && (here->BSIM4dNodePrime != 0)) { - while (here->BSIM4DdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4DdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DdpStructPtr = matched ; + here->BSIM4DdpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4gNodePrime != 0) && (here->BSIM4dNodePrime != 0)) { - while (here->BSIM4GPdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GPdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4GPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GPdpStructPtr = matched ; + here->BSIM4GPdpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4gNodePrime != 0) && (here->BSIM4sNodePrime != 0)) { - while (here->BSIM4GPspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GPspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4GPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GPspStructPtr = matched ; + here->BSIM4GPspPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4sNode != 0) && (here->BSIM4sNodePrime != 0)) { - while (here->BSIM4SspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4SspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SspStructPtr = matched ; + here->BSIM4SspPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4dNodePrime != 0) && (here->BSIM4sNodePrime != 0)) { - while (here->BSIM4DPspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DPspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4DPspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DPspStructPtr = matched ; + here->BSIM4DPspPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dNode != 0)) { - while (here->BSIM4DPdPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DPdPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4DPdPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DPdStructPtr = matched ; + here->BSIM4DPdPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4dNodePrime != 0) && (here->BSIM4gNodePrime != 0)) { - while (here->BSIM4DPgpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DPgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4DPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DPgpStructPtr = matched ; + here->BSIM4DPgpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4sNodePrime != 0) && (here->BSIM4gNodePrime != 0)) { - while (here->BSIM4SPgpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SPgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4SPgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SPgpStructPtr = matched ; + here->BSIM4SPgpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sNode != 0)) { - while (here->BSIM4SPsPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SPsPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4SPsPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SPsStructPtr = matched ; + here->BSIM4SPsPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4sNodePrime != 0) && (here->BSIM4dNodePrime != 0)) { - while (here->BSIM4SPdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SPdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4SPdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SPdpStructPtr = matched ; + here->BSIM4SPdpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4qNode != 0) && (here->BSIM4qNode != 0)) { - while (here->BSIM4QqPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4QqPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4QqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4QqStructPtr = matched ; + here->BSIM4QqPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4qNode != 0) && (here->BSIM4bNodePrime != 0)) { - while (here->BSIM4QbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4QbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4QbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4QbpStructPtr = matched ; + here->BSIM4QbpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4qNode != 0) && (here->BSIM4dNodePrime != 0)) { - while (here->BSIM4QdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4QdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4QdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4QdpStructPtr = matched ; + here->BSIM4QdpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4qNode != 0) && (here->BSIM4sNodePrime != 0)) { - while (here->BSIM4QspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4QspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4QspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4QspStructPtr = matched ; + here->BSIM4QspPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4qNode != 0) && (here->BSIM4gNodePrime != 0)) { - while (here->BSIM4QgpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4QgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4QgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4QgpStructPtr = matched ; + here->BSIM4QgpPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4dNodePrime != 0) && (here->BSIM4qNode != 0)) { - while (here->BSIM4DPqPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DPqPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4DPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DPqStructPtr = matched ; + here->BSIM4DPqPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4sNodePrime != 0) && (here->BSIM4qNode != 0)) { - while (here->BSIM4SPqPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SPqPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4SPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SPqStructPtr = matched ; + here->BSIM4SPqPtr = matched->CSC ; } - i = 0 ; if ((here->BSIM4gNodePrime != 0) && (here->BSIM4qNode != 0)) { - while (here->BSIM4GPqPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GPqPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + i = here->BSIM4GPqPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GPqStructPtr = matched ; + here->BSIM4GPqPtr = matched->CSC ; } - i = 0 ; - if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodeExt != 0)) + if (here->BSIM4rgateMod != 0) { - while (here->BSIM4GEgePtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GEgePtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodeExt != 0)) + { + i = here->BSIM4GEgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GEgeStructPtr = matched ; + here->BSIM4GEgePtr = matched->CSC ; + } + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodePrime != 0)) + { + i = here->BSIM4GEgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GEgpStructPtr = matched ; + here->BSIM4GEgpPtr = matched->CSC ; + } + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodeExt != 0)) + { + i = here->BSIM4GPgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GPgeStructPtr = matched ; + here->BSIM4GPgePtr = matched->CSC ; + } + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4dNodePrime != 0)) + { + i = here->BSIM4GEdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GEdpStructPtr = matched ; + here->BSIM4GEdpPtr = matched->CSC ; + } + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4sNodePrime != 0)) + { + i = here->BSIM4GEspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GEspStructPtr = matched ; + here->BSIM4GEspPtr = matched->CSC ; + } + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4bNodePrime != 0)) + { + i = here->BSIM4GEbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GEbpStructPtr = matched ; + here->BSIM4GEbpPtr = matched->CSC ; + } + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4dNodePrime != 0)) + { + i = here->BSIM4GMdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GMdpStructPtr = matched ; + here->BSIM4GMdpPtr = matched->CSC ; + } + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodePrime != 0)) + { + i = here->BSIM4GMgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GMgpStructPtr = matched ; + here->BSIM4GMgpPtr = matched->CSC ; + } + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodeMid != 0)) + { + i = here->BSIM4GMgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GMgmStructPtr = matched ; + here->BSIM4GMgmPtr = matched->CSC ; + } + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodeExt != 0)) + { + i = here->BSIM4GMgePtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GMgeStructPtr = matched ; + here->BSIM4GMgePtr = matched->CSC ; + } + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4sNodePrime != 0)) + { + i = here->BSIM4GMspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GMspStructPtr = matched ; + here->BSIM4GMspPtr = matched->CSC ; + } + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4bNodePrime != 0)) + { + i = here->BSIM4GMbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GMbpStructPtr = matched ; + here->BSIM4GMbpPtr = matched->CSC ; + } + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + { + i = here->BSIM4DPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DPgmStructPtr = matched ; + here->BSIM4DPgmPtr = matched->CSC ; + } + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + { + i = here->BSIM4GPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GPgmStructPtr = matched ; + here->BSIM4GPgmPtr = matched->CSC ; + } + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodeMid != 0)) + { + i = here->BSIM4GEgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4GEgmStructPtr = matched ; + here->BSIM4GEgmPtr = matched->CSC ; + } + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + { + i = here->BSIM4SPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SPgmStructPtr = matched ; + here->BSIM4SPgmPtr = matched->CSC ; + } + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + { + i = here->BSIM4BPgmPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BPgmStructPtr = matched ; + here->BSIM4BPgmPtr = matched->CSC ; + } } - i = 0 ; - if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodePrime != 0)) + if ((here->BSIM4rbodyMod == 1) || (here->BSIM4rbodyMod == 2)) { - while (here->BSIM4GEgpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GEgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dbNode != 0)) + { + i = here->BSIM4DPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DPdbStructPtr = matched ; + here->BSIM4DPdbPtr = matched->CSC ; + } + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sbNode != 0)) + { + i = here->BSIM4SPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SPsbStructPtr = matched ; + here->BSIM4SPsbPtr = matched->CSC ; + } + + if ((here->BSIM4dbNode != 0) && (here->BSIM4dNodePrime != 0)) + { + i = here->BSIM4DBdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DBdpStructPtr = matched ; + here->BSIM4DBdpPtr = matched->CSC ; + } + + if ((here->BSIM4dbNode != 0) && (here->BSIM4dbNode != 0)) + { + i = here->BSIM4DBdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DBdbStructPtr = matched ; + here->BSIM4DBdbPtr = matched->CSC ; + } + + if ((here->BSIM4dbNode != 0) && (here->BSIM4bNodePrime != 0)) + { + i = here->BSIM4DBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DBbpStructPtr = matched ; + here->BSIM4DBbpPtr = matched->CSC ; + } + + if ((here->BSIM4dbNode != 0) && (here->BSIM4bNode != 0)) + { + i = here->BSIM4DBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DBbStructPtr = matched ; + here->BSIM4DBbPtr = matched->CSC ; + } + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4dbNode != 0)) + { + i = here->BSIM4BPdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BPdbStructPtr = matched ; + here->BSIM4BPdbPtr = matched->CSC ; + } + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4bNode != 0)) + { + i = here->BSIM4BPbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BPbStructPtr = matched ; + here->BSIM4BPbPtr = matched->CSC ; + } + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4sbNode != 0)) + { + i = here->BSIM4BPsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BPsbStructPtr = matched ; + here->BSIM4BPsbPtr = matched->CSC ; + } + + if ((here->BSIM4sbNode != 0) && (here->BSIM4sNodePrime != 0)) + { + i = here->BSIM4SBspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SBspStructPtr = matched ; + here->BSIM4SBspPtr = matched->CSC ; + } + + if ((here->BSIM4sbNode != 0) && (here->BSIM4bNodePrime != 0)) + { + i = here->BSIM4SBbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SBbpStructPtr = matched ; + here->BSIM4SBbpPtr = matched->CSC ; + } + + if ((here->BSIM4sbNode != 0) && (here->BSIM4bNode != 0)) + { + i = here->BSIM4SBbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SBbStructPtr = matched ; + here->BSIM4SBbPtr = matched->CSC ; + } + + if ((here->BSIM4sbNode != 0) && (here->BSIM4sbNode != 0)) + { + i = here->BSIM4SBsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SBsbStructPtr = matched ; + here->BSIM4SBsbPtr = matched->CSC ; + } + + if ((here->BSIM4bNode != 0) && (here->BSIM4dbNode != 0)) + { + i = here->BSIM4BdbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BdbStructPtr = matched ; + here->BSIM4BdbPtr = matched->CSC ; + } + + if ((here->BSIM4bNode != 0) && (here->BSIM4bNodePrime != 0)) + { + i = here->BSIM4BbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BbpStructPtr = matched ; + here->BSIM4BbpPtr = matched->CSC ; + } + + if ((here->BSIM4bNode != 0) && (here->BSIM4sbNode != 0)) + { + i = here->BSIM4BsbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BsbStructPtr = matched ; + here->BSIM4BsbPtr = matched->CSC ; + } + + if ((here->BSIM4bNode != 0) && (here->BSIM4bNode != 0)) + { + i = here->BSIM4BbPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4BbStructPtr = matched ; + here->BSIM4BbPtr = matched->CSC ; + } } - i = 0 ; - if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodeExt != 0)) + if (model->BSIM4rdsMod) { - while (here->BSIM4GPgePtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GPgePtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here->BSIM4dNode != 0) && (here->BSIM4gNodePrime != 0)) + { + i = here->BSIM4DgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DgpStructPtr = matched ; + here->BSIM4DgpPtr = matched->CSC ; + } - i = 0 ; - if ((here->BSIM4gNodeExt != 0) && (here->BSIM4dNodePrime != 0)) - { - while (here->BSIM4GEdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GEdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here->BSIM4dNode != 0) && (here->BSIM4sNodePrime != 0)) + { + i = here->BSIM4DspPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DspStructPtr = matched ; + here->BSIM4DspPtr = matched->CSC ; + } - i = 0 ; - if ((here->BSIM4gNodeExt != 0) && (here->BSIM4sNodePrime != 0)) - { - while (here->BSIM4GEspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GEspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here->BSIM4dNode != 0) && (here->BSIM4bNodePrime != 0)) + { + i = here->BSIM4DbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4DbpStructPtr = matched ; + here->BSIM4DbpPtr = matched->CSC ; + } - i = 0 ; - if ((here->BSIM4gNodeExt != 0) && (here->BSIM4bNodePrime != 0)) - { - while (here->BSIM4GEbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GEbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here->BSIM4sNode != 0) && (here->BSIM4dNodePrime != 0)) + { + i = here->BSIM4SdpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SdpStructPtr = matched ; + here->BSIM4SdpPtr = matched->CSC ; + } - i = 0 ; - if ((here->BSIM4gNodeMid != 0) && (here->BSIM4dNodePrime != 0)) - { - while (here->BSIM4GMdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GMdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here->BSIM4sNode != 0) && (here->BSIM4gNodePrime != 0)) + { + i = here->BSIM4SgpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SgpStructPtr = matched ; + here->BSIM4SgpPtr = matched->CSC ; + } - i = 0 ; - if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodePrime != 0)) - { - while (here->BSIM4GMgpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GMgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodeMid != 0)) - { - while (here->BSIM4GMgmPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GMgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodeExt != 0)) - { - while (here->BSIM4GMgePtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GMgePtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4gNodeMid != 0) && (here->BSIM4sNodePrime != 0)) - { - while (here->BSIM4GMspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GMspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4gNodeMid != 0) && (here->BSIM4bNodePrime != 0)) - { - while (here->BSIM4GMbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GMbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4dNodePrime != 0) && (here->BSIM4gNodeMid != 0)) - { - while (here->BSIM4DPgmPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DPgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodeMid != 0)) - { - while (here->BSIM4GPgmPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GPgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodeMid != 0)) - { - while (here->BSIM4GEgmPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4GEgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4sNodePrime != 0) && (here->BSIM4gNodeMid != 0)) - { - while (here->BSIM4SPgmPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SPgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4bNodePrime != 0) && (here->BSIM4gNodeMid != 0)) - { - while (here->BSIM4BPgmPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BPgmPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dbNode != 0)) - { - while (here->BSIM4DPdbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DPdbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sbNode != 0)) - { - while (here->BSIM4SPsbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SPsbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4dbNode != 0) && (here->BSIM4dNodePrime != 0)) - { - while (here->BSIM4DBdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DBdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4dbNode != 0) && (here->BSIM4dbNode != 0)) - { - while (here->BSIM4DBdbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DBdbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4dbNode != 0) && (here->BSIM4bNodePrime != 0)) - { - while (here->BSIM4DBbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DBbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4dbNode != 0) && (here->BSIM4bNode != 0)) - { - while (here->BSIM4DBbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DBbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4bNodePrime != 0) && (here->BSIM4dbNode != 0)) - { - while (here->BSIM4BPdbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BPdbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4bNodePrime != 0) && (here->BSIM4bNode != 0)) - { - while (here->BSIM4BPbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BPbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4bNodePrime != 0) && (here->BSIM4sbNode != 0)) - { - while (here->BSIM4BPsbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BPsbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4sbNode != 0) && (here->BSIM4sNodePrime != 0)) - { - while (here->BSIM4SBspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SBspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4sbNode != 0) && (here->BSIM4bNodePrime != 0)) - { - while (here->BSIM4SBbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SBbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4sbNode != 0) && (here->BSIM4bNode != 0)) - { - while (here->BSIM4SBbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SBbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4sbNode != 0) && (here->BSIM4sbNode != 0)) - { - while (here->BSIM4SBsbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SBsbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4bNode != 0) && (here->BSIM4dbNode != 0)) - { - while (here->BSIM4BdbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BdbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4bNode != 0) && (here->BSIM4bNodePrime != 0)) - { - while (here->BSIM4BbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4bNode != 0) && (here->BSIM4sbNode != 0)) - { - while (here->BSIM4BsbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BsbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4bNode != 0) && (here->BSIM4bNode != 0)) - { - while (here->BSIM4BbPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4BbPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4dNode != 0) && (here->BSIM4gNodePrime != 0)) - { - while (here->BSIM4DgpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4dNode != 0) && (here->BSIM4sNodePrime != 0)) - { - while (here->BSIM4DspPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DspPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4dNode != 0) && (here->BSIM4bNodePrime != 0)) - { - while (here->BSIM4DbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4DbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4sNode != 0) && (here->BSIM4dNodePrime != 0)) - { - while (here->BSIM4SdpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SdpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4sNode != 0) && (here->BSIM4gNodePrime != 0)) - { - while (here->BSIM4SgpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SgpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->BSIM4sNode != 0) && (here->BSIM4bNodePrime != 0)) - { - while (here->BSIM4SbpPtr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->BSIM4SbpPtr = ckt->CKTmatrix->CKTbind_CSC [i] ; + if ((here->BSIM4sNode != 0) && (here->BSIM4bNodePrime != 0)) + { + i = here->BSIM4SbpPtr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->BSIM4SbpStructPtr = matched ; + here->BSIM4SbpPtr = matched->CSC ; + } } } } return (OK) ; -} \ No newline at end of file +} + +int +BSIM4bindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM4model *model = (BSIM4model *)inModel ; + BSIM4instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM4 models */ + for ( ; model != NULL ; model = model->BSIM4nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM4instances ; here != NULL ; here = here->BSIM4nextInstance) + { + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4DPbpPtr = here->BSIM4DPbpStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4GPbpPtr = here->BSIM4GPbpStructPtr->CSC_Complex ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4SPbpPtr = here->BSIM4SPbpStructPtr->CSC_Complex ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4BPdpPtr = here->BSIM4BPdpStructPtr->CSC_Complex ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4BPgpPtr = here->BSIM4BPgpStructPtr->CSC_Complex ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4BPspPtr = here->BSIM4BPspStructPtr->CSC_Complex ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4BPbpPtr = here->BSIM4BPbpStructPtr->CSC_Complex ; + + if ((here->BSIM4dNode != 0) && (here->BSIM4dNode != 0)) + here->BSIM4DdPtr = here->BSIM4DdStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4GPgpPtr = here->BSIM4GPgpStructPtr->CSC_Complex ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4sNode != 0)) + here->BSIM4SsPtr = here->BSIM4SsStructPtr->CSC_Complex ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4DPdpPtr = here->BSIM4DPdpStructPtr->CSC_Complex ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4SPspPtr = here->BSIM4SPspStructPtr->CSC_Complex ; + + if ((here->BSIM4dNode != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4DdpPtr = here->BSIM4DdpStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4GPdpPtr = here->BSIM4GPdpStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4GPspPtr = here->BSIM4GPspStructPtr->CSC_Complex ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4SspPtr = here->BSIM4SspStructPtr->CSC_Complex ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4DPspPtr = here->BSIM4DPspStructPtr->CSC_Complex ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dNode != 0)) + here->BSIM4DPdPtr = here->BSIM4DPdStructPtr->CSC_Complex ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4DPgpPtr = here->BSIM4DPgpStructPtr->CSC_Complex ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4SPgpPtr = here->BSIM4SPgpStructPtr->CSC_Complex ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sNode != 0)) + here->BSIM4SPsPtr = here->BSIM4SPsStructPtr->CSC_Complex ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4SPdpPtr = here->BSIM4SPdpStructPtr->CSC_Complex ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4qNode != 0)) + here->BSIM4QqPtr = here->BSIM4QqStructPtr->CSC_Complex ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4QbpPtr = here->BSIM4QbpStructPtr->CSC_Complex ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4QdpPtr = here->BSIM4QdpStructPtr->CSC_Complex ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4QspPtr = here->BSIM4QspStructPtr->CSC_Complex ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4QgpPtr = here->BSIM4QgpStructPtr->CSC_Complex ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4qNode != 0)) + here->BSIM4DPqPtr = here->BSIM4DPqStructPtr->CSC_Complex ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4qNode != 0)) + here->BSIM4SPqPtr = here->BSIM4SPqStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4qNode != 0)) + here->BSIM4GPqPtr = here->BSIM4GPqStructPtr->CSC_Complex ; + + if (here->BSIM4rgateMod != 0) + { + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodeExt != 0)) + here->BSIM4GEgePtr = here->BSIM4GEgeStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4GEgpPtr = here->BSIM4GEgpStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodeExt != 0)) + here->BSIM4GPgePtr = here->BSIM4GPgeStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4GEdpPtr = here->BSIM4GEdpStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4GEspPtr = here->BSIM4GEspStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4GEbpPtr = here->BSIM4GEbpStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4GMdpPtr = here->BSIM4GMdpStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4GMgpPtr = here->BSIM4GMgpStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4GMgmPtr = here->BSIM4GMgmStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodeExt != 0)) + here->BSIM4GMgePtr = here->BSIM4GMgeStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4GMspPtr = here->BSIM4GMspStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4GMbpPtr = here->BSIM4GMbpStructPtr->CSC_Complex ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4DPgmPtr = here->BSIM4DPgmStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4GPgmPtr = here->BSIM4GPgmStructPtr->CSC_Complex ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4GEgmPtr = here->BSIM4GEgmStructPtr->CSC_Complex ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4SPgmPtr = here->BSIM4SPgmStructPtr->CSC_Complex ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4BPgmPtr = here->BSIM4BPgmStructPtr->CSC_Complex ; + } + + if ((here->BSIM4rbodyMod == 1) || (here->BSIM4rbodyMod == 2)) + { + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dbNode != 0)) + here->BSIM4DPdbPtr = here->BSIM4DPdbStructPtr->CSC_Complex ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sbNode != 0)) + here->BSIM4SPsbPtr = here->BSIM4SPsbStructPtr->CSC_Complex ; + + if ((here->BSIM4dbNode != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4DBdpPtr = here->BSIM4DBdpStructPtr->CSC_Complex ; + + if ((here->BSIM4dbNode != 0) && (here->BSIM4dbNode != 0)) + here->BSIM4DBdbPtr = here->BSIM4DBdbStructPtr->CSC_Complex ; + + if ((here->BSIM4dbNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4DBbpPtr = here->BSIM4DBbpStructPtr->CSC_Complex ; + + if ((here->BSIM4dbNode != 0) && (here->BSIM4bNode != 0)) + here->BSIM4DBbPtr = here->BSIM4DBbStructPtr->CSC_Complex ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4dbNode != 0)) + here->BSIM4BPdbPtr = here->BSIM4BPdbStructPtr->CSC_Complex ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4bNode != 0)) + here->BSIM4BPbPtr = here->BSIM4BPbStructPtr->CSC_Complex ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4sbNode != 0)) + here->BSIM4BPsbPtr = here->BSIM4BPsbStructPtr->CSC_Complex ; + + if ((here->BSIM4sbNode != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4SBspPtr = here->BSIM4SBspStructPtr->CSC_Complex ; + + if ((here->BSIM4sbNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4SBbpPtr = here->BSIM4SBbpStructPtr->CSC_Complex ; + + if ((here->BSIM4sbNode != 0) && (here->BSIM4bNode != 0)) + here->BSIM4SBbPtr = here->BSIM4SBbStructPtr->CSC_Complex ; + + if ((here->BSIM4sbNode != 0) && (here->BSIM4sbNode != 0)) + here->BSIM4SBsbPtr = here->BSIM4SBsbStructPtr->CSC_Complex ; + + if ((here->BSIM4bNode != 0) && (here->BSIM4dbNode != 0)) + here->BSIM4BdbPtr = here->BSIM4BdbStructPtr->CSC_Complex ; + + if ((here->BSIM4bNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4BbpPtr = here->BSIM4BbpStructPtr->CSC_Complex ; + + if ((here->BSIM4bNode != 0) && (here->BSIM4sbNode != 0)) + here->BSIM4BsbPtr = here->BSIM4BsbStructPtr->CSC_Complex ; + + if ((here->BSIM4bNode != 0) && (here->BSIM4bNode != 0)) + here->BSIM4BbPtr = here->BSIM4BbStructPtr->CSC_Complex ; + } + + if (model->BSIM4rdsMod) + { + if ((here->BSIM4dNode != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4DgpPtr = here->BSIM4DgpStructPtr->CSC_Complex ; + + if ((here->BSIM4dNode != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4DspPtr = here->BSIM4DspStructPtr->CSC_Complex ; + + if ((here->BSIM4dNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4DbpPtr = here->BSIM4DbpStructPtr->CSC_Complex ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4SdpPtr = here->BSIM4SdpStructPtr->CSC_Complex ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4SgpPtr = here->BSIM4SgpStructPtr->CSC_Complex ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4SbpPtr = here->BSIM4SbpStructPtr->CSC_Complex ; + } + } + } + + return (OK) ; +} +int +BSIM4bindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) +{ + BSIM4model *model = (BSIM4model *)inModel ; + BSIM4instance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the BSIM4 models */ + for ( ; model != NULL ; model = model->BSIM4nextModel) + { + /* loop through all the instances of the model */ + for (here = model->BSIM4instances ; here != NULL ; here = here->BSIM4nextInstance) + { + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4DPbpPtr = here->BSIM4DPbpStructPtr->CSC ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4GPbpPtr = here->BSIM4GPbpStructPtr->CSC ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4SPbpPtr = here->BSIM4SPbpStructPtr->CSC ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4BPdpPtr = here->BSIM4BPdpStructPtr->CSC ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4BPgpPtr = here->BSIM4BPgpStructPtr->CSC ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4BPspPtr = here->BSIM4BPspStructPtr->CSC ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4BPbpPtr = here->BSIM4BPbpStructPtr->CSC ; + + if ((here->BSIM4dNode != 0) && (here->BSIM4dNode != 0)) + here->BSIM4DdPtr = here->BSIM4DdStructPtr->CSC ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4GPgpPtr = here->BSIM4GPgpStructPtr->CSC ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4sNode != 0)) + here->BSIM4SsPtr = here->BSIM4SsStructPtr->CSC ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4DPdpPtr = here->BSIM4DPdpStructPtr->CSC ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4SPspPtr = here->BSIM4SPspStructPtr->CSC ; + + if ((here->BSIM4dNode != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4DdpPtr = here->BSIM4DdpStructPtr->CSC ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4GPdpPtr = here->BSIM4GPdpStructPtr->CSC ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4GPspPtr = here->BSIM4GPspStructPtr->CSC ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4SspPtr = here->BSIM4SspStructPtr->CSC ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4DPspPtr = here->BSIM4DPspStructPtr->CSC ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dNode != 0)) + here->BSIM4DPdPtr = here->BSIM4DPdStructPtr->CSC ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4DPgpPtr = here->BSIM4DPgpStructPtr->CSC ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4SPgpPtr = here->BSIM4SPgpStructPtr->CSC ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sNode != 0)) + here->BSIM4SPsPtr = here->BSIM4SPsStructPtr->CSC ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4SPdpPtr = here->BSIM4SPdpStructPtr->CSC ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4qNode != 0)) + here->BSIM4QqPtr = here->BSIM4QqStructPtr->CSC ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4QbpPtr = here->BSIM4QbpStructPtr->CSC ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4QdpPtr = here->BSIM4QdpStructPtr->CSC ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4QspPtr = here->BSIM4QspStructPtr->CSC ; + + if ((here->BSIM4qNode != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4QgpPtr = here->BSIM4QgpStructPtr->CSC ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4qNode != 0)) + here->BSIM4DPqPtr = here->BSIM4DPqStructPtr->CSC ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4qNode != 0)) + here->BSIM4SPqPtr = here->BSIM4SPqStructPtr->CSC ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4qNode != 0)) + here->BSIM4GPqPtr = here->BSIM4GPqStructPtr->CSC ; + + if (here->BSIM4rgateMod != 0) + { + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodeExt != 0)) + here->BSIM4GEgePtr = here->BSIM4GEgeStructPtr->CSC ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4GEgpPtr = here->BSIM4GEgpStructPtr->CSC ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodeExt != 0)) + here->BSIM4GPgePtr = here->BSIM4GPgeStructPtr->CSC ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4GEdpPtr = here->BSIM4GEdpStructPtr->CSC ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4GEspPtr = here->BSIM4GEspStructPtr->CSC ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4GEbpPtr = here->BSIM4GEbpStructPtr->CSC ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4GMdpPtr = here->BSIM4GMdpStructPtr->CSC ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4GMgpPtr = here->BSIM4GMgpStructPtr->CSC ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4GMgmPtr = here->BSIM4GMgmStructPtr->CSC ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4gNodeExt != 0)) + here->BSIM4GMgePtr = here->BSIM4GMgeStructPtr->CSC ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4GMspPtr = here->BSIM4GMspStructPtr->CSC ; + + if ((here->BSIM4gNodeMid != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4GMbpPtr = here->BSIM4GMbpStructPtr->CSC ; + + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4DPgmPtr = here->BSIM4DPgmStructPtr->CSC ; + + if ((here->BSIM4gNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4GPgmPtr = here->BSIM4GPgmStructPtr->CSC ; + + if ((here->BSIM4gNodeExt != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4GEgmPtr = here->BSIM4GEgmStructPtr->CSC ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4SPgmPtr = here->BSIM4SPgmStructPtr->CSC ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4gNodeMid != 0)) + here->BSIM4BPgmPtr = here->BSIM4BPgmStructPtr->CSC ; + } + + if ((here->BSIM4rbodyMod == 1) || (here->BSIM4rbodyMod == 2)) + { + if ((here->BSIM4dNodePrime != 0) && (here->BSIM4dbNode != 0)) + here->BSIM4DPdbPtr = here->BSIM4DPdbStructPtr->CSC ; + + if ((here->BSIM4sNodePrime != 0) && (here->BSIM4sbNode != 0)) + here->BSIM4SPsbPtr = here->BSIM4SPsbStructPtr->CSC ; + + if ((here->BSIM4dbNode != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4DBdpPtr = here->BSIM4DBdpStructPtr->CSC ; + + if ((here->BSIM4dbNode != 0) && (here->BSIM4dbNode != 0)) + here->BSIM4DBdbPtr = here->BSIM4DBdbStructPtr->CSC ; + + if ((here->BSIM4dbNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4DBbpPtr = here->BSIM4DBbpStructPtr->CSC ; + + if ((here->BSIM4dbNode != 0) && (here->BSIM4bNode != 0)) + here->BSIM4DBbPtr = here->BSIM4DBbStructPtr->CSC ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4dbNode != 0)) + here->BSIM4BPdbPtr = here->BSIM4BPdbStructPtr->CSC ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4bNode != 0)) + here->BSIM4BPbPtr = here->BSIM4BPbStructPtr->CSC ; + + if ((here->BSIM4bNodePrime != 0) && (here->BSIM4sbNode != 0)) + here->BSIM4BPsbPtr = here->BSIM4BPsbStructPtr->CSC ; + + if ((here->BSIM4sbNode != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4SBspPtr = here->BSIM4SBspStructPtr->CSC ; + + if ((here->BSIM4sbNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4SBbpPtr = here->BSIM4SBbpStructPtr->CSC ; + + if ((here->BSIM4sbNode != 0) && (here->BSIM4bNode != 0)) + here->BSIM4SBbPtr = here->BSIM4SBbStructPtr->CSC ; + + if ((here->BSIM4sbNode != 0) && (here->BSIM4sbNode != 0)) + here->BSIM4SBsbPtr = here->BSIM4SBsbStructPtr->CSC ; + + if ((here->BSIM4bNode != 0) && (here->BSIM4dbNode != 0)) + here->BSIM4BdbPtr = here->BSIM4BdbStructPtr->CSC ; + + if ((here->BSIM4bNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4BbpPtr = here->BSIM4BbpStructPtr->CSC ; + + if ((here->BSIM4bNode != 0) && (here->BSIM4sbNode != 0)) + here->BSIM4BsbPtr = here->BSIM4BsbStructPtr->CSC ; + + if ((here->BSIM4bNode != 0) && (here->BSIM4bNode != 0)) + here->BSIM4BbPtr = here->BSIM4BbStructPtr->CSC ; + } + + if (model->BSIM4rdsMod) + { + if ((here->BSIM4dNode != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4DgpPtr = here->BSIM4DgpStructPtr->CSC ; + + if ((here->BSIM4dNode != 0) && (here->BSIM4sNodePrime != 0)) + here->BSIM4DspPtr = here->BSIM4DspStructPtr->CSC ; + + if ((here->BSIM4dNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4DbpPtr = here->BSIM4DbpStructPtr->CSC ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4dNodePrime != 0)) + here->BSIM4SdpPtr = here->BSIM4SdpStructPtr->CSC ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4gNodePrime != 0)) + here->BSIM4SgpPtr = here->BSIM4SgpStructPtr->CSC ; + + if ((here->BSIM4sNode != 0) && (here->BSIM4bNodePrime != 0)) + here->BSIM4SbpPtr = here->BSIM4SbpStructPtr->CSC ; + } + } + } + + return (OK) ; +} diff --git a/src/spicelib/devices/bsim4/bsim4def.h b/src/spicelib/devices/bsim4/bsim4def.h index 5f1cbec06..5ac7c0fc2 100644 --- a/src/spicelib/devices/bsim4/bsim4def.h +++ b/src/spicelib/devices/bsim4/bsim4def.h @@ -569,6 +569,91 @@ typedef struct sBSIM4instance double **BSIM4nVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *BSIM4DPdStructPtr ; + BindElement *BSIM4DPdpStructPtr ; + BindElement *BSIM4DPgpStructPtr ; + BindElement *BSIM4DPgmStructPtr ; + BindElement *BSIM4DPspStructPtr ; + BindElement *BSIM4DPbpStructPtr ; + BindElement *BSIM4DPdbStructPtr ; + + BindElement *BSIM4DdStructPtr ; + BindElement *BSIM4DdpStructPtr ; + + BindElement *BSIM4GPdpStructPtr ; + BindElement *BSIM4GPgpStructPtr ; + BindElement *BSIM4GPgmStructPtr ; + BindElement *BSIM4GPgeStructPtr ; + BindElement *BSIM4GPspStructPtr ; + BindElement *BSIM4GPbpStructPtr ; + + BindElement *BSIM4GMdpStructPtr ; + BindElement *BSIM4GMgpStructPtr ; + BindElement *BSIM4GMgmStructPtr ; + BindElement *BSIM4GMgeStructPtr ; + BindElement *BSIM4GMspStructPtr ; + BindElement *BSIM4GMbpStructPtr ; + + BindElement *BSIM4GEdpStructPtr ; + BindElement *BSIM4GEgpStructPtr ; + BindElement *BSIM4GEgmStructPtr ; + BindElement *BSIM4GEgeStructPtr ; + BindElement *BSIM4GEspStructPtr ; + BindElement *BSIM4GEbpStructPtr ; + + BindElement *BSIM4SPdpStructPtr ; + BindElement *BSIM4SPgpStructPtr ; + BindElement *BSIM4SPgmStructPtr ; + BindElement *BSIM4SPsStructPtr ; + BindElement *BSIM4SPspStructPtr ; + BindElement *BSIM4SPbpStructPtr ; + BindElement *BSIM4SPsbStructPtr ; + + BindElement *BSIM4SspStructPtr ; + BindElement *BSIM4SsStructPtr ; + + BindElement *BSIM4BPdpStructPtr ; + BindElement *BSIM4BPgpStructPtr ; + BindElement *BSIM4BPgmStructPtr ; + BindElement *BSIM4BPspStructPtr ; + BindElement *BSIM4BPdbStructPtr ; + BindElement *BSIM4BPbStructPtr ; + BindElement *BSIM4BPsbStructPtr ; + BindElement *BSIM4BPbpStructPtr ; + + BindElement *BSIM4DBdpStructPtr ; + BindElement *BSIM4DBdbStructPtr ; + BindElement *BSIM4DBbpStructPtr ; + BindElement *BSIM4DBbStructPtr ; + + BindElement *BSIM4SBspStructPtr ; + BindElement *BSIM4SBbpStructPtr ; + BindElement *BSIM4SBbStructPtr ; + BindElement *BSIM4SBsbStructPtr ; + + BindElement *BSIM4BdbStructPtr ; + BindElement *BSIM4BbpStructPtr ; + BindElement *BSIM4BsbStructPtr ; + BindElement *BSIM4BbStructPtr ; + + BindElement *BSIM4DgpStructPtr ; + BindElement *BSIM4DspStructPtr ; + BindElement *BSIM4DbpStructPtr ; + BindElement *BSIM4SdpStructPtr ; + BindElement *BSIM4SgpStructPtr ; + BindElement *BSIM4SbpStructPtr ; + + BindElement *BSIM4QdpStructPtr ; + BindElement *BSIM4QgpStructPtr ; + BindElement *BSIM4QspStructPtr ; + BindElement *BSIM4QbpStructPtr ; + BindElement *BSIM4QqStructPtr ; + BindElement *BSIM4DPqStructPtr ; + BindElement *BSIM4GPqStructPtr ; + BindElement *BSIM4SPqStructPtr ; +#endif + } BSIM4instance ; struct bsim4SizeDependParam diff --git a/src/spicelib/devices/cap/capbindCSC.c b/src/spicelib/devices/cap/capbindCSC.c index 153f63181..3cef6c4a8 100644 --- a/src/spicelib/devices/cap/capbindCSC.c +++ b/src/spicelib/devices/cap/capbindCSC.c @@ -7,44 +7,70 @@ Author: 2012 Francesco Lannutti #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 ; - int i ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; - /* loop through all the capacitor models */ - for ( ; model != NULL ; model = model->CAPnextModel) + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + + /* loop through all the capacitor models */ + for ( ; model != NULL ; model = model->CAPnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CAPinstances ; here != NULL ; here = here->CAPnextInstance) { - /* 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 = 0 ; - if ((here->CAPposNode != 0) && (here->CAPposNode != 0)) { - while (here->CAPposPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->CAPposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + i = here->CAPposPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CAPposPosStructPtr = matched ; + here->CAPposPosptr = matched->CSC ; + } - i = 0 ; - if ((here->CAPnegNode != 0) && (here->CAPnegNode != 0)) { - while (here->CAPnegNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->CAPnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here->CAPnegNode != 0) && (here->CAPnegNode != 0)) + { + i = here->CAPnegNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CAPnegNegStructPtr = matched ; + here->CAPnegNegptr = matched->CSC ; + } - i = 0 ; - if ((here->CAPposNode != 0) && (here->CAPnegNode != 0)) { - while (here->CAPposNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->CAPposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here->CAPposNode != 0) && (here->CAPnegNode != 0)) + { + i = here->CAPposNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CAPposNegStructPtr = matched ; + here->CAPposNegptr = matched->CSC ; + } - i = 0 ; - if ((here->CAPnegNode != 0) && (here->CAPposNode != 0)) { - while (here->CAPnegPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->CAPnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - } - } + if ((here->CAPnegNode != 0) && (here->CAPposNode != 0)) + { + i = here->CAPnegPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->CAPnegPosStructPtr = matched ; + here->CAPnegPosptr = matched->CSC ; + } + } + } return (OK) ; } @@ -54,39 +80,28 @@ CAPbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) { CAPmodel *model = (CAPmodel *)inModel ; CAPinstance *here ; - int i ; - /* loop through all the capacitor models */ - for ( ; model != NULL ; model = model->CAPnextModel) + NG_IGNORE (ckt) ; + + /* loop through all the capacitor models */ + for ( ; model != NULL ; model = model->CAPnextModel) + { + /* loop through all the instances of the model */ + for (here = model->CAPinstances ; here != NULL ; here = here->CAPnextInstance) { - /* loop through all the instances of the model */ - for (here = model->CAPinstances ; here != NULL ; here = here->CAPnextInstance) - { - i = 0 ; - if ((here->CAPposNode != 0) && (here->CAPposNode != 0)) { - while (here->CAPposPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->CAPposPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->CAPposNode != 0) && (here->CAPposNode != 0)) + here->CAPposPosptr = here->CAPposPosStructPtr->CSC_Complex ; - i = 0 ; - if ((here->CAPnegNode != 0) && (here->CAPnegNode != 0)) { - while (here->CAPnegNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->CAPnegNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->CAPnegNode != 0) && (here->CAPnegNode != 0)) + here->CAPnegNegptr = here->CAPnegNegStructPtr->CSC_Complex ; - i = 0 ; - if ((here->CAPposNode != 0) && (here->CAPnegNode != 0)) { - while (here->CAPposNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->CAPposNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->CAPposNode != 0) && (here->CAPnegNode != 0)) + here->CAPposNegptr = here->CAPposNegStructPtr->CSC_Complex ; - i = 0 ; - if ((here->CAPnegNode != 0) && (here->CAPposNode != 0)) { - while (here->CAPnegPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->CAPnegPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - } - } + if ((here->CAPnegNode != 0) && (here->CAPposNode != 0)) + here->CAPnegPosptr = here->CAPnegPosStructPtr->CSC_Complex ; + } + } return (OK) ; } @@ -96,43 +111,28 @@ CAPbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) { CAPmodel *model = (CAPmodel *)inModel ; CAPinstance *here ; - int i ; - /* loop through all the capacitor models */ + NG_IGNORE (ckt) ; + + /* loop through all the capacitor models */ for ( ; model != NULL ; model = model->CAPnextModel) { /* loop through all the instances of the model */ for (here = model->CAPinstances ; here != NULL ; here = here->CAPnextInstance) { - i = 0 ; if ((here->CAPposNode != 0) && (here->CAPposNode != 0)) - { - while (here->CAPposPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->CAPposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->CAPposPosptr = here->CAPposPosStructPtr->CSC ; - i = 0 ; if ((here->CAPnegNode != 0) && (here->CAPnegNode != 0)) - { - while (here->CAPnegNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->CAPnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->CAPnegNegptr = here->CAPnegNegStructPtr->CSC ; - i = 0 ; if ((here->CAPposNode != 0) && (here->CAPnegNode != 0)) - { - while (here->CAPposNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->CAPposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->CAPposNegptr = here->CAPposNegStructPtr->CSC ; - i = 0 ; if ((here->CAPnegNode != 0) && (here->CAPposNode != 0)) - { - while (here->CAPnegPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->CAPnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->CAPnegPosptr = here->CAPnegPosStructPtr->CSC ; } } return (OK) ; -} \ No newline at end of file +} diff --git a/src/spicelib/devices/cap/capdefs.h b/src/spicelib/devices/cap/capdefs.h index 321460c59..9ac5719f9 100644 --- a/src/spicelib/devices/cap/capdefs.h +++ b/src/spicelib/devices/cap/capdefs.h @@ -55,6 +55,13 @@ typedef struct sCAPinstance { int CAPsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ +#ifdef KLU + BindElement *CAPposPosStructPtr ; + BindElement *CAPposNegStructPtr ; + BindElement *CAPnegPosStructPtr ; + BindElement *CAPnegNegStructPtr ; +#endif + } CAPinstance ; #define CAPqcap CAPstate /* charge on the capacitor */ diff --git a/src/spicelib/devices/ind/indMUTbindCSC.c b/src/spicelib/devices/ind/indMUTbindCSC.c index dc63d63b2..6013cf322 100644 --- a/src/spicelib/devices/ind/indMUTbindCSC.c +++ b/src/spicelib/devices/ind/indMUTbindCSC.c @@ -7,100 +7,114 @@ Author: 2012 Francesco Lannutti #include "inddefs.h" #include "ngspice/sperror.h" +#include + +static int -INDbindCSC(GENmodel *inModel, CKTcircuit *ckt) +BindCompare (const void *a, const void *b) { - INDmodel *model = (INDmodel *)inModel; - INDinstance *here; - int i ; + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; - /* loop through all the INDacitor models */ - for( ; model != NULL; model = model->INDnextModel ) { - - /* loop through all the instances of the model */ - for (here = model->INDinstances; here != NULL ; - here=here->INDnextInstance) { - - i = 0 ; - if ((here->INDposNode != 0) && (here->INDbrEq != 0)) { - while (here->INDposIbrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->INDposIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->INDnegNode != 0) && (here->INDbrEq != 0)) { - while (here->INDnegIbrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->INDnegIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->INDbrEq != 0) && (here->INDnegNode != 0)) { - while (here->INDibrNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->INDibrNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->INDbrEq != 0) && (here->INDposNode != 0)) { - while (here->INDibrPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->INDibrPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->INDbrEq != 0) && (here->INDbrEq != 0)) { - while (here->INDibrIbrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->INDibrIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - } - } - return(OK); + return ((int)(A->Sparse - B->Sparse)) ; } int -INDbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt) +INDbindCSC (GENmodel *inModel, CKTcircuit *ckt) { - INDmodel *model = (INDmodel *)inModel; - INDinstance *here; - int i ; + INDmodel *model = (INDmodel *)inModel ; + INDinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; - /* loop through all the INDacitor models */ - for( ; model != NULL; model = model->INDnextModel ) { + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; - /* loop through all the instances of the model */ - for (here = model->INDinstances; here != NULL ; - here=here->INDnextInstance) { + /* loop through all the inductor 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->INDposIbrStructPtr = matched ; + here->INDposIbrptr = matched->CSC ; + } - i = 0 ; - if ((here->INDposNode != 0) && (here->INDbrEq != 0)) { - while (here->INDposIbrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->INDposIbrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->INDnegNode != 0) && (here->INDbrEq != 0)) + { + i = here->INDnegIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->INDnegIbrStructPtr = matched ; + here->INDnegIbrptr = matched->CSC ; + } - i = 0 ; - if ((here->INDnegNode != 0) && (here->INDbrEq != 0)) { - while (here->INDnegIbrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->INDnegIbrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->INDbrEq != 0) && (here->INDnegNode != 0)) + { + i = here->INDibrNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->INDibrNegStructPtr = matched ; + here->INDibrNegptr = matched->CSC ; + } - i = 0 ; - if ((here->INDbrEq != 0) && (here->INDnegNode != 0)) { - while (here->INDibrNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->INDibrNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->INDbrEq != 0) && (here->INDposNode != 0)) + { + i = here->INDibrPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->INDibrPosStructPtr = matched ; + here->INDibrPosptr = matched->CSC ; + } - i = 0 ; - if ((here->INDbrEq != 0) && (here->INDposNode != 0)) { - while (here->INDibrPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->INDibrPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->INDbrEq != 0) && (here->INDbrEq != 0)) + { + i = here->INDibrIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->INDibrIbrStructPtr = matched ; + here->INDibrIbrptr = matched->CSC ; + } + } + } - i = 0 ; - if ((here->INDbrEq != 0) && (here->INDbrEq != 0)) { - while (here->INDibrIbrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->INDibrIbrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - } - } - return(OK); + return (OK) ; +} + +int +INDbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + INDmodel *model = (INDmodel *)inModel ; + INDinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the inductor 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->INDposIbrStructPtr->CSC_Complex ; + + if ((here->INDnegNode != 0) && (here->INDbrEq != 0)) + here->INDnegIbrptr = here->INDnegIbrStructPtr->CSC_Complex ; + + if ((here->INDbrEq != 0) && (here->INDnegNode != 0)) + here->INDibrNegptr = here->INDibrNegStructPtr->CSC_Complex ; + + if ((here->INDbrEq != 0) && (here->INDposNode != 0)) + here->INDibrPosptr = here->INDibrPosStructPtr->CSC_Complex ; + + if ((here->INDbrEq != 0) && (here->INDbrEq != 0)) + here->INDibrIbrptr = here->INDibrIbrStructPtr->CSC_Complex ; + } + } + + return (OK) ; } int @@ -108,48 +122,29 @@ INDbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) { INDmodel *model = (INDmodel *)inModel ; INDinstance *here ; - int i ; - /* loop through all the Inductor models */ + NG_IGNORE (ckt) ; + + /* loop through all the inductor models */ for ( ; model != NULL ; model = model->INDnextModel) { /* loop through all the instances of the model */ for (here = model->INDinstances ; here != NULL ; here = here->INDnextInstance) { - i = 0 ; if ((here->INDposNode != 0) && (here->INDbrEq != 0)) - { - while (here->INDposIbrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->INDposIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->INDposIbrptr = here->INDposIbrStructPtr->CSC ; - i = 0 ; if ((here->INDnegNode != 0) && (here->INDbrEq != 0)) - { - while (here->INDnegIbrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->INDnegIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->INDnegIbrptr = here->INDnegIbrStructPtr->CSC ; - i = 0 ; if ((here->INDbrEq != 0) && (here->INDnegNode != 0)) - { - while (here->INDibrNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->INDibrNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->INDibrNegptr = here->INDibrNegStructPtr->CSC ; - i = 0 ; if ((here->INDbrEq != 0) && (here->INDposNode != 0)) - { - while (here->INDibrPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->INDibrPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->INDibrPosptr = here->INDibrPosStructPtr->CSC ; - i = 0 ; if ((here->INDbrEq != 0) && (here->INDbrEq != 0)) - { - while (here->INDibrIbrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->INDibrIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->INDibrIbrptr = here->INDibrIbrStructPtr->CSC ; } } @@ -158,63 +153,67 @@ INDbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) #ifdef MUTUAL int -MUTbindCSC(GENmodel *inModel, CKTcircuit *ckt) +MUTbindCSC (GENmodel *inModel, CKTcircuit *ckt) { - MUTmodel *model = (MUTmodel *)inModel; - MUTinstance *here; - int i ; + MUTmodel *model = (MUTmodel *)inModel ; + MUTinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; - /* loop through all the INDacitor models */ - for( ; model != NULL; model = model->MUTnextModel ) { + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; - /* loop through all the instances of the model */ - for (here = model->MUTinstances; here != NULL ; - here=here->MUTnextInstance) { + /* loop through all the mutual inductor 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 ; + } - i = 0 ; - if ((here->MUTind1->INDbrEq != 0) && (here->MUTind2->INDbrEq != 0)) { - while (here->MUTbr1br2 != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->MUTbr1br2 = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + 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 ; + } + } + } - i = 0 ; - if ((here->MUTind2->INDbrEq != 0) && (here->MUTind1->INDbrEq != 0)) { - while (here->MUTbr2br1 != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->MUTbr2br1 = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - } - } - return(OK); + return (OK) ; } int -MUTbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt) +MUTbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) { - MUTmodel *model = (MUTmodel *)inModel; - MUTinstance *here; - int i ; + MUTmodel *model = (MUTmodel *)inModel ; + MUTinstance *here ; - /* loop through all the INDacitor models */ - for( ; model != NULL; model = model->MUTnextModel ) { + NG_IGNORE (ckt) ; - /* loop through all the instances of the model */ - for (here = model->MUTinstances; here != NULL ; - here=here->MUTnextInstance) { + /* loop through all the mutual inductor 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 ; - i = 0 ; - if ((here->MUTind1->INDbrEq != 0) && (here->MUTind2->INDbrEq != 0)) { - while (here->MUTbr1br2 != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->MUTbr1br2 = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->MUTind2->INDbrEq != 0) && (here->MUTind1->INDbrEq != 0)) + here->MUTbr2br1 = here->MUTbr2br1StructPtr->CSC_Complex ; + } + } - i = 0 ; - if ((here->MUTind2->INDbrEq != 0) && (here->MUTind1->INDbrEq != 0)) { - while (here->MUTbr2br1 != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->MUTbr2br1 = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - } - } - return(OK); + return (OK) ; } int @@ -222,27 +221,20 @@ MUTbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) { MUTmodel *model = (MUTmodel *)inModel ; MUTinstance *here ; - int i ; - /* loop through all the MutualInductor models */ + NG_IGNORE (ckt) ; + + /* loop through all the mutual inductor models */ for ( ; model != NULL ; model = model->MUTnextModel) { /* loop through all the instances of the model */ for (here = model->MUTinstances ; here != NULL ; here = here->MUTnextInstance) { - i = 0 ; if ((here->MUTind1->INDbrEq != 0) && (here->MUTind2->INDbrEq != 0)) - { - while (here->MUTbr1br2 != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->MUTbr1br2 = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->MUTbr1br2 = here->MUTbr1br2StructPtr->CSC ; - i = 0 ; if ((here->MUTind2->INDbrEq != 0) && (here->MUTind1->INDbrEq != 0)) - { - while (here->MUTbr2br1 != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->MUTbr2br1 = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->MUTbr2br1 = here->MUTbr2br1StructPtr->CSC ; } } diff --git a/src/spicelib/devices/ind/inddefs.h b/src/spicelib/devices/ind/inddefs.h index 86c65a497..6f7228e14 100644 --- a/src/spicelib/devices/ind/inddefs.h +++ b/src/spicelib/devices/ind/inddefs.h @@ -59,6 +59,14 @@ typedef struct sINDinstance { int INDsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ +#ifdef KLU + BindElement *INDposIbrStructPtr ; + BindElement *INDnegIbrStructPtr ; + BindElement *INDibrPosStructPtr ; + BindElement *INDibrNegStructPtr ; + BindElement *INDibrIbrStructPtr ; +#endif + } INDinstance ; #define INDflux INDstate /* flux in the inductor */ @@ -125,6 +133,10 @@ typedef struct sMUTinstance { 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/res/resbindCSC.c b/src/spicelib/devices/res/resbindCSC.c index 2c720bfb7..7bed793cb 100644 --- a/src/spicelib/devices/res/resbindCSC.c +++ b/src/spicelib/devices/res/resbindCSC.c @@ -7,88 +7,103 @@ Author: 2012 Francesco Lannutti #include "resdefs.h" #include "ngspice/sperror.h" +#include + +static int -RESbindCSC(GENmodel *inModel, CKTcircuit *ckt) +BindCompare (const void *a, const void *b) { - RESmodel *model = (RESmodel *)inModel; - int i ; + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; - /* loop through all the resistor models */ - for( ; model != NULL; model = model->RESnextModel ) { - RESinstance *here; - - /* loop through all the instances of the model */ - for (here = model->RESinstances; here != NULL ; - here = here->RESnextInstance) { - - i = 0 ; - if ((here->RESposNode != 0) && (here->RESposNode != 0)) { - while (here->RESposPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->RESposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->RESnegNode != 0) && (here->RESnegNode != 0)) { - while (here->RESnegNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->RESnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->RESposNode != 0) && (here->RESnegNode != 0)) { - while (here->RESposNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->RESposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->RESnegNode != 0) && (here->RESposNode != 0)) { - while (here->RESnegPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->RESnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - } - } - return(OK); + return ((int)(A->Sparse - B->Sparse)) ; } int -RESbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt) +RESbindCSC (GENmodel *inModel, CKTcircuit *ckt) { - RESmodel *model = (RESmodel *)inModel; - int i ; + RESmodel *model = (RESmodel *)inModel ; + RESinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; - /* loop through all the resistor models */ - for( ; model != NULL; model = model->RESnextModel ) { - RESinstance *here; + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + /* loop through all the resistor models */ + for ( ; model != NULL ; model = model->RESnextModel) + { /* loop through all the instances of the model */ - for (here = model->RESinstances; here != NULL ; - here = here->RESnextInstance) { + 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->RESposPosStructPtr = matched ; + here->RESposPosptr = matched->CSC ; + } - i = 0 ; - if ((here->RESposNode != 0) && (here->RESposNode != 0)) { - while (here->RESposPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->RESposPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->RESnegNode != 0) && (here->RESnegNode != 0)) + { + i = here->RESnegNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->RESnegNegStructPtr = matched ; + here->RESnegNegptr = matched->CSC ; + } - i = 0 ; - if ((here->RESnegNode != 0) && (here->RESnegNode != 0)) { - while (here->RESnegNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->RESnegNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->RESposNode != 0) && (here->RESnegNode != 0)) + { + i = here->RESposNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->RESposNegStructPtr = matched ; + here->RESposNegptr = matched->CSC ; + } - i = 0 ; - if ((here->RESposNode != 0) && (here->RESnegNode != 0)) { - while (here->RESposNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->RESposNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here->RESnegNode != 0) && (here->RESposNode != 0)) { - while (here->RESnegPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->RESnegPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - } + if ((here->RESnegNode != 0) && (here->RESposNode != 0)) + { + i = here->RESnegPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->RESnegPosStructPtr = matched ; + here->RESnegPosptr = matched->CSC ; + } + } } - return(OK); + + return (OK) ; +} + +int +RESbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + RESmodel *model = (RESmodel *)inModel ; + RESinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the resistor 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->RESposPosStructPtr->CSC_Complex ; + + if ((here->RESnegNode != 0) && (here->RESnegNode != 0)) + here->RESnegNegptr = here->RESnegNegStructPtr->CSC_Complex ; + + if ((here->RESposNode != 0) && (here->RESnegNode != 0)) + here->RESposNegptr = here->RESposNegStructPtr->CSC_Complex ; + + if ((here->RESnegNode != 0) && (here->RESposNode != 0)) + here->RESnegPosptr = here->RESnegPosStructPtr->CSC_Complex ; + } + } + + return (OK) ; } int @@ -96,41 +111,26 @@ RESbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) { RESmodel *model = (RESmodel *)inModel ; RESinstance *here ; - int i ; - /* loop through all the resistor models */ + NG_IGNORE (ckt) ; + + /* loop through all the resistor models */ for ( ; model != NULL ; model = model->RESnextModel) { /* loop through all the instances of the model */ for (here = model->RESinstances ; here != NULL ; here = here->RESnextInstance) { - i = 0 ; if ((here->RESposNode != 0) && (here->RESposNode != 0)) - { - while (here->RESposPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->RESposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->RESposPosptr = here->RESposPosStructPtr->CSC ; - i = 0 ; if ((here->RESnegNode != 0) && (here->RESnegNode != 0)) - { - while (here->RESnegNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->RESnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->RESnegNegptr = here->RESnegNegStructPtr->CSC ; - i = 0 ; if ((here->RESposNode != 0) && (here->RESnegNode != 0)) - { - while (here->RESposNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->RESposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->RESposNegptr = here->RESposNegStructPtr->CSC ; - i = 0 ; if ((here->RESnegNode != 0) && (here->RESposNode != 0)) - { - while (here->RESnegPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->RESnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->RESnegPosptr = here->RESnegPosStructPtr->CSC ; } } diff --git a/src/spicelib/devices/res/resdefs.h b/src/spicelib/devices/res/resdefs.h index 18c701e76..68669df3d 100644 --- a/src/spicelib/devices/res/resdefs.h +++ b/src/spicelib/devices/res/resdefs.h @@ -81,6 +81,13 @@ typedef struct sRESinstance { double **RESnVar; #endif /* NONOISE */ +#ifdef KLU + BindElement *RESposPosStructPtr ; + BindElement *RESposNegStructPtr ; + BindElement *RESnegPosStructPtr ; + BindElement *RESnegNegStructPtr ; +#endif + } RESinstance ; diff --git a/src/spicelib/devices/vsrc/vsrcbindCSC.c b/src/spicelib/devices/vsrc/vsrcbindCSC.c index c280329ef..968fc90fd 100644 --- a/src/spicelib/devices/vsrc/vsrcbindCSC.c +++ b/src/spicelib/devices/vsrc/vsrcbindCSC.c @@ -7,88 +7,103 @@ Author: 2012 Francesco Lannutti #include "vsrcdefs.h" #include "ngspice/sperror.h" +#include + +static int -VSRCbindCSC(GENmodel *inModel, CKTcircuit *ckt) +BindCompare (const void *a, const void *b) { - VSRCmodel *model = (VSRCmodel *)inModel; - int i ; + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; - /* loop through all the resistor models */ - for( ; model != NULL; model = model->VSRCnextModel ) { - VSRCinstance *here; - - /* loop through all the instances of the model */ - for (here = model->VSRCinstances; here != NULL ; - here = here->VSRCnextInstance) { - - i = 0 ; - if ((here->VSRCposNode != 0) && (here->VSRCbranch != 0)) { - while (here->VSRCposIbrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->VSRCposIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->VSRCnegNode != 0) && (here->VSRCbranch != 0)) { - while (here->VSRCnegIbrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->VSRCnegIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->VSRCbranch != 0) && (here->VSRCnegNode != 0)) { - while (here->VSRCibrNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->VSRCibrNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - - i = 0 ; - if ((here->VSRCbranch != 0) && (here->VSRCposNode != 0)) { - while (here->VSRCibrPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->VSRCibrPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - } - } - return(OK); + return ((int)(A->Sparse - B->Sparse)) ; } int -VSRCbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt) +VSRCbindCSC (GENmodel *inModel, CKTcircuit *ckt) { - VSRCmodel *model = (VSRCmodel *)inModel; - int i ; + VSRCmodel *model = (VSRCmodel *)inModel ; + VSRCinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; - /* loop through all the resistor models */ - for( ; model != NULL; model = model->VSRCnextModel ) { - VSRCinstance *here; + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + /* loop through all the voltage source models */ + for ( ; model != NULL ; model = model->VSRCnextModel) + { /* loop through all the instances of the model */ - for (here = model->VSRCinstances; here != NULL ; - here = here->VSRCnextInstance) { + 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->VSRCposIbrStructPtr = matched ; + here->VSRCposIbrptr = matched->CSC ; + } - i = 0 ; - if ((here->VSRCposNode != 0) && (here->VSRCbranch != 0)) { - while (here->VSRCposIbrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->VSRCposIbrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->VSRCnegNode != 0) && (here->VSRCbranch != 0)) + { + i = here->VSRCnegIbrptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VSRCnegIbrStructPtr = matched ; + here->VSRCnegIbrptr = matched->CSC ; + } - i = 0 ; - if ((here->VSRCnegNode != 0) && (here->VSRCbranch != 0)) { - while (here->VSRCnegIbrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->VSRCnegIbrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } + if ((here->VSRCbranch != 0) && (here->VSRCnegNode != 0)) + { + i = here->VSRCibrNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VSRCibrNegStructPtr = matched ; + here->VSRCibrNegptr = matched->CSC ; + } - i = 0 ; - if ((here->VSRCbranch != 0) && (here->VSRCnegNode != 0)) { - while (here->VSRCibrNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->VSRCibrNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - - i = 0 ; - if ((here->VSRCbranch != 0) && (here->VSRCposNode != 0)) { - while (here->VSRCibrPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->VSRCibrPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - } + if ((here->VSRCbranch != 0) && (here->VSRCposNode != 0)) + { + i = here->VSRCibrPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->VSRCibrPosStructPtr = matched ; + here->VSRCibrPosptr = matched->CSC ; + } + } } - return(OK); + + return (OK) ; +} + +int +VSRCbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + VSRCmodel *model = (VSRCmodel *)inModel ; + VSRCinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the voltage source 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->VSRCposIbrStructPtr->CSC_Complex ; + + if ((here->VSRCnegNode != 0) && (here->VSRCbranch != 0)) + here->VSRCnegIbrptr = here->VSRCnegIbrStructPtr->CSC_Complex ; + + if ((here->VSRCbranch != 0) && (here->VSRCnegNode != 0)) + here->VSRCibrNegptr = here->VSRCibrNegStructPtr->CSC_Complex ; + + if ((here->VSRCbranch != 0) && (here->VSRCposNode != 0)) + here->VSRCibrPosptr = here->VSRCibrPosStructPtr->CSC_Complex ; + } + } + + return (OK) ; } int @@ -96,41 +111,26 @@ VSRCbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) { VSRCmodel *model = (VSRCmodel *)inModel ; VSRCinstance *here ; - int i ; - /* loop through all the source models */ + NG_IGNORE (ckt) ; + + /* loop through all the voltage source models */ for ( ; model != NULL ; model = model->VSRCnextModel) { /* loop through all the instances of the model */ for (here = model->VSRCinstances ; here != NULL ; here = here->VSRCnextInstance) { - i = 0 ; if ((here->VSRCposNode != 0) && (here->VSRCbranch != 0)) - { - while (here->VSRCposIbrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->VSRCposIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->VSRCposIbrptr = here->VSRCposIbrStructPtr->CSC ; - i = 0 ; if ((here->VSRCnegNode != 0) && (here->VSRCbranch != 0)) - { - while (here->VSRCnegIbrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->VSRCnegIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->VSRCnegIbrptr = here->VSRCnegIbrStructPtr->CSC ; - i = 0 ; if ((here->VSRCbranch != 0) && (here->VSRCnegNode != 0)) - { - while (here->VSRCibrNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->VSRCibrNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->VSRCibrNegptr = here->VSRCibrNegStructPtr->CSC ; - i = 0 ; if ((here->VSRCbranch != 0) && (here->VSRCposNode != 0)) - { - while (here->VSRCibrPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->VSRCibrPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + here->VSRCibrPosptr = here->VSRCibrPosStructPtr->CSC ; } } diff --git a/src/spicelib/devices/vsrc/vsrcdefs.h b/src/spicelib/devices/vsrc/vsrcdefs.h index d8f71ec5e..45fa95a4c 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 *VSRCposIbrStructPtr ; + BindElement *VSRCnegIbrStructPtr ; + BindElement *VSRCibrPosStructPtr ; + BindElement *VSRCibrNegStructPtr ; +#endif + } VSRCinstance ;