diff --git a/src/spicelib/devices/csw/csw.c b/src/spicelib/devices/csw/csw.c index c257e12e9..ff9e74d5e 100644 --- a/src/spicelib/devices/csw/csw.c +++ b/src/spicelib/devices/csw/csw.c @@ -9,6 +9,7 @@ Author: 1987 Thomas L. Quarles #include "cswdefs.h" #include "ngspice/suffix.h" + IFparm CSWpTable[] = { /* parameters */ IOP( "control",CSW_CONTROL, IF_INSTANCE, "Name of controlling source"), IP( "on", CSW_IC_ON, IF_FLAG , "Initially closed"), diff --git a/src/spicelib/devices/csw/cswacld.c b/src/spicelib/devices/csw/cswacld.c index cf4ec3151..38ffd089e 100644 --- a/src/spicelib/devices/csw/cswacld.c +++ b/src/spicelib/devices/csw/cswacld.c @@ -14,7 +14,6 @@ Author: 1985 Gordon Jacobs int CSWacLoad(GENmodel *inModel, CKTcircuit *ckt) - /* load the current values into the * sparse matrix previously provided * during AC analysis @@ -27,7 +26,6 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt) /* loop through all the switch models */ for( ; model; model = CSWnextModel(model)) - /* loop through all the instances of the model */ for (here = CSWinstances(model); here; here=CSWnextInstance(here)) { @@ -40,5 +38,6 @@ 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 9156b4281..662538a3a 100644 --- a/src/spicelib/devices/csw/cswload.c +++ b/src/spicelib/devices/csw/cswload.c @@ -12,9 +12,9 @@ Modified: 2001 Jon Engelbert #include "ngspice/sperror.h" #include "ngspice/suffix.h" + int CSWload(GENmodel *inModel, CKTcircuit *ckt) - /* actually load the current values into the * sparse matrix previously provided */ @@ -32,7 +32,6 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt) /* loop through all the switch models */ for( ; model; model = CSWnextModel(model)) - /* loop through all the instances of the model */ for (here = CSWinstances(model); here; here=CSWnextInstance(here)) { @@ -134,10 +133,12 @@ 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) g_now = model->CSWonConduct; else g_now = model->CSWoffConduct; + here->CSWcond = g_now; *(here->CSWposPosPtr) += g_now; @@ -145,5 +146,6 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt) *(here->CSWnegPosPtr) -= g_now; *(here->CSWnegNegPtr) += g_now; } + return OK; } diff --git a/src/spicelib/devices/csw/cswmpar.c b/src/spicelib/devices/csw/cswmpar.c index 056dc8549..b1c5c58e3 100644 --- a/src/spicelib/devices/csw/cswmpar.c +++ b/src/spicelib/devices/csw/cswmpar.c @@ -17,6 +17,7 @@ int CSWmParam(int param, IFvalue *value, GENmodel *inModel) { CSWmodel *model = (CSWmodel*)inModel; + switch(param) { case CSW_CSW: /* just says that this is a switch */ @@ -44,5 +45,6 @@ CSWmParam(int param, IFvalue *value, GENmodel *inModel) default: return E_BADPARM; } + return OK; } diff --git a/src/spicelib/devices/csw/cswnoise.c b/src/spicelib/devices/csw/cswnoise.c index 98edc8ec1..18593102e 100644 --- a/src/spicelib/devices/csw/cswnoise.c +++ b/src/spicelib/devices/csw/cswnoise.c @@ -35,7 +35,6 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d double lnNdens; int current_state; - for (model=firstModel; model; model=CSWnextModel(model)) for (inst=CSWinstances(model); inst; inst=CSWnextInstance(inst)) { @@ -48,11 +47,9 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d if (job->NStpsSm != 0) switch (mode) { - case N_DENS: NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->CSWname, ""); break; - case INT_NOIZ: NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->CSWname, ""); NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->CSWname, ""); diff --git a/src/spicelib/devices/csw/cswparam.c b/src/spicelib/devices/csw/cswparam.c index c0e7a3524..034132263 100644 --- a/src/spicelib/devices/csw/cswparam.c +++ b/src/spicelib/devices/csw/cswparam.c @@ -35,5 +35,6 @@ CSWparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) default: return E_BADPARM; } + return OK; } diff --git a/src/spicelib/devices/csw/cswpzld.c b/src/spicelib/devices/csw/cswpzld.c index 4106ad714..4414e1cf6 100644 --- a/src/spicelib/devices/csw/cswpzld.c +++ b/src/spicelib/devices/csw/cswpzld.c @@ -16,7 +16,6 @@ Author: 1985 Gordon Jacobs /* ARGSUSED */ int CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) - /* load the current values into the * sparse matrix previously provided * during AC analysis @@ -31,7 +30,6 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) /* loop through all the switch models */ for( ; model; model = CSWnextModel(model)) - /* loop through all the instances of the model */ for (here = CSWinstances(model); here; here=CSWnextInstance(here)) { @@ -44,5 +42,6 @@ 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 a931b6762..bb09f7f40 100644 --- a/src/spicelib/devices/csw/cswsetup.c +++ b/src/spicelib/devices/csw/cswsetup.c @@ -23,13 +23,13 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) /* load the switch conductance with those pointers needed later * for fast matrix loading */ - { CSWmodel *model = (CSWmodel*)inModel; CSWinstance *here; /* loop through all the current source models */ for( ; model; model = CSWnextModel(model)) { + /* Default Value Processing for Switch Model */ if (!model->CSWthreshGiven) model->CSWiThreshold = 0; @@ -64,5 +64,6 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) TSTALLOC(CSWnegNegPtr, CSWnegNode, CSWnegNode); } } + return OK; } diff --git a/src/spicelib/devices/csw/cswtrunc.c b/src/spicelib/devices/csw/cswtrunc.c index 82618fe26..348bb27cd 100644 --- a/src/spicelib/devices/csw/cswtrunc.c +++ b/src/spicelib/devices/csw/cswtrunc.c @@ -13,6 +13,7 @@ Modified: 2000 AlansFixes #include "cswdefs.h" + int CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) { @@ -48,5 +49,6 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) } } } + return OK; } diff --git a/src/spicelib/devices/sw/swacload.c b/src/spicelib/devices/sw/swacload.c index a88912d44..7c102f800 100644 --- a/src/spicelib/devices/sw/swacload.c +++ b/src/spicelib/devices/sw/swacload.c @@ -26,7 +26,6 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt) /* loop through all the switch models */ for( ; model; model = SWnextModel(model)) - /* loop through all the instances of the model */ for (here = SWinstances(model); here; here=SWnextInstance(here)) { @@ -41,5 +40,6 @@ 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 b0e697345..62243dcd4 100644 --- a/src/spicelib/devices/sw/swload.c +++ b/src/spicelib/devices/sw/swload.c @@ -12,6 +12,7 @@ Modified: 2001 Jon Engelbert #include "ngspice/sperror.h" #include "ngspice/suffix.h" + int SWload(GENmodel *inModel, CKTcircuit *ckt) /* actually load the current values into the @@ -32,7 +33,6 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) /* loop through all the switch models */ for( ; model; model = SWnextModel(model)) - /* loop through all the instances of the model */ for (here = SWinstances(model); here; here=SWnextInstance(here)) { @@ -101,7 +101,6 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) ckt->CKTtroubleElt = (GENinstance *) here; } - } else if(ckt->CKTmode & (MODEINITTRAN|MODEINITPRED) ) { if (model->SWvHysteresis > 0) { @@ -127,12 +126,14 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) } } } + // code added to force the state to be updated. // there is a possible problem. What if, during the transient analysis, the time is stepped // forward enough to change the switch's state, but that time point is rejected as being too // 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 + 0] = current_state; ckt->CKTstates[0][here->SWstate + 1] = v_ctrl; @@ -140,6 +141,7 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) g_now = model->SWonConduct; else g_now = model->SWoffConduct; + here->SWcond = g_now; *(here->SWposPosPtr) += g_now; @@ -147,5 +149,6 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) *(here->SWnegPosPtr) -= g_now; *(here->SWnegNegPtr) += g_now; } + return OK; } diff --git a/src/spicelib/devices/sw/swmparam.c b/src/spicelib/devices/sw/swmparam.c index 3d49e9b3a..43437579c 100644 --- a/src/spicelib/devices/sw/swmparam.c +++ b/src/spicelib/devices/sw/swmparam.c @@ -17,6 +17,7 @@ int SWmParam(int param, IFvalue *value, GENmodel *inModel) { SWmodel *model = (SWmodel *)inModel; + switch(param) { case SW_MOD_SW: /* just says that this is a switch */ diff --git a/src/spicelib/devices/sw/swnoise.c b/src/spicelib/devices/sw/swnoise.c index f0b0facde..b48783700 100644 --- a/src/spicelib/devices/sw/swnoise.c +++ b/src/spicelib/devices/sw/swnoise.c @@ -35,7 +35,6 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da double lnNdens; int current_state; - for (model=firstModel; model; model=SWnextModel(model)) for (inst=SWinstances(model); inst; inst=SWnextInstance(inst)) { @@ -48,11 +47,9 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da if (job->NStpsSm != 0) switch (mode) { - case N_DENS: NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->SWname, ""); break; - case INT_NOIZ: NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->SWname, ""); NOISE_ADD_OUTVAR(ckt, data, "inoise_total_%s%s", inst->SWname, ""); diff --git a/src/spicelib/devices/sw/swpzload.c b/src/spicelib/devices/sw/swpzload.c index a741f238b..f3a4d4d2e 100644 --- a/src/spicelib/devices/sw/swpzload.c +++ b/src/spicelib/devices/sw/swpzload.c @@ -30,7 +30,6 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s) /* loop through all the switch models */ for( ; model; model = SWnextModel(model)) - /* loop through all the instances of the model */ for (here = SWinstances(model); here; here=SWnextInstance(here)) { @@ -45,5 +44,6 @@ 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 0f5f55a60..47cd175b3 100644 --- a/src/spicelib/devices/sw/swsetup.c +++ b/src/spicelib/devices/sw/swsetup.c @@ -30,6 +30,7 @@ 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) model->SWvThreshold = 0; @@ -59,5 +60,6 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) TSTALLOC(SWnegNegPtr, SWnegNode, SWnegNode); } } + return OK; } diff --git a/src/spicelib/devices/sw/swtrunc.c b/src/spicelib/devices/sw/swtrunc.c index 7968d7c54..63906dc27 100644 --- a/src/spicelib/devices/sw/swtrunc.c +++ b/src/spicelib/devices/sw/swtrunc.c @@ -12,6 +12,7 @@ Modified: 2000 AlansFixes #include "ngspice/suffix.h" #include "swdefs.h" + int SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) { @@ -46,5 +47,6 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) } } } + return OK; }