Jspice3
inp2dot.c File Reference
#include "spice.h"
#include "ftedefs.h"
#include "inpdefs.h"
#include "inpmacs.h"
#include "jobdefs.h"
#include "misc.h"
Include dependency graph for inp2dot.c:

Go to the source code of this file.

Functions

static int get_anal ()
 
int INP2dot (GENERIC *ckt, INPtables *tab, card *current, GENERIC *task, GENERIC *gnode)
 
static int get_anal (char *string)
 

Function Documentation

static int get_anal ( )
static
static int get_anal ( char *  string)
static

Definition at line 303 of file inp2dot.c.

305 {
306  int i;
307 
308  for (i = 0; i < ft_sim->numAnalyses; i++) {
309  if (strcmp(ft_sim->analyses[i]->name,string) == 0) {
310  return (i);
311  }
312  }
313  return (-1);
314 }
IFsimulator * ft_sim
Definition: main.c:111
char * name
Definition: ifsim.h:336
int numAnalyses
Definition: ifsim.h:463
IFanalysis ** analyses
Definition: ifsim.h:464
int INP2dot ( GENERIC ckt,
INPtables tab,
card current,
GENERIC task,
GENERIC gnode 
)

Definition at line 22 of file inp2dot.c.

29 {
30  /* .<something> Many possibilities */
31 
32  char *line; /* the part of the current line left to parse */
33  char *name; /* the device's name */
34  GENERIC *node; /* the first node's node pointer */
35  IFvalue ptemp; /* a value structure to package stuff into */
36  IFparm *prm; /* pointer to parameter to search through array */
37  char *token; /* a token from the line */
38  int which; /* which analysis we are performing */
39  int length; /* length of a name */
40  int error; /* error code temporary */
41 
42 
43  line = current->line;
44  INPgetTok(&line,&token,1);
45 
46  if (strcmp(token,".model") == 0) {
47  /* don't have to do anything, since models were all done in
48  * pass 1
49  */
50  txfree(token);
51  return (0);
52  }
53 
54  if ( (strcmp(token,".width") == 0) ||
55  (strcmp(token,".print") == 0) ||
56  (strcmp(token,".plot" ) == 0) ) {
57  /* obsolete - ignore */
58  LITERR("Obsolete control card - ignored.")
59  txfree(token);
60  return (0);
61  }
62 
63  if (strcmp(token,".temp") == 0) {
64  /* .temp temp1 temp2 temp3 temp4 ..... */
65  /* not yet implemented - warn & ignore */
66  LITERR(".TEMP card obsolete - use .options TEMP and TNOM.")
67  txfree(token);
68  return (0);
69  }
70 
71  if ( (strcmp(token,".four") == 0) ||
72  (strcmp(token,".fourier") == 0) ) {
73  /* .four */
74  /* not implemented - warn & ignore */
75  LITERR("Use fourier command to obtain fourier analysis.")
76  txfree(token);
77  return (0);
78  }
79 
80  if (strcmp(token,".nodeset") == 0) {
81  /* .nodeset */
82  txfree(token);
83  which = -1;
84  for (prm = ft_sim->nodeParms;
85  prm < ft_sim->nodeParms+ft_sim->numNodeParms; prm++) {
86  if (strcmp(prm->keyword,"nodeset") == 0) {
87  which = prm->id;
88  break;
89  }
90  }
91  if (which == -1) {
92  LITERR("Nodeset unknown to simulator.")
93  return (0);
94  }
95  for (;;) { /* loop until we run out of data */
96  INPgetTok(&line,&name,1);
97  /* check to see if in the form V(xxx) and grab the xxx */
98  if (*name == 0) break; /* end of line */
99  length = strlen(name);
100  if ((*name == 'V' || *(name) == 'v') && (length == 1)) {
101  /* looks like V - must be V(xx) - get xx now*/
102  INPgetTok(&line,&name,1);
103  INPtermInsert(ckt,&name,tab,&node);
104  ptemp.rValue = INPevaluate(&line,&error,1);
105  IFC(setNodeParm,(ckt,node,which,&ptemp,(IFvalue*)NULL))
106  continue;
107  }
108  LITERR(".NODESET syntax error.")
109  break;
110  }
111  return (0);
112  }
113 
114  if (strcmp(token,".ic") == 0) {
115  /* .ic */
116  txfree(token);
117  which = -1;
118  for (prm = ft_sim->nodeParms;
119  prm < ft_sim->nodeParms+ft_sim->numNodeParms; prm++) {
120  if (strcmp(prm->keyword,"ic") == 0) {
121  which = prm->id;
122  break;
123  }
124  }
125  if (which == -1) {
126  LITERR("IC unknown to simulator.")
127  return (0);
128  }
129  for (;;) { /* loop until we run out of data */
130  INPgetTok(&line,&name,1);
131  /* check to see if in the form V(xxx) and grab the xxx */
132  if (*name == 0) break; /* end of line */
133  length = strlen(name);
134  if ((*name == 'V' || *(name) == 'v') && (length == 1)) {
135  /* looks like V - must be V(xx) - get xx now*/
136  INPgetTok(&line,&name,1);
137  INPtermInsert(ckt,&name,tab,&node);
138  ptemp.rValue = INPevaluate(&line,&error,1);
139  IFC(setNodeParm,(ckt,node,which,&ptemp,(IFvalue*)NULL))
140  continue;
141  }
142  LITERR(".IC syntax error.")
143  break;
144  }
145  return (0);
146  }
147 
148  if (strcmp(token,".op") == 0) {
149  /* .op */
150  txfree(token);
151  which = get_anal("DCOP");
152  if (which == -1) {
153  LITERR("DC operating point analysis unsupported.")
154  return (0);
155  }
156  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
157  return (0);
158  }
159 
160  if (strcmp(token,".tran") == 0) {
161  /* .tran Tstep Tstop <Tstart <Tmax> > <UIC> */
162  txfree(token);
163  which = get_anal("TRAN");
164  if (which == -1) {
165  LITERR("Transient analysis unsupported.")
166  return (0);
167  }
168  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
169  return (0);
170  }
171 
172  if (strcmp(token,".dc") == 0) {
173  /* .dc SRC1NAME Vstart1 Vstop1 Vinc1 [SRC2NAME Vstart2 */
174  /* Vstop2 Vinc2 */
175  txfree(token);
176  which = get_anal("DCTransfer");
177  if (which == -1) {
178  LITERR("DC transfer curve analysis unsupported.")
179  return (0);
180  }
181  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
182  return (0);
183  }
184 
185  if (strcmp(token,".tf") == 0) {
186  /* .tf v( node1, node2 ) src */
187  /* .tf vsrc2 src */
188  txfree(token);
189  which = get_anal("TF");
190  if (which == -1) {
191  LITERR("DC Transfer function analysis unsupported.")
192  return (0);
193  }
194  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
195  return (0);
196  }
197 
198  if (strcmp(token,".ac") == 0) {
199  /* .ac {DEC OCT LIN} NP FSTART FSTOP */
200  txfree(token);
201  which = get_anal("AC");
202  if (which == -1) {
203  LITERR("AC small signal analysis unsupported.")
204  return (0);
205  }
206  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
207  return (0);
208  }
209 
210  if (strcmp(token,".pz") == 0) {
211  /* .pz nodeI nodeG nodeJ nodeK {V I} {POL ZER PZ} */
212  txfree(token);
213  which = get_anal("PZ");
214  if (which == -1) {
215  LITERR("Pole-zero analysis unsupported.")
216  return (0);
217  }
218  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
219  return (0);
220  }
221 
222  if (strcmp(token,".disto") == 0) {
223  txfree(token);
224  /* .disto {DEC OCT LIN} NP FSTART FSTOP <F2OVERF1> */
225  which = get_anal("DISTO");
226  if (which == -1) {
227  LITERR("Small signal distortion analysis unsupported.")
228  return (0);
229  }
230  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
231  return (0);
232  }
233 
234  if (strcmp(token,".noise") == 0) {
235  /* .noise V(OUTPUT) SRC {DEC OCT LIN} NP FSTART FSTOP <PTSPRSUM> */
236  txfree(token);
237  which = get_anal("NOISE");
238  if (which == -1) {
239  LITERR("Noise analysis unsupported.");
240  return (0);
241  }
242  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
243  return (0);
244  }
245 
246  if (strcmp(token, ".sens") == 0) {
247  /* Format is:
248  * .sens <output>
249  * + [ac [dec|lin|oct] <pts> <low freq> <high freq> | dc ]
250  */
251  txfree(token);
252  which = get_anal("SENS");
253  if (which == -1) {
254  LITERR("Sensitivity unsupported.")
255  return (0);
256  }
257  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
258  return(0);
259  }
260 
261  if ((strcmp(token,".options") == 0) ||
262  (strcmp(token,".option" ) == 0) ||
263  (strcmp(token,".opt" ) == 0)) {
264  /* .option - specify program options */
265  txfree(token);
266  which = get_anal("options");
267  if (which == -1) {
268  LITERR("Analysis options table not found.")
269  return (0);
270  }
271  (*(analInfo[which]->parse))(ckt,tab,which,current,&line,task,gnode);
272  return (0);
273  }
274 
275  if ((strcmp(token,".subckt") == 0) ||
276  (strcmp(token,".ends" ) == 0)) {
277  /* not yet implemented - warn & ignore */
278  LITERR("Subcircuits not yet implemented - ignored.")
279  txfree(token);
280  return (0);
281  }
282 
283  if (strcmp(token,".end") == 0) {
284  /* .end - end of input */
285  /* not allowed to pay attention to additional input - return */
286  txfree(token);
287  return (1);
288  /*NOTREACHED*/
289  }
290 
291  if (strcmp(token,".table") == 0) {
292  txfree(token);
293  current->error = INPerrCat(current->error,INPtablCheck(line,ckt));
294  return 0;
295  }
296 
297  LITERR("Unimplemented control card.")
298  txfree(token);
299  return (0);
300 }
IFsimulator * ft_sim
Definition: main.c:111
char * line
Definition: inpdefs.h:64
int INPtermInsert()
int numNodeParms
Definition: ifsim.h:466
if(TDesc==NULL)
Definition: cd.c:1326
char * INPtablCheck()
static int get_anal()
double INPevaluate()
#define tab(num)
Definition: front.c:1365
double rValue
Definition: ifsim.h:233
#define LITERR(text)
Definition: inpmacs.h:35
SPICEanalysis * analInfo[]
Definition: sconfig.c:57
IFparm * nodeParms
Definition: ifsim.h:467
Definition: fteinp.h:14
int id
Definition: ifsim.h:56
static struct pnode * parse()
Definition: parse.c:479
void txfree()
#define NULL
Definition: spdefs.h:121
static IFparm nodeParms[]
Definition: sconfig.c:172
#define IFC(func, args)
Definition: inpmacs.h:19
Definition: fteparse.h:28
Definition: ifsim.h:54
return(True)
char * keyword
Definition: ifsim.h:55
char GENERIC
Definition: ifsim.h:27
char * INPerrCat()
int INPgetTok()