diff --git a/src/spicelib/devices/bjt/bjtsetup.c b/src/spicelib/devices/bjt/bjtsetup.c index e2cc3d3ba..961ea5100 100644 --- a/src/spicelib/devices/bjt/bjtsetup.c +++ b/src/spicelib/devices/bjt/bjtsetup.c @@ -366,7 +366,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 c6fe2959e..5761df119 100644 --- a/src/spicelib/devices/cap/capdefs.h +++ b/src/spicelib/devices/cap/capdefs.h @@ -68,9 +68,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 /* data per model */ diff --git a/src/spicelib/devices/cap/capsetup.c b/src/spicelib/devices/cap/capsetup.c index c003bd57a..2626b0e3e 100644 --- a/src/spicelib/devices/cap/capsetup.c +++ b/src/spicelib/devices/cap/capsetup.c @@ -100,9 +100,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 280a1e0ce..4ba49466a 100644 --- a/src/spicelib/devices/dio/diodefs.h +++ b/src/spicelib/devices/dio/diodefs.h @@ -159,10 +159,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 e06b13ba1..fa2c14127 100644 --- a/src/spicelib/devices/dio/diosetup.c +++ b/src/spicelib/devices/dio/diosetup.c @@ -196,9 +196,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 1c3ac5ce4..64f03f099 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 fa29ef325..4b45a477d 100644 --- a/src/spicelib/devices/hfet1/hfetsetup.c +++ b/src/spicelib/devices/hfet1/hfetsetup.c @@ -243,7 +243,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 5e938c7f2..7710d210b 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 cb51d3a7c..5c94a8e60 100644 --- a/src/spicelib/devices/hfet2/hfet2setup.c +++ b/src/spicelib/devices/hfet2/hfet2setup.c @@ -127,7 +127,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 e987bc4cb..ac8b9766a 100644 --- a/src/spicelib/devices/ind/inddefs.h +++ b/src/spicelib/devices/ind/inddefs.h @@ -79,10 +79,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 + /* per model data */ diff --git a/src/spicelib/devices/ind/indsetup.c b/src/spicelib/devices/ind/indsetup.c index 51bd0d924..92da1746d 100644 --- a/src/spicelib/devices/ind/indsetup.c +++ b/src/spicelib/devices/ind/indsetup.c @@ -76,9 +76,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 2dbc79b29..64d30177f 100644 --- a/src/spicelib/devices/jfet/jfetdefs.h +++ b/src/spicelib/devices/jfet/jfetdefs.h @@ -168,6 +168,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 d2de3d65f..6202dae3e 100644 --- a/src/spicelib/devices/jfet/jfetset.c +++ b/src/spicelib/devices/jfet/jfetset.c @@ -110,7 +110,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 320c96608..b1e7b7f64 100644 --- a/src/spicelib/devices/jfet2/jfet2defs.h +++ b/src/spicelib/devices/jfet2/jfet2defs.h @@ -178,7 +178,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 344379320..028ee4505 100644 --- a/src/spicelib/devices/jfet2/jfet2set.c +++ b/src/spicelib/devices/jfet2/jfet2set.c @@ -50,7 +50,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 1f6c652cd..9d9a02975 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 95c7a05ec..9807c0a5d 100644 --- a/src/spicelib/devices/mesa/mesasetup.c +++ b/src/spicelib/devices/mesa/mesasetup.c @@ -251,7 +251,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 81b79c7f4..17a8b85d4 100644 --- a/src/spicelib/devices/mos1/mos1defs.h +++ b/src/spicelib/devices/mos1/mos1defs.h @@ -293,9 +293,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 a4483de3a..6912cbe71 100644 --- a/src/spicelib/devices/mos1/mos1set.c +++ b/src/spicelib/devices/mos1/mos1set.c @@ -97,7 +97,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 431dc7d35..8f9cc213a 100644 --- a/src/spicelib/devices/mos2/mos2defs.h +++ b/src/spicelib/devices/mos2/mos2defs.h @@ -302,8 +302,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 b12eb1a98..3c3acfd4d 100644 --- a/src/spicelib/devices/mos2/mos2set.c +++ b/src/spicelib/devices/mos2/mos2set.c @@ -129,7 +129,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 ba871ac67..8fd3a9979 100644 --- a/src/spicelib/devices/mos6/mos6defs.h +++ b/src/spicelib/devices/mos6/mos6defs.h @@ -225,9 +225,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 a46840630..79bd2bf6b 100644 --- a/src/spicelib/devices/mos6/mos6set.c +++ b/src/spicelib/devices/mos6/mos6set.c @@ -145,7 +145,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 11eade08a..eb7178c9d 100644 --- a/src/spicelib/devices/soi3/soi3set.c +++ b/src/spicelib/devices/soi3/soi3set.c @@ -329,7 +329,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 012bd7e95..df4214cd3 100644 --- a/src/spicelib/devices/vbic/vbicdefs.h +++ b/src/spicelib/devices/vbic/vbicdefs.h @@ -339,9 +339,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 b483cfdf4..53d8d0f3b 100644 --- a/src/spicelib/devices/vbic/vbicsetup.c +++ b/src/spicelib/devices/vbic/vbicsetup.c @@ -398,7 +398,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) {