source: vis_dev/vis-2.3/src/part/partBoundary.c @ 93

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

vis2.3

File size: 6.8 KB
RevLine 
[14]1/**CFile***********************************************************************
2
3  FileName    [partBoundary.c]
4
5  PackageName [part]
6
7  Synopsis [Implements the partition of the network with respect to the
8  nodes that comprise the submodules boundaries.]
9
10  Description [The network is composed of an arbitrary set of nodes, each of
11  them implementing some function. This partitioning method will produce a
12  graph representing the network in which the nodes that constitute submodule
13  boundaries will be preserved in the graph structure.]
14
15  SeeAlso     [partInOut.c partTotal.c]
16
17  Author      [Sunil P Khatri]
18
19  Copyright   [This file was created at the University of California at
20  Berkeley.  The University of California at Berkeley makes no warranty
21  about the suitability of this software for any purpose.  It is
22  presented on an AS IS basis.]
23
24******************************************************************************/
25
26#include "partInt.h"
27
28static char rcsid[] UNUSED = "$Id: partBoundary.c,v 1.5 2002/09/10 05:06:25 fabio Exp $";
29
30/*---------------------------------------------------------------------------*/
31/* Constant declarations                                                     */
32/*---------------------------------------------------------------------------*/
33
34
35/*---------------------------------------------------------------------------*/
36/* Structure declarations                                                    */
37/*---------------------------------------------------------------------------*/
38
39
40/*---------------------------------------------------------------------------*/
41/* Type declarations                                                         */
42/*---------------------------------------------------------------------------*/
43
44
45/*---------------------------------------------------------------------------*/
46/* Variable declarations                                                     */
47/*---------------------------------------------------------------------------*/
48
49
50/*---------------------------------------------------------------------------*/
51/* Macro declarations                                                        */
52/*---------------------------------------------------------------------------*/
53
54
55/**AutomaticStart*************************************************************/
56
57/*---------------------------------------------------------------------------*/
58/* Static function prototypes                                                */
59/*---------------------------------------------------------------------------*/
60
61
62/**AutomaticEnd***************************************************************/
63
64
65/*---------------------------------------------------------------------------*/
66/* Definition of exported functions                                          */
67/*---------------------------------------------------------------------------*/
68
69
70/*---------------------------------------------------------------------------*/
71/* Definition of internal functions                                          */
72/*---------------------------------------------------------------------------*/
73
74/**Function********************************************************************
75
76  Synopsis [Finds names of all partition nodes the boundary partitioning method.]
77
78  SideEffects []
79
80  SeeAlso     []
81
82******************************************************************************/
83void
84partCreateBoundaryNames(
85  Hrc_Node_t    *hnode,
86  st_table      *tableOfFormalNames)
87{
88  st_generator *stGen;
89  char *childName, *nodeName, *inputVarName, *outputVarName, *formalName;
90  Hrc_Node_t *childNode;
91  int i;
92  Var_Variable_t *inputVar, *outputVar;
93
94 
95  Hrc_NodeForEachChild(hnode, stGen, childName, childNode){
96    /* add childrens inputs' formal names to tableOfFormalNames */
97    Hrc_NodeForEachFormalInput(childNode, i, inputVar){
98      inputVarName = Var_VariableReadName(inputVar);
99      nodeName = Hrc_NodeFindHierarchicalName(childNode, 1);
100      formalName = ALLOC(char, strlen(nodeName) + strlen(inputVarName) +2);
101      sprintf(formalName, "%s.%s", nodeName, inputVarName);     
102      FREE(nodeName);
103      st_insert(tableOfFormalNames, (char *) formalName, (char *) (long) ( -1));
104    }
105    /* add childrens outputs' formal names to tableOfFormalNames */
106    Hrc_NodeForEachFormalOutput(childNode, i, outputVar){
107      outputVarName = Var_VariableReadName(outputVar);
108      nodeName = Hrc_NodeFindHierarchicalName(childNode, 1);
109      formalName = ALLOC(char, strlen(nodeName) + strlen(outputVarName) +2);
110      sprintf(formalName, "%s.%s", nodeName, outputVarName);     
111      FREE(nodeName);
112      st_insert(tableOfFormalNames, (char *) formalName, (char *) (long) ( -1));
113    }
114    /* recurse */
115    partCreateBoundaryNames(childNode, tableOfFormalNames);
116  }
117}
118
119
120/**Function********************************************************************
121
122  Synopsis [Implements the partition with respect to the submodule boundary
123  nodes.]
124
125  SideEffects []
126
127  SeeAlso     [PartPartitionTotal PartPartitionInputsOutputs]
128
129******************************************************************************/
130void
131PartPartitionBoundary(
132  Ntk_Network_t *network,
133  Hrc_Node_t    *hnode,
134  graph_t       *partition,
135  lsList        rootList,
136  lsList        leaveList,
137  mdd_t         *careSet,
138  int           inTermsOfCombInputs)
139{
140  int            i;                /* Index for loops */
141  st_generator   *stGen;           /* To iterate over the MddIds of the support */
142  char           *formalName;
143  char           *actualName;
144  st_table       *tableOfActualNames;
145  st_table       *tableOfFormalNames;
146  lsList         nodeList;
147
148
149  assert(rootList == (lsList)0);
150  assert(leaveList == (lsList)0);
151
152  /* create table of all formal names */
153  tableOfFormalNames = st_init_table(strcmp, st_strhash);
154  partCreateBoundaryNames(hnode, tableOfFormalNames);
155
156  nodeList = lsCreate();
157  tableOfActualNames = st_init_table(strcmp, st_strhash);
158  st_foreach_item_int(tableOfFormalNames, stGen, &formalName, &i){
159    actualName = Ntk_NetworkReadActualNameFromFormalName(network, formalName);
160    if(!st_is_member(tableOfActualNames, actualName)){
161      lsNewEnd(nodeList, (lsGeneric) actualName, NIL(lsHandle));
162      st_insert(tableOfActualNames, actualName, (char *) (long) ( -1));
163    }
164  }
165 
166 
167  PartPartitionPartial(network, partition, rootList, leaveList, careSet, nodeList,
168                       inTermsOfCombInputs);
169  lsDestroy(nodeList, (void (*)(lsGeneric))0); 
170  st_free_table(tableOfActualNames);
171  st_foreach_item_int(tableOfFormalNames, stGen, &formalName, &i){
172    FREE(formalName);
173  }
174  st_free_table(tableOfFormalNames);
175} /* End of PartPartitionPartial */
176
177/*---------------------------------------------------------------------------*/
178/* Definition of static functions                                            */
179/*---------------------------------------------------------------------------*/
Note: See TracBrowser for help on using the repository browser.