rewrite-rw, parens

This commit is contained in:
rlar 2018-03-07 20:10:30 +01:00
parent fd4a8bf51b
commit d1acfdc738
12 changed files with 32 additions and 32 deletions

View File

@ -34,7 +34,7 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
current_state = (int) ckt->CKTstates[0][here->CSWstate + 0];
g_now = current_state?(model->CSWonConduct):(model->CSWoffConduct);
g_now = current_state ? model->CSWonConduct : model->CSWoffConduct;
*(here->CSWposPosPtr) += g_now;
*(here->CSWposNegPtr) -= g_now;

View File

@ -47,16 +47,16 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
if(here->CSWzero_stateGiven) {
/* switch specified "on" */
if ((model->CSWiHysteresis >= 0) && (i_ctrl > (model->CSWiThreshold + model->CSWiHysteresis)))
if (model->CSWiHysteresis >= 0 && i_ctrl > model->CSWiThreshold + model->CSWiHysteresis)
current_state = REALLY_ON;
else if ((model->CSWiHysteresis < 0) && (i_ctrl > (model->CSWiThreshold - model->CSWiHysteresis)))
else if (model->CSWiHysteresis < 0 && i_ctrl > model->CSWiThreshold - model->CSWiHysteresis)
current_state = REALLY_ON;
else
current_state = HYST_ON;
} else {
if ((model->CSWiHysteresis >= 0) && (i_ctrl < (model->CSWiThreshold - model->CSWiHysteresis)))
if (model->CSWiHysteresis >= 0 && i_ctrl < model->CSWiThreshold - model->CSWiHysteresis)
current_state = REALLY_OFF;
else if ((model->CSWiHysteresis < 0) && (i_ctrl < (model->CSWiThreshold + model->CSWiHysteresis)))
else if (model->CSWiHysteresis < 0 && i_ctrl < model->CSWiThreshold + model->CSWiHysteresis)
current_state = REALLY_OFF;
else
current_state = HYST_OFF;
@ -86,7 +86,7 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
* or from hi to hysteresis. */
/* if previous state was in hysteresis, then don't change the state.. */
if ((previous_state == HYST_OFF) || (previous_state == HYST_ON))
if (previous_state == HYST_OFF || previous_state == HYST_ON)
current_state = previous_state;
else if (previous_state == REALLY_ON)
current_state = HYST_OFF;
@ -121,7 +121,7 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
* or from hi to hysteresis. */
/* if previous state was in hysteresis, then don't change the state.. */
if ((previous_state == HYST_OFF) || (previous_state == HYST_ON))
if (previous_state == HYST_OFF || previous_state == HYST_ON)
current_state = previous_state;
else if (previous_state == REALLY_ON)
current_state = HYST_OFF;
@ -135,7 +135,7 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
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))
if (current_state == REALLY_ON || current_state == HYST_ON)
g_now = model->CSWonConduct;
else
g_now = model->CSWoffConduct;

View File

@ -23,12 +23,12 @@ CSWmParam(int param, IFvalue *value, GENmodel *inModel)
break;
case CSW_RON:
model->CSWonResistance = value->rValue;
model->CSWonConduct = 1.0/(value->rValue);
model->CSWonConduct = 1.0/value->rValue;
model->CSWonGiven = TRUE;
break;
case CSW_ROFF:
model->CSWoffResistance = value->rValue;
model->CSWoffConduct = 1.0/(value->rValue);
model->CSWoffConduct = 1.0/value->rValue;
model->CSWoffGiven = TRUE;
break;
case CSW_ITH:

View File

@ -67,7 +67,7 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
current_state = (int) ckt->CKTstates[0][inst->CSWstate + 0];
NevalSrc(&noizDens,&lnNdens,ckt,THERMNOISE,
inst->CSWposNode,inst->CSWnegNode,
current_state?(model->CSWonConduct):(model->CSWoffConduct));
current_state ? model->CSWonConduct : model->CSWoffConduct);
*OnDens += noizDens;

View File

@ -38,7 +38,7 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
current_state = (int) ckt->CKTstates[0][here->CSWstate + 0];
g_now = current_state?(model->CSWonConduct):(model->CSWoffConduct);
g_now = current_state ? model->CSWonConduct : model->CSWoffConduct;
*(here->CSWposPosPtr) += g_now;
*(here->CSWposNegPtr) -= g_now;

View File

@ -27,16 +27,16 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
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->CKTstates[0][here->CSWstate + 1]<ref) && (lastChange>0)) {
ref = model->CSWiThreshold + model->CSWiHysteresis;
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->CKTstates[0][here->CSWstate + 1]>ref) && (lastChange<0)) {
ref = model->CSWiThreshold - model->CSWiHysteresis;
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];

View File

@ -35,7 +35,7 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
current_state = (int) ckt->CKTstates[0][here->SWstate + 0];
g_now = current_state?(model->SWonConduct):(model->SWoffConduct);
g_now = current_state ? model->SWonConduct : model->SWoffConduct;
*(here->SWposPosPtr) += g_now;
*(here->SWposNegPtr) -= g_now;

View File

@ -49,16 +49,16 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
if(here->SWzero_stateGiven) {
/* switch specified "on" */
if ((model->SWvHysteresis >= 0) && (v_ctrl > (model->SWvThreshold + model->SWvHysteresis)))
if (model->SWvHysteresis >= 0 && v_ctrl > model->SWvThreshold + model->SWvHysteresis)
current_state = REALLY_ON;
else if ((model->SWvHysteresis < 0) && (v_ctrl > (model->SWvThreshold - model->SWvHysteresis)))
else if (model->SWvHysteresis < 0 && v_ctrl > model->SWvThreshold - model->SWvHysteresis)
current_state = REALLY_ON;
else
current_state = HYST_ON;
} else {
if ((model->SWvHysteresis >= 0) && (v_ctrl < (model->SWvThreshold - model->SWvHysteresis)))
if (model->SWvHysteresis >= 0 && v_ctrl < model->SWvThreshold - model->SWvHysteresis)
current_state = REALLY_OFF;
else if ((model->SWvHysteresis < 0) && (v_ctrl < (model->SWvThreshold + model->SWvHysteresis)))
else if (model->SWvHysteresis < 0 && v_ctrl < model->SWvThreshold + model->SWvHysteresis)
current_state = REALLY_OFF;
else
current_state = HYST_OFF;
@ -85,7 +85,7 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
current_state = REALLY_OFF;
else { // in hysteresis... change value if going from low to hysteresis, or from hi to hysteresis.
// if previous state was in hysteresis, then don't change the state..
if ((previous_state == HYST_OFF) || (previous_state == HYST_ON))
if (previous_state == HYST_OFF || previous_state == HYST_ON)
current_state = previous_state;
else if (previous_state == REALLY_ON)
current_state = HYST_OFF;
@ -118,7 +118,7 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
current_state = REALLY_OFF;
else {
current_state = 0.0;
if ((previous_state == HYST_ON) || (previous_state == HYST_OFF))
if (previous_state == HYST_ON || previous_state == HYST_OFF)
current_state = previous_state;
else if (previous_state == REALLY_ON)
current_state = REALLY_OFF;
@ -136,7 +136,7 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
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))
if (current_state == REALLY_ON || current_state == HYST_ON)
g_now = model->SWonConduct;
else
g_now = model->SWoffConduct;

View File

@ -23,12 +23,12 @@ SWmParam(int param, IFvalue *value, GENmodel *inModel)
break;
case SW_MOD_RON:
model->SWonResistance = value->rValue;
model->SWonConduct = 1.0/(value->rValue);
model->SWonConduct = 1.0/value->rValue;
model->SWonGiven = TRUE;
break;
case SW_MOD_ROFF:
model->SWoffResistance = value->rValue;
model->SWoffConduct = 1.0/(value->rValue);
model->SWoffConduct = 1.0/value->rValue;
model->SWoffGiven = TRUE;
break;
case SW_MOD_VTH:

View File

@ -67,7 +67,7 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
current_state = (int) ckt->CKTstates[0][inst->SWstate + 0];
NevalSrc(&noizDens,&lnNdens,ckt,THERMNOISE,
inst->SWposNode,inst->SWnegNode,
current_state?(model->SWonConduct):(model->SWoffConduct));
current_state ? model->SWonConduct : model->SWoffConduct);
*OnDens += noizDens;

View File

@ -39,7 +39,7 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
current_state = (int) ckt->CKTstates[0][here->SWstate + 0];
g_now = current_state?(model->SWonConduct):(model->SWoffConduct);
g_now = current_state ? model->SWonConduct : model->SWoffConduct;
*(here->SWposPosPtr) += g_now;
*(here->SWposNegPtr) -= g_now;

View File

@ -25,16 +25,16 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
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->CKTstates[0][here->SWstate + 1]<ref) && (lastChange>0)) {
ref = model->SWvThreshold + model->SWvHysteresis;
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->CKTstates[0][here->SWstate + 1]>ref) && (lastChange<0)) {
ref = model->SWvThreshold - model->SWvHysteresis;
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];