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

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 15 of file genmosp.c.

21 {
22  /* mosfet parser */
23 
24  /* Mname <node> <node> <node> <node> <model> [L=<val>]
25  * [W=<val>] [AD=<val>] [AS=<val>] [PD=<val>]
26  * [PS=<val>] [NRD=<val>] [NRS=<val>] [OFF]
27  * [IC=<val>,<val>,<val>]
28  */
29 
30  INPtables *tab = (INPtables*)tabp;
31  card *current = (card*)currentp;
32 
33  char *line; /* the part of the current line left to parse */
34  char *name; /* the device's name */
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  GENERIC *fast; /* pointer to the actual instance */
45  int waslead; /* flag to indicate that unlabeled number was found */
46  double leadval; /* actual value of unlabeled number */
47  char *model; /* the name of the model */
48  INPmodel *thismodel; /* pointer to model description for user's model */
49  GENERIC *mdfast; /* pointer to the actual model */
50  IFuid uid; /* uid for default model */
51  int ntype, i;
52  IFkeys *keys;
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,&nname4,1);
68  INPtermInsert(ckt,&nname4,tab,&node4);
69 
70  INPgetTok(&line,&model,1);
71  INPinsert(&model,tab);
72 
73  thismodel = (INPmodel *)NULL;
74  current->error = INPgetMod(ckt,model,&thismodel,tab);
75  if (thismodel != NULL) {
76  ntype = thismodel->INPmodType;
77  if (ntype != type) {
78 
79  /* hack for shared key for MOS and BSIM */
80 
81  keys = ft_sim->devices[ntype]->keys;
82  for (i = 0; i < *ft_sim->devices[ntype]->numKeys; i++) {
83  if (keys[i].key == 'm')
84  break;
85  }
86  if (i == *ft_sim->devices[ntype]->numKeys) {
88  return;
89  }
90  type = ntype;
91  }
92  mdfast = (thismodel->INPmodfast);
93  }
94  else {
95  if (!tab->defMmod) {
96  /* create default M model */
97  IFnewUid(ckt,&uid,(IFuid)NULL,"M",UID_MODEL,(GENERIC**)NULL);
98  IFC(newModel,(ckt,type,&(tab->defMmod),uid))
99  }
100  mdfast = tab->defMmod;
101  }
102  IFC(newInstance,(ckt,mdfast,&fast,name))
103  IFC(bindNode,(ckt,fast,1,node1))
104  IFC(bindNode,(ckt,fast,2,node2))
105  IFC(bindNode,(ckt,fast,3,node3))
106  IFC(bindNode,(ckt,fast,4,node4))
107  PARSECALL((&line,ckt,type,fast,&leadval,&waslead,tab))
108  if (waslead) {
109  LITERR("No unlabeled parameter permitted on mosfet.")
110  }
111 }
GENERIC * defMmod
Definition: inpdefs.h:47
IFkeys * keys
Definition: ifsim.h:297
IFsimulator * ft_sim
Definition: main.c:111
char * line
Definition: inpdefs.h:64
int INPtermInsert()
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 LITERR(text)
Definition: inpmacs.h:35
int INPmodType
Definition: inpdefs.h:73
int INPinsert()
Definition: fteinp.h:14
GENERIC * IFuid
Definition: ifsim.h:72
IFdevice ** devices
Definition: ifsim.h:461
#define NULL
Definition: spdefs.h:121
Definition: types.c:18
#define IFC(func, args)
Definition: inpmacs.h:19
Definition: ifsim.h:267
char * error
Definition: inpdefs.h:65
#define PARSECALL(args)
Definition: inpmacs.h:42
static char model[32]
Definition: subckt.c:76
return(True)
int * numKeys
Definition: ifsim.h:296
char * INPdevErr()
char GENERIC
Definition: ifsim.h:27
char * INPgetMod()
int INPgetTok()