From b0a8cd33d212eef3c0385cb7595c24694693abbe Mon Sep 17 00:00:00 2001 From: rlar Date: Wed, 7 Mar 2018 21:33:07 +0100 Subject: [PATCH] rewrite-rw, line wraps --- src/spicelib/devices/csw/cswacld.c | 3 +-- src/spicelib/devices/csw/cswask.c | 14 ++++++++------ src/spicelib/devices/csw/cswload.c | 3 +-- src/spicelib/devices/csw/cswpzld.c | 3 +-- src/spicelib/devices/csw/cswsetup.c | 3 +-- src/spicelib/devices/csw/cswtrunc.c | 22 +++++++++++++--------- src/spicelib/devices/sw/swacload.c | 3 +-- src/spicelib/devices/sw/swask.c | 14 ++++++++------ src/spicelib/devices/sw/swload.c | 8 ++++---- src/spicelib/devices/sw/swpzload.c | 3 +-- src/spicelib/devices/sw/swsetup.c | 3 +-- src/spicelib/devices/sw/swtrunc.c | 22 +++++++++++++--------- 12 files changed, 53 insertions(+), 48 deletions(-) diff --git a/src/spicelib/devices/csw/cswacld.c b/src/spicelib/devices/csw/cswacld.c index 9b2379358..cf4ec3151 100644 --- a/src/spicelib/devices/csw/cswacld.c +++ b/src/spicelib/devices/csw/cswacld.c @@ -29,8 +29,7 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt) for( ; model; model = CSWnextModel(model)) /* loop through all the instances of the model */ - for (here = CSWinstances(model); here; - here=CSWnextInstance(here)) { + for (here = CSWinstances(model); here; here=CSWnextInstance(here)) { current_state = (int) ckt->CKTstates[0][here->CSWstate + 0]; diff --git a/src/spicelib/devices/csw/cswask.c b/src/spicelib/devices/csw/cswask.c index b93c7ddf0..48a919cf0 100644 --- a/src/spicelib/devices/csw/cswask.c +++ b/src/spicelib/devices/csw/cswask.c @@ -45,8 +45,9 @@ CSWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s strcpy(errMsg,msg); 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; @@ -57,10 +58,11 @@ CSWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *s strcpy(errMsg,msg); 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; diff --git a/src/spicelib/devices/csw/cswload.c b/src/spicelib/devices/csw/cswload.c index 4e36e0a73..9156b4281 100644 --- a/src/spicelib/devices/csw/cswload.c +++ b/src/spicelib/devices/csw/cswload.c @@ -34,8 +34,7 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt) for( ; model; model = CSWnextModel(model)) /* loop through all the instances of the model */ - for (here = CSWinstances(model); here; - here=CSWnextInstance(here)) { + 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]; diff --git a/src/spicelib/devices/csw/cswpzld.c b/src/spicelib/devices/csw/cswpzld.c index 7fcafc658..4106ad714 100644 --- a/src/spicelib/devices/csw/cswpzld.c +++ b/src/spicelib/devices/csw/cswpzld.c @@ -33,8 +33,7 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) for( ; model; model = CSWnextModel(model)) /* loop through all the instances of the model */ - for (here = CSWinstances(model); here; - here=CSWnextInstance(here)) { + for (here = CSWinstances(model); here; here=CSWnextInstance(here)) { current_state = (int) ckt->CKTstates[0][here->CSWstate + 0]; diff --git a/src/spicelib/devices/csw/cswsetup.c b/src/spicelib/devices/csw/cswsetup.c index d2a9bc23e..a931b6762 100644 --- a/src/spicelib/devices/csw/cswsetup.c +++ b/src/spicelib/devices/csw/cswsetup.c @@ -45,8 +45,7 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) } /* loop through all the instances of the model */ - for (here = CSWinstances(model); here; - here=CSWnextInstance(here)) { + for (here = CSWinstances(model); here; here=CSWnextInstance(here)) { /* Default Value Processing for Switch Instance */ here->CSWstate = *states; diff --git a/src/spicelib/devices/csw/cswtrunc.c b/src/spicelib/devices/csw/cswtrunc.c index e11d017f2..82618fe26 100644 --- a/src/spicelib/devices/csw/cswtrunc.c +++ b/src/spicelib/devices/csw/cswtrunc.c @@ -22,25 +22,29 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) double lastChange, maxChange, maxStep, ref; for( ; model; model = CSWnextModel(model)) - for(here = CSWinstances(model); here; - here = CSWnextInstance(here)) { - lastChange = ckt->CKTstates[0][here->CSWstate + 1] - + 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) { ref = model->CSWiThreshold + model->CSWiHysteresis; if (ckt->CKTstates[0][here->CSWstate + 1]0) { - maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) * - 0.75 + 0.00005; + 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; if (ckt->CKTstates[0][here->CSWstate + 1]>ref && lastChange<0) { - maxChange = (ref - ckt->CKTstates[0][here->CSWstate + 1]) * - 0.75 - 0.00005; + 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; } } } diff --git a/src/spicelib/devices/sw/swacload.c b/src/spicelib/devices/sw/swacload.c index ad7c6638d..a88912d44 100644 --- a/src/spicelib/devices/sw/swacload.c +++ b/src/spicelib/devices/sw/swacload.c @@ -28,8 +28,7 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt) for( ; model; model = SWnextModel(model)) /* loop through all the instances of the model */ - for (here = SWinstances(model); here; - here=SWnextInstance(here)) { + for (here = SWinstances(model); here; here=SWnextInstance(here)) { /* In AC analysis, just propogate the state... */ diff --git a/src/spicelib/devices/sw/swask.c b/src/spicelib/devices/sw/swask.c index f447d5f46..66d8baff4 100644 --- a/src/spicelib/devices/sw/swask.c +++ b/src/spicelib/devices/sw/swask.c @@ -48,8 +48,9 @@ SWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *se strcpy(errMsg,msg); 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; @@ -60,10 +61,11 @@ SWask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *se strcpy(errMsg,msg); 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; diff --git a/src/spicelib/devices/sw/swload.c b/src/spicelib/devices/sw/swload.c index 7840148d8..b0e697345 100644 --- a/src/spicelib/devices/sw/swload.c +++ b/src/spicelib/devices/sw/swload.c @@ -34,14 +34,14 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) for( ; model; model = SWnextModel(model)) /* loop through all the instances of the model */ - for (here = SWinstances(model); here; - here=SWnextInstance(here)) { + 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]; - 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 */ diff --git a/src/spicelib/devices/sw/swpzload.c b/src/spicelib/devices/sw/swpzload.c index b936d7c89..a741f238b 100644 --- a/src/spicelib/devices/sw/swpzload.c +++ b/src/spicelib/devices/sw/swpzload.c @@ -32,8 +32,7 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) for( ; model; model = SWnextModel(model)) /* loop through all the instances of the model */ - for (here = SWinstances(model); here; - here=SWnextInstance(here)) { + for (here = SWinstances(model); here; here=SWnextInstance(here)) { /* In AC analysis, just propogate the state... */ diff --git a/src/spicelib/devices/sw/swsetup.c b/src/spicelib/devices/sw/swsetup.c index f9a6840cc..0f5f55a60 100644 --- a/src/spicelib/devices/sw/swsetup.c +++ b/src/spicelib/devices/sw/swsetup.c @@ -45,8 +45,7 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) } /* loop through all the instances of the model */ - for (here = SWinstances(model); here; - here=SWnextInstance(here)) { + for (here = SWinstances(model); here; here=SWnextInstance(here)) { here->SWstate = *states; *states += SW_NUM_STATES; diff --git a/src/spicelib/devices/sw/swtrunc.c b/src/spicelib/devices/sw/swtrunc.c index 2da6f43ed..7968d7c54 100644 --- a/src/spicelib/devices/sw/swtrunc.c +++ b/src/spicelib/devices/sw/swtrunc.c @@ -20,25 +20,29 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) double lastChange, maxChange, maxStep, ref; for( ; model; model = SWnextModel(model)) - for(here = SWinstances(model); here; - here = SWnextInstance(here)) { - lastChange = ckt->CKTstates[0][here->SWstate + 1] - + 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) { ref = model->SWvThreshold + model->SWvHysteresis; if (ckt->CKTstates[0][here->SWstate + 1]0) { - maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) * - 0.75 + 0.05; + 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; if (ckt->CKTstates[0][here->SWstate + 1]>ref && lastChange<0) { - maxChange = (ref - ckt->CKTstates[0][here->SWstate + 1]) * - 0.75 - 0.05; + 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; } } }