diff --git a/src/spicelib/devices/csw/cswacld.c b/src/spicelib/devices/csw/cswacld.c index 844021ea9..b9966f6c6 100644 --- a/src/spicelib/devices/csw/cswacld.c +++ b/src/spicelib/devices/csw/cswacld.c @@ -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; } diff --git a/src/spicelib/devices/csw/cswask.c b/src/spicelib/devices/csw/cswask.c index 56b2de2ae..b93c7ddf0 100644 --- a/src/spicelib/devices/csw/cswask.c +++ b/src/spicelib/devices/csw/cswask.c @@ -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 */ } diff --git a/src/spicelib/devices/csw/cswload.c b/src/spicelib/devices/csw/cswload.c index 473bee330..4911bc220 100644 --- a/src/spicelib/devices/csw/cswload.c +++ b/src/spicelib/devices/csw/cswload.c @@ -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; } diff --git a/src/spicelib/devices/csw/cswmask.c b/src/spicelib/devices/csw/cswmask.c index f4dad7b11..e7ab1f607 100644 --- a/src/spicelib/devices/csw/cswmask.c +++ b/src/spicelib/devices/csw/cswmask.c @@ -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 */ } diff --git a/src/spicelib/devices/csw/cswmpar.c b/src/spicelib/devices/csw/cswmpar.c index fb047b47d..35fe7ebff 100644 --- a/src/spicelib/devices/csw/cswmpar.c +++ b/src/spicelib/devices/csw/cswmpar.c @@ -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; } diff --git a/src/spicelib/devices/csw/cswnoise.c b/src/spicelib/devices/csw/cswnoise.c index 81c4700e7..2fd953e1e 100644 --- a/src/spicelib/devices/csw/cswnoise.c +++ b/src/spicelib/devices/csw/cswnoise.c @@ -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; } diff --git a/src/spicelib/devices/csw/cswparam.c b/src/spicelib/devices/csw/cswparam.c index c154a1175..d372a0723 100644 --- a/src/spicelib/devices/csw/cswparam.c +++ b/src/spicelib/devices/csw/cswparam.c @@ -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; } diff --git a/src/spicelib/devices/csw/cswpzld.c b/src/spicelib/devices/csw/cswpzld.c index 766d8a69f..a9af85a59 100644 --- a/src/spicelib/devices/csw/cswpzld.c +++ b/src/spicelib/devices/csw/cswpzld.c @@ -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; } diff --git a/src/spicelib/devices/csw/cswsetup.c b/src/spicelib/devices/csw/cswsetup.c index edb09ff8c..b9b7d6379 100644 --- a/src/spicelib/devices/csw/cswsetup.c +++ b/src/spicelib/devices/csw/cswsetup.c @@ -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; } diff --git a/src/spicelib/devices/csw/cswtrunc.c b/src/spicelib/devices/csw/cswtrunc.c index 150a0dec2..7fd2e6c30 100644 --- a/src/spicelib/devices/csw/cswtrunc.c +++ b/src/spicelib/devices/csw/cswtrunc.c @@ -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))0)) { - maxChange = (ref - *(ckt->CKTstate0+(here->CSWstate+1))) * + if ((ckt->CKTstates[0][here->CSWstate + 1]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; } diff --git a/src/spicelib/devices/sw/swacload.c b/src/spicelib/devices/sw/swacload.c index 5b6e71e82..70b43ef48 100644 --- a/src/spicelib/devices/sw/swacload.c +++ b/src/spicelib/devices/sw/swacload.c @@ -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; } diff --git a/src/spicelib/devices/sw/swask.c b/src/spicelib/devices/sw/swask.c index 7af8f7511..f447d5f46 100644 --- a/src/spicelib/devices/sw/swask.c +++ b/src/spicelib/devices/sw/swask.c @@ -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 */ } diff --git a/src/spicelib/devices/sw/swload.c b/src/spicelib/devices/sw/swload.c index a492b4a77..041901b41 100644 --- a/src/spicelib/devices/sw/swload.c +++ b/src/spicelib/devices/sw/swload.c @@ -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; } diff --git a/src/spicelib/devices/sw/swmask.c b/src/spicelib/devices/sw/swmask.c index ff8a0c3aa..4a0a34cce 100644 --- a/src/spicelib/devices/sw/swmask.c +++ b/src/spicelib/devices/sw/swmask.c @@ -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 */ } diff --git a/src/spicelib/devices/sw/swmparam.c b/src/spicelib/devices/sw/swmparam.c index 1eb1b1478..7f7030f35 100644 --- a/src/spicelib/devices/sw/swmparam.c +++ b/src/spicelib/devices/sw/swmparam.c @@ -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; } diff --git a/src/spicelib/devices/sw/swnoise.c b/src/spicelib/devices/sw/swnoise.c index 1e429a2e1..dc779f1a0 100644 --- a/src/spicelib/devices/sw/swnoise.c +++ b/src/spicelib/devices/sw/swnoise.c @@ -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; } diff --git a/src/spicelib/devices/sw/swparam.c b/src/spicelib/devices/sw/swparam.c index bda497b0e..2c2c5a476 100644 --- a/src/spicelib/devices/sw/swparam.c +++ b/src/spicelib/devices/sw/swparam.c @@ -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; } diff --git a/src/spicelib/devices/sw/swpzload.c b/src/spicelib/devices/sw/swpzload.c index ddcd08dc0..4ee31492d 100644 --- a/src/spicelib/devices/sw/swpzload.c +++ b/src/spicelib/devices/sw/swpzload.c @@ -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; } diff --git a/src/spicelib/devices/sw/swsetup.c b/src/spicelib/devices/sw/swsetup.c index 11eea0421..c058f5726 100644 --- a/src/spicelib/devices/sw/swsetup.c +++ b/src/spicelib/devices/sw/swsetup.c @@ -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; } diff --git a/src/spicelib/devices/sw/swtrunc.c b/src/spicelib/devices/sw/swtrunc.c index 9b40e3098..3c1bb0edc 100644 --- a/src/spicelib/devices/sw/swtrunc.c +++ b/src/spicelib/devices/sw/swtrunc.c @@ -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))0)) { - maxChange = (ref - *(ckt->CKTstate0+(here->SWstate+1))) * + if ((ckt->CKTstates[0][here->SWstate + 1]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; }