Jspice3
cktbindn.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Thomas L. Quarles
5  1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 /* CKTbindNode
9  * bind a node of the specified device of the given type to its place
10  * in the specified circuit.
11  */
12 
13 #include "spice.h"
14 #include <stdio.h>
15 #include "devdefs.h"
16 #include "sperror.h"
17 #include "util.h"
18 #include "cktext.h"
19 
20 extern SPICEdev *DEVices[];
21 
22 /*ARGSUSED*/
23 int
24 CKTbindNode(ckt,fast,term,node)
25 
26 GENERIC *ckt;
27 GENERIC *fast;
28 int term;
29 GENERIC *node;
30 {
31  int i, mappednode;
32  int type = ((GENinstance *)fast)->GENmodPtr->GENmodType;
33  char key = *(char*)((GENinstance *)fast)->GENname;
34  IFkeys *keys = DEVices[type]->DEVpublic.keys;
35 
36  for (i = 0; i < *DEVices[type]->DEVpublic.numKeys; i++) {
37  if (keys[i].key == key)
38  break;
39  }
40  if (i == *DEVices[type]->DEVpublic.numKeys)
41  return (E_NOTERM);
42 
43  mappednode = ((CKTnode *)node)->number;
44 
45  if (keys[i].numTerms >= term && term > 0) {
46  switch (term) {
47  default:
48  return (E_NOTERM);
49  case 1:
50  ((GENinstance *)fast)->GENnode1 = mappednode;
51  break;
52  case 2:
53  ((GENinstance *)fast)->GENnode2 = mappednode;
54  break;
55  case 3:
56  ((GENinstance *)fast)->GENnode3 = mappednode;
57  break;
58  case 4:
59  ((GENinstance *)fast)->GENnode4 = mappednode;
60  break;
61  case 5:
62  ((GENinstance *)fast)->GENnode5 = mappednode;
63  break;
64  }
65  return (OK);
66  }
67  return (E_NOTERM);
68 }
IFkeys * keys
Definition: ifsim.h:297
IFdevice DEVpublic
Definition: devdefs.h:44
SPICEdev * DEVices[]
Definition: sconfig.c:109
#define OK
Definition: iferrmsg.h:17
Definition: types.c:18
Definition: ifsim.h:267
#define E_NOTERM
Definition: iferrmsg.h:25
int type
Definition: cktdefs.h:56
int * numKeys
Definition: ifsim.h:296
int CKTbindNode(GENERIC *ckt, GENERIC *fast, int term, GENERIC *node)
Definition: cktbindn.c:24
char GENERIC
Definition: ifsim.h:27