Jspice3
capparse.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1987 Thomas L. Quarles
5  1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 #include "spice.h"
9 #include <stdio.h>
10 #include "inpdefs.h"
11 #include "inpmacs.h"
12 
13 void
14 CAPparse(type,ckt,tabp,currentp)
15 
16 int type;
17 GENERIC *ckt;
18 GENERIC *tabp;
19 GENERIC *currentp;
20 {
21  /* capacitor parser */
22 
23  /* Cname <node> <node> [<model>] [<val>] [IC=<val>] */
24 
25  INPtables *tab = (INPtables*)tabp;
26  card *current = (card*)currentp;
27 
28  char *line; /* the part of the current line left to parse */
29  char *name; /* the device's name */
30  char *model; /* the name of the resistor's model */
31  char *nname1; /* the first node's name */
32  char *nname2; /* the second node's name */
33  GENERIC *node1; /* the first node's node pointer */
34  GENERIC *node2; /* the second node's node pointer */
35  double val; /* temp to held resistance */
36  int error; /* error code temporary */
37  INPmodel *thismodel; /* pointer to model structure describing our model */
38  GENERIC *mdfast; /* pointer to the actual model */
39  GENERIC *fast; /* pointer to the actual instance */
40  IFvalue ptemp; /* a value structure to package resistance into */
41  int waslead; /* flag to indicate that unlabeled number was found */
42  double leadval; /* actual value of unlabeled number */
43  IFuid uid; /* uid for default cap model */
44 
45  line = current->line;
46  INPgetTok(&line,&name,1);
47  INPinsert(&name,tab);
48 
49  INPgetTok(&line,&nname1,1);
50  INPtermInsert(ckt,&nname1,tab,&node1);
51 
52  INPgetTok(&line,&nname2,1);
53  INPtermInsert(ckt,&nname2,tab,&node2);
54 
55  val = INPevaluate(&line,&error,1);
56  if (error == 0) { /* Looks like a number */
57  ptemp.rValue = val;
58  if (!tab->defCmod) {
59  IFnewUid(ckt,&uid,(IFuid)NULL,"C",UID_MODEL,(GENERIC**)NULL);
60  IFC(newModel,(ckt,type,&(tab->defCmod),uid))
61  }
62  IFC(newInstance,(ckt,tab->defCmod,&fast,name))
63  GCA(INPpName,("capacitance",&ptemp,ckt,type,fast))
64  }
65  else { /* looks like character strings */
66  INPgetTok(&line,&model,1);
67  INPinsert(&model,tab);
68  thismodel = (INPmodel *)NULL;
69  current->error = INPgetMod(ckt,model,&thismodel,tab);
70  if (thismodel != NULL) {
71  if (type != thismodel->INPmodType) {
73  return;
74  }
75  mdfast = thismodel->INPmodfast;
76  }
77  else {
78  if (!tab->defCmod) {
79  IFnewUid(ckt,&uid,(IFuid)NULL,"C",UID_MODEL,(GENERIC**)NULL);
80  IFC(newModel,(ckt,type,&(tab->defCmod),uid))
81  }
82  mdfast = tab->defCmod;
83  }
84  IFC(newInstance,(ckt,mdfast,&fast,name))
85  }
86  IFC(bindNode,(ckt,fast,1,node1))
87  IFC(bindNode,(ckt,fast,2,node2))
88  PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab))
89  if (waslead) {
90  ptemp.rValue = leadval;
91  GCA(INPpName,("capacitance",&ptemp,ckt,type,fast))
92  }
93 }
int INPpName()
char * line
Definition: inpdefs.h:64
int INPtermInsert()
int IFnewUid()
Definition: inpdefs.h:62
#define UID_MODEL
Definition: ifsim.h:83
double INPevaluate()
Definition: subckt.c:51
double rValue
Definition: ifsim.h:233
#define LITERR(text)
Definition: inpmacs.h:35
int INPmodType
Definition: inpdefs.h:73
int INPinsert()
GENERIC * defCmod
Definition: inpdefs.h:37
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
GENERIC * INPmodfast
Definition: inpdefs.h:77
char * INPdevErr()
void CAPparse(int type, GENERIC *ckt, GENERIC *tabp, GENERIC *currentp)
Definition: capparse.c:14
char GENERIC
Definition: ifsim.h:27
char * INPgetMod()
int INPgetTok()