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

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 14 of file bjtparse.c.

20 {
21  /* bipolar transistor parser */
22 
23  /* Qname <node> <node> <node> [<node>] <model> [<val>] [OFF]
24  * [IC=<val>,<val>]
25  */
26 
27  INPtables *tab = (INPtables*)tabp;
28  card *current = (card*)currentp;
29 
30  char *line; /* the part of the current line left to parse */
31  char *name; /* the device's name */
32  char *nname1; /* the first node's name */
33  char *nname2; /* the second node's name */
34  char *nname3; /* the third node's name */
35  char *nname4; /* the fourth node's name */
36  GENERIC *node1; /* the first node's node pointer */
37  GENERIC *node2; /* the second node's node pointer */
38  GENERIC *node3; /* the third node's node pointer */
39  GENERIC *node4; /* the fourth node's node pointer */
40  int error; /* error code temporary */
41  GENERIC *fast; /* pointer to the actual instance */
42  IFvalue ptemp; /* a value structure to package resistance into */
43  int waslead; /* flag to indicate that unlabeled number was found */
44  double leadval; /* actual value of unlabeled number */
45  char *model; /* the name of the model */
46  INPmodel *thismodel; /* pointer to model description for user's model */
47  GENERIC *mdfast; /* pointer to the actual model */
48  IFuid uid; /* uid of default model */
49 
50  char *groundname = "0";
51  char *gname;
52  GENERIC *gnode;
53 
54  line = current->line;
55  INPgetTok(&line,&name,1);
56  INPinsert(&name,tab);
57 
58  INPgetTok(&line,&nname1,1);
59  INPtermInsert(ckt,&nname1,tab,&node1);
60 
61  INPgetTok(&line,&nname2,1);
62  INPtermInsert(ckt,&nname2,tab,&node2);
63 
64  INPgetTok(&line,&nname3,1);
65  INPtermInsert(ckt,&nname3,tab,&node3);
66 
67  INPgetTok(&line,&model,1);
68  if (!*model || INPlookMod(model) ) {
69  /* only 3 nodes */
70  INPgetTok(&groundname,&gname,1);
71  INPgndInsert(ckt,&gname,tab,&node4);
72  }
73  else {
74  nname4 = model;
75  INPtermInsert(ckt,&nname4,tab,&node4);
76  INPgetTok(&line,&model,1);
77  }
78  INPinsert(&model,tab);
79 
80  current->error = INPgetMod(ckt,model,&thismodel,tab);
81  if (thismodel != NULL) {
82  if (type != thismodel->INPmodType) {
84  return;
85  }
86  mdfast = (thismodel->INPmodfast);
87  }
88  else {
89  if (!tab->defQmod) {
90  /* create default Q model */
91  IFnewUid(ckt,&uid,(IFuid)NULL,"Q",UID_MODEL,(GENERIC**)NULL);
92  IFC(newModel,(ckt,type,&(tab->defQmod),uid))
93  }
94  mdfast = tab->defQmod;
95  }
96  IFC(newInstance,(ckt,mdfast,&fast,name))
97  IFC(bindNode,(ckt,fast,1,node1))
98  IFC(bindNode,(ckt,fast,2,node2))
99  IFC(bindNode,(ckt,fast,3,node3))
100  IFC(bindNode,(ckt,fast,4,node4))
101  PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab))
102  if (waslead) {
103  ptemp.rValue = leadval;
104  GCA(INPpName,("area",&ptemp,ckt,type,fast))
105  }
106 }
int INPpName()
char * line
Definition: inpdefs.h:64
int INPtermInsert()
int IFnewUid()
int INPgndInsert()
if(TDesc==NULL)
Definition: cd.c:1326
Definition: inpdefs.h:62
#define UID_MODEL
Definition: ifsim.h:83
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()
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
int INPlookMod()
char * error
Definition: inpdefs.h:65
#define PARSECALL(args)
Definition: inpmacs.h:42
static char model[32]
Definition: subckt.c:76
GENERIC * defQmod
Definition: inpdefs.h:51
return(True)
char * INPdevErr()
char GENERIC
Definition: ifsim.h:27
char * INPgetMod()
int INPgetTok()