rewrite-sw, coccinelle semantic patch #1
This commit is contained in:
parent
c6d7f59920
commit
98cd4cb408
|
|
@ -26,13 +26,13 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
int current_state;
|
||||
|
||||
/* loop through all the switch models */
|
||||
for( ; model != NULL; model = CSWnextModel(model)) {
|
||||
for( ; model; model = CSWnextModel(model)) {
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = CSWinstances(model); here != NULL ;
|
||||
for (here = CSWinstances(model); here;
|
||||
here=CSWnextInstance(here)) {
|
||||
|
||||
current_state = (int)*(ckt->CKTstate0 + here->CSWstate);
|
||||
current_state = (int) ckt->CKTstates[0][here->CSWstate + 0];
|
||||
|
||||
g_now = current_state?(model->CSWonConduct):(model->CSWoffConduct);
|
||||
|
||||
|
|
@ -42,5 +42,5 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
*(here->CSWnegNegPtr) += g_now;
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,41 +31,41 @@ CSWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s
|
|||
switch(which) {
|
||||
case CSW_CONTROL:
|
||||
value->uValue = here->CSWcontName;
|
||||
return (OK);
|
||||
return OK;
|
||||
case CSW_POS_NODE:
|
||||
value->iValue = here->CSWposNode;
|
||||
return (OK);
|
||||
return OK;
|
||||
case CSW_NEG_NODE:
|
||||
value->iValue = here->CSWnegNode;
|
||||
return (OK);
|
||||
return OK;
|
||||
case CSW_CURRENT:
|
||||
if (ckt->CKTcurrentAnalysis & DOING_AC) {
|
||||
errMsg = TMALLOC(char, strlen(msg) + 1);
|
||||
errRtn = "CSWask";
|
||||
strcpy(errMsg,msg);
|
||||
return(E_ASKCURRENT);
|
||||
return E_ASKCURRENT;
|
||||
} else {
|
||||
value->rValue = (*(ckt->CKTrhsOld+here->CSWposNode)
|
||||
- *(ckt->CKTrhsOld + here->CSWnegNode)) *
|
||||
value->rValue = (ckt->CKTrhsOld[here->CSWposNode]
|
||||
- ckt->CKTrhsOld[here->CSWnegNode]) *
|
||||
here->CSWcond;
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
case CSW_POWER:
|
||||
if (ckt->CKTcurrentAnalysis & DOING_AC) {
|
||||
errMsg = TMALLOC(char, strlen(msg) + 1);
|
||||
errRtn = "CSWask";
|
||||
strcpy(errMsg,msg);
|
||||
return(E_ASKPOWER);
|
||||
return E_ASKPOWER;
|
||||
} else {
|
||||
value->rValue = (*(ckt->CKTrhsOld+here->CSWposNode)
|
||||
- *(ckt->CKTrhsOld + here->CSWnegNode)) *
|
||||
(*(ckt->CKTrhsOld + here->CSWposNode)
|
||||
- *(ckt->CKTrhsOld + here->CSWnegNode)) *
|
||||
value->rValue = (ckt->CKTrhsOld[here->CSWposNode]
|
||||
- ckt->CKTrhsOld[here->CSWnegNode]) *
|
||||
(ckt->CKTrhsOld[here->CSWposNode]
|
||||
- ckt->CKTrhsOld[here->CSWnegNode]) *
|
||||
here->CSWcond;
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
default:
|
||||
return (E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,16 +31,15 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
/* switch is on or off while control value is in hysteresis region. */
|
||||
|
||||
/* loop through all the switch models */
|
||||
for( ; model != NULL; model = CSWnextModel(model)) {
|
||||
for( ; model; model = CSWnextModel(model)) {
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = CSWinstances(model); here != NULL ;
|
||||
for (here = CSWinstances(model); here;
|
||||
here=CSWnextInstance(here)) {
|
||||
|
||||
old_current_state = *(ckt->CKTstates[0] + here->CSWstate);
|
||||
previous_state = *(ckt->CKTstates[1] + here->CSWstate);
|
||||
i_ctrl = *(ckt->CKTrhsOld +
|
||||
here->CSWcontBranch);
|
||||
old_current_state = ckt->CKTstates[0][here->CSWstate + 0];
|
||||
previous_state = ckt->CKTstates[1][here->CSWstate + 0];
|
||||
i_ctrl = ckt->CKTrhsOld[here->CSWcontBranch];
|
||||
|
||||
/* decide the state of the switch */
|
||||
|
||||
|
|
@ -136,8 +135,8 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
}
|
||||
}
|
||||
|
||||
*(ckt->CKTstates[0] + here->CSWstate) = current_state;
|
||||
*(ckt->CKTstates[1] + here->CSWstate) = previous_state;
|
||||
ckt->CKTstates[0][here->CSWstate + 0] = current_state;
|
||||
ckt->CKTstates[1][here->CSWstate + 0] = previous_state;
|
||||
if ((current_state == REALLY_ON) || (current_state == HYST_ON))
|
||||
g_now = model->CSWonConduct;
|
||||
else
|
||||
|
|
@ -150,5 +149,5 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
*(here->CSWnegNegPtr) += g_now;
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,24 +30,24 @@ CSWmAsk(CKTcircuit *ckt, GENmodel *inst, int which, IFvalue *value)
|
|||
switch(which) {
|
||||
case CSW_RON:
|
||||
value->rValue = here->CSWonResistance;
|
||||
return (OK);
|
||||
return OK;
|
||||
case CSW_ROFF:
|
||||
value->rValue = here->CSWoffResistance;
|
||||
return (OK);
|
||||
return OK;
|
||||
case CSW_ITH:
|
||||
value->rValue = here->CSWiThreshold;
|
||||
return (OK);
|
||||
return OK;
|
||||
case CSW_IHYS:
|
||||
value->rValue = here->CSWiHysteresis;
|
||||
return (OK);
|
||||
return OK;
|
||||
case CSW_GON:
|
||||
value->rValue = here->CSWonConduct;
|
||||
return (OK);
|
||||
return OK;
|
||||
case CSW_GOFF:
|
||||
value->rValue = here->CSWoffConduct;
|
||||
return (OK);
|
||||
return OK;
|
||||
default:
|
||||
return (E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ CSWmParam(int param, IFvalue *value, GENmodel *inModel)
|
|||
model->CSWhystGiven = TRUE;
|
||||
break;
|
||||
default:
|
||||
return(E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
|
|||
int current_state;
|
||||
|
||||
|
||||
for (model=firstModel; model != NULL; model=CSWnextModel(model)) {
|
||||
for (inst=CSWinstances(model); inst != NULL; inst=CSWnextInstance(inst)) {
|
||||
for (model=firstModel; model; model=CSWnextModel(model)) {
|
||||
for (inst=CSWinstances(model); inst; inst=CSWnextInstance(inst)) {
|
||||
|
||||
switch (operation) {
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
current_state = (int)*(ckt->CKTstate0 + inst->CSWstate);
|
||||
current_state = (int) ckt->CKTstates[0][inst->CSWstate + 0];
|
||||
NevalSrc(&noizDens,&lnNdens,ckt,THERMNOISE,
|
||||
inst->CSWposNode,inst->CSWnegNode,
|
||||
current_state?(model->CSWonConduct):(model->CSWoffConduct));
|
||||
|
|
@ -112,13 +112,13 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
|
|||
break;
|
||||
|
||||
case N_CLOSE:
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
return OK; /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ CSWparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
return(E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
NG_IGNORE(s);
|
||||
|
||||
/* loop through all the switch models */
|
||||
for( ; model != NULL; model = CSWnextModel(model)) {
|
||||
for( ; model; model = CSWnextModel(model)) {
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = CSWinstances(model); here != NULL ;
|
||||
for (here = CSWinstances(model); here;
|
||||
here=CSWnextInstance(here)) {
|
||||
|
||||
current_state = (int)*(ckt->CKTstate0 + here->CSWstate);
|
||||
current_state = (int) ckt->CKTstates[0][here->CSWstate + 0];
|
||||
|
||||
g_now = current_state?(model->CSWonConduct):(model->CSWoffConduct);
|
||||
|
||||
|
|
@ -46,5 +46,5 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
*(here->CSWnegNegPtr) += g_now;
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
CSWinstance *here;
|
||||
|
||||
/* loop through all the current source models */
|
||||
for( ; model != NULL; model = CSWnextModel(model)) {
|
||||
for( ; model; model = CSWnextModel(model)) {
|
||||
/* Default Value Processing for Switch Model */
|
||||
if (!model->CSWthreshGiven) {
|
||||
model->CSWiThreshold = 0;
|
||||
|
|
@ -41,7 +41,7 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
}
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = CSWinstances(model); here != NULL ;
|
||||
for (here = CSWinstances(model); here;
|
||||
here=CSWnextInstance(here)) {
|
||||
|
||||
/* Default Value Processing for Switch Instance */
|
||||
|
|
@ -52,7 +52,7 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
if(here->CSWcontBranch == 0) {
|
||||
SPfrontEnd->IFerrorf (ERR_FATAL,
|
||||
"%s: unknown controlling source %s", here->CSWname, here->CSWcontName);
|
||||
return(E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
|
||||
/* macro to make elements with built in test for out of memory */
|
||||
|
|
@ -67,5 +67,5 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
|
|||
TSTALLOC(CSWnegNegPtr, CSWnegNode, CSWnegNode);
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,23 +21,23 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
|
||||
double lastChange, maxChange, maxStep, ref;
|
||||
|
||||
for( ; model!= NULL; model = CSWnextModel(model)) {
|
||||
for(here = CSWinstances(model); here != NULL ;
|
||||
for( ; model; model = CSWnextModel(model)) {
|
||||
for(here = CSWinstances(model); here;
|
||||
here = CSWnextInstance(here)) {
|
||||
lastChange = *(ckt->CKTstate0+(here->CSWstate+1)) -
|
||||
*(ckt->CKTstate1+(here->CSWstate+1));
|
||||
if (*(ckt->CKTstate0+(here->CSWstate))==0) {
|
||||
lastChange = ckt->CKTstates[0][here->CSWstate + 1] -
|
||||
ckt->CKTstates[1][here->CSWstate + 1];
|
||||
if (ckt->CKTstates[0][here->CSWstate + 0]==0) {
|
||||
ref = (model->CSWiThreshold + model->CSWiHysteresis);
|
||||
if ((*(ckt->CKTstate0+(here->CSWstate+1))<ref) && (lastChange>0)) {
|
||||
maxChange = (ref - *(ckt->CKTstate0+(here->CSWstate+1))) *
|
||||
if ((ckt->CKTstates[0][here->CSWstate + 1]<ref) && (lastChange>0)) {
|
||||
maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) *
|
||||
0.75 + 0.00005;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) { *timeStep = maxStep; }
|
||||
}
|
||||
} else {
|
||||
ref = (model->CSWiThreshold - model->CSWiHysteresis);
|
||||
if ((*(ckt->CKTstate0+(here->CSWstate+1))>ref) && (lastChange<0)) {
|
||||
maxChange = (ref - *(ckt->CKTstate0+(here->CSWstate+1))) *
|
||||
if ((ckt->CKTstates[0][here->CSWstate + 1]>ref) && (lastChange<0)) {
|
||||
maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) *
|
||||
0.75 - 0.00005;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) { *timeStep = maxStep; }
|
||||
|
|
@ -45,5 +45,5 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
}
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,15 +25,15 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
int current_state;
|
||||
|
||||
/* loop through all the switch models */
|
||||
for( ; model != NULL; model = SWnextModel(model)) {
|
||||
for( ; model; model = SWnextModel(model)) {
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = SWinstances(model); here != NULL ;
|
||||
for (here = SWinstances(model); here;
|
||||
here=SWnextInstance(here)) {
|
||||
|
||||
/* In AC analysis, just propogate the state... */
|
||||
|
||||
current_state = (int)*(ckt->CKTstate0 + here->SWstate);
|
||||
current_state = (int) ckt->CKTstates[0][here->SWstate + 0];
|
||||
|
||||
g_now = current_state?(model->SWonConduct):(model->SWoffConduct);
|
||||
|
||||
|
|
@ -43,5 +43,5 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
|||
*(here->SWnegNegPtr) += g_now;
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,44 +31,44 @@ SWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *se
|
|||
switch(which) {
|
||||
case SW_POS_NODE:
|
||||
value->iValue = here->SWposNode;
|
||||
return (OK);
|
||||
return OK;
|
||||
case SW_NEG_NODE:
|
||||
value->iValue = here->SWnegNode;
|
||||
return (OK);
|
||||
return OK;
|
||||
case SW_POS_CONT_NODE:
|
||||
value->iValue = here->SWposCntrlNode;
|
||||
return (OK);
|
||||
return OK;
|
||||
case SW_NEG_CONT_NODE:
|
||||
value->iValue = here->SWnegCntrlNode;
|
||||
return (OK);
|
||||
return OK;
|
||||
case SW_CURRENT:
|
||||
if (ckt->CKTcurrentAnalysis & DOING_AC) {
|
||||
errMsg = TMALLOC(char, strlen(msg) + 1);
|
||||
errRtn = "SWask";
|
||||
strcpy(errMsg,msg);
|
||||
return(E_ASKCURRENT);
|
||||
return E_ASKCURRENT;
|
||||
} else {
|
||||
value->rValue = (*(ckt->CKTrhsOld + here->SWposNode)
|
||||
- *(ckt->CKTrhsOld + here->SWnegNode)) *
|
||||
value->rValue = (ckt->CKTrhsOld[here->SWposNode]
|
||||
- ckt->CKTrhsOld[here->SWnegNode]) *
|
||||
here->SWcond;
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
case SW_POWER:
|
||||
if (ckt->CKTcurrentAnalysis & DOING_AC) {
|
||||
errMsg = TMALLOC(char, strlen(msg) + 1);
|
||||
errRtn = "SWask";
|
||||
strcpy(errMsg,msg);
|
||||
return(E_ASKPOWER);
|
||||
return E_ASKPOWER;
|
||||
} else {
|
||||
value->rValue = (*(ckt->CKTrhsOld + here->SWposNode)
|
||||
- *(ckt->CKTrhsOld + here->SWnegNode)) *
|
||||
(*(ckt->CKTrhsOld + here->SWposNode)
|
||||
- *(ckt->CKTrhsOld + here->SWnegNode)) *
|
||||
value->rValue = (ckt->CKTrhsOld[here->SWposNode]
|
||||
- ckt->CKTrhsOld[here->SWnegNode]) *
|
||||
(ckt->CKTrhsOld[here->SWposNode]
|
||||
- ckt->CKTrhsOld[here->SWnegNode]) *
|
||||
here->SWcond;
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
default:
|
||||
return (E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,17 +31,17 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
// double current_region = -1;
|
||||
|
||||
/* loop through all the switch models */
|
||||
for( ; model != NULL; model = SWnextModel(model)) {
|
||||
for( ; model; model = SWnextModel(model)) {
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = SWinstances(model); here != NULL ;
|
||||
for (here = SWinstances(model); here;
|
||||
here=SWnextInstance(here)) {
|
||||
|
||||
old_current_state = *(ckt->CKTstates[0] + here->SWstate);
|
||||
previous_state = *(ckt->CKTstates[1] + here->SWstate);
|
||||
old_current_state = ckt->CKTstates[0][here->SWstate + 0];
|
||||
previous_state = ckt->CKTstates[1][here->SWstate + 0];
|
||||
|
||||
v_ctrl = *(ckt->CKTrhsOld + here->SWposCntrlNode)
|
||||
- *(ckt->CKTrhsOld + here->SWnegCntrlNode);
|
||||
v_ctrl = ckt->CKTrhsOld[here->SWposCntrlNode]
|
||||
- ckt->CKTrhsOld[here->SWnegCntrlNode];
|
||||
|
||||
/* decide the state of the switch */
|
||||
|
||||
|
|
@ -137,8 +137,8 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
// distant and then the time is pushed back to a time before the switch changed states.
|
||||
// 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) = current_state;
|
||||
*(ckt->CKTstates[0] + here->SWstate + 1) = v_ctrl;
|
||||
ckt->CKTstates[0][here->SWstate + 0] = current_state;
|
||||
ckt->CKTstates[0][here->SWstate + 1] = v_ctrl;
|
||||
|
||||
if ((current_state == REALLY_ON) || (current_state == HYST_ON))
|
||||
g_now = model->SWonConduct;
|
||||
|
|
@ -152,5 +152,5 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
|||
*(here->SWnegNegPtr) += g_now;
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,24 +30,24 @@ SWmAsk(CKTcircuit *ckt, GENmodel *inModel, int which, IFvalue *value)
|
|||
switch(which) {
|
||||
case SW_MOD_RON:
|
||||
value->rValue = model->SWonResistance;
|
||||
return (OK);
|
||||
return OK;
|
||||
case SW_MOD_ROFF:
|
||||
value->rValue = model->SWoffResistance;
|
||||
return (OK);
|
||||
return OK;
|
||||
case SW_MOD_VTH:
|
||||
value->rValue = model->SWvThreshold;
|
||||
return (OK);
|
||||
return OK;
|
||||
case SW_MOD_VHYS:
|
||||
value->rValue = model->SWvHysteresis;
|
||||
return (OK);
|
||||
return OK;
|
||||
case SW_MOD_GON:
|
||||
value->rValue = model->SWonConduct;
|
||||
return (OK);
|
||||
return OK;
|
||||
case SW_MOD_GOFF:
|
||||
value->rValue = model->SWoffConduct;
|
||||
return (OK);
|
||||
return OK;
|
||||
default:
|
||||
return (E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ SWmParam(int param, IFvalue *value, GENmodel *inModel)
|
|||
model->SWhystGiven = TRUE;
|
||||
break;
|
||||
default:
|
||||
return(E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
|
|||
int current_state;
|
||||
|
||||
|
||||
for (model=firstModel; model != NULL; model=SWnextModel(model)) {
|
||||
for (inst=SWinstances(model); inst != NULL; inst=SWnextInstance(inst)) {
|
||||
for (model=firstModel; model; model=SWnextModel(model)) {
|
||||
for (inst=SWinstances(model); inst; inst=SWnextInstance(inst)) {
|
||||
|
||||
switch (operation) {
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
|
|||
switch (mode) {
|
||||
|
||||
case N_DENS:
|
||||
current_state = (int)*(ckt->CKTstate0 + inst->SWstate);
|
||||
current_state = (int) ckt->CKTstates[0][inst->SWstate + 0];
|
||||
NevalSrc(&noizDens,&lnNdens,ckt,THERMNOISE,
|
||||
inst->SWposNode,inst->SWnegNode,
|
||||
current_state?(model->SWonConduct):(model->SWoffConduct));
|
||||
|
|
@ -112,11 +112,11 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
|
|||
break;
|
||||
|
||||
case N_CLOSE:
|
||||
return (OK); /* do nothing, the main calling routine will close */
|
||||
return OK; /* do nothing, the main calling routine will close */
|
||||
break; /* the plots */
|
||||
} /* switch (operation) */
|
||||
} /* for inst */
|
||||
} /* for model */
|
||||
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ SWparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
return(E_BADPARM);
|
||||
return E_BADPARM;
|
||||
}
|
||||
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,15 +29,15 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
NG_IGNORE(s);
|
||||
|
||||
/* loop through all the switch models */
|
||||
for( ; model != NULL; model = SWnextModel(model)) {
|
||||
for( ; model; model = SWnextModel(model)) {
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = SWinstances(model); here != NULL ;
|
||||
for (here = SWinstances(model); here;
|
||||
here=SWnextInstance(here)) {
|
||||
|
||||
/* In AC analysis, just propogate the state... */
|
||||
|
||||
current_state = (int)*(ckt->CKTstate0 + here->SWstate);
|
||||
current_state = (int) ckt->CKTstates[0][here->SWstate + 0];
|
||||
|
||||
g_now = current_state?(model->SWonConduct):(model->SWoffConduct);
|
||||
|
||||
|
|
@ -47,5 +47,5 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
|||
*(here->SWnegNegPtr) += g_now;
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
SWinstance *here;
|
||||
|
||||
/* loop through all the current source models */
|
||||
for( ; model != NULL; model = SWnextModel(model)) {
|
||||
for( ; model; model = SWnextModel(model)) {
|
||||
/* Default Value Processing for Switch Model */
|
||||
if (!model->SWthreshGiven) {
|
||||
model->SWvThreshold = 0;
|
||||
|
|
@ -41,7 +41,7 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
}
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = SWinstances(model); here != NULL ;
|
||||
for (here = SWinstances(model); here;
|
||||
here=SWnextInstance(here)) {
|
||||
|
||||
here->SWstate = *states;
|
||||
|
|
@ -62,5 +62,5 @@ do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\
|
|||
TSTALLOC(SWnegNegPtr, SWnegNode, SWnegNode);
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,23 +19,23 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
SWinstance *here;
|
||||
double lastChange, maxChange, maxStep, ref;
|
||||
|
||||
for( ; model!= NULL; model = SWnextModel(model)) {
|
||||
for(here = SWinstances(model); here != NULL ;
|
||||
for( ; model; model = SWnextModel(model)) {
|
||||
for(here = SWinstances(model); here;
|
||||
here = SWnextInstance(here)) {
|
||||
lastChange = *(ckt->CKTstate0+(here->SWstate+1)) -
|
||||
*(ckt->CKTstate1+(here->SWstate+1));
|
||||
if (*(ckt->CKTstate0+(here->SWstate))==0) {
|
||||
lastChange = ckt->CKTstates[0][here->SWstate + 1] -
|
||||
ckt->CKTstates[1][here->SWstate + 1];
|
||||
if (ckt->CKTstates[0][here->SWstate + 0]==0) {
|
||||
ref = (model->SWvThreshold + model->SWvHysteresis);
|
||||
if ((*(ckt->CKTstate0+(here->SWstate+1))<ref) && (lastChange>0)) {
|
||||
maxChange = (ref - *(ckt->CKTstate0+(here->SWstate+1))) *
|
||||
if ((ckt->CKTstates[0][here->SWstate + 1]<ref) && (lastChange>0)) {
|
||||
maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) *
|
||||
0.75 + 0.05;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) { *timeStep = maxStep; }
|
||||
}
|
||||
} else {
|
||||
ref = (model->SWvThreshold - model->SWvHysteresis);
|
||||
if ((*(ckt->CKTstate0+(here->SWstate+1))>ref) && (lastChange<0)) {
|
||||
maxChange = (ref - *(ckt->CKTstate0+(here->SWstate+1))) *
|
||||
if ((ckt->CKTstates[0][here->SWstate + 1]>ref) && (lastChange<0)) {
|
||||
maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) *
|
||||
0.75 - 0.05;
|
||||
maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0];
|
||||
if (*timeStep > maxStep) { *timeStep = maxStep; }
|
||||
|
|
@ -43,5 +43,5 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
|||
}
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue