diff --git a/src/spicelib/devices/csw/cswacld.c b/src/spicelib/devices/csw/cswacld.c index b9966f6c6..6fb290052 100644 --- a/src/spicelib/devices/csw/cswacld.c +++ b/src/spicelib/devices/csw/cswacld.c @@ -26,7 +26,7 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt) int current_state; /* loop through all the switch models */ - for( ; model; model = CSWnextModel(model)) { + for( ; model; model = CSWnextModel(model)) /* loop through all the instances of the model */ for (here = CSWinstances(model); here; @@ -41,6 +41,5 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt) *(here->CSWnegPosPtr) -= g_now; *(here->CSWnegNegPtr) += g_now; } - } return OK; } diff --git a/src/spicelib/devices/csw/cswload.c b/src/spicelib/devices/csw/cswload.c index 4911bc220..ac12d49c2 100644 --- a/src/spicelib/devices/csw/cswload.c +++ b/src/spicelib/devices/csw/cswload.c @@ -31,7 +31,7 @@ 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; model = CSWnextModel(model)) { + for( ; model; model = CSWnextModel(model)) /* loop through all the instances of the model */ for (here = CSWinstances(model); here; @@ -70,30 +70,29 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt) /* use state0 since INITTRAN or INITPRED already called */ if (model->CSWiHysteresis > 0) { - if (i_ctrl > (model->CSWiThreshold + model->CSWiHysteresis)) { + if (i_ctrl > (model->CSWiThreshold + model->CSWiHysteresis)) current_state = REALLY_ON; - } else if (i_ctrl < (model->CSWiThreshold - model->CSWiHysteresis)) { + else if (i_ctrl < (model->CSWiThreshold - model->CSWiHysteresis)) current_state = REALLY_OFF; - } else { + else current_state = previous_state; - } } else { - if (i_ctrl > (model->CSWiThreshold - model->CSWiHysteresis)) { + if (i_ctrl > (model->CSWiThreshold - model->CSWiHysteresis)) current_state = REALLY_ON; - } else if (i_ctrl < (model->CSWiThreshold + model->CSWiHysteresis)) { + else if (i_ctrl < (model->CSWiThreshold + model->CSWiHysteresis)) current_state = REALLY_OFF; - } else { + 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) { + else if (previous_state == REALLY_ON) current_state = HYST_OFF; - } else if (previous_state == REALLY_OFF) { + else if (previous_state == REALLY_OFF) current_state = HYST_ON; - } else + else internalerror("bad value for previous region in swload"); } } @@ -106,30 +105,29 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt) } else if (ckt->CKTmode & (MODEINITTRAN|MODEINITPRED)) { if (model->CSWiHysteresis > 0) { - if (i_ctrl > (model->CSWiThreshold + model->CSWiHysteresis)) { + if (i_ctrl > (model->CSWiThreshold + model->CSWiHysteresis)) current_state = REALLY_ON; - } else if (i_ctrl < (model->CSWiThreshold - model->CSWiHysteresis)) { + else if (i_ctrl < (model->CSWiThreshold - model->CSWiHysteresis)) current_state = REALLY_OFF; - } else { + else current_state = previous_state; - } } else { - if (i_ctrl > (model->CSWiThreshold - model->CSWiHysteresis)) { + if (i_ctrl > (model->CSWiThreshold - model->CSWiHysteresis)) current_state = REALLY_ON; - } else if (i_ctrl < (model->CSWiThreshold + model->CSWiHysteresis)) { + else if (i_ctrl < (model->CSWiThreshold + model->CSWiHysteresis)) current_state = REALLY_OFF; - } else { + 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) { + else if (previous_state == REALLY_ON) current_state = HYST_OFF; - } else if (previous_state == REALLY_OFF) { + else if (previous_state == REALLY_OFF) current_state = HYST_ON; - } else + else internalerror("bad value for previous region in cswload"); } } @@ -148,6 +146,5 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt) *(here->CSWnegPosPtr) -= g_now; *(here->CSWnegNegPtr) += g_now; } - } return OK; } diff --git a/src/spicelib/devices/csw/cswnoise.c b/src/spicelib/devices/csw/cswnoise.c index 2fd953e1e..6c08061f0 100644 --- a/src/spicelib/devices/csw/cswnoise.c +++ b/src/spicelib/devices/csw/cswnoise.c @@ -36,7 +36,7 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d int current_state; - for (model=firstModel; model; model=CSWnextModel(model)) { + for (model=firstModel; model; model=CSWnextModel(model)) for (inst=CSWinstances(model); inst; inst=CSWnextInstance(inst)) { switch (operation) { @@ -46,7 +46,7 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d /* see if we have to to produce a summary report */ /* if so, name the noise generator */ - if (job->NStpsSm != 0) { + if (job->NStpsSm != 0) switch (mode) { case N_DENS: @@ -58,7 +58,6 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->CSWname, ""); break; } - } break; case N_CALC: @@ -81,9 +80,8 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d /* clear out our integration variable if it's the first pass */ - if (data->freq == job->NstartFreq) { + if (data->freq == job->NstartFreq) inst->CSWnVar[OUTNOIZ] = 0.0; - } } else { /* data->delFreq != 0.0 (we have to integrate) */ tempOutNoise = Nintegrate(noizDens, lnNdens, inst->CSWnVar[LNLSTDENS], data); @@ -97,9 +95,8 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d data->inNoise += tempInNoise; inst->CSWnVar[LNLSTDENS] = lnNdens; } - if (data->prtSummary) { + if (data->prtSummary) data->outpVector[data->outNumber++] = noizDens; - } break; case INT_NOIZ: /* already calculated, just output */ @@ -116,7 +113,6 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d break; /* the plots */ } /* switch (operation) */ } /* for inst */ - } /* for model */ return OK; } diff --git a/src/spicelib/devices/csw/cswparam.c b/src/spicelib/devices/csw/cswparam.c index d372a0723..c0e7a3524 100644 --- a/src/spicelib/devices/csw/cswparam.c +++ b/src/spicelib/devices/csw/cswparam.c @@ -25,14 +25,12 @@ CSWparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) here->CSWcontName = value->uValue; break; case CSW_IC_ON: - if(value->iValue) { + if(value->iValue) here->CSWzero_stateGiven = TRUE; - } break; case CSW_IC_OFF: - if(value->iValue) { + if(value->iValue) here->CSWzero_stateGiven = FALSE; - } break; default: return E_BADPARM; diff --git a/src/spicelib/devices/csw/cswpzld.c b/src/spicelib/devices/csw/cswpzld.c index a9af85a59..b6a39819a 100644 --- a/src/spicelib/devices/csw/cswpzld.c +++ b/src/spicelib/devices/csw/cswpzld.c @@ -30,7 +30,7 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) NG_IGNORE(s); /* loop through all the switch models */ - for( ; model; model = CSWnextModel(model)) { + for( ; model; model = CSWnextModel(model)) /* loop through all the instances of the model */ for (here = CSWinstances(model); here; @@ -45,6 +45,5 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) *(here->CSWnegPosPtr) -= g_now; *(here->CSWnegNegPtr) += g_now; } - } return OK; } diff --git a/src/spicelib/devices/csw/cswsetup.c b/src/spicelib/devices/csw/cswsetup.c index b9b7d6379..3726de31a 100644 --- a/src/spicelib/devices/csw/cswsetup.c +++ b/src/spicelib/devices/csw/cswsetup.c @@ -25,12 +25,10 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) /* loop through all the current source models */ for( ; model; model = CSWnextModel(model)) { /* Default Value Processing for Switch Model */ - if (!model->CSWthreshGiven) { + if (!model->CSWthreshGiven) model->CSWiThreshold = 0; - } - if (!model->CSWhystGiven) { + if (!model->CSWhystGiven) model->CSWiHysteresis = 0; - } if (!model->CSWonGiven) { model->CSWonConduct = CSW_ON_CONDUCTANCE; model->CSWonResistance = 1.0/model->CSWonConduct; diff --git a/src/spicelib/devices/csw/cswtrunc.c b/src/spicelib/devices/csw/cswtrunc.c index 7fd2e6c30..0e9b670b9 100644 --- a/src/spicelib/devices/csw/cswtrunc.c +++ b/src/spicelib/devices/csw/cswtrunc.c @@ -21,7 +21,7 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) double lastChange, maxChange, maxStep, ref; - for( ; model; model = CSWnextModel(model)) { + for( ; model; model = CSWnextModel(model)) for(here = CSWinstances(model); here; here = CSWnextInstance(here)) { lastChange = ckt->CKTstates[0][here->CSWstate + 1] - @@ -32,7 +32,7 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) * 0.75 + 0.00005; maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0]; - if (*timeStep > maxStep) { *timeStep = maxStep; } + if (*timeStep > maxStep) *timeStep = maxStep; } } else { ref = (model->CSWiThreshold - model->CSWiHysteresis); @@ -40,10 +40,9 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) * 0.75 - 0.00005; maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0]; - if (*timeStep > maxStep) { *timeStep = maxStep; } + if (*timeStep > maxStep) *timeStep = maxStep; } } } - } return OK; } diff --git a/src/spicelib/devices/sw/swacload.c b/src/spicelib/devices/sw/swacload.c index 70b43ef48..7d92f94d1 100644 --- a/src/spicelib/devices/sw/swacload.c +++ b/src/spicelib/devices/sw/swacload.c @@ -25,7 +25,7 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt) int current_state; /* loop through all the switch models */ - for( ; model; model = SWnextModel(model)) { + for( ; model; model = SWnextModel(model)) /* loop through all the instances of the model */ for (here = SWinstances(model); here; @@ -42,6 +42,5 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt) *(here->SWnegPosPtr) -= g_now; *(here->SWnegNegPtr) += g_now; } - } return OK; } diff --git a/src/spicelib/devices/sw/swload.c b/src/spicelib/devices/sw/swload.c index 041901b41..837c2ca3e 100644 --- a/src/spicelib/devices/sw/swload.c +++ b/src/spicelib/devices/sw/swload.c @@ -31,7 +31,7 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) // double current_region = -1; /* loop through all the switch models */ - for( ; model; model = SWnextModel(model)) { + for( ; model; model = SWnextModel(model)) /* loop through all the instances of the model */ for (here = SWinstances(model); here; @@ -72,29 +72,26 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) /* use state0 since INITTRAN or INITPRED already called */ if (model->SWvHysteresis > 0) { - if (v_ctrl > (model->SWvThreshold + model->SWvHysteresis)) { + if (v_ctrl > (model->SWvThreshold + model->SWvHysteresis)) current_state = REALLY_ON; - } else if (v_ctrl < (model->SWvThreshold - model->SWvHysteresis)) { + else if (v_ctrl < (model->SWvThreshold - model->SWvHysteresis)) current_state = REALLY_OFF; - } else { + else current_state = old_current_state; - } } else { // negative hysteresis case. if (v_ctrl > (model->SWvThreshold - model->SWvHysteresis)) - { current_state = REALLY_ON; - } else if (v_ctrl < (model->SWvThreshold + model->SWvHysteresis)) - { + else if (v_ctrl < (model->SWvThreshold + model->SWvHysteresis)) current_state = REALLY_OFF; - } else { // in hysteresis... change value if going from low to hysteresis, or from hi to hysteresis. + 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) { + else if (previous_state == REALLY_ON) current_state = HYST_OFF; - } else if (previous_state == REALLY_OFF) { + else if (previous_state == REALLY_OFF) current_state = HYST_ON; - } else + else internalerror("bad value for previous state in swload"); } } @@ -121,13 +118,12 @@ 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) { + else if (previous_state == REALLY_ON) current_state = REALLY_OFF; - } else if (previous_state == REALLY_OFF) { + else if (previous_state == REALLY_OFF) current_state = REALLY_ON; - } } } } @@ -151,6 +147,5 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) *(here->SWnegPosPtr) -= g_now; *(here->SWnegNegPtr) += g_now; } - } return OK; } diff --git a/src/spicelib/devices/sw/swnoise.c b/src/spicelib/devices/sw/swnoise.c index dc779f1a0..e1d0a015f 100644 --- a/src/spicelib/devices/sw/swnoise.c +++ b/src/spicelib/devices/sw/swnoise.c @@ -36,7 +36,7 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da int current_state; - for (model=firstModel; model; model=SWnextModel(model)) { + for (model=firstModel; model; model=SWnextModel(model)) for (inst=SWinstances(model); inst; inst=SWnextInstance(inst)) { switch (operation) { @@ -46,7 +46,7 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da /* see if we have to to produce a summary report */ /* if so, name the noise generator */ - if (job->NStpsSm != 0) { + if (job->NStpsSm != 0) switch (mode) { case N_DENS: @@ -58,7 +58,6 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->SWname, ""); break; } - } break; case N_CALC: @@ -81,9 +80,8 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da /* clear out our integration variable if it's the first pass */ - if (data->freq == job->NstartFreq) { + if (data->freq == job->NstartFreq) inst->SWnVar[OUTNOIZ] = 0.0; - } } else { /* data->delFreq != 0.0 (we have to integrate) */ tempOutNoise = Nintegrate(noizDens, lnNdens, inst->SWnVar[LNLSTDENS], data); @@ -97,9 +95,8 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da data->inNoise += tempInNoise; inst->SWnVar[LNLSTDENS] = lnNdens; } - if (data->prtSummary) { + if (data->prtSummary) data->outpVector[data->outNumber++] = noizDens; - } break; case INT_NOIZ: /* already calculated, just output */ @@ -116,7 +113,6 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da break; /* the plots */ } /* switch (operation) */ } /* for inst */ - } /* for model */ return OK; } diff --git a/src/spicelib/devices/sw/swparam.c b/src/spicelib/devices/sw/swparam.c index 2c2c5a476..116b81d89 100644 --- a/src/spicelib/devices/sw/swparam.c +++ b/src/spicelib/devices/sw/swparam.c @@ -22,14 +22,12 @@ SWparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) switch(param) { case SW_IC_ON: - if(value->iValue) { + if(value->iValue) here->SWzero_stateGiven = TRUE; - } break; case SW_IC_OFF: - if(value->iValue) { + if(value->iValue) here->SWzero_stateGiven = FALSE; - } break; default: return E_BADPARM; diff --git a/src/spicelib/devices/sw/swpzload.c b/src/spicelib/devices/sw/swpzload.c index 4ee31492d..e2027263c 100644 --- a/src/spicelib/devices/sw/swpzload.c +++ b/src/spicelib/devices/sw/swpzload.c @@ -29,7 +29,7 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) NG_IGNORE(s); /* loop through all the switch models */ - for( ; model; model = SWnextModel(model)) { + for( ; model; model = SWnextModel(model)) /* loop through all the instances of the model */ for (here = SWinstances(model); here; @@ -46,6 +46,5 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) *(here->SWnegPosPtr) -= g_now; *(here->SWnegNegPtr) += g_now; } - } return OK; } diff --git a/src/spicelib/devices/sw/swsetup.c b/src/spicelib/devices/sw/swsetup.c index c058f5726..be0f748c2 100644 --- a/src/spicelib/devices/sw/swsetup.c +++ b/src/spicelib/devices/sw/swsetup.c @@ -25,12 +25,10 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) /* loop through all the current source models */ for( ; model; model = SWnextModel(model)) { /* Default Value Processing for Switch Model */ - if (!model->SWthreshGiven) { + if (!model->SWthreshGiven) model->SWvThreshold = 0; - } - if (!model->SWhystGiven) { + if (!model->SWhystGiven) model->SWvHysteresis = 0; - } if (!model->SWonGiven) { model->SWonConduct = SW_ON_CONDUCTANCE; model->SWonResistance = 1.0/model->SWonConduct; diff --git a/src/spicelib/devices/sw/swtrunc.c b/src/spicelib/devices/sw/swtrunc.c index 3c1bb0edc..49890e0dc 100644 --- a/src/spicelib/devices/sw/swtrunc.c +++ b/src/spicelib/devices/sw/swtrunc.c @@ -19,7 +19,7 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) SWinstance *here; double lastChange, maxChange, maxStep, ref; - for( ; model; model = SWnextModel(model)) { + for( ; model; model = SWnextModel(model)) for(here = SWinstances(model); here; here = SWnextInstance(here)) { lastChange = ckt->CKTstates[0][here->SWstate + 1] - @@ -30,7 +30,7 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) * 0.75 + 0.05; maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0]; - if (*timeStep > maxStep) { *timeStep = maxStep; } + if (*timeStep > maxStep) *timeStep = maxStep; } } else { ref = (model->SWvThreshold - model->SWvHysteresis); @@ -38,10 +38,9 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) * 0.75 - 0.05; maxStep = maxChange/lastChange * ckt->CKTdeltaOld[0]; - if (*timeStep > maxStep) { *timeStep = maxStep; } + if (*timeStep > maxStep) *timeStep = maxStep; } } } - } return OK; }