From e73fcbb124f8ff11c78787277a6880246f10363a Mon Sep 17 00:00:00 2001 From: Francesco Lannutti Date: Mon, 1 Apr 2013 23:07:30 +0200 Subject: [PATCH] New Binding Method extended to TXL device --- src/spicelib/devices/txl/txlbindCSC.c | 483 ++++++++++++-------------- src/spicelib/devices/txl/txldefs.h | 17 + src/spicelib/devices/txl/txlsetup.c | 18 +- 3 files changed, 257 insertions(+), 261 deletions(-) diff --git a/src/spicelib/devices/txl/txlbindCSC.c b/src/spicelib/devices/txl/txlbindCSC.c index 0a3ec0e81..0be160b0a 100644 --- a/src/spicelib/devices/txl/txlbindCSC.c +++ b/src/spicelib/devices/txl/txlbindCSC.c @@ -1,5 +1,5 @@ /********** -Author: 2012 Francesco Lannutti +Author: 2013 Francesco Lannutti **********/ #include "ngspice/ngspice.h" @@ -7,182 +7,215 @@ Author: 2012 Francesco Lannutti #include "txldefs.h" #include "ngspice/sperror.h" +#include + +static int -TXLbindCSC(GENmodel *inModel, CKTcircuit *ckt) +BindCompare (const void *a, const void *b) { - TXLmodel *model = (TXLmodel *)inModel; - int i ; + BindElement *A, *B ; + A = (BindElement *)a ; + B = (BindElement *)b ; - /* loop through all the txl models */ - for( ; model != NULL; model = model->TXLnextModel ) { - TXLinstance *here; - - /* loop through all the instances of the model */ - for (here = model->TXLinstances; here != NULL ; - here = here->TXLnextInstance) { - - i = 0 ; - if ((here-> TXLposNode != 0) && (here-> TXLposNode != 0)) { - while (here->TXLposPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLposNode != 0) && (here-> TXLnegNode != 0)) { - while (here->TXLposNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLnegNode != 0) && (here-> TXLposNode != 0)) { - while (here->TXLnegPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLnegNode != 0) && (here-> TXLnegNode != 0)) { - while (here->TXLnegNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLibr1 != 0) && (here-> TXLposNode != 0)) { - while (here->TXLibr1Posptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLibr1Posptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLibr2 != 0) && (here-> TXLnegNode != 0)) { - while (here->TXLibr2Negptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLibr2Negptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLnegNode != 0) && (here-> TXLibr2 != 0)) { - while (here->TXLnegIbr2ptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLnegIbr2ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLposNode != 0) && (here-> TXLibr1 != 0)) { - while (here->TXLposIbr1ptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLposIbr1ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLibr1 != 0) && (here-> TXLibr1 != 0)) { - while (here->TXLibr1Ibr1ptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLibr1Ibr1ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLibr2 != 0) && (here-> TXLibr2 != 0)) { - while (here->TXLibr2Ibr2ptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLibr2Ibr2ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLibr1 != 0) && (here-> TXLnegNode != 0)) { - while (here->TXLibr1Negptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLibr1Negptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLibr2 != 0) && (here-> TXLposNode != 0)) { - while (here->TXLibr2Posptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLibr2Posptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLibr1 != 0) && (here-> TXLibr2 != 0)) { - while (here->TXLibr1Ibr2ptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLibr1Ibr2ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - i = 0 ; - if ((here-> TXLibr2 != 0) && (here-> TXLibr1 != 0)) { - while (here->TXLibr2Ibr1ptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ; - here->TXLibr2Ibr1ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } - } - } - return(OK); + return ((int)(A->Sparse - B->Sparse)) ; } int -TXLbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt) +TXLbindCSC (GENmodel *inModel, CKTcircuit *ckt) { - TXLmodel *model = (TXLmodel *)inModel; - int i ; + TXLmodel *model = (TXLmodel *)inModel ; + TXLinstance *here ; + double *i ; + BindElement *matched, *BindStruct ; + size_t nz ; - /* loop through all the txl models */ - for( ; model != NULL; model = model->TXLnextModel ) { - TXLinstance *here; + BindStruct = ckt->CKTmatrix->CKTbindStruct ; + nz = (size_t)ckt->CKTmatrix->CKTklunz ; + /* loop through all the TXL models */ + for ( ; model != NULL ; model = model->TXLnextModel) + { /* loop through all the instances of the model */ - for (here = model->TXLinstances; here != NULL ; - here = here->TXLnextInstance) { + for (here = model->TXLinstances ; here != NULL ; here = here->TXLnextInstance) + { + if ((here-> TXLposNode != 0) && (here-> TXLposNode != 0)) + { + i = here->TXLposPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLposPosptrStructPtr = matched ; + here->TXLposPosptr = matched->CSC ; + } - i = 0 ; - if ((here-> TXLposNode != 0) && (here-> TXLposNode != 0)) { - while (here->TXLposPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLposPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLposNode != 0) && (here-> TXLnegNode != 0)) { - while (here->TXLposNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLposNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLnegNode != 0) && (here-> TXLposNode != 0)) { - while (here->TXLnegPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLnegPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLnegNode != 0) && (here-> TXLnegNode != 0)) { - while (here->TXLnegNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLnegNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLibr1 != 0) && (here-> TXLposNode != 0)) { - while (here->TXLibr1Posptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLibr1Posptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLibr2 != 0) && (here-> TXLnegNode != 0)) { - while (here->TXLibr2Negptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLibr2Negptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLnegNode != 0) && (here-> TXLibr2 != 0)) { - while (here->TXLnegIbr2ptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLnegIbr2ptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLposNode != 0) && (here-> TXLibr1 != 0)) { - while (here->TXLposIbr1ptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLposIbr1ptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLibr1 != 0) && (here-> TXLibr1 != 0)) { - while (here->TXLibr1Ibr1ptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLibr1Ibr1ptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLibr2 != 0) && (here-> TXLibr2 != 0)) { - while (here->TXLibr2Ibr2ptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLibr2Ibr2ptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLibr1 != 0) && (here-> TXLnegNode != 0)) { - while (here->TXLibr1Negptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLibr1Negptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLibr2 != 0) && (here-> TXLposNode != 0)) { - while (here->TXLibr2Posptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLibr2Posptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLibr1 != 0) && (here-> TXLibr2 != 0)) { - while (here->TXLibr1Ibr2ptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLibr1Ibr2ptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - i = 0 ; - if ((here-> TXLibr2 != 0) && (here-> TXLibr1 != 0)) { - while (here->TXLibr2Ibr1ptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ; - here->TXLibr2Ibr1ptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ; - } - } + if ((here-> TXLposNode != 0) && (here-> TXLnegNode != 0)) + { + i = here->TXLposNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLposNegptrStructPtr = matched ; + here->TXLposNegptr = matched->CSC ; + } + + if ((here-> TXLnegNode != 0) && (here-> TXLposNode != 0)) + { + i = here->TXLnegPosptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLnegPosptrStructPtr = matched ; + here->TXLnegPosptr = matched->CSC ; + } + + if ((here-> TXLnegNode != 0) && (here-> TXLnegNode != 0)) + { + i = here->TXLnegNegptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLnegNegptrStructPtr = matched ; + here->TXLnegNegptr = matched->CSC ; + } + + if ((here-> TXLibr1 != 0) && (here-> TXLposNode != 0)) + { + i = here->TXLibr1Posptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr1PosptrStructPtr = matched ; + here->TXLibr1Posptr = matched->CSC ; + } + + if ((here-> TXLibr2 != 0) && (here-> TXLnegNode != 0)) + { + i = here->TXLibr2Negptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr2NegptrStructPtr = matched ; + here->TXLibr2Negptr = matched->CSC ; + } + + if ((here-> TXLnegNode != 0) && (here-> TXLibr2 != 0)) + { + i = here->TXLnegIbr2ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLnegIbr2ptrStructPtr = matched ; + here->TXLnegIbr2ptr = matched->CSC ; + } + + if ((here-> TXLposNode != 0) && (here-> TXLibr1 != 0)) + { + i = here->TXLposIbr1ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLposIbr1ptrStructPtr = matched ; + here->TXLposIbr1ptr = matched->CSC ; + } + + if ((here-> TXLibr1 != 0) && (here-> TXLibr1 != 0)) + { + i = here->TXLibr1Ibr1ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr1Ibr1ptrStructPtr = matched ; + here->TXLibr1Ibr1ptr = matched->CSC ; + } + + if ((here-> TXLibr2 != 0) && (here-> TXLibr2 != 0)) + { + i = here->TXLibr2Ibr2ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr2Ibr2ptrStructPtr = matched ; + here->TXLibr2Ibr2ptr = matched->CSC ; + } + + if ((here-> TXLibr1 != 0) && (here-> TXLnegNode != 0)) + { + i = here->TXLibr1Negptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr1NegptrStructPtr = matched ; + here->TXLibr1Negptr = matched->CSC ; + } + + if ((here-> TXLibr2 != 0) && (here-> TXLposNode != 0)) + { + i = here->TXLibr2Posptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr2PosptrStructPtr = matched ; + here->TXLibr2Posptr = matched->CSC ; + } + + if ((here-> TXLibr1 != 0) && (here-> TXLibr2 != 0)) + { + i = here->TXLibr1Ibr2ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr1Ibr2ptrStructPtr = matched ; + here->TXLibr1Ibr2ptr = matched->CSC ; + } + + if ((here-> TXLibr2 != 0) && (here-> TXLibr1 != 0)) + { + i = here->TXLibr2Ibr1ptr ; + matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; + here->TXLibr2Ibr1ptrStructPtr = matched ; + here->TXLibr2Ibr1ptr = matched->CSC ; + } + + } } - return(OK); + + return (OK) ; +} + +int +TXLbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt) +{ + TXLmodel *model = (TXLmodel *)inModel ; + TXLinstance *here ; + + NG_IGNORE (ckt) ; + + /* loop through all the TXL models */ + for ( ; model != NULL ; model = model->TXLnextModel) + { + /* loop through all the instances of the model */ + for (here = model->TXLinstances ; here != NULL ; here = here->TXLnextInstance) + { + if ((here-> TXLposNode != 0) && (here-> TXLposNode != 0)) + here->TXLposPosptr = here->TXLposPosptrStructPtr->CSC_Complex ; + + if ((here-> TXLposNode != 0) && (here-> TXLnegNode != 0)) + here->TXLposNegptr = here->TXLposNegptrStructPtr->CSC_Complex ; + + if ((here-> TXLnegNode != 0) && (here-> TXLposNode != 0)) + here->TXLnegPosptr = here->TXLnegPosptrStructPtr->CSC_Complex ; + + if ((here-> TXLnegNode != 0) && (here-> TXLnegNode != 0)) + here->TXLnegNegptr = here->TXLnegNegptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr1 != 0) && (here-> TXLposNode != 0)) + here->TXLibr1Posptr = here->TXLibr1PosptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr2 != 0) && (here-> TXLnegNode != 0)) + here->TXLibr2Negptr = here->TXLibr2NegptrStructPtr->CSC_Complex ; + + if ((here-> TXLnegNode != 0) && (here-> TXLibr2 != 0)) + here->TXLnegIbr2ptr = here->TXLnegIbr2ptrStructPtr->CSC_Complex ; + + if ((here-> TXLposNode != 0) && (here-> TXLibr1 != 0)) + here->TXLposIbr1ptr = here->TXLposIbr1ptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr1 != 0) && (here-> TXLibr1 != 0)) + here->TXLibr1Ibr1ptr = here->TXLibr1Ibr1ptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr2 != 0) && (here-> TXLibr2 != 0)) + here->TXLibr2Ibr2ptr = here->TXLibr2Ibr2ptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr1 != 0) && (here-> TXLnegNode != 0)) + here->TXLibr1Negptr = here->TXLibr1NegptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr2 != 0) && (here-> TXLposNode != 0)) + here->TXLibr2Posptr = here->TXLibr2PosptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr1 != 0) && (here-> TXLibr2 != 0)) + here->TXLibr1Ibr2ptr = here->TXLibr1Ibr2ptrStructPtr->CSC_Complex ; + + if ((here-> TXLibr2 != 0) && (here-> TXLibr1 != 0)) + here->TXLibr2Ibr1ptr = here->TXLibr2Ibr1ptrStructPtr->CSC_Complex ; + + } + } + + return (OK) ; } int @@ -190,113 +223,59 @@ TXLbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt) { TXLmodel *model = (TXLmodel *)inModel ; TXLinstance *here ; - int i ; - /* loop through all the txl models */ + NG_IGNORE (ckt) ; + + /* loop through all the TXL models */ for ( ; model != NULL ; model = model->TXLnextModel) { /* loop through all the instances of the model */ for (here = model->TXLinstances ; here != NULL ; here = here->TXLnextInstance) { - i = 0 ; - if ((here->TXLposNode != 0) && (here->TXLposNode != 0)) - { - while (here->TXLposPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLposNode != 0) && (here-> TXLposNode != 0)) + here->TXLposPosptr = here->TXLposPosptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLposNode != 0) && (here->TXLnegNode != 0)) - { - while (here->TXLposNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLposNode != 0) && (here-> TXLnegNode != 0)) + here->TXLposNegptr = here->TXLposNegptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLnegNode != 0) && (here->TXLposNode != 0)) - { - while (here->TXLnegPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLnegNode != 0) && (here-> TXLposNode != 0)) + here->TXLnegPosptr = here->TXLnegPosptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLnegNode != 0) && (here->TXLnegNode != 0)) - { - while (here->TXLnegNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLnegNode != 0) && (here-> TXLnegNode != 0)) + here->TXLnegNegptr = here->TXLnegNegptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLibr1 != 0) && (here->TXLposNode != 0)) - { - while (here->TXLibr1Posptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLibr1Posptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLibr1 != 0) && (here-> TXLposNode != 0)) + here->TXLibr1Posptr = here->TXLibr1PosptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLibr2 != 0) && (here->TXLnegNode != 0)) - { - while (here->TXLibr2Negptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLibr2Negptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLibr2 != 0) && (here-> TXLnegNode != 0)) + here->TXLibr2Negptr = here->TXLibr2NegptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLnegNode != 0) && (here->TXLibr2 != 0)) - { - while (here->TXLnegIbr2ptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLnegIbr2ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLnegNode != 0) && (here-> TXLibr2 != 0)) + here->TXLnegIbr2ptr = here->TXLnegIbr2ptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLposNode != 0) && (here->TXLibr1 != 0)) - { - while (here->TXLposIbr1ptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLposIbr1ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLposNode != 0) && (here-> TXLibr1 != 0)) + here->TXLposIbr1ptr = here->TXLposIbr1ptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLibr1 != 0) && (here->TXLibr1 != 0)) - { - while (here->TXLibr1Ibr1ptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLibr1Ibr1ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLibr1 != 0) && (here-> TXLibr1 != 0)) + here->TXLibr1Ibr1ptr = here->TXLibr1Ibr1ptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLibr2 != 0) && (here->TXLibr2 != 0)) - { - while (here->TXLibr2Ibr2ptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLibr2Ibr2ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLibr2 != 0) && (here-> TXLibr2 != 0)) + here->TXLibr2Ibr2ptr = here->TXLibr2Ibr2ptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLibr1 != 0) && (here->TXLnegNode != 0)) - { - while (here->TXLibr1Negptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLibr1Negptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLibr1 != 0) && (here-> TXLnegNode != 0)) + here->TXLibr1Negptr = here->TXLibr1NegptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLibr2 != 0) && (here->TXLposNode != 0)) - { - while (here->TXLibr2Posptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLibr2Posptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLibr2 != 0) && (here-> TXLposNode != 0)) + here->TXLibr2Posptr = here->TXLibr2PosptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLibr1 != 0) && (here->TXLibr2 != 0)) - { - while (here->TXLibr1Ibr2ptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLibr1Ibr2ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } + if ((here-> TXLibr1 != 0) && (here-> TXLibr2 != 0)) + here->TXLibr1Ibr2ptr = here->TXLibr1Ibr2ptrStructPtr->CSC ; + + if ((here-> TXLibr2 != 0) && (here-> TXLibr1 != 0)) + here->TXLibr2Ibr1ptr = here->TXLibr2Ibr1ptrStructPtr->CSC ; - i = 0 ; - if ((here->TXLibr2 != 0) && (here->TXLibr1 != 0)) - { - while (here->TXLibr2Ibr1ptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ; - here->TXLibr2Ibr1ptr = ckt->CKTmatrix->CKTbind_CSC [i] ; - } } } return (OK) ; -} \ No newline at end of file +} diff --git a/src/spicelib/devices/txl/txldefs.h b/src/spicelib/devices/txl/txldefs.h index c1dc5178d..abc620100 100644 --- a/src/spicelib/devices/txl/txldefs.h +++ b/src/spicelib/devices/txl/txldefs.h @@ -49,6 +49,23 @@ typedef struct sTXLinstance { unsigned TXLdcGiven : 1; unsigned TXLlengthgiven : 1; /* flag to indicate C was specified */ +#ifdef KLU + BindElement *TXLposPosptrStructPtr ; + BindElement *TXLposNegptrStructPtr ; + BindElement *TXLnegPosptrStructPtr ; + BindElement *TXLnegNegptrStructPtr ; + BindElement *TXLibr1PosptrStructPtr ; + BindElement *TXLibr2NegptrStructPtr ; + BindElement *TXLnegIbr2ptrStructPtr ; + BindElement *TXLposIbr1ptrStructPtr ; + BindElement *TXLibr1Ibr1ptrStructPtr ; + BindElement *TXLibr2Ibr2ptrStructPtr ; + BindElement *TXLibr1NegptrStructPtr ; + BindElement *TXLibr2PosptrStructPtr ; + BindElement *TXLibr1Ibr2ptrStructPtr ; + BindElement *TXLibr2Ibr1ptrStructPtr ; +#endif + } TXLinstance ; diff --git a/src/spicelib/devices/txl/txlsetup.c b/src/spicelib/devices/txl/txlsetup.c index 9a176a7b4..c19be4f95 100644 --- a/src/spicelib/devices/txl/txlsetup.c +++ b/src/spicelib/devices/txl/txlsetup.c @@ -117,12 +117,6 @@ TXLsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit*ckt, int *state) /* loop through all the instances of the model */ for (here = model->TXLinstances; here != NULL ; here=here->TXLnextInstance) { - -/* macro to make elements with built in test for out of memory */ -#define TSTALLOC(ptr,first,second) \ -if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ - return(E_NOMEM);\ -} if (! here->TXLibr1Given) { error = CKTmkCur(ckt, &tmp, here->TXLname, "branch1"); @@ -135,6 +129,12 @@ if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ here->TXLibr2 = tmp->number; } +/* macro to make elements with built in test for out of memory */ +#define TSTALLOC(ptr,first,second) \ +if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ + return(E_NOMEM);\ +} + TSTALLOC(TXLposPosptr, TXLposNode, TXLposNode); TSTALLOC(TXLposNegptr, TXLposNode, TXLnegNode); TSTALLOC(TXLnegPosptr, TXLnegNode, TXLposNode); @@ -150,9 +150,9 @@ if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ TSTALLOC(TXLibr1Ibr2ptr, TXLibr1, TXLibr2); TSTALLOC(TXLibr2Ibr1ptr, TXLibr2, TXLibr1); - here->in_node_name = CKTnodName(ckt,here->TXLposNode); - here->out_node_name = CKTnodName(ckt,here->TXLnegNode); - ReadTxL(here, ckt); + here->in_node_name = CKTnodName(ckt,here->TXLposNode); + here->out_node_name = CKTnodName(ckt,here->TXLnegNode); + ReadTxL(here, ckt); } }