rewrite-rw, newlines
This commit is contained in:
parent
b0a8cd33d2
commit
ae12f10fce
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, "");
|
||||
|
|
|
|||
|
|
@ -35,5 +35,6 @@ CSWparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
|||
default:
|
||||
return E_BADPARM;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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, "");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue