VIS

src/part/partBoundary.c

Go to the documentation of this file.
00001 
00026 #include "partInt.h"
00027 
00028 static char rcsid[] UNUSED = "$Id: partBoundary.c,v 1.5 2002/09/10 05:06:25 fabio Exp $";
00029 
00030 /*---------------------------------------------------------------------------*/
00031 /* Constant declarations                                                     */
00032 /*---------------------------------------------------------------------------*/
00033 
00034 
00035 /*---------------------------------------------------------------------------*/
00036 /* Structure declarations                                                    */
00037 /*---------------------------------------------------------------------------*/
00038 
00039 
00040 /*---------------------------------------------------------------------------*/
00041 /* Type declarations                                                         */
00042 /*---------------------------------------------------------------------------*/
00043 
00044 
00045 /*---------------------------------------------------------------------------*/
00046 /* Variable declarations                                                     */
00047 /*---------------------------------------------------------------------------*/
00048 
00049 
00050 /*---------------------------------------------------------------------------*/
00051 /* Macro declarations                                                        */
00052 /*---------------------------------------------------------------------------*/
00053 
00054 
00057 /*---------------------------------------------------------------------------*/
00058 /* Static function prototypes                                                */
00059 /*---------------------------------------------------------------------------*/
00060 
00061 
00065 /*---------------------------------------------------------------------------*/
00066 /* Definition of exported functions                                          */
00067 /*---------------------------------------------------------------------------*/
00068 
00069 
00070 /*---------------------------------------------------------------------------*/
00071 /* Definition of internal functions                                          */
00072 /*---------------------------------------------------------------------------*/
00073 
00083 void
00084 partCreateBoundaryNames(
00085   Hrc_Node_t    *hnode,
00086   st_table      *tableOfFormalNames)
00087 {
00088   st_generator *stGen;
00089   char *childName, *nodeName, *inputVarName, *outputVarName, *formalName;
00090   Hrc_Node_t *childNode;
00091   int i;
00092   Var_Variable_t *inputVar, *outputVar;
00093 
00094   
00095   Hrc_NodeForEachChild(hnode, stGen, childName, childNode){
00096     /* add childrens inputs' formal names to tableOfFormalNames */
00097     Hrc_NodeForEachFormalInput(childNode, i, inputVar){
00098       inputVarName = Var_VariableReadName(inputVar);
00099       nodeName = Hrc_NodeFindHierarchicalName(childNode, 1);
00100       formalName = ALLOC(char, strlen(nodeName) + strlen(inputVarName) +2);
00101       sprintf(formalName, "%s.%s", nodeName, inputVarName);      
00102       FREE(nodeName);
00103       st_insert(tableOfFormalNames, (char *) formalName, (char *) (long) ( -1));
00104     }
00105     /* add childrens outputs' formal names to tableOfFormalNames */
00106     Hrc_NodeForEachFormalOutput(childNode, i, outputVar){
00107       outputVarName = Var_VariableReadName(outputVar);
00108       nodeName = Hrc_NodeFindHierarchicalName(childNode, 1);
00109       formalName = ALLOC(char, strlen(nodeName) + strlen(outputVarName) +2);
00110       sprintf(formalName, "%s.%s", nodeName, outputVarName);      
00111       FREE(nodeName);
00112       st_insert(tableOfFormalNames, (char *) formalName, (char *) (long) ( -1));
00113     }
00114     /* recurse */
00115     partCreateBoundaryNames(childNode, tableOfFormalNames);
00116   }
00117 }
00118 
00119 
00130 void
00131 PartPartitionBoundary(
00132   Ntk_Network_t *network,
00133   Hrc_Node_t    *hnode,
00134   graph_t       *partition,
00135   lsList        rootList,
00136   lsList        leaveList,
00137   mdd_t         *careSet,
00138   int           inTermsOfCombInputs)
00139 {
00140   int            i;                /* Index for loops */
00141   st_generator   *stGen;           /* To iterate over the MddIds of the support */
00142   char           *formalName;
00143   char           *actualName;
00144   st_table       *tableOfActualNames;
00145   st_table       *tableOfFormalNames;
00146   lsList         nodeList;
00147 
00148 
00149   assert(rootList == (lsList)0);
00150   assert(leaveList == (lsList)0);
00151 
00152   /* create table of all formal names */
00153   tableOfFormalNames = st_init_table(strcmp, st_strhash);
00154   partCreateBoundaryNames(hnode, tableOfFormalNames);
00155 
00156   nodeList = lsCreate();
00157   tableOfActualNames = st_init_table(strcmp, st_strhash);
00158   st_foreach_item_int(tableOfFormalNames, stGen, &formalName, &i){
00159     actualName = Ntk_NetworkReadActualNameFromFormalName(network, formalName);
00160     if(!st_is_member(tableOfActualNames, actualName)){
00161       lsNewEnd(nodeList, (lsGeneric) actualName, NIL(lsHandle));
00162       st_insert(tableOfActualNames, actualName, (char *) (long) ( -1));
00163     }
00164   }
00165   
00166   
00167   PartPartitionPartial(network, partition, rootList, leaveList, careSet, nodeList,
00168                        inTermsOfCombInputs);
00169   lsDestroy(nodeList, (void (*)(lsGeneric))0);  
00170   st_free_table(tableOfActualNames);
00171   st_foreach_item_int(tableOfFormalNames, stGen, &formalName, &i){
00172     FREE(formalName);
00173   }
00174   st_free_table(tableOfFormalNames);
00175 } /* End of PartPartitionPartial */
00176 
00177 /*---------------------------------------------------------------------------*/
00178 /* Definition of static functions                                            */
00179 /*---------------------------------------------------------------------------*/