1 /************************************************************
3 ** COPYRIGHT (C) 2004 GANNON UNIVERSITY
6 ** This software is distributed on an as-is basis
7 ** with no warranty implied or intended. No author
8 ** or distributor takes responsibility to anyone
9 ** regarding its use of or suitability.
11 ** The software may be distributed and modified
12 ** freely for academic and other non-commercial
13 ** use but may NOT be utilized or included in whole
14 ** or part within any commercial product.
16 ** This copyright notice must remain on all copies
17 ** and modified versions of this software.
19 ************************************************************/
22 /* file parse_support.c */
23 /* ------------------------------------------------------------------------
24 * Routines for integrating ASG into a language parser, such as the
25 * hpice parser in XCircuit 3.2.7+.
26 * ------------------------------------------------------------------------
34 /*---------------------------------------------------------------
35 * Global Variable Definitions
36 *---------------------------------------------------------------
39 module
*curobj_module
;
41 /***********************************************************************************
42 Add2TermModule - This method is used to add a new module found in the parse tree of a language. E.g., this can be used in HSPICE
43 parser to add a module.
46 **************************************************************************************/
48 void Add2TermModule( name
, type
, inNode
, outNode
)
49 char* name
; // Parser-supplied module name (e.g., CAP32)
50 char* type
; // Parser-supplied identification type (e.g., CAPACITOR)
51 char* inNode
; // Net name for input net
52 char* outNode
; // Net name for output net
56 //Create a new Module( Capacitor or Resistor or Inductor or Buffer, Inverter gate etc)
57 curobj_module
= newobject(name
, type
);
60 pNet
= get_net(inNode
);
62 //If Input Node does not exist in the global database
70 pNet
= get_net(outNode
);
72 //If output Node does not exist in the global database
77 addout(outNode
, 0, 1);
80 /***********************************************************************************
81 Add3TermModule - This method is used to add a new module. This can be used in HSPICE
82 parser to add a module.
85 **************************************************************************************/
87 void Add3TermModule( name
, type
, inNode
, outNode
, inoutNode
)
88 char* name
; // Parser-supplied module name (e.g., CAP32)
89 char* type
; // Parser-supplied identification type (e.g., CAPACITOR)
90 char* inNode
; // Net name for input (left) net
91 char* outNode
; // Net name for output (right) net
92 char* inoutNode
; // Net name for inout (top) net
96 //Create a new Module( Capacitor or Resistor or Inductor or Buffer, Inverter gate etc)
97 curobj_module
= newobject(name
, type
);
100 pNet
= get_net(inNode
);
102 //If Input Node does not exist in the global database
110 pNet
= get_net(outNode
);
112 //If output Node does not exist in the global database
117 addout(outNode
, 0, 1);
120 pNet
= get_net(inoutNode
);
122 //If inout Node does not exist in the global database
127 addinout(inoutNode
, 0, 1);
130 /*----------------------------------------------------------------------*/
131 /* AddNTermModule --- */
132 /* Add a module of N terminals to the database */
134 /* name = Parser-supplied module name (e.g., CAP32) */
135 /* type = Parser-supplied identification type (e.g., CAPACITOR) */
136 /* N = Number of nodes, followed by list of node names. */
137 /* followed by pairs of char * types declaring the name of the pin */
138 /* (expected in the xcircuit object) followed by the name of the net. */
139 /*----------------------------------------------------------------------*/
141 void AddNTermModule(char *name
, char *type
, int N
, ...)
150 // Create a new Module (Capacitor, Resistor, Inductor or Buffer, Inverter gate etc)
151 curobj_module
= newobject(name
, type
);
153 // Get the corresponding XCircuit object and get the object dimensions
154 pobj
= NameToObject(type
, NULL
, FALSE
);
156 curobj_module
->x_size
= pobj
->bbox
.width
;
157 curobj_module
->y_size
= pobj
->bbox
.height
;
160 error("AddNTermModule: No such object", type
);
165 for (i
= 0; i
< N
; i
++) {
167 pinName
= va_arg(args
, char *);
168 netName
= va_arg(args
, char *);
169 pNet
= get_net(netName
);
171 // If Input Node does not exist in the global database
175 add_xc_term(type
, pinName
, netName
, i
, N
);
180 /*--------------------------------------------------------------*/
181 /* Handle modules with an abitrary number of terminals in the */
182 /* following way: AddNTermModule() is called with N = 0 to */
183 /* create curobj_module (which is global). Then, for each pin, */
184 /* the routine AddModuleTerm() is called to associate a net */
185 /* with each pin, in turn. */
186 /*--------------------------------------------------------------*/
188 /*--------------------------------------------------------------*/
189 /* For the moment, pins will be named "1", "2", etc. To do: */
190 /* look up the object having a name matching "type". Confirm */
191 /* a match in the number of pins N, and then pick up the pin */
192 /* names from the object itself. Presumably this is done by */
193 /* assuming that the object has an info label "spice:..." and */
194 /* using that. It is the responsibility of the user to ensure */
195 /* that the library used to represent primitives in the spice */
196 /* deck contains the correct number and order of pins. */
197 /*--------------------------------------------------------------*/
199 void AddModuleTerm(char *type
, char *netName
, int portnum
, int allports
)
203 pNet
= get_net(netName
);
205 // If Input Node does not exist in the global database
209 add_xc_term(type
, NULL
, netName
, portnum
, allports
);
212 /*---------------------------------------------------------------
214 *---------------------------------------------------------------