From 624c523ad3318a68afff930855d14ad4c2efb206 Mon Sep 17 00:00:00 2001 From: rlar Date: Wed, 28 Mar 2018 17:20:38 +0200 Subject: [PATCH] spicelib/devices/{sw,csw}, #12/, minor, increase similiarity CSW vs SW to ease diff'ing of those two models (compile "for i in swacld.c swask.c sw.c swdefs.h swdel.c swdest.c swext.h swinit.c swinit.h switf.h swload.c swmask.c swmdel.c swmpar.c swnoise.c swparam.c swpzld.c swsetup.c swtrunc.c ; do diff -U2 -b -w src/spicelib/devices/sw/$i src/spicelib/devices/csw/c$i ; done" 'diff-mode) --- src/spicelib/devices/csw/csw.c | 2 +- src/spicelib/devices/csw/cswask.c | 2 +- src/spicelib/devices/csw/cswdefs.h | 4 ++-- src/spicelib/devices/csw/cswext.h | 2 +- src/spicelib/devices/csw/cswload.c | 8 +++----- src/spicelib/devices/csw/cswmask.c | 6 +++--- src/spicelib/devices/csw/cswsetup.c | 1 - src/spicelib/devices/csw/cswtrunc.c | 2 -- src/spicelib/devices/sw/swload.c | 5 +++-- src/spicelib/devices/sw/swmask.c | 2 +- src/spicelib/devices/sw/swsetup.c | 4 ---- 11 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/spicelib/devices/csw/csw.c b/src/spicelib/devices/csw/csw.c index 47bc335fb..21269629b 100644 --- a/src/spicelib/devices/csw/csw.c +++ b/src/spicelib/devices/csw/csw.c @@ -4,8 +4,8 @@ Author: 1987 Thomas L. Quarles **********/ #include "ngspice/ngspice.h" -#include "ngspice/ifsim.h" #include "ngspice/devdefs.h" +#include "ngspice/ifsim.h" #include "cswdefs.h" #include "ngspice/suffix.h" diff --git a/src/spicelib/devices/csw/cswask.c b/src/spicelib/devices/csw/cswask.c index 104c8920c..7b8f31e30 100644 --- a/src/spicelib/devices/csw/cswask.c +++ b/src/spicelib/devices/csw/cswask.c @@ -5,7 +5,7 @@ Author: 1987 Thomas L. Quarles /* * This routine gives access to the internal device parameters - * of Current controlled SWitch + * of current controlled SWitch */ #include "ngspice/ngspice.h" diff --git a/src/spicelib/devices/csw/cswdefs.h b/src/spicelib/devices/csw/cswdefs.h index 2fdf0a5fd..46c1ebddf 100644 --- a/src/spicelib/devices/csw/cswdefs.h +++ b/src/spicelib/devices/csw/cswdefs.h @@ -8,10 +8,10 @@ Modified: 2000 AlansFixes #define CSW #include "ngspice/ifsim.h" -#include "ngspice/gendefs.h" #include "ngspice/cktdefs.h" -#include "ngspice/noisedef.h" +#include "ngspice/gendefs.h" #include "ngspice/complex.h" +#include "ngspice/noisedef.h" /* structures used to describe current controlled switches */ diff --git a/src/spicelib/devices/csw/cswext.h b/src/spicelib/devices/csw/cswext.h index 8bdded038..2a4310135 100644 --- a/src/spicelib/devices/csw/cswext.h +++ b/src/spicelib/devices/csw/cswext.h @@ -4,8 +4,8 @@ Author: 1985 Gordon M. Jacobs Modified: 2000 AlansFixes **********/ -extern int CSWask(CKTcircuit *, GENinstance *, int, IFvalue *, IFvalue *); extern int CSWacLoad(GENmodel *, CKTcircuit *); +extern int CSWask(CKTcircuit *, GENinstance *, int, IFvalue *, IFvalue *); extern int CSWdelete(GENinstance *); extern void CSWdestroy(void); extern int CSWload(GENmodel *, CKTcircuit *); diff --git a/src/spicelib/devices/csw/cswload.c b/src/spicelib/devices/csw/cswload.c index 6bca9f5ce..ef30ef77d 100644 --- a/src/spicelib/devices/csw/cswload.c +++ b/src/spicelib/devices/csw/cswload.c @@ -6,8 +6,8 @@ Modified: 2001 Jon Engelbert #include "ngspice/ngspice.h" #include "ngspice/cktdefs.h" -#include "cswdefs.h" #include "ngspice/fteext.h" +#include "cswdefs.h" #include "ngspice/trandefs.h" #include "ngspice/sperror.h" #include "ngspice/suffix.h" @@ -65,9 +65,9 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt) current_state = previous_state; } else if (ckt->CKTmode & (MODEINITFLOAT)) { + /* fixme, missleading comment: */ /* use state0 since INITTRAN or INITPRED already called */ - if (i_ctrl > (model->CSWiThreshold + fabs(model->CSWiHysteresis))) current_state = REALLY_ON; else if (i_ctrl < (model->CSWiThreshold - fabs(model->CSWiHysteresis))) @@ -105,12 +105,9 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt) if (model->CSWiHysteresis > 0) { current_state = previous_state; } else { - /* in hysteresis... change value if going from low to hysteresis, - * or from hi to hysteresis. */ verify(previous_state, "bad value for previous_state in cswload"); - /* if previous state was in hysteresis, then don't change the state.. */ if (previous_state == REALLY_ON) current_state = HYST_ON; else if (previous_state == REALLY_OFF) @@ -118,6 +115,7 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt) else current_state = previous_state; } + } else { internalerror("bad things in swload"); controlled_exit(1); diff --git a/src/spicelib/devices/csw/cswmask.c b/src/spicelib/devices/csw/cswmask.c index ae5f9d693..e0ba3f31b 100644 --- a/src/spicelib/devices/csw/cswmask.c +++ b/src/spicelib/devices/csw/cswmask.c @@ -5,7 +5,7 @@ Author: 1987 Thomas L. Quarles /* * This routine gives access to the internal model parameters - * of Current controlled SWitch + * of current controlled SWitch */ #include "ngspice/ngspice.h" @@ -18,9 +18,9 @@ Author: 1987 Thomas L. Quarles int -CSWmAsk(CKTcircuit *ckt, GENmodel *inst, int which, IFvalue *value) +CSWmAsk(CKTcircuit *ckt, GENmodel *inModel, int which, IFvalue *value) { - CSWmodel *here = (CSWmodel *) inst; + CSWmodel *here = (CSWmodel *) inModel; NG_IGNORE(ckt); diff --git a/src/spicelib/devices/csw/cswsetup.c b/src/spicelib/devices/csw/cswsetup.c index b66afee75..bf869653f 100644 --- a/src/spicelib/devices/csw/cswsetup.c +++ b/src/spicelib/devices/csw/cswsetup.c @@ -40,7 +40,6 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) for (here = CSWinstances(model); here; here = CSWnextInstance(here)) { - /* Default Value Processing for Switch Instance */ here->CSWstate = *states; *states += CSW_NUM_STATES; diff --git a/src/spicelib/devices/csw/cswtrunc.c b/src/spicelib/devices/csw/cswtrunc.c index de8d0af0b..97418246a 100644 --- a/src/spicelib/devices/csw/cswtrunc.c +++ b/src/spicelib/devices/csw/cswtrunc.c @@ -8,7 +8,6 @@ Modified: 2000 AlansFixes #include "ngspice/cktdefs.h" #include "ngspice/sperror.h" #include "ngspice/suffix.h" - #include "cswdefs.h" @@ -17,7 +16,6 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep) { CSWmodel *model = (CSWmodel *) inModel; CSWinstance *here; - double lastChange, maxChange, maxStep, ref; for (; model; model = CSWnextModel(model)) diff --git a/src/spicelib/devices/sw/swload.c b/src/spicelib/devices/sw/swload.c index db208cc5d..ee2fa7802 100644 --- a/src/spicelib/devices/sw/swload.c +++ b/src/spicelib/devices/sw/swload.c @@ -78,11 +78,12 @@ SWload(GENmodel *inModel, CKTcircuit *ckt) if (model->SWvHysteresis > 0) { current_state = old_current_state; } else { - // in hysteresis... change value if going from low to hysteresis, or from hi to hysteresis. + /* in hysteresis... change value if going from low to hysteresis, + * or from hi to hysteresis. */ verify(previous_state, "bad value for previous_state in swload"); - // if previous state was in hysteresis, then don't change the state.. + /* if previous state was in hysteresis, then don't change the state.. */ if (previous_state == REALLY_ON) current_state = HYST_ON; else if (previous_state == REALLY_OFF) diff --git a/src/spicelib/devices/sw/swmask.c b/src/spicelib/devices/sw/swmask.c index 3fec325d2..3ae1ed44e 100644 --- a/src/spicelib/devices/sw/swmask.c +++ b/src/spicelib/devices/sw/swmask.c @@ -4,7 +4,7 @@ Author: 1987 Thomas L. Quarles **********/ /* - * This routine gives access to the internal model parameter + * This routine gives access to the internal model parameters * of voltage controlled SWitch */ diff --git a/src/spicelib/devices/sw/swsetup.c b/src/spicelib/devices/sw/swsetup.c index 50972ae74..dc7d7ef4c 100644 --- a/src/spicelib/devices/sw/swsetup.c +++ b/src/spicelib/devices/sw/swsetup.c @@ -4,7 +4,6 @@ Author: 1985 Gordon Jacobs **********/ #include "ngspice/ngspice.h" -#include "ngspice/smpdefs.h" #include "ngspice/cktdefs.h" #include "swdefs.h" #include "ngspice/sperror.h" @@ -44,9 +43,6 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) here->SWstate = *states; *states += SW_NUM_STATES; - /* Default Value Processing for Switch Instance */ - /* none */ - TSTALLOC(SWposPosPtr, SWposNode, SWposNode); TSTALLOC(SWposNegPtr, SWposNode, SWnegNode); TSTALLOC(SWnegPosPtr, SWnegNode, SWposNode);