From d15cb732c290df04e27626631e64960c5623977c Mon Sep 17 00:00:00 2001 From: rlar Date: Thu, 8 Mar 2018 17:50:15 +0100 Subject: [PATCH] rewrite-rw, cleanup --- src/spicelib/devices/csw/csw.c | 38 +++++++++++++------------- src/spicelib/devices/csw/cswdefs.h | 22 +++++++-------- src/spicelib/devices/csw/cswnoise.c | 10 +++---- src/spicelib/devices/sw/sw.c | 42 ++++++++++++++--------------- src/spicelib/devices/sw/swdefs.h | 18 ++++++------- src/spicelib/devices/sw/swnoise.c | 10 +++---- 6 files changed, 69 insertions(+), 71 deletions(-) diff --git a/src/spicelib/devices/csw/csw.c b/src/spicelib/devices/csw/csw.c index 5ec2e4779..47bc335fb 100644 --- a/src/spicelib/devices/csw/csw.c +++ b/src/spicelib/devices/csw/csw.c @@ -11,23 +11,23 @@ Author: 1987 Thomas L. Quarles IFparm CSWpTable[] = { /* parameters */ - IOP( "control", CSW_CONTROL, IF_INSTANCE, "Name of controlling source"), - IP( "on", CSW_IC_ON, IF_FLAG, "Initially closed"), - IP( "off", CSW_IC_OFF, IF_FLAG, "Initially open"), - OPU( "pos_node", CSW_POS_NODE, IF_INTEGER, "Positive node of switch"), - OPU( "neg_node", CSW_NEG_NODE, IF_INTEGER, "Negative node of switch"), - OP( "i", CSW_CURRENT, IF_REAL, "Switch current"), - OP( "p", CSW_POWER, IF_REAL, "Instantaneous power") + IOP("control", CSW_CONTROL, IF_INSTANCE, "Name of controlling source"), + IP("on", CSW_IC_ON, IF_FLAG, "Initially closed"), + IP("off", CSW_IC_OFF, IF_FLAG, "Initially open"), + OPU("pos_node", CSW_POS_NODE, IF_INTEGER, "Positive node of switch"), + OPU("neg_node", CSW_NEG_NODE, IF_INTEGER, "Negative node of switch"), + OP("i", CSW_CURRENT, IF_REAL, "Switch current"), + OP("p", CSW_POWER, IF_REAL, "Instantaneous power") }; IFparm CSWmPTable[] = { /* model parameters */ - IOPU( "csw", CSW_CSW, IF_FLAG, "Current controlled switch model"), - IOPU( "it", CSW_ITH, IF_REAL, "Threshold current"), - IOPU( "ih", CSW_IHYS, IF_REAL, "Hysterisis current"), - IOPU( "ron", CSW_RON, IF_REAL, "Closed resistance"), - IOPU( "roff", CSW_ROFF, IF_REAL, "Open resistance"), - OPU( "gon", CSW_GON, IF_REAL, "Closed conductance"), - OPU( "goff", CSW_GOFF, IF_REAL, "Open conductance") + IOPU("csw", CSW_CSW, IF_FLAG, "Current controlled switch model"), + IOPU("it", CSW_ITH, IF_REAL, "Threshold current"), + IOPU("ih", CSW_IHYS, IF_REAL, "Hysterisis current"), + IOPU("ron", CSW_RON, IF_REAL, "Closed resistance"), + IOPU("roff", CSW_ROFF, IF_REAL, "Open resistance"), + OPU("gon", CSW_GON, IF_REAL, "Closed conductance"), + OPU("goff", CSW_GOFF, IF_REAL, "Open conductance") }; char *CSWnames[] = { @@ -35,8 +35,8 @@ char *CSWnames[] = { "W-" }; -int CSWnSize = NUMELEMS(CSWnames); -int CSWpTSize = NUMELEMS(CSWpTable); -int CSWmPTSize = NUMELEMS(CSWmPTable); -int CSWiSize = sizeof(CSWinstance); -int CSWmSize = sizeof(CSWmodel); +int CSWnSize = NUMELEMS(CSWnames); +int CSWpTSize = NUMELEMS(CSWpTable); +int CSWmPTSize = NUMELEMS(CSWmPTable); +int CSWiSize = sizeof(CSWinstance); +int CSWmSize = sizeof(CSWmodel); diff --git a/src/spicelib/devices/csw/cswdefs.h b/src/spicelib/devices/csw/cswdefs.h index bec0de545..898d9a41b 100644 --- a/src/spicelib/devices/csw/cswdefs.h +++ b/src/spicelib/devices/csw/cswdefs.h @@ -27,11 +27,11 @@ typedef struct sCSWinstance { #define CSWname gen.GENname #define CSWstate gen.GENstate - const int CSWposNode; /* number of positive node of switch */ - const int CSWnegNode; /* number of negative node of switch */ - int CSWcontBranch; /* number of branch of controlling current */ + const int CSWposNode; /* number of positive node of switch */ + const int CSWnegNode; /* number of negative node of switch */ + int CSWcontBranch; /* number of branch of controlling current */ - IFuid CSWcontName; /* name of controlling source */ + IFuid CSWcontName; /* name of controlling source */ double *CSWposPosPtr; /* pointer to sparse matrix diagonal at (positive,positive) for switch conductance */ @@ -42,14 +42,14 @@ typedef struct sCSWinstance { double *CSWnegNegPtr; /* pointer to sparse matrix diagonal at (neagtive,neagtive) for switch conductance */ - double CSWcond; /* current conductance of switch */ + double CSWcond; /* current conductance of switch */ unsigned CSWzero_stateGiven : 1; /* flag to indicate initial state */ #ifndef NONOISE double CSWnVar[NSTATVARS]; -#else /* NONOISE */ +#else double *CSWnVar; -#endif /* NONOISE */ +#endif } CSWinstance; /* data per model */ @@ -74,10 +74,10 @@ typedef struct sCSWmodel { /* model structure for a switch */ double CSWonConduct; /* switch "on" conductance */ double CSWoffConduct; /* switch "off" conductance */ - unsigned CSWonGiven : 1; /* flag to indicate on-resistance was specified */ - unsigned CSWoffGiven : 1; /* flag to indicate off-resistance was " */ + unsigned CSWonGiven : 1; /* flag to indicate on-resistance was specified */ + unsigned CSWoffGiven : 1; /* flag to indicate off-resistance was " */ unsigned CSWthreshGiven : 1; /* flag to indicate threshold volt was given */ - unsigned CSWhystGiven : 1; /* flag to indicate hysteresis volt was given */ + unsigned CSWhystGiven : 1; /* flag to indicate hysteresis volt was given */ } CSWmodel; /* device parameters */ @@ -104,4 +104,4 @@ typedef struct sCSWmodel { /* model structure for a switch */ #include "cswext.h" -#endif /*CSW*/ +#endif diff --git a/src/spicelib/devices/csw/cswnoise.c b/src/spicelib/devices/csw/cswnoise.c index 76473c7a5..4e452d891 100644 --- a/src/spicelib/devices/csw/cswnoise.c +++ b/src/spicelib/devices/csw/cswnoise.c @@ -100,16 +100,16 @@ CSWnoise(int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da if (job->NStpsSm != 0) { data->outpVector[data->outNumber++] = inst->CSWnVar[OUTNOIZ]; data->outpVector[data->outNumber++] = inst->CSWnVar[INNOIZ]; - } /* if */ + } break; - } /* switch (mode) */ + } break; case N_CLOSE: return OK; /* do nothing, the main calling routine will close */ - break; /* the plots */ - } /* switch (operation) */ - } /* for inst */ + break; /* the plots */ + } + } return OK; } diff --git a/src/spicelib/devices/sw/sw.c b/src/spicelib/devices/sw/sw.c index 5dc4ecf56..536060abb 100644 --- a/src/spicelib/devices/sw/sw.c +++ b/src/spicelib/devices/sw/sw.c @@ -10,26 +10,24 @@ Author: 1987 #include "ngspice/suffix.h" IFparm SWpTable[] = { /* parameters */ - IP("on", SW_IC_ON, IF_FLAG, "Switch initially closed"), - IP("off", SW_IC_OFF, IF_FLAG, "Switch initially open"), - IOPU("pos_node", SW_POS_NODE, IF_INTEGER, "Positive node of switch"), - IOPU("neg_node", SW_NEG_NODE, IF_INTEGER, "Negative node of switch"), - OPU("cont_p_node", SW_POS_CONT_NODE, IF_INTEGER, - "Positive contr. node of switch"), - OPU("cont_n_node", SW_NEG_CONT_NODE, IF_INTEGER, - "Positive contr. node of switch"), - OP("i", SW_CURRENT, IF_REAL, "Switch current"), - OP("p", SW_POWER, IF_REAL, "Switch power") + IP("on", SW_IC_ON, IF_FLAG, "Switch initially closed"), + IP("off", SW_IC_OFF, IF_FLAG, "Switch initially open"), + IOPU("pos_node", SW_POS_NODE, IF_INTEGER, "Positive node of switch"), + IOPU("neg_node", SW_NEG_NODE, IF_INTEGER, "Negative node of switch"), + OPU("cont_p_node", SW_POS_CONT_NODE, IF_INTEGER, "Positive contr. node of switch"), + OPU("cont_n_node", SW_NEG_CONT_NODE, IF_INTEGER, "Positive contr. node of switch"), + OP("i", SW_CURRENT, IF_REAL, "Switch current"), + OP("p", SW_POWER, IF_REAL, "Switch power") }; IFparm SWmPTable[] = { /* model parameters */ - IOPU( "sw", SW_MOD_SW, IF_FLAG, "Switch model"), - IOPU( "vt", SW_MOD_VTH, IF_REAL, "Threshold voltage"), - IOPU( "vh", SW_MOD_VHYS, IF_REAL, "Hysteresis voltage"), - IOPU( "ron", SW_MOD_RON, IF_REAL, "Resistance when closed"), - OPU( "gon", SW_MOD_GON, IF_REAL, "Conductance when closed"), - IOPU( "roff", SW_MOD_ROFF, IF_REAL, "Resistance when open"), - OPU( "goff", SW_MOD_GOFF, IF_REAL, "Conductance when open") + IOPU("sw", SW_MOD_SW, IF_FLAG, "Switch model"), + IOPU("vt", SW_MOD_VTH, IF_REAL, "Threshold voltage"), + IOPU("vh", SW_MOD_VHYS, IF_REAL, "Hysteresis voltage"), + IOPU("ron", SW_MOD_RON, IF_REAL, "Resistance when closed"), + OPU("gon", SW_MOD_GON, IF_REAL, "Conductance when closed"), + IOPU("roff", SW_MOD_ROFF, IF_REAL, "Resistance when open"), + OPU("goff", SW_MOD_GOFF, IF_REAL, "Conductance when open") }; char *SWnames[] = { @@ -39,8 +37,8 @@ char *SWnames[] = { "SC-" }; -int SWnSize = NUMELEMS(SWnames); -int SWpTSize = NUMELEMS(SWpTable); -int SWmPTSize = NUMELEMS(SWmPTable); -int SWiSize = sizeof(SWinstance); -int SWmSize = sizeof(SWmodel); +int SWnSize = NUMELEMS(SWnames); +int SWpTSize = NUMELEMS(SWpTable); +int SWmPTSize = NUMELEMS(SWmPTable); +int SWiSize = sizeof(SWinstance); +int SWmSize = sizeof(SWmodel); diff --git a/src/spicelib/devices/sw/swdefs.h b/src/spicelib/devices/sw/swdefs.h index 14e96c390..fe7576e72 100644 --- a/src/spicelib/devices/sw/swdefs.h +++ b/src/spicelib/devices/sw/swdefs.h @@ -27,8 +27,8 @@ typedef struct sSWinstance { #define SWname gen.GENname #define SWstate gen.GENstate - const int SWposNode; /* number of positive node of switch */ - const int SWnegNode; /* number of negative node of switch */ + const int SWposNode; /* number of positive node of switch */ + const int SWnegNode; /* number of negative node of switch */ const int SWposCntrlNode; /* number of positive controlling node of switch */ const int SWnegCntrlNode; /* number of negative controlling node of switch */ @@ -41,14 +41,14 @@ typedef struct sSWinstance { double *SWnegNegPtr; /* pointer to sparse matrix diagonal at (neagtive,neagtive) for switch conductance */ - double SWcond; /* conductance of the switch now */ + double SWcond; /* conductance of the switch now */ unsigned SWzero_stateGiven : 1; /* flag to indicate initial state */ #ifndef NONOISE double SWnVar[NSTATVARS]; -#else /* NONOISE */ +#else double *SWnVar; -#endif /* NONOISE */ +#endif } SWinstance; /* data per model */ @@ -73,10 +73,10 @@ typedef struct sSWmodel { /* model structure for a switch */ double SWonConduct; /* switch "on" conductance */ double SWoffConduct; /* switch "off" conductance */ - unsigned SWonGiven : 1; /* flag to indicate on-resistance was specified */ - unsigned SWoffGiven : 1; /* flag to indicate off-resistance was " */ + unsigned SWonGiven : 1; /* flag to indicate on-resistance was specified */ + unsigned SWoffGiven : 1; /* flag to indicate off-resistance was " */ unsigned SWthreshGiven : 1; /* flag to indicate threshold volt was given */ - unsigned SWhystGiven : 1; /* flag to indicate hysteresis volt was given */ + unsigned SWhystGiven : 1; /* flag to indicate hysteresis volt was given */ } SWmodel; /* device parameters */ @@ -104,4 +104,4 @@ typedef struct sSWmodel { /* model structure for a switch */ #include "swext.h" -#endif /*SW*/ +#endif diff --git a/src/spicelib/devices/sw/swnoise.c b/src/spicelib/devices/sw/swnoise.c index ce75dac6a..9ec1c46bc 100644 --- a/src/spicelib/devices/sw/swnoise.c +++ b/src/spicelib/devices/sw/swnoise.c @@ -100,16 +100,16 @@ SWnoise(int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *dat if (job->NStpsSm != 0) { data->outpVector[data->outNumber++] = inst->SWnVar[OUTNOIZ]; data->outpVector[data->outNumber++] = inst->SWnVar[INNOIZ]; - } /* if */ + } break; - } /* switch (mode) */ + } break; case N_CLOSE: return OK; /* do nothing, the main calling routine will close */ - break; /* the plots */ - } /* switch (operation) */ - } /* for inst */ + break; /* the plots */ + } + } return OK; }