Jspice3
swparse.c File Reference
#include "spice.h"
#include <stdio.h>
#include "inpdefs.h"
#include "inpmacs.h"
Include dependency graph for swparse.c:

Go to the source code of this file.

Functions

void SWparse (int type, GENERIC *ckt, GENERIC *tabp, GENERIC *currentp)
 

Function Documentation

void SWparse ( int  type,
GENERIC ckt,
GENERIC tabp,
GENERIC currentp 
)

Definition at line 14 of file swparse.c.

20 {
21  /* switch parser */
22 
23  /* VOLTAGE CONTROLLED SWITCH */
24  /* Sname <node> <node> <node> <node> [<modname>] [IC] */
25 
26  /* CURRENT CONTROLLED SWITCH */
27  /* Wname <node> <node> <vctrl> [<modname>] [IC] */
28 
29  INPtables *tab = (INPtables*)tabp;
30  card *current = (card*)currentp;
31 
32  char *line; /* the part of the current line left to parse */
33  char *name; /* the device's name */
34  char *model; /* the name of the resistor's model */
35  char *nname1; /* the first node's name */
36  char *nname2; /* the second node's name */
37  char *nname3; /* the third node's name */
38  char *nname4; /* the fourth node's name */
39  GENERIC *node1; /* the first node's node pointer */
40  GENERIC *node2; /* the second node's node pointer */
41  GENERIC *node3; /* the third node's node pointer */
42  GENERIC *node4; /* the fourth node's node pointer */
43  int error; /* error code temporary */
44  INPmodel *thismodel; /* pointer to model structure describing our model */
45  GENERIC *mdfast; /* pointer to the actual model */
46  GENERIC *fast; /* pointer to the actual instance */
47  IFvalue ptemp; /* a value structure to package resistance into */
48  IFvalue *parm; /* pointer to a value structure for functions to return */
49  int waslead; /* flag to indicate that funny unlabeled number was found */
50  double leadval; /* actual value of unlabeled number */
51  IFuid uid; /* uid of default model */
52  char key;
53 
54  line = current->line;
55  key = *line;
56  if (islower(key))
57  key = toupper(key);
58 
59  INPgetTok(&line,&name,1);
60  INPinsert(&name,tab);
61 
62  INPgetTok(&line,&nname1,1);
63  INPtermInsert(ckt,&nname1,tab,&node1);
64 
65  INPgetTok(&line,&nname2,1);
66  INPtermInsert(ckt,&nname2,tab,&node2);
67 
68  if (key == 'S') {
69  /* voltage controlled switch */
70 
71  INPgetTok(&line,&nname3,1);
72  INPtermInsert(ckt,&nname3,tab,&node3);
73 
74  INPgetTok(&line,&nname4,1);
75  INPtermInsert(ckt,&nname4,tab,&node4);
76  }
77  else {
78  /* current controlled switch */
79 
80  parm = INPgetValue(ckt,&line,IF_INSTANCE,tab);
81  ptemp.uValue = parm->uValue;
82  }
83  INPgetTok(&line,&model,1);
84  INPinsert(&model,tab);
85 
86  current->error = INPgetMod(ckt,model,&thismodel,tab);
87  if (thismodel != NULL) {
88  if (type != thismodel->INPmodType) {
90  return;
91  }
92  mdfast = (thismodel->INPmodfast);
93  }
94  else {
95  if (!tab->defSmod) {
96  /* create deafult S model */
97  IFnewUid(ckt,&uid,(IFuid)NULL,"S",UID_MODEL,(GENERIC**)NULL);
98  IFC(newModel,(ckt,type,&(tab->defSmod),uid))
99  }
100  mdfast = tab->defSmod;
101  }
102  IFC(newInstance,(ckt,mdfast,&fast,name))
103  IFC(bindNode,(ckt,fast,1,node1))
104  IFC(bindNode,(ckt,fast,2,node2))
105 
106  if (key == 'S') {
107  IFC(bindNode,(ckt,fast,3,node3))
108  IFC(bindNode,(ckt,fast,4,node4))
109  }
110  else {
111  GCA(INPpName,("control",&ptemp,ckt,type,fast))
112  }
113 
114  PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab))
115  if (waslead) {
116  /* ignore a number */
117  }
118 }
GENERIC * defSmod
Definition: inpdefs.h:53
int INPpName()
char * line
Definition: inpdefs.h:64
int INPtermInsert()
IFvalue * INPgetValue()
int IFnewUid()
if(TDesc==NULL)
Definition: cd.c:1326
Definition: inpdefs.h:62
#define UID_MODEL
Definition: ifsim.h:83
Definition: subckt.c:51
#define IF_INSTANCE
Definition: ifsim.h:112
#define LITERR(text)
Definition: inpmacs.h:35
int INPmodType
Definition: inpdefs.h:73
int INPinsert()
Definition: fteinp.h:14
GENERIC * IFuid
Definition: ifsim.h:72
#define NULL
Definition: spdefs.h:121
Definition: types.c:18
#define GCA(func, args)
Definition: inpmacs.h:27
#define IFC(func, args)
Definition: inpmacs.h:19
char * error
Definition: inpdefs.h:65
#define PARSECALL(args)
Definition: inpmacs.h:42
static char model[32]
Definition: subckt.c:76
return(True)
char * INPdevErr()
char GENERIC
Definition: ifsim.h:27
IFuid uValue
Definition: ifsim.h:236
char * INPgetMod()
int INPgetTok()