diff --git a/src/spicelib/devices/bjt/bjtsetup.c b/src/spicelib/devices/bjt/bjtsetup.c index 6c34fd1e2..cb2995660 100644 --- a/src/spicelib/devices/bjt/bjtsetup.c +++ b/src/spicelib/devices/bjt/bjtsetup.c @@ -371,7 +371,7 @@ BJTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) here->BJTstate = *states; *states += BJTnumStates; if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){ - *states += 8 * (ckt->CKTsenInfo->SENparms); + *states += BJTnumSenStates * (ckt->CKTsenInfo->SENparms); } if(model->BJTcollectorResist == 0) { diff --git a/src/spicelib/devices/cap/capdefs.h b/src/spicelib/devices/cap/capdefs.h index 604f6d40e..42ff915ef 100644 --- a/src/spicelib/devices/cap/capdefs.h +++ b/src/spicelib/devices/cap/capdefs.h @@ -75,9 +75,14 @@ typedef struct sCAPinstance { #define CAPqcap CAPstate /* charge on the capacitor */ #define CAPccap CAPstate+1 /* current through the capacitor */ + +#define CAPnumStates 2 + #define CAPsensxp CAPstate+2 /* charge sensitivities and their derivatives. -+3 for the derivatives - pointer to the -beginning of the array */ + * +3 for the derivatives - pointer to the + * beginning of the array */ + +#define CAPnumSenStates 2 #ifdef USE_CUSPICE typedef struct sCAPparamCPUstruct { diff --git a/src/spicelib/devices/cap/capsetup.c b/src/spicelib/devices/cap/capsetup.c index d6d91ef9b..c343a5aa0 100644 --- a/src/spicelib/devices/cap/capsetup.c +++ b/src/spicelib/devices/cap/capsetup.c @@ -103,9 +103,9 @@ CAPsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) } here->CAPqcap = *states; - *states += 2; + *states += CAPnumStates; if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){ - *states += 2 * (ckt->CKTsenInfo->SENparms); + *states += CAPnumSenStates * (ckt->CKTsenInfo->SENparms); } /* macro to make elements with built in test for out of memory */ diff --git a/src/spicelib/devices/dio/diodefs.h b/src/spicelib/devices/dio/diodefs.h index 97f7cf65f..03f9d04ae 100644 --- a/src/spicelib/devices/dio/diodefs.h +++ b/src/spicelib/devices/dio/diodefs.h @@ -169,10 +169,15 @@ typedef struct sDIOinstance { #define DIOconduct DIOstate+2 #define DIOcapCharge DIOstate+3 #define DIOcapCurrent DIOstate+4 + +#define DIOnumStates 5 + #define DIOsensxp DIOstate+5 /* charge sensitivities and their derivatives. * +6 for the derivatives - pointer to the * beginning of the array */ +#define DIOnumSenStates 2 + /* per model data */ diff --git a/src/spicelib/devices/dio/diosetup.c b/src/spicelib/devices/dio/diosetup.c index df6c5a628..8fbff587b 100644 --- a/src/spicelib/devices/dio/diosetup.c +++ b/src/spicelib/devices/dio/diosetup.c @@ -201,9 +201,9 @@ DIOsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) here->DIOjunctionSWCap = model->DIOjunctionSWCap * here->DIOpj; here->DIOstate = *states; - *states += 5; + *states += DIOnumStates; if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){ - *states += 2 * (ckt->CKTsenInfo->SENparms); + *states += DIOnumSenStates * (ckt->CKTsenInfo->SENparms); } if(model->DIOresist == 0) { diff --git a/src/spicelib/devices/hfet1/hfetdefs.h b/src/spicelib/devices/hfet1/hfetdefs.h index 0a08d892b..c17f7c966 100644 --- a/src/spicelib/devices/hfet1/hfetdefs.h +++ b/src/spicelib/devices/hfet1/hfetdefs.h @@ -12,8 +12,6 @@ Modified: Paolo Nenzi #include "ngspice/complex.h" #include "ngspice/noisedef.h" -#define HFETAnumStates 24 - typedef struct sHFETAinstance { struct GENinstance gen; @@ -97,6 +95,8 @@ typedef struct sHFETAinstance { #define HFETAgmg HFETAstate+22 #define HFETAgmd HFETAstate+23 +#define HFETAnumStates 24 + int HFETAoff; diff --git a/src/spicelib/devices/hfet1/hfetsetup.c b/src/spicelib/devices/hfet1/hfetsetup.c index ce6b8dc84..74fbd3329 100644 --- a/src/spicelib/devices/hfet1/hfetsetup.c +++ b/src/spicelib/devices/hfet1/hfetsetup.c @@ -249,7 +249,6 @@ HFETAsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) } here->HFETAstate = *states; - /* *states += 24; */ *states += HFETAnumStates; if(model->HFETArs != 0) { diff --git a/src/spicelib/devices/hfet2/hfet2defs.h b/src/spicelib/devices/hfet2/hfet2defs.h index a41e952e3..bfa6e461a 100644 --- a/src/spicelib/devices/hfet2/hfet2defs.h +++ b/src/spicelib/devices/hfet2/hfet2defs.h @@ -63,7 +63,9 @@ typedef struct sHFET2instance { #define HFET2cqgs HFET2state+10 #define HFET2qgd HFET2state+11 #define HFET2cqgd HFET2state+12 - + +#define HFET2numStates 13 + int HFET2mode; int HFET2off; diff --git a/src/spicelib/devices/hfet2/hfet2setup.c b/src/spicelib/devices/hfet2/hfet2setup.c index fb3fce920..ff24b1909 100644 --- a/src/spicelib/devices/hfet2/hfet2setup.c +++ b/src/spicelib/devices/hfet2/hfet2setup.c @@ -133,7 +133,7 @@ int HFET2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *state IFuid tmpName; here->HFET2state = *states; - *states += 13; + *states += HFET2numStates; if(!here->HFET2lengthGiven) L = 1e-6; diff --git a/src/spicelib/devices/ind/inddefs.h b/src/spicelib/devices/ind/inddefs.h index a157dc3ea..e2ff89c21 100644 --- a/src/spicelib/devices/ind/inddefs.h +++ b/src/spicelib/devices/ind/inddefs.h @@ -89,10 +89,15 @@ struct sINDinstance { #define INDflux INDstate /* flux in the inductor */ #define INDvolt INDstate+1 /* voltage - save an entry in table */ + +#define INDnumStates 2 + #define INDsensxp INDstate+2 /* charge sensitivities and their derivatives. * +3 for the derivatives - pointer to the * beginning of the array */ +#define INDnumSenStates 2 + #ifdef USE_CUSPICE typedef struct sINDparamCPUstruct { double *INDcpuPointersD [4]; diff --git a/src/spicelib/devices/ind/indsetup.c b/src/spicelib/devices/ind/indsetup.c index 889cb468d..b5ef543ea 100644 --- a/src/spicelib/devices/ind/indsetup.c +++ b/src/spicelib/devices/ind/indsetup.c @@ -80,9 +80,9 @@ INDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) here=INDnextInstance(here)) { here->INDflux = *states; - *states += 2 ; + *states += INDnumStates ; if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){ - *states += 2 * (ckt->CKTsenInfo->SENparms); + *states += INDnumSenStates * (ckt->CKTsenInfo->SENparms); } if(here->INDbrEq == 0) { diff --git a/src/spicelib/devices/jfet/jfetdefs.h b/src/spicelib/devices/jfet/jfetdefs.h index 701dc0375..90a1d5cd7 100644 --- a/src/spicelib/devices/jfet/jfetdefs.h +++ b/src/spicelib/devices/jfet/jfetdefs.h @@ -186,6 +186,8 @@ typedef struct sJFETinstance { #define JFETqgd JFETstate+11 #define JFETcqgd JFETstate+12 +#define JFETnumStates 13 + /* per model data */ typedef struct sJFETmodel { /* model structure for a jfet */ diff --git a/src/spicelib/devices/jfet/jfetset.c b/src/spicelib/devices/jfet/jfetset.c index 0089aca18..8250faa23 100644 --- a/src/spicelib/devices/jfet/jfetset.c +++ b/src/spicelib/devices/jfet/jfetset.c @@ -115,7 +115,7 @@ JFETsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) here->JFETm = 1; } here->JFETstate = *states; - *states += 13; + *states += JFETnumStates; if(model->JFETsourceResist != 0) { if(here->JFETsourcePrimeNode == 0) { diff --git a/src/spicelib/devices/jfet2/jfet2defs.h b/src/spicelib/devices/jfet2/jfet2defs.h index f8b2a230b..bb0aae1d4 100644 --- a/src/spicelib/devices/jfet2/jfet2defs.h +++ b/src/spicelib/devices/jfet2/jfet2defs.h @@ -196,7 +196,9 @@ typedef struct sJFET2instance { #define JFET2pave JFET2state+15 #define JFET2vtrap JFET2state+16 #define JFET2vgstrap JFET2state+17 -#define JFET2_STATE_COUNT 18 +#define JFET2unknown JFET2state+18 + +#define JFET2numStates 19 /* per model data */ diff --git a/src/spicelib/devices/jfet2/jfet2set.c b/src/spicelib/devices/jfet2/jfet2set.c index 5a6e07ac1..7ac6482fa 100644 --- a/src/spicelib/devices/jfet2/jfet2set.c +++ b/src/spicelib/devices/jfet2/jfet2set.c @@ -55,7 +55,7 @@ JFET2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) } here->JFET2state = *states; - *states += JFET2_STATE_COUNT + 1; + *states += JFET2numStates; if(model->JFET2rs != 0) { if(here->JFET2sourcePrimeNode == 0) { diff --git a/src/spicelib/devices/mesa/mesadefs.h b/src/spicelib/devices/mesa/mesadefs.h index 50bdcece4..a7d89dade 100644 --- a/src/spicelib/devices/mesa/mesadefs.h +++ b/src/spicelib/devices/mesa/mesadefs.h @@ -111,6 +111,8 @@ typedef struct sMESAinstance { #define MESAggdpp MESAstate+18 #define MESAcgdpp MESAstate+19 +#define MESAnumStates 20 + int MESAoff; unsigned MESAlengthGiven : 1; unsigned MESAwidthGiven : 1; diff --git a/src/spicelib/devices/mesa/mesasetup.c b/src/spicelib/devices/mesa/mesasetup.c index fbb40946c..924f13efa 100644 --- a/src/spicelib/devices/mesa/mesasetup.c +++ b/src/spicelib/devices/mesa/mesasetup.c @@ -257,7 +257,7 @@ MESAsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) here->MESAstate = *states; - *states += 20; + *states += MESAnumStates; if(model->MESAsourceResist != 0) { if(here->MESAsourcePrimeNode == 0) { diff --git a/src/spicelib/devices/mos1/mos1defs.h b/src/spicelib/devices/mos1/mos1defs.h index 8117bf655..85f9d7afa 100644 --- a/src/spicelib/devices/mos1/mos1defs.h +++ b/src/spicelib/devices/mos1/mos1defs.h @@ -318,9 +318,9 @@ typedef struct sMOS1instance { #define MOS1numStates 17 -#define MOS1sensxpgs MOS1states+17 /* charge sensitivities and - their derivatives. +18 for the derivatives: - pointer to the beginning of the array */ +#define MOS1sensxpgs MOS1states+17 /* charge sensitivities and their derivatives. + * +18 for the derivatives + * pointer to the beginning of the array */ #define MOS1sensxpgd MOS1states+19 #define MOS1sensxpgb MOS1states+21 #define MOS1sensxpbs MOS1states+23 diff --git a/src/spicelib/devices/mos1/mos1set.c b/src/spicelib/devices/mos1/mos1set.c index ed8eac5d7..d829d3c91 100644 --- a/src/spicelib/devices/mos1/mos1set.c +++ b/src/spicelib/devices/mos1/mos1set.c @@ -102,7 +102,7 @@ MOS1setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, *states += MOS1numStates; if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){ - *states += 10 * (ckt->CKTsenInfo->SENparms); + *states += MOS1numSenStates * (ckt->CKTsenInfo->SENparms); } if(!here->MOS1drainPerimiterGiven) { diff --git a/src/spicelib/devices/mos2/mos2defs.h b/src/spicelib/devices/mos2/mos2defs.h index 407ac3026..79fcf8e4a 100644 --- a/src/spicelib/devices/mos2/mos2defs.h +++ b/src/spicelib/devices/mos2/mos2defs.h @@ -325,8 +325,8 @@ typedef struct sMOS2instance { #define MOS2sensxpgs MOS2states+17 /* charge sensitivities and their derivatives - +18 for the derivatives - pointer to the - beginning of the array */ + * +18 for the derivatives + * pointer to the beginning of the array */ #define MOS2sensxpgd MOS2states+19 #define MOS2sensxpgb MOS2states+21 diff --git a/src/spicelib/devices/mos2/mos2set.c b/src/spicelib/devices/mos2/mos2set.c index b452a81a0..c1959f722 100644 --- a/src/spicelib/devices/mos2/mos2set.c +++ b/src/spicelib/devices/mos2/mos2set.c @@ -134,7 +134,7 @@ MOS2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) *states += MOS2numStates; if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){ - *states += 10 * (ckt->CKTsenInfo->SENparms); + *states += MOS2numSenStates * (ckt->CKTsenInfo->SENparms); } if(!here->MOS2drainPerimiterGiven) { diff --git a/src/spicelib/devices/mos6/mos6defs.h b/src/spicelib/devices/mos6/mos6defs.h index 580a3b2af..56685e9f4 100644 --- a/src/spicelib/devices/mos6/mos6defs.h +++ b/src/spicelib/devices/mos6/mos6defs.h @@ -250,9 +250,9 @@ typedef struct sMOS6instance { #define MOS6numStates 17 -#define MOS6sensxpgs MOS6states+17 /* charge sensitivities and - their derivatives. +18 for the derivatives: - pointer to the beginning of the array */ +#define MOS6sensxpgs MOS6states+17 /* charge sensitivities and their derivatives. + * +18 for the derivatives + * pointer to the beginning of the array */ #define MOS6sensxpgd MOS6states+19 #define MOS6sensxpgb MOS6states+21 #define MOS6sensxpbs MOS6states+23 diff --git a/src/spicelib/devices/mos6/mos6set.c b/src/spicelib/devices/mos6/mos6set.c index 351600dfc..4ff71040f 100644 --- a/src/spicelib/devices/mos6/mos6set.c +++ b/src/spicelib/devices/mos6/mos6set.c @@ -150,7 +150,7 @@ MOS6setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, here->MOS6states = *states; *states += MOS6numStates; if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){ - *states += 10 * (ckt->CKTsenInfo->SENparms); + *states += MOS6numSenStates * (ckt->CKTsenInfo->SENparms); } if((model->MOS6drainResistance != 0 || diff --git a/src/spicelib/devices/soi3/soi3set.c b/src/spicelib/devices/soi3/soi3set.c index 703b9cea2..c7392672e 100644 --- a/src/spicelib/devices/soi3/soi3set.c +++ b/src/spicelib/devices/soi3/soi3set.c @@ -334,7 +334,7 @@ SOI3setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) here->SOI3states = *states; *states += SOI3numStates; /* if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){ - *states += 10 * (ckt->CKTsenInfo->SENparms); + *states += SOI3numSenStates * (ckt->CKTsenInfo->SENparms); } */ /****** Part 4 - check resistance values for internal nodes, ******/ diff --git a/src/spicelib/devices/vbic/vbicdefs.h b/src/spicelib/devices/vbic/vbicdefs.h index 1dd356607..1cd42e311 100644 --- a/src/spicelib/devices/vbic/vbicdefs.h +++ b/src/spicelib/devices/vbic/vbicdefs.h @@ -393,9 +393,9 @@ typedef struct sVBICinstance { #define VBICnumStates 66 -#define VBICsensxpbe VBICstate+66 /* charge sensitivities and their - derivatives. +67 for the derivatives - - pointer to the beginning of the array */ +#define VBICsensxpbe VBICstate+66 /* charge sensitivities and their derivatives. + * +67 for the derivatives + * pointer to the beginning of the array */ #define VBICsensxpbex VBICstate+68 #define VBICsensxpbc VBICstate+70 #define VBICsensxpbcx VBICstate+72 diff --git a/src/spicelib/devices/vbic/vbicsetup.c b/src/spicelib/devices/vbic/vbicsetup.c index 9db9787ca..297604925 100644 --- a/src/spicelib/devices/vbic/vbicsetup.c +++ b/src/spicelib/devices/vbic/vbicsetup.c @@ -403,7 +403,7 @@ VBICsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) here->VBICstate = *states; *states += VBICnumStates; if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & TRANSEN) ){ - *states += 10 * (ckt->CKTsenInfo->SENparms); + *states += VBICnumSenStates * (ckt->CKTsenInfo->SENparms); } if(model->VBICextCollResist == 0) {