Jspice3
swsetup.c File Reference
#include "spice.h"
#include <stdio.h>
#include "swdefs.h"
#include "sperror.h"
Include dependency graph for swsetup.c:

Go to the source code of this file.

Functions

int SWsetup (SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
 

Function Documentation

int SWsetup ( SMPmatrix matrix,
GENmodel inModel,
CKTcircuit ckt,
int *  states 
)

Definition at line 15 of file swsetup.c.

24 {
25  SWmodel *model = (SWmodel *)inModel;
26  SWinstance *here;
27 
28  /* loop through all the current source models */
29  for ( ; model != NULL; model = model->SWnextModel) {
30  /* Default Value Processing for Switch Model */
31  if (!model->SWvThreshGiven) {
32  model->SWvThreshold = 0;
33  }
34  if (!model->SWvHystGiven) {
35  model->SWvHysteresis = 0;
36  }
37  if (!model->SWiThreshGiven) {
38  model->SWiThreshold = 0;
39  }
40  if (!model->SWiHystGiven) {
41  model->SWiHysteresis = 0;
42  }
43  if (!model->SWonGiven) {
45  model->SWonResistance = 1.0/model->SWonConduct;
46  }
47  if (!model->SWoffGiven) {
49  model->SWoffResistance = 1.0/model->SWoffConduct;
50  }
51 
52  /* loop through all the instances of the model */
53  for (here = model->SWinstances; here != NULL;
54  here = here->SWnextInstance) {
55 
56  if (here->SWcontName) {
57  here->SWcontBranch = CKTfndBranch(ckt,here->SWcontName);
58  if (here->SWcontBranch == 0) {
59  IFuid namarray[2];
60  namarray[0] = here->SWname;
61  namarray[1] = here->SWcontName;
62  (*(SPfrontEnd->IFerror))(ERR_FATAL,
63  "%s: unknown controlling source %s",namarray);
64  return(E_BADPARM);
65  }
66  }
67 
68  TSTALLOC(SWposPosptr, SWposNode, SWposNode)
69  TSTALLOC(SWposNegptr, SWposNode, SWnegNode)
70  TSTALLOC(SWnegPosptr, SWnegNode, SWposNode)
71  TSTALLOC(SWnegNegptr, SWnegNode, SWnegNode)
72  here->SWstate = *states;
73  *states += SW_NUM_STATES;
74  }
75  }
76  return (OK);
77 }
IFuid SWcontName
Definition: swdefs.h:30
double SWiHysteresis
Definition: swdefs.h:71
#define SW_ON_CONDUCTANCE
Definition: swdefs.h:54
unsigned SWiHystGiven
Definition: swdefs.h:81
int SWcontBranch
Definition: swdefs.h:29
#define ERR_FATAL
Definition: ifsim.h:518
IFfrontEnd * SPfrontEnd
Definition: main.c:917
#define E_BADPARM
Definition: iferrmsg.h:26
unsigned SWonGiven
Definition: swdefs.h:76
double SWonResistance
Definition: swdefs.h:66
unsigned SWiThreshGiven
Definition: swdefs.h:80
#define TSTALLOC(ptr, first, second)
Definition: devdefs.h:124
unsigned SWoffGiven
Definition: swdefs.h:77
#define OK
Definition: iferrmsg.h:17
GENERIC * IFuid
Definition: ifsim.h:72
double SWvHysteresis
Definition: swdefs.h:69
double SWvThreshold
Definition: swdefs.h:68
#define NULL
Definition: spdefs.h:121
double SWonConduct
Definition: swdefs.h:72
struct sSWinstance * SWnextInstance
Definition: swdefs.h:20
static char model[32]
Definition: subckt.c:76
unsigned SWvHystGiven
Definition: swdefs.h:79
return(True)
SWinstance * SWinstances
Definition: swdefs.h:62
#define SW_OFF_CONDUCTANCE
Definition: swdefs.h:55
IFuid SWname
Definition: swdefs.h:22
int CKTfndBranch()
double SWiThreshold
Definition: swdefs.h:70
double SWoffConduct
Definition: swdefs.h:73
struct sSWmodel * SWnextModel
Definition: swdefs.h:60
double SWoffResistance
Definition: swdefs.h:67
unsigned SWvThreshGiven
Definition: swdefs.h:78
#define SW_NUM_STATES
Definition: swdefs.h:56