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)
This commit is contained in:
rlar 2018-03-28 17:20:38 +02:00
parent d515a10bde
commit 624c523ad3
11 changed files with 15 additions and 23 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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 */

View File

@ -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 *);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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))

View File

@ -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)

View File

@ -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
*/

View File

@ -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);