source: vis_dev/vis-2.3/src/hrc/hrc.h @ 104

Last change on this file since 104 was 14, checked in by cecile, 13 years ago

vis2.3

File size: 19.9 KB
Line 
1/**CHeaderFile*****************************************************************
2
3  FileName    [hrc.h]
4
5  PackageName [hrc]
6
7  Synopsis    [Hierarchical representation of a design.]
8
9  Description [The concept of a hierarchy is directly related to the
10  constructs in a blifmv file. It is built around three important data
11  structures viz. Hrc_Model_t, Hrc_Subckt_t and Hrc_Node_t. These will be
12  referred to as model, subckt and node.<p>
13
14  A model corresponds directly to a model definition in a blifmv file. It can
15  be viewed as a black box with some I/O pins. A model could call another
16  model as a module within itself using names for the I/O pins which are, in
17  general, different from those actually used inside the model that is
18  called. The correspondence between the two sets of names is stored in a
19  subckt. A call to a model will henceforth be referred to as an instantiation
20  of the model.<p>
21               
22  Since a given model could be called by many other models, it is necessary to
23  distinguish between its different instantiations. An instantiation is
24  represented by a node.  A hierarchy is a tree of nodes. The root node of the
25  tree corresponds to the single instantiation of the root model in a blifmv
26  file. An instantiation of a model results in the instantiation of all models
27  recursively called by it. Thus, the instantiation of root model results in a
28  tree structure being formed.<p>
29               
30  There is also a structure called a hierarchy manager which contains a list
31  of all models and pointers to the root node and the current node. The
32  current node represents the current position in the hierarchy. The designer
33  can, if he wishes, make changes in this node only, or modify the whole
34  sub-tree below it.]
35
36  SeeAlso     [hrcInt.h]
37
38  Author      [Yuji Kukimoto, Shaz Qadeer]
39
40  Copyright   [Copyright (c) 1994-1996 The Regents of the Univ. of California.
41  All rights reserved.
42
43  Permission is hereby granted, without written agreement and without license
44  or royalty fees, to use, copy, modify, and distribute this software and its
45  documentation for any purpose, provided that the above copyright notice and
46  the following two paragraphs appear in all copies of this software.
47
48  IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
49  DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
50  OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
51  CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52
53  THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
54  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
55  FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN
56  "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE
57  MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.]
58
59  Revision    [$Id: hrc.h,v 1.5 2005/04/16 04:23:47 fabio Exp $]
60
61******************************************************************************/
62
63#ifndef _HRC
64#define _HRC
65
66/*---------------------------------------------------------------------------*/
67/* Constant declarations                                                     */
68/*---------------------------------------------------------------------------*/
69
70
71/*---------------------------------------------------------------------------*/
72/* Type declarations                                                         */
73/*---------------------------------------------------------------------------*/
74
75typedef struct HrcModelStruct Hrc_Model_t;
76typedef struct HrcManagerStruct Hrc_Manager_t;
77typedef struct HrcNodeStruct Hrc_Node_t;
78typedef struct HrcSubcktStruct Hrc_Subckt_t;
79typedef struct HrcLatchStruct Hrc_Latch_t;
80typedef void (*Hrc_ApplInfoFreeFn) (void *);
81typedef void (*Hrc_ApplInfoChangeFn) (Hrc_Node_t *, Hrc_Node_t *, void **);
82
83
84/*---------------------------------------------------------------------------*/
85/* Stucture declarations                                                     */
86/*---------------------------------------------------------------------------*/
87
88
89/*---------------------------------------------------------------------------*/
90/* Variable declarations                                                     */
91/*---------------------------------------------------------------------------*/
92
93
94/*---------------------------------------------------------------------------*/
95/* Macro declarations                                                        */
96/*---------------------------------------------------------------------------*/
97
98/**Macro***********************************************************************
99
100  Synopsis     [Iterates over the models in the hierarchy manager.]
101
102  Description  [This macro iterates over the models in the hierarchy manager.
103                It is an error to modify the models while iterating over them.]
104
105  SideEffects  []
106
107  SeeAlso      []
108
109******************************************************************************/
110#define Hrc_ManagerForEachModel(                                    \
111  /* Hrc_Manager_t * */ manager   /* manager to iterate models */,  \
112  /* st_generator * */  gen       /* local variable for iterator */,\
113  /* char * */          modelName /* name of model */,              \
114  /* Hrc_Model_t * */   model     /* model * */                     \
115)                                                                   \
116  st_foreach_item(Hrc_ManagerReadModelTable(manager), gen, &(modelName), &(model))
117   
118/**Macro***********************************************************************
119
120  Synopsis     [Iterates over the formal inputs of a node.]
121
122  Description  [This macro iterates over the formal inputs of a node. It is an
123                error to modify the formal inputs while iterating over them.]
124
125  SideEffects  [This macro instantiates macros from the array package.  Hence
126                it is advisable not to nest this macro within array macros.]
127
128  SeeAlso      [Hrc_NodeForEachFormalOutput()]
129
130******************************************************************************/
131#define Hrc_NodeForEachFormalInput(                             \
132  /* Hrc_Node_t * */     node /* node to iterate inputs */,     \
133  /* int */              i    /* local variable for iterator */,\
134  /* Var_Variable_t * */ var  /* input variable of node */      \
135)                                                               \
136  arrayForEachItem(Var_Variable_t *, Hrc_NodeReadFormalInputs(node), i, var)
137
138/**Macro***********************************************************************
139
140  Synopsis     [Iterates over the formal outputs of a node.]
141
142  Description  [This macro iterates over the formal outputs of a node. It is an
143                error to modify the formal outputs while iterating over them.]
144
145  SideEffects  [This macro instantiates macros from the array package.  Hence
146                it is advisable not to nest this macro within array macros.]
147
148  SeeAlso      [Hrc_NodeForEachFormalInput()]
149
150******************************************************************************/
151#define Hrc_NodeForEachFormalOutput(                            \
152  /* Hrc_Node_t * */     node /* node to iterate outputs */,    \
153  /* int */              i    /* local variable for iterator */,\
154  /* Var_Variable_t * */ var  /* output variable of node */     \
155)                                                               \
156  arrayForEachItem(Var_Variable_t *, Hrc_NodeReadFormalOutputs(node), i, var)
157
158/**Macro***********************************************************************
159
160  Synopsis     [Iterates over the actual inputs of a model.]
161
162  Description  [This macro iterates over the actual inputs of a node. It is an
163                error to modify the actual inputs while iterating over them.]
164
165  SideEffects  [This macro instantiates macros from the array package.  Hence
166                it is advisable not to nest this macro within array macros.]
167
168  SeeAlso      [Hrc_NodeForEachActualOutput()]
169
170******************************************************************************/
171#define Hrc_NodeForEachActualInput(                               \
172  /* Hrc_Node_t * */     node /* node to iterate actual inputs */,\
173  /* int */              i    /* local variable for iterator */,  \
174  /* Var_Variable_t * */ var  /* actual input variable of node */ \
175)                                                                 \
176  arrayForEachItem(Var_Variable_t *, Hrc_NodeReadActualInputs(node), i, var)
177
178/**Macro***********************************************************************
179
180  Synopsis     [Iterates over the actual outputs of a node.]
181
182  Description  [This macro iterates over the actual outputs of a node. It is an
183                error to modify the actual outputs while iterating over them.]
184
185  SideEffects  [This macro instantiates macros from the array package.  Hence
186                it is advisable not to nest this macro within array macros.]
187
188  SeeAlso      [Hrc_NodeForEachActualInput()]
189
190******************************************************************************/
191#define Hrc_NodeForEachActualOutput(                               \
192  /* Hrc_Node_t * */     node /* node to iterate actual outputs */,\
193  /* int */              i    /* local variable for iterator */,   \
194  /* Var_Variable_t * */ var  /* actual output variable of node */ \
195)                                                                  \
196  arrayForEachItem(Var_Variable_t *, Hrc_NodeReadActualOutputs(node), i, var)
197
198/**Macro***********************************************************************
199
200  Synopsis     [Iterates over the name tables of a node.]
201
202  Description  [This macro iterates over the name tables of a node. It is an
203                error to modify the name tables while iterating over them.]
204
205  SideEffects  [This macro instantiates macros from the array package.  Hence
206                it is advisable not to nest this macro within array macros.]
207
208  SeeAlso      [Hrc_NodeForEachLatch()]
209
210******************************************************************************/
211#define Hrc_NodeForEachNameTable(                             \
212  /* Hrc_Node_t * */  node  /* node to iterate tables */,     \
213  /* int */           i     /* local variable for iterator */,\
214  /* Tbl_Table_t * */ table /* table of node */               \
215)                                                             \
216  arrayForEachItem(Tbl_Table_t *, Hrc_NodeReadNameTables(node), i, table)
217
218/**Macro***********************************************************************
219
220  Synopsis     [Iterates over the subckts of a model.]
221
222  Description  [This macro iterates over the sub-circuits of a node. It is an
223                error to modify the sub-circuits while iterating over them.]
224
225  SideEffects  []
226
227  SeeAlso      []
228
229******************************************************************************/
230#define Hrc_ModelForEachSubckt(                                  \
231  /* Hrc_Model_t */    model  /* model to iterate subcircuits */,\
232  /* st_generator * */ gen    /* local variable for iterator */, \
233  /* char * */         name   /* instance name of subcircuit */, \
234  /* Hrc_Subckt_t * */ subckt /* subcircuit */                   \
235)                                                                \
236  st_foreach_item(Hrc_ModelReadSubcktTable(model), gen, &(name), &(subckt))
237   
238/**Macro***********************************************************************
239
240  Synopsis     [Iterates over the children of a node.]
241
242  Description  [This macro iterates over the children of a node. It is an
243                error to modify the children while iterating over them.]
244
245  SideEffects  []
246
247  SeeAlso      []
248
249******************************************************************************/
250#define Hrc_NodeForEachChild(                                        \
251  /* Hrc_Node_t * */   node      /* node to iterate child nodes */, \
252  /* st_generator * */ gen       /* local variable for iterator */, \
253  /* char * */         childName /* name of child */,               \
254  /* Hrc_Node_t * */   child     /* child */                        \
255)                                                                    \
256  st_foreach_item(Hrc_NodeReadChildTable(node), gen, &(childName), &(child))
257   
258
259/**Macro***********************************************************************
260
261  Synopsis     [Iterates over the latches of a node.]
262
263  Description  [This macro iterates over the latches of a node. It is an
264                error to modify the latches while iterating over them.]
265
266  SideEffects  []
267
268  SeeAlso      [Hrc_NodeForEachNameTable()]
269
270******************************************************************************/
271#define Hrc_NodeForEachLatch(                                      \
272  /* Hrc_Node_t * */   node      /* node to iterate latches */,    \
273  /* st_generator * */ gen       /* local variable for iterator */,\
274  /* char * */         latchName /* name of latch */,              \
275  /* Hrc_Latch_t * */  latch     /* latch */                       \
276)                                                                  \
277  st_foreach_item(Hrc_NodeReadLatchTable(node), gen, &(latchName), &(latch))
278   
279/**Macro***********************************************************************
280
281  Synopsis     [Iterates over the formal variables of a node.]
282
283  Description  [This macro iterates over the formal variables of a node. It
284                is an error to modify the formal variables while iterating
285                over them.]
286
287  SideEffects  []
288
289  SeeAlso      [Hrc_NodeForEachFormalInput(), Hrc_NodeForEachFormalOuput()]
290
291******************************************************************************/
292#define Hrc_NodeForEachVariable(                                   \
293  /* Hrc_Node_t * */     node    /* node to iterate variables */,  \
294  /* st_generator * */   gen     /* local variable for iterator */,\
295  /* char * */           varName /* name of variable */,           \
296  /* Var_Variable_t * */ var     /* variable */                    \
297)                                                                  \
298  st_foreach_item(Hrc_NodeReadVariableTable(node), gen, &(varName), &var)
299   
300#include "tbl.h"
301
302/**AutomaticStart*************************************************************/
303
304/*---------------------------------------------------------------------------*/
305/* Function prototypes                                                       */
306/*---------------------------------------------------------------------------*/
307
308EXTERN void Hrc_Init(void);
309EXTERN void Hrc_End(void);
310EXTERN Hrc_Node_t * Hrc_ModelCreateHierarchy(Hrc_Manager_t *hmgr, Hrc_Model_t *model, char *instanceName);
311EXTERN boolean Hrc_NodeAddApplInfo(Hrc_Node_t *node, char * key, Hrc_ApplInfoFreeFn freeFn, Hrc_ApplInfoChangeFn changeFn, void * data);
312EXTERN void * Hrc_NodeReadApplInfo(Hrc_Node_t *node, char * key);
313EXTERN boolean Hrc_NodeFreeApplInfo(Hrc_Node_t *node, char * key);
314EXTERN void Hrc_ModelWriteBlifMv(FILE *fp, Hrc_Model_t *model, boolean isRootModel, char *rootInstanceName);
315EXTERN Hrc_Node_t * Hrc_ManagerReadRootNode(Hrc_Manager_t *manager);
316EXTERN Hrc_Node_t * Hrc_ManagerReadCurrentNode(Hrc_Manager_t *manager);
317EXTERN st_table * Hrc_ManagerReadModelTable(Hrc_Manager_t *manager);
318EXTERN Hrc_Model_t * Hrc_ManagerFindModelByName(Hrc_Manager_t *manager, char *modelName);
319EXTERN Hrc_Node_t * Hrc_ModelReadMasterNode(Hrc_Model_t *model);
320EXTERN char * Hrc_ModelReadName(Hrc_Model_t *model);
321EXTERN st_table * Hrc_ModelReadSubcktTable(Hrc_Model_t *model);
322EXTERN Hrc_Model_t * Hrc_SubcktReadModel(Hrc_Subckt_t *subckt);
323EXTERN char * Hrc_SubcktReadInstanceName(Hrc_Subckt_t *subckt);
324EXTERN array_t * Hrc_SubcktReadActualInputVars(Hrc_Subckt_t *subckt);
325EXTERN array_t * Hrc_SubcktReadActualOutputVars(Hrc_Subckt_t *subckt);
326EXTERN Hrc_Manager_t * Hrc_NodeReadManager(Hrc_Node_t *node);
327EXTERN char * Hrc_NodeReadModelName(Hrc_Node_t *node);
328EXTERN char * Hrc_NodeReadInstanceName(Hrc_Node_t *node);
329EXTERN Hrc_Node_t * Hrc_NodeReadParentNode(Hrc_Node_t *node);
330EXTERN int Hrc_NodeReadNumFormalInputs(Hrc_Node_t *node);
331EXTERN int Hrc_NodeReadNumFormalOutputs(Hrc_Node_t *node);
332EXTERN int Hrc_NodeReadNumVariables(Hrc_Node_t *node);
333EXTERN int Hrc_NodeReadNumTables(Hrc_Node_t *node);
334EXTERN int Hrc_NodeReadNumLatches(Hrc_Node_t *node);
335EXTERN int Hrc_NodeReadNumChildren(Hrc_Node_t *node);
336EXTERN array_t * Hrc_NodeReadFormalInputs(Hrc_Node_t *node);
337EXTERN array_t * Hrc_NodeReadFormalOutputs(Hrc_Node_t *node);
338EXTERN array_t * Hrc_NodeReadActualInputs(Hrc_Node_t *node);
339EXTERN array_t * Hrc_NodeReadActualOutputs(Hrc_Node_t *node);
340EXTERN array_t * Hrc_NodeReadNameTables(Hrc_Node_t *node);
341EXTERN st_table * Hrc_NodeReadChildTable(Hrc_Node_t *node);
342EXTERN st_table * Hrc_NodeReadLatchTable(Hrc_Node_t *node);
343EXTERN st_table * Hrc_NodeReadVariableTable(Hrc_Node_t *node);
344EXTERN void * Hrc_NodeReadUndef(Hrc_Node_t *node);
345EXTERN Hrc_Latch_t * Hrc_NodeFindLatchByName(Hrc_Node_t *node, char *latchName);
346EXTERN Var_Variable_t * Hrc_NodeFindVariableByName(Hrc_Node_t *node, char *varName);
347EXTERN Hrc_Node_t * Hrc_NodeFindChildByName(Hrc_Node_t *node, char *instanceName);
348EXTERN Var_Variable_t * Hrc_LatchReadInput(Hrc_Latch_t *latch);
349EXTERN Var_Variable_t * Hrc_LatchReadOutput(Hrc_Latch_t *latch);
350EXTERN Tbl_Table_t * Hrc_LatchReadResetTable(Hrc_Latch_t *latch);
351EXTERN void * Hrc_LatchReadUndef(Hrc_Latch_t *latch);
352EXTERN void Hrc_ManagerSetRootNode(Hrc_Manager_t *manager, Hrc_Node_t *node);
353EXTERN void Hrc_ManagerSetCurrentNode(Hrc_Manager_t *manager, Hrc_Node_t *currentNode);
354EXTERN boolean Hrc_NodeAddFormalInput(Hrc_Node_t *node, Var_Variable_t *var);
355EXTERN boolean Hrc_NodeAddFormalOutput(Hrc_Node_t *node, Var_Variable_t *var);
356EXTERN void Hrc_NodeAddNameTable(Hrc_Node_t *node, Tbl_Table_t *nameTable);
357EXTERN void Hrc_NodeSetUndef(Hrc_Node_t *node, void *value);
358EXTERN boolean Hrc_LatchSetResetTable(Hrc_Latch_t *latch, Tbl_Table_t *table);
359EXTERN void Hrc_LatchSetUndef(Hrc_Latch_t *latch, void *value);
360EXTERN Hrc_Manager_t * Hrc_ManagerAlloc(void);
361EXTERN Hrc_Model_t * Hrc_ModelAlloc(Hrc_Manager_t *manager, char *modelName);
362EXTERN Hrc_Node_t * Hrc_NodeAlloc(Hrc_Manager_t *manager, char *modelName, char *instanceName, Hrc_Node_t *parentNode);
363EXTERN Hrc_Node_t * Hrc_NodeDup(Hrc_Node_t *node, char *instanceName);
364EXTERN Hrc_Latch_t * Hrc_LatchCreate(Hrc_Model_t *model, Var_Variable_t *latchInput, Var_Variable_t *latchOutput);
365EXTERN void Hrc_ManagerFree(Hrc_Manager_t *manager);
366EXTERN boolean Hrc_ModelDelete(Hrc_Manager_t *manager, char *modelName);
367EXTERN Hrc_Node_t * Hrc_ManagerFindNodeByPathName(Hrc_Manager_t *manager, char *path, boolean pathFlag);
368EXTERN Var_Variable_t * Hrc_VariableFindActualFromFormal(Hrc_Node_t *node, Var_Variable_t *formalVar, Hrc_Node_t *referenceNode);
369EXTERN array_t * Hrc_ManagerObtainComponentModels(Hrc_Manager_t *manager);
370EXTERN char * Hrc_NodeFindHierarchicalName(Hrc_Node_t *node, boolean pathFlag);
371EXTERN boolean Hrc_TreeReplace(Hrc_Node_t *oldNode, Hrc_Node_t *newNode);
372EXTERN boolean Hrc_NodeTestIsInTree(Hrc_Node_t *node1, Hrc_Node_t *node2);
373EXTERN boolean Hrc_NodeTestIsUninterpreted(Hrc_Node_t *node);
374EXTERN boolean Hrc_ModelTestIsUninterpreted(Hrc_Model_t* model);
375EXTERN boolean Hrc_NodeTestRecursivelyIsUninterpreted(Hrc_Node_t* parent);
376EXTERN boolean Hrc_NodeTestIsUninterpretedNodeInHierarchy(Hrc_Manager_t* hmgr);
377EXTERN boolean Hrc_NodeCheckVariableConsistency(Hrc_Node_t *node);
378EXTERN boolean Hrc_ModelAddSubckt(Hrc_Model_t *callerModel, Hrc_Model_t *calleeModel, char *instanceName, array_t *actualInputVars, array_t *actualOutputVars);
379EXTERN void Hrc_ModelAddNameTable(Hrc_Model_t *model, Tbl_Table_t *table);
380EXTERN boolean Hrc_NodeAddChild(Hrc_Node_t *parent, Hrc_Node_t *child, array_t *actualInputs, array_t *actualOutputs);
381EXTERN boolean Hrc_NodeAddLatch(Hrc_Node_t *node, Hrc_Latch_t *latch);
382EXTERN boolean Hrc_NodeAddVariable(Hrc_Node_t *node, Var_Variable_t *var);
383EXTERN boolean Hrc_NodeDeleteVariable(Hrc_Node_t *node, Var_Variable_t *var);
384EXTERN boolean Hrc_NodeDeleteLatch(Hrc_Node_t *node, Hrc_Latch_t *latch);
385EXTERN void Hrc_ModelWriteSmv(FILE *fp, Hrc_Model_t *model, boolean isRootModel, char *rootInstanceName);
386
387/**AutomaticEnd***************************************************************/
388
389#endif /* _HRC */
Note: See TracBrowser for help on using the repository browser.