spicelib/devices/{sw,csw}, unify CKTstates[] access
do it the same way as the other devices do access CKTstates[][slot] via device specific descriptive macros access CKTstates[] via CKTstate0 CKTstate1 macros this patch has been checked for object file in-variance with gcc
This commit is contained in:
parent
c2892f98b7
commit
5cff30f5c4
|
|
@ -21,7 +21,7 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
for (; model; model = CSWnextModel(model))
|
||||
for (here = CSWinstances(model); here; here = CSWnextInstance(here)) {
|
||||
|
||||
current_state = (int) ckt->CKTstates[0][here->CSWstate + 0];
|
||||
current_state = (int) ckt->CKTstate0[here->CSWswitchstate];
|
||||
|
||||
g_now = current_state ? model->CSWonConduct : model->CSWoffConduct;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,10 @@ typedef struct sCSWinstance {
|
|||
#define CSW_OFF_CONDUCTANCE ckt->CKTgmin /* default off conductance */
|
||||
#define CSW_NUM_STATES 2
|
||||
|
||||
#define CSWswitchstate CSWstate+0
|
||||
#define CSWctrlvalue CSWstate+1
|
||||
|
||||
|
||||
typedef struct sCSWmodel { /* model structure for a switch */
|
||||
|
||||
struct GENmodel gen;
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
for (; model; model = CSWnextModel(model))
|
||||
for (here = CSWinstances(model); here; here = CSWnextInstance(here)) {
|
||||
|
||||
old_current_state = ckt->CKTstates[0][here->CSWstate + 0];
|
||||
previous_state = ckt->CKTstates[1][here->CSWstate + 0];
|
||||
old_current_state = ckt->CKTstate0[here->CSWswitchstate];
|
||||
previous_state = ckt->CKTstate1[here->CSWswitchstate];
|
||||
i_ctrl = ckt->CKTrhsOld[here->CSWcontBranch];
|
||||
|
||||
/* decide the state of the switch */
|
||||
|
|
@ -126,8 +126,8 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
}
|
||||
}
|
||||
|
||||
ckt->CKTstates[0][here->CSWstate + 0] = current_state;
|
||||
ckt->CKTstates[1][here->CSWstate + 0] = previous_state;
|
||||
ckt->CKTstate0[here->CSWswitchstate] = current_state;
|
||||
ckt->CKTstate1[here->CSWswitchstate] = previous_state;
|
||||
|
||||
if (current_state == REALLY_ON || current_state == HYST_ON)
|
||||
g_now = model->CSWonConduct;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ CSWnoise(int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
current_state = (int) ckt->CKTstates[0][inst->CSWstate + 0];
|
||||
current_state = (int) ckt->CKTstate0[inst->CSWswitchstate];
|
||||
NevalSrc(&noizDens, &lnNdens, ckt, THERMNOISE,
|
||||
inst->CSWposNode, inst->CSWnegNode,
|
||||
current_state ? model->CSWonConduct : model->CSWoffConduct);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
for (; model; model = CSWnextModel(model))
|
||||
for (here = CSWinstances(model); here; here = CSWnextInstance(here)) {
|
||||
|
||||
current_state = (int) ckt->CKTstates[0][here->CSWstate + 0];
|
||||
current_state = (int) ckt->CKTstate0[here->CSWswitchstate];
|
||||
|
||||
g_now = current_state ? model->CSWonConduct : model->CSWoffConduct;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
for (; model; model = CSWnextModel(model))
|
||||
for (here = CSWinstances(model); here; here = CSWnextInstance(here)) {
|
||||
lastChange =
|
||||
ckt->CKTstates[0][here->CSWstate + 1] -
|
||||
ckt->CKTstates[1][here->CSWstate + 1];
|
||||
if (ckt->CKTstates[0][here->CSWstate + 0] == 0) {
|
||||
ckt->CKTstate0[here->CSWctrlvalue] -
|
||||
ckt->CKTstate1[here->CSWctrlvalue];
|
||||
if (ckt->CKTstate0[here->CSWswitchstate] == 0) {
|
||||
ref = model->CSWiThreshold + model->CSWiHysteresis;
|
||||
if (ckt->CKTstates[0][here->CSWstate + 1] < ref && lastChange > 0) {
|
||||
if (ckt->CKTstate0[here->CSWctrlvalue] < ref && lastChange > 0) {
|
||||
maxChange =
|
||||
(ref - ckt->CKTstates[0][here->CSWstate + 1]) * 0.75
|
||||
(ref - ckt->CKTstate0[here->CSWctrlvalue]) * 0.75
|
||||
+ 0.00005;
|
||||
maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep)
|
||||
|
|
@ -37,9 +37,9 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
}
|
||||
} else {
|
||||
ref = model->CSWiThreshold - model->CSWiHysteresis;
|
||||
if (ckt->CKTstates[0][here->CSWstate + 1] > ref && lastChange < 0) {
|
||||
if (ckt->CKTstate0[here->CSWctrlvalue] > ref && lastChange < 0) {
|
||||
maxChange =
|
||||
(ref - ckt->CKTstates[0][here->CSWstate + 1]) * 0.75
|
||||
(ref - ckt->CKTstate0[here->CSWctrlvalue]) * 0.75
|
||||
- 0.00005;
|
||||
maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
|
||||
/* In AC analysis, just propogate the state... */
|
||||
|
||||
current_state = (int) ckt->CKTstates[0][here->SWstate + 0];
|
||||
current_state = (int) ckt->CKTstate0[here->SWswitchstate];
|
||||
|
||||
g_now = current_state ? model->SWonConduct : model->SWoffConduct;
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,10 @@ typedef struct sSWinstance {
|
|||
#define SW_OFF_CONDUCTANCE ckt->CKTgmin /* default off conductance */
|
||||
#define SW_NUM_STATES 2
|
||||
|
||||
#define SWswitchstate SWstate+0
|
||||
#define SWctrlvalue SWstate+1
|
||||
|
||||
|
||||
typedef struct sSWmodel { /* model structure for a switch */
|
||||
|
||||
struct GENmodel gen;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
for (; model; model = SWnextModel(model))
|
||||
for (here = SWinstances(model); here; here = SWnextInstance(here)) {
|
||||
|
||||
old_current_state = ckt->CKTstates[0][here->SWstate + 0];
|
||||
previous_state = ckt->CKTstates[1][here->SWstate + 0];
|
||||
old_current_state = ckt->CKTstate0[here->SWswitchstate];
|
||||
previous_state = ckt->CKTstate1[here->SWswitchstate];
|
||||
|
||||
v_ctrl =
|
||||
ckt->CKTrhsOld[here->SWposCntrlNode] -
|
||||
|
|
@ -129,8 +129,8 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
// After analyzing the transient code, it seems that this is not a problem because state updating
|
||||
// occurs before the convergence loop in transient processing.
|
||||
|
||||
ckt->CKTstates[0][here->SWstate + 0] = current_state;
|
||||
ckt->CKTstates[0][here->SWstate + 1] = v_ctrl;
|
||||
ckt->CKTstate0[here->SWswitchstate] = current_state;
|
||||
ckt->CKTstate0[here->SWctrlvalue] = v_ctrl;
|
||||
|
||||
if (current_state == REALLY_ON || current_state == HYST_ON)
|
||||
g_now = model->SWonConduct;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ SWnoise(int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *dat
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
current_state = (int) ckt->CKTstates[0][inst->SWstate + 0];
|
||||
current_state = (int) ckt->CKTstate0[inst->SWswitchstate];
|
||||
NevalSrc(&noizDens, &lnNdens, ckt, THERMNOISE,
|
||||
inst->SWposNode, inst->SWnegNode,
|
||||
current_state ? model->SWonConduct : model->SWoffConduct);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
|
||||
/* In AC analysis, just propogate the state... */
|
||||
|
||||
current_state = (int) ckt->CKTstates[0][here->SWstate + 0];
|
||||
current_state = (int) ckt->CKTstate0[here->SWswitchstate];
|
||||
|
||||
g_now = current_state ? model->SWonConduct : model->SWoffConduct;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
for (; model; model = SWnextModel(model))
|
||||
for (here = SWinstances(model); here; here = SWnextInstance(here)) {
|
||||
lastChange =
|
||||
ckt->CKTstates[0][here->SWstate + 1] -
|
||||
ckt->CKTstates[1][here->SWstate + 1];
|
||||
if (ckt->CKTstates[0][here->SWstate + 0] == 0) {
|
||||
ckt->CKTstate0[here->SWctrlvalue] -
|
||||
ckt->CKTstate1[here->SWctrlvalue];
|
||||
if (ckt->CKTstate0[here->SWswitchstate] == 0) {
|
||||
ref = model->SWvThreshold + model->SWvHysteresis;
|
||||
if (ckt->CKTstates[0][here->SWstate + 1] < ref && lastChange > 0) {
|
||||
if (ckt->CKTstate0[here->SWctrlvalue] < ref && lastChange > 0) {
|
||||
maxChange =
|
||||
(ref - ckt->CKTstates[0][here->SWstate + 1]) * 0.75
|
||||
(ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75
|
||||
+ 0.05;
|
||||
maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep)
|
||||
|
|
@ -35,9 +35,9 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
}
|
||||
} else {
|
||||
ref = model->SWvThreshold - model->SWvHysteresis;
|
||||
if (ckt->CKTstates[0][here->SWstate + 1] > ref && lastChange < 0) {
|
||||
if (ckt->CKTstate0[here->SWctrlvalue] > ref && lastChange < 0) {
|
||||
maxChange =
|
||||
(ref - ckt->CKTstates[0][here->SWstate + 1]) * 0.75
|
||||
(ref - ckt->CKTstate0[here->SWctrlvalue]) * 0.75
|
||||
- 0.05;
|
||||
maxStep = maxChange / lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep)
|
||||
|
|
|
|||
Loading…
Reference in New Issue