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 "cswdefs.h"
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
|
|
||||||
|
|
||||||
IFparm CSWpTable[] = { /* parameters */
|
IFparm CSWpTable[] = { /* parameters */
|
||||||
IOP( "control",CSW_CONTROL, IF_INSTANCE, "Name of controlling source"),
|
IOP( "control",CSW_CONTROL, IF_INSTANCE, "Name of controlling source"),
|
||||||
IP( "on", CSW_IC_ON, IF_FLAG , "Initially closed"),
|
IP( "on", CSW_IC_ON, IF_FLAG , "Initially closed"),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ Author: 1985 Gordon Jacobs
|
||||||
|
|
||||||
int
|
int
|
||||||
CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
|
||||||
/* load the current values into the
|
/* load the current values into the
|
||||||
* sparse matrix previously provided
|
* sparse matrix previously provided
|
||||||
* during AC analysis
|
* during AC analysis
|
||||||
|
|
@ -27,7 +26,6 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
|
||||||
/* loop through all the switch models */
|
/* loop through all the switch models */
|
||||||
for( ; model; model = CSWnextModel(model))
|
for( ; model; model = CSWnextModel(model))
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = CSWinstances(model); here; here=CSWnextInstance(here)) {
|
for (here = CSWinstances(model); here; here=CSWnextInstance(here)) {
|
||||||
|
|
||||||
|
|
@ -40,5 +38,6 @@ CSWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
*(here->CSWnegPosPtr) -= g_now;
|
*(here->CSWnegPosPtr) -= g_now;
|
||||||
*(here->CSWnegNegPtr) += g_now;
|
*(here->CSWnegNegPtr) += g_now;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ Modified: 2001 Jon Engelbert
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
|
||||||
/* actually load the current values into the
|
/* actually load the current values into the
|
||||||
* sparse matrix previously provided
|
* sparse matrix previously provided
|
||||||
*/
|
*/
|
||||||
|
|
@ -32,7 +32,6 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
|
||||||
/* loop through all the switch models */
|
/* loop through all the switch models */
|
||||||
for( ; model; model = CSWnextModel(model))
|
for( ; model; model = CSWnextModel(model))
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = CSWinstances(model); here; here=CSWnextInstance(here)) {
|
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[0][here->CSWstate + 0] = current_state;
|
||||||
ckt->CKTstates[1][here->CSWstate + 0] = previous_state;
|
ckt->CKTstates[1][here->CSWstate + 0] = previous_state;
|
||||||
|
|
||||||
if (current_state == REALLY_ON || current_state == HYST_ON)
|
if (current_state == REALLY_ON || current_state == HYST_ON)
|
||||||
g_now = model->CSWonConduct;
|
g_now = model->CSWonConduct;
|
||||||
else
|
else
|
||||||
g_now = model->CSWoffConduct;
|
g_now = model->CSWoffConduct;
|
||||||
|
|
||||||
here->CSWcond = g_now;
|
here->CSWcond = g_now;
|
||||||
|
|
||||||
*(here->CSWposPosPtr) += g_now;
|
*(here->CSWposPosPtr) += g_now;
|
||||||
|
|
@ -145,5 +146,6 @@ CSWload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
*(here->CSWnegPosPtr) -= g_now;
|
*(here->CSWnegPosPtr) -= g_now;
|
||||||
*(here->CSWnegNegPtr) += g_now;
|
*(here->CSWnegNegPtr) += g_now;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ int
|
||||||
CSWmParam(int param, IFvalue *value, GENmodel *inModel)
|
CSWmParam(int param, IFvalue *value, GENmodel *inModel)
|
||||||
{
|
{
|
||||||
CSWmodel *model = (CSWmodel*)inModel;
|
CSWmodel *model = (CSWmodel*)inModel;
|
||||||
|
|
||||||
switch(param) {
|
switch(param) {
|
||||||
case CSW_CSW:
|
case CSW_CSW:
|
||||||
/* just says that this is a switch */
|
/* just says that this is a switch */
|
||||||
|
|
@ -44,5 +45,6 @@ CSWmParam(int param, IFvalue *value, GENmodel *inModel)
|
||||||
default:
|
default:
|
||||||
return E_BADPARM;
|
return E_BADPARM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ CSWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *d
|
||||||
double lnNdens;
|
double lnNdens;
|
||||||
int current_state;
|
int current_state;
|
||||||
|
|
||||||
|
|
||||||
for (model=firstModel; model; model=CSWnextModel(model))
|
for (model=firstModel; model; model=CSWnextModel(model))
|
||||||
for (inst=CSWinstances(model); inst; inst=CSWnextInstance(inst)) {
|
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)
|
if (job->NStpsSm != 0)
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|
||||||
case N_DENS:
|
case N_DENS:
|
||||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->CSWname, "");
|
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->CSWname, "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INT_NOIZ:
|
case INT_NOIZ:
|
||||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->CSWname, "");
|
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->CSWname, "");
|
||||||
NOISE_ADD_OUTVAR(ckt, data, "inoise_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:
|
default:
|
||||||
return E_BADPARM;
|
return E_BADPARM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ Author: 1985 Gordon Jacobs
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
int
|
||||||
CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
|
|
||||||
/* load the current values into the
|
/* load the current values into the
|
||||||
* sparse matrix previously provided
|
* sparse matrix previously provided
|
||||||
* during AC analysis
|
* during AC analysis
|
||||||
|
|
@ -31,7 +30,6 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
|
|
||||||
/* loop through all the switch models */
|
/* loop through all the switch models */
|
||||||
for( ; model; model = CSWnextModel(model))
|
for( ; model; model = CSWnextModel(model))
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = CSWinstances(model); here; here=CSWnextInstance(here)) {
|
for (here = CSWinstances(model); here; here=CSWnextInstance(here)) {
|
||||||
|
|
||||||
|
|
@ -44,5 +42,6 @@ CSWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
*(here->CSWnegPosPtr) -= g_now;
|
*(here->CSWnegPosPtr) -= g_now;
|
||||||
*(here->CSWnegNegPtr) += g_now;
|
*(here->CSWnegNegPtr) += g_now;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
/* load the switch conductance with those pointers needed later
|
/* load the switch conductance with those pointers needed later
|
||||||
* for fast matrix loading
|
* for fast matrix loading
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
CSWmodel *model = (CSWmodel*)inModel;
|
CSWmodel *model = (CSWmodel*)inModel;
|
||||||
CSWinstance *here;
|
CSWinstance *here;
|
||||||
|
|
||||||
/* loop through all the current source models */
|
/* loop through all the current source models */
|
||||||
for( ; model; model = CSWnextModel(model)) {
|
for( ; model; model = CSWnextModel(model)) {
|
||||||
|
|
||||||
/* Default Value Processing for Switch Model */
|
/* Default Value Processing for Switch Model */
|
||||||
if (!model->CSWthreshGiven)
|
if (!model->CSWthreshGiven)
|
||||||
model->CSWiThreshold = 0;
|
model->CSWiThreshold = 0;
|
||||||
|
|
@ -64,5 +64,6 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
TSTALLOC(CSWnegNegPtr, CSWnegNode, CSWnegNode);
|
TSTALLOC(CSWnegNegPtr, CSWnegNode, CSWnegNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ Modified: 2000 AlansFixes
|
||||||
|
|
||||||
#include "cswdefs.h"
|
#include "cswdefs.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
||||||
{
|
{
|
||||||
|
|
@ -48,5 +49,6 @@ CSWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
|
||||||
/* loop through all the switch models */
|
/* loop through all the switch models */
|
||||||
for( ; model; model = SWnextModel(model))
|
for( ; model; model = SWnextModel(model))
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
||||||
|
|
||||||
|
|
@ -41,5 +40,6 @@ SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
*(here->SWnegPosPtr) -= g_now;
|
*(here->SWnegPosPtr) -= g_now;
|
||||||
*(here->SWnegNegPtr) += g_now;
|
*(here->SWnegNegPtr) += g_now;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ Modified: 2001 Jon Engelbert
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
SWload(GENmodel *inModel, CKTcircuit *ckt)
|
SWload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
/* actually load the current values into the
|
/* actually load the current values into the
|
||||||
|
|
@ -32,7 +33,6 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
|
||||||
/* loop through all the switch models */
|
/* loop through all the switch models */
|
||||||
for( ; model; model = SWnextModel(model))
|
for( ; model; model = SWnextModel(model))
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
||||||
|
|
||||||
|
|
@ -101,7 +101,6 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
ckt->CKTtroubleElt = (GENinstance *) here;
|
ckt->CKTtroubleElt = (GENinstance *) here;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if(ckt->CKTmode & (MODEINITTRAN|MODEINITPRED) ) {
|
} else if(ckt->CKTmode & (MODEINITTRAN|MODEINITPRED) ) {
|
||||||
|
|
||||||
if (model->SWvHysteresis > 0) {
|
if (model->SWvHysteresis > 0) {
|
||||||
|
|
@ -127,12 +126,14 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// code added to force the state to be updated.
|
// code added to force the state to be updated.
|
||||||
// there is a possible problem. What if, during the transient analysis, the time is stepped
|
// 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
|
// 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.
|
// 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
|
// After analyzing the transient code, it seems that this is not a problem because state updating
|
||||||
// occurs before the convergence loop in transient processing.
|
// occurs before the convergence loop in transient processing.
|
||||||
|
|
||||||
ckt->CKTstates[0][here->SWstate + 0] = current_state;
|
ckt->CKTstates[0][here->SWstate + 0] = current_state;
|
||||||
ckt->CKTstates[0][here->SWstate + 1] = v_ctrl;
|
ckt->CKTstates[0][here->SWstate + 1] = v_ctrl;
|
||||||
|
|
||||||
|
|
@ -140,6 +141,7 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
g_now = model->SWonConduct;
|
g_now = model->SWonConduct;
|
||||||
else
|
else
|
||||||
g_now = model->SWoffConduct;
|
g_now = model->SWoffConduct;
|
||||||
|
|
||||||
here->SWcond = g_now;
|
here->SWcond = g_now;
|
||||||
|
|
||||||
*(here->SWposPosPtr) += g_now;
|
*(here->SWposPosPtr) += g_now;
|
||||||
|
|
@ -147,5 +149,6 @@ SWload(GENmodel *inModel, CKTcircuit *ckt)
|
||||||
*(here->SWnegPosPtr) -= g_now;
|
*(here->SWnegPosPtr) -= g_now;
|
||||||
*(here->SWnegNegPtr) += g_now;
|
*(here->SWnegNegPtr) += g_now;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ int
|
||||||
SWmParam(int param, IFvalue *value, GENmodel *inModel)
|
SWmParam(int param, IFvalue *value, GENmodel *inModel)
|
||||||
{
|
{
|
||||||
SWmodel *model = (SWmodel *)inModel;
|
SWmodel *model = (SWmodel *)inModel;
|
||||||
|
|
||||||
switch(param) {
|
switch(param) {
|
||||||
case SW_MOD_SW:
|
case SW_MOD_SW:
|
||||||
/* just says that this is a switch */
|
/* just says that this is a switch */
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ SWnoise (int mode, int operation, GENmodel *genmodel, CKTcircuit *ckt, Ndata *da
|
||||||
double lnNdens;
|
double lnNdens;
|
||||||
int current_state;
|
int current_state;
|
||||||
|
|
||||||
|
|
||||||
for (model=firstModel; model; model=SWnextModel(model))
|
for (model=firstModel; model; model=SWnextModel(model))
|
||||||
for (inst=SWinstances(model); inst; inst=SWnextInstance(inst)) {
|
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)
|
if (job->NStpsSm != 0)
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|
||||||
case N_DENS:
|
case N_DENS:
|
||||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->SWname, "");
|
NOISE_ADD_OUTVAR(ckt, data, "onoise_%s%s", inst->SWname, "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INT_NOIZ:
|
case INT_NOIZ:
|
||||||
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->SWname, "");
|
NOISE_ADD_OUTVAR(ckt, data, "onoise_total_%s%s", inst->SWname, "");
|
||||||
NOISE_ADD_OUTVAR(ckt, data, "inoise_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 */
|
/* loop through all the switch models */
|
||||||
for( ; model; model = SWnextModel(model))
|
for( ; model; model = SWnextModel(model))
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
for (here = SWinstances(model); here; here=SWnextInstance(here)) {
|
||||||
|
|
||||||
|
|
@ -45,5 +44,6 @@ SWpzLoad(GENmodel *inModel, CKTcircuit *ckt, SPcomplex *s)
|
||||||
*(here->SWnegPosPtr) -= g_now;
|
*(here->SWnegPosPtr) -= g_now;
|
||||||
*(here->SWnegNegPtr) += g_now;
|
*(here->SWnegNegPtr) += g_now;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
|
|
||||||
/* loop through all the current source models */
|
/* loop through all the current source models */
|
||||||
for( ; model; model = SWnextModel(model)) {
|
for( ; model; model = SWnextModel(model)) {
|
||||||
|
|
||||||
/* Default Value Processing for Switch Model */
|
/* Default Value Processing for Switch Model */
|
||||||
if (!model->SWthreshGiven)
|
if (!model->SWthreshGiven)
|
||||||
model->SWvThreshold = 0;
|
model->SWvThreshold = 0;
|
||||||
|
|
@ -59,5 +60,6 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
TSTALLOC(SWnegNegPtr, SWnegNode, SWnegNode);
|
TSTALLOC(SWnegNegPtr, SWnegNode, SWnegNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ Modified: 2000 AlansFixes
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
#include "swdefs.h"
|
#include "swdefs.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
||||||
{
|
{
|
||||||
|
|
@ -46,5 +47,6 @@ SWtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue