VIS

src/rst/rst.c

Go to the documentation of this file.
00001 
00032 #include "rstInt.h"
00033 
00034 static char rcsid[] UNUSED = "$Id: rst.c,v 1.6 2005/04/16 07:33:12 fabio Exp $";
00035 
00036 /*---------------------------------------------------------------------------*/
00037 /* Constant declarations                                                     */
00038 /*---------------------------------------------------------------------------*/
00039 
00040 /*---------------------------------------------------------------------------*/
00041 /* Structure declarations                                                    */
00042 /*---------------------------------------------------------------------------*/
00043 
00044 /*---------------------------------------------------------------------------*/
00045 /* Type declarations                                                         */
00046 /*---------------------------------------------------------------------------*/
00047 
00048 /*---------------------------------------------------------------------------*/
00049 /* Variable declarations                                                     */
00050 /*---------------------------------------------------------------------------*/
00051   int            verbose = 0;              /* default value */
00052 
00053 /*---------------------------------------------------------------------------*/
00054 /* Macro declarations                                                        */
00055 /*---------------------------------------------------------------------------*/
00056 
00059 /*---------------------------------------------------------------------------*/
00060 /* Static function prototypes                                                */
00061 /*---------------------------------------------------------------------------*/
00062 
00063 static int CommandCollapseChild(Hrc_Manager_t ** hmgr, int argc, char ** argv);
00064 
00068 /*---------------------------------------------------------------------------*/
00069 /* Definition of exported functions                                          */
00070 /*---------------------------------------------------------------------------*/
00071 
00081 void
00082 Rst_Init(void)
00083 {
00084   /*
00085    * Add a command to the global command table.  By using the leading
00086    * underscore, the command will be listed under "help -a" but not "help".
00087    */
00088   Cmd_CommandAdd("collapse_child", CommandCollapseChild,
00089                  /* doesn't changes_network */ 0);
00090   Cmd_CommandAdd("decompose_child", Rst_CommandGroupComponents,
00091                  /* doesn't changes_network */ 0);
00092 
00093 }
00094 
00095 
00105 void
00106 Rst_End(void)
00107 {
00108   /*
00109    * For example, free any global memory (if any) which the test package is
00110    * responsible for.
00111    */
00112 }
00113 
00114 
00115 /*---------------------------------------------------------------------------*/
00116 /* Definition of internal functions                                          */
00117 /*---------------------------------------------------------------------------*/
00118 
00119 
00120 /*---------------------------------------------------------------------------*/
00121 /* Definition of static functions                                            */
00122 /*---------------------------------------------------------------------------*/
00123 
00175 static int
00176 CommandCollapseChild(
00177   Hrc_Manager_t ** hmgr,
00178   int  argc,
00179   char ** argv)
00180 {
00181   int            c;
00182   Hrc_Node_t  *parent, *child;
00183   boolean retVal;
00184 
00185   verbose = 0;
00186   
00187   /*
00188    * Parse command line options.
00189    */
00190   util_getopt_reset();
00191   while ((c = util_getopt(argc, argv, "vh")) != EOF) {
00192     switch(c) {
00193       case 'v':
00194         verbose = 1;
00195         break;
00196       case 'h':
00197         goto usage;
00198       default:
00199         goto usage;
00200     }
00201   }
00202 
00203   
00204   if(argc < 2){
00205     goto usage;
00206   }
00207 
00208 
00209   parent =   Hrc_ManagerReadCurrentNode(*hmgr);
00210   if (parent == NULL) {
00211     fprintf(vis_stderr, "Can't find parent node \n");
00212     return(1);
00213   }
00214 
00215   if (argc - util_optind == 0) {
00216     (void) fprintf(vis_stderr, "Child node name not provided\n");
00217     goto usage;
00218   }
00219   else if (argc - util_optind > 1) {
00220     (void) fprintf(vis_stderr, "too many arguments\n");
00221     goto usage;
00222   }
00223   
00224 
00225   if(verbose)
00226     (void)fprintf(vis_stdout, "Collapsing child : %s\n", argv[util_optind]);
00227   
00228   child =   Hrc_ManagerFindNodeByPathName(*hmgr, argv[util_optind],TRUE);
00229   if (child == NULL) {
00230     fprintf(vis_stderr, "Can't find child node %s\n", argv[util_optind]);
00231     return(1);
00232   }  
00233 
00234   retVal = RstCollapseNode( *hmgr, parent, child);
00235   return(retVal);
00236   
00237 
00238   usage:
00239   (void) fprintf(vis_stdout,
00240                  "The collapse_child command collapses the child node into the current node.\n");
00241   (void) fprintf(vis_stderr,
00242                  "usage: collapse_child [-h] [-v] <child instance name>\n");
00243   (void) fprintf(vis_stderr, "   -h\t\tprint the command usage\n");
00244   (void) fprintf(vis_stderr, "   -v\t\tverbose\n");
00245   return 1;             /* error exit */
00246 }
00247 
00263 int RstCollapseNode(
00264   Hrc_Manager_t *hmgr,
00265   Hrc_Node_t    *parent,
00266   Hrc_Node_t    *child
00267   )
00268 {
00269   boolean foundChild;
00270   st_generator *gen; /*XXX -  Do I need to initialize this */
00271   char *curChildName, *newModelName, *parentModelName, *parentInstanceName, *suffixModelName;
00272   Hrc_Node_t *curChild, *newNode, *root;
00273   Hrc_Model_t *parentModelPtr, *childModelPtr, *newModelPtr;
00274   array_t *actualInputArray, *actualOutputArray, *formalInputArray, *formalOutputArray;
00275   st_table *parentVarTable, *childVarTable;
00276   int i;
00277   Var_Variable_t *var, *newVar;
00278   boolean retVal;
00279     
00280   /* set current node to parent */
00281   Hrc_ManagerSetCurrentNode(hmgr, parent);
00282 
00283   /* get root node */
00284   root = Hrc_ManagerReadRootNode(hmgr);
00285   
00286   /* check if the child is really our child */
00287   foundChild = FALSE;
00288   Hrc_NodeForEachChild ( parent, gen, curChildName, curChild){
00289     if(curChild == child) foundChild = TRUE;
00290   }
00291 
00292   if(!foundChild) {
00293       fprintf(vis_stdout, "Collapse called with bad child\n");
00294       return(-1);
00295   }
00296 
00297   /* get masternodes for parent and child */
00298   parentModelPtr     =
00299       Hrc_ManagerFindModelByName(hmgr,Hrc_NodeReadModelName(parent));
00300   assert(parentModelPtr != NULL);
00301 
00302   childModelPtr     =
00303       Hrc_ManagerFindModelByName(hmgr,Hrc_NodeReadModelName(child));
00304   assert(childModelPtr != NULL);
00305  
00306 
00307   /* create a new model by concatenating names of parent and child */
00308   suffixModelName = util_strcat3( Hrc_ModelReadName(parentModelPtr),
00309                                "#",Hrc_ModelReadName(childModelPtr));
00310   newModelName = util_strcat3( Hrc_NodeReadInstanceName(child),
00311                                "#",suffixModelName);
00312   FREE(suffixModelName);
00313   assert(newModelName != 0);
00314 
00315   newModelPtr = Hrc_ManagerFindModelByName(hmgr, newModelName);
00316   if(newModelPtr != NULL){
00317     fprintf(vis_stdout, "Warning: rst has detected an existing model with name %s\n",
00318            newModelName);
00319     fprintf(vis_stdout, "If you have collapsed another instance of this child model\n");
00320     fprintf(vis_stdout, "into another instance of this parent previously this is \n");
00321     fprintf(vis_stdout, "normal and collapse_child will function correctly.\n");
00322     fprintf(vis_stdout, "Otherwise, you have a name conflict that rst cannot handle\n");
00323   }
00324   else {
00325     newModelPtr = Hrc_ModelAlloc(hmgr, newModelName);
00326     
00327     if(verbose){
00328       fprintf(vis_stdout, "Adding child components to new model\n");
00329     }
00330     childVarTable = RstAddChildComponentsToNewModel(hmgr,child, parent, newModelPtr);
00331     
00332     actualInputArray = Hrc_NodeReadActualInputs(child);
00333     actualOutputArray = Hrc_NodeReadActualOutputs(child);
00334     formalInputArray = Hrc_NodeReadFormalInputs(child);
00335     formalOutputArray = Hrc_NodeReadFormalOutputs(child);
00336     
00337     assert(array_n(actualInputArray) == array_n(formalInputArray));
00338     assert(array_n(actualOutputArray) == array_n(formalOutputArray));
00339     
00340     parentVarTable =  st_init_table(st_ptrcmp,st_ptrhash);
00341     
00342     for (  i = 0; i < array_n(formalInputArray); i++) {
00343       /* get the modified child var */
00344       var = array_fetch(Var_Variable_t *, formalInputArray, i);
00345       retVal = st_lookup(childVarTable, (char *)var, &newVar);
00346       assert(retVal);
00347       var = array_fetch(Var_Variable_t *, actualInputArray, i);
00348       st_insert(parentVarTable, (char *) var, (char *) newVar);
00349     }
00350     
00351     for (  i = 0; i < array_n(formalOutputArray); i++) {
00352       /* get the modified child var */
00353       var  = array_fetch(Var_Variable_t *, formalOutputArray, i);
00354       retVal = st_lookup(childVarTable, (char *)var, &newVar);
00355       assert(retVal);
00356       var = array_fetch(Var_Variable_t *, actualOutputArray, i);
00357       st_insert(parentVarTable, (char *) var, (char *) newVar);
00358     }
00359     
00360     if(verbose){
00361       fprintf(vis_stdout, "Adding parent components to new model\n");
00362     }
00363     
00364     RstAddParentComponentsToNewModel(hmgr, parent, newModelPtr,
00365                                      parentVarTable, child);
00366     st_free_table(childVarTable);
00367     st_free_table(parentVarTable);
00368   }
00369   
00370   if(verbose)
00371     fprintf(vis_stdout, "Creating new model hierarchy.\n");
00372 
00373   parentInstanceName = Hrc_NodeReadInstanceName(parent);
00374   if(verbose)
00375     fprintf(vis_stdout, "Retaining old parent's instance name %s\n",
00376             parentInstanceName);
00377     
00378     newNode = Hrc_ModelCreateHierarchy(hmgr, newModelPtr,parentInstanceName);
00379                                      
00380   
00381   if(verbose)
00382     fprintf(vis_stdout, "Replacing old hierarchy tree with new tree.\n");
00383   retVal = Hrc_TreeReplace(parent,newNode);
00384   assert(retVal);
00385 
00386   Hrc_ManagerSetCurrentNode(hmgr,newNode);
00387 
00388   if(root == parent){
00389     if(verbose){
00390       fprintf(vis_stdout, "Current parent IS the root...\n");
00391       fprintf(vis_stdout, "Deleting old root model\n");
00392     }
00393     
00394     parentModelName =  util_strsav(Hrc_ModelReadName(parentModelPtr));
00395     Hrc_ModelDelete(hmgr, parentModelName);
00396     FREE(parentModelName);
00397   }
00398   
00399   
00400   FREE(newModelName);
00401   return(0);
00402 }
00403 
00417 st_table * RstAddChildComponentsToNewModel(
00418   Hrc_Manager_t *hmgr,
00419   Hrc_Node_t    *child,
00420   Hrc_Node_t    *parent,
00421   Hrc_Model_t   *newModelPtr
00422   )
00423 {
00424   Hrc_Node_t *newMaster, *grandChild;
00425   st_generator *gen; 
00426   int i,index;
00427   Tbl_Table_t *tbl,*newTbl, *resetTbl, *newResetTbl;
00428   Var_Variable_t *var, *newVar ,  *newLatchInput, *newLatchOutput, *parentVar;
00429   char *latchName, *varName, *newVarName, *grandChildInstName, *newSubcktName;
00430   Hrc_Latch_t *latch, *newLatch;
00431   st_table *childVarToNewVar;
00432   array_t *actualInputArray, *newActualInputArray;
00433   array_t *actualOutputArray, *newActualOutputArray;
00434   boolean retVal;
00435 
00436   newMaster = Hrc_ModelReadMasterNode(newModelPtr);
00437   
00438   childVarToNewVar = st_init_table(st_ptrcmp,st_ptrhash);
00439   /* Add all Child's variables to the new model after prefixing child name */
00440   Hrc_NodeForEachVariable(child, gen, varName, var){
00441     if( Var_VariableTestIsPI(var) || Var_VariableTestIsPO(var)){
00442       parentVar = Hrc_VariableFindActualFromFormal(child, var, parent);
00443       assert(parentVar != NULL);
00444       newVarName = util_strsav(Var_VariableReadName(parentVar));
00445       assert(newVarName != NULL);
00446     }
00447     else{
00448     newVarName = util_strcat3(Hrc_NodeReadInstanceName(child), "$",
00449                               Var_VariableReadName(var));
00450     assert(newVarName != NULL);
00451     }
00452 
00453     newVar = Hrc_NodeFindVariableByName(newMaster, newVarName);
00454     if (newVar != NULL){
00455       assert (Var_VariableTestIsPI(var) || Var_VariableTestIsPO(var));
00456     }
00457 
00458     if(newVar == NULL)
00459       {
00460         newVar = Var_VariableDup(var,newMaster);
00461         retVal = Var_VariableChangeName(newVar,newVarName);
00462         assert(retVal);
00463         Var_VariableResetAllTypes(newVar);
00464       }
00465     
00466     FREE(newVarName);
00467     st_insert(childVarToNewVar, (char *)var, (char *)newVar);
00468   }
00469 
00470   /* Add all Child's tables to new model */
00471   Hrc_NodeForEachNameTable(child, i, tbl){
00472     /* copy the table */
00473     newTbl = Tbl_TableHardDup(tbl);
00474 
00475     /* Muck with its vars */
00476     Tbl_TableForEachInputVar(newTbl, index, var){
00477       retVal = st_lookup(childVarToNewVar, (char *)var, &newVar);
00478       assert(retVal);
00479       Tbl_TableSubstituteVar(newTbl,var,newVar);
00480     }
00481     Tbl_TableForEachOutputVar(newTbl, index, var){
00482       retVal = st_lookup(childVarToNewVar, (char *)var, &newVar);
00483       assert(retVal);
00484       Tbl_TableSubstituteVar(newTbl,var,newVar);
00485     }
00486 
00487     /* add it in! */
00488     Hrc_NodeAddNameTable(newMaster, newTbl);
00489   }
00490 
00491   /* Add all Child's latches to the new model */
00492   Hrc_NodeForEachLatch( child, gen, latchName, latch){
00493 
00494     /* muck with the variables */
00495     retVal = st_lookup(childVarToNewVar, (char *)Hrc_LatchReadInput(latch),
00496                        &(newLatchInput));
00497     assert(retVal);
00498     Var_VariableSetNS(newLatchInput);
00499     retVal = st_lookup(childVarToNewVar, (char *)Hrc_LatchReadOutput(latch),
00500                        &(newLatchOutput));
00501     Var_VariableSetPS(newLatchOutput);
00502     assert(retVal);
00503 
00504     /* get new latch */
00505     newLatch = Hrc_LatchCreate(newModelPtr, newLatchInput, newLatchOutput);
00506     assert(newLatch != NULL);
00507 
00508     /* copy reset table */
00509     resetTbl = Hrc_LatchReadResetTable(latch);
00510     assert(resetTbl != NULL);
00511     newResetTbl = Tbl_TableSoftDup(resetTbl);
00512     
00513     /* muck with reset table vars */
00514     Tbl_TableForEachInputVar(newResetTbl, index, var){
00515       retVal = st_lookup(childVarToNewVar, (char *)var, &newVar);
00516       assert(retVal);
00517       Tbl_TableSubstituteVar(newResetTbl,var,newVar);
00518     }
00519     Tbl_TableForEachOutputVar(newResetTbl, index, var){
00520       retVal = st_lookup(childVarToNewVar, (char *)var, &newVar);
00521       assert(retVal);
00522       Tbl_TableSubstituteVar(newResetTbl,var,newVar);
00523     }
00524 
00525     /* Add table to latch */
00526     retVal = Hrc_LatchSetResetTable(newLatch,newResetTbl);
00527     assert(retVal);
00528     
00529     /* add it in! */
00530     Hrc_NodeAddLatch(newMaster, newLatch);
00531   }
00532 
00533   /* add all Child's sub circuits  to master */
00534   Hrc_NodeForEachChild(child, gen, grandChildInstName, grandChild) {
00535 
00536     actualInputArray = Hrc_NodeReadActualInputs(grandChild);
00537     actualOutputArray = Hrc_NodeReadActualOutputs(grandChild);
00538 
00539     newActualInputArray = array_alloc(Var_Variable_t *, 0);
00540     newActualOutputArray = array_alloc(Var_Variable_t *, 0);
00541 
00542     /* same story - var mucking */
00543     for ( i = 0; i < array_n(actualInputArray); i++){
00544       var = array_fetch(Var_Variable_t *, actualInputArray, i);
00545       assert(var != NULL);
00546       retVal = st_lookup(childVarToNewVar, (char *)var, &newVar);
00547       assert(retVal);
00548       Var_VariableSetSI(newVar);
00549       array_insert_last(Var_Variable_t *, newActualInputArray, newVar);
00550     }
00551 
00552     for ( i = 0; i < array_n(actualOutputArray); i++){
00553       var = array_fetch(Var_Variable_t *, actualOutputArray, i);
00554       assert(var != NULL);
00555       retVal = st_lookup(childVarToNewVar, (char *)var, &newVar);
00556       assert(retVal);
00557       Var_VariableSetSO(newVar);
00558       array_insert_last(Var_Variable_t *, newActualOutputArray, newVar);
00559     }
00560 
00561     
00562     /* add subcircuit to model */
00563     newSubcktName = util_strcat3(Hrc_NodeReadInstanceName(child), "$",
00564                                  Hrc_NodeReadInstanceName(grandChild));
00565     Hrc_ModelAddSubckt(newModelPtr,
00566                        Hrc_ManagerFindModelByName(hmgr,Hrc_NodeReadModelName(grandChild)),
00567                        newSubcktName,
00568                        newActualInputArray, newActualOutputArray);
00569     FREE(newSubcktName);
00570   }
00571 
00572   return(childVarToNewVar);
00573 }
00588 int RstAddParentComponentsToNewModel(
00589   Hrc_Manager_t *hmgr,
00590   Hrc_Node_t   *parent,
00591   Hrc_Model_t   *newModelPtr,
00592   st_table      *parentVarTable,
00593   Hrc_Node_t   *child
00594   )
00595 {
00596   Hrc_Node_t *newMaster, *curChild;
00597   st_generator *gen; 
00598   int i,index;
00599 
00600   Tbl_Table_t *tbl,*newTbl, *resetTbl, *newResetTbl;
00601   Var_Variable_t *var, *newVar ,  *newLatchInput, *newLatchOutput ;
00602   char *latchName, *varName, *curChildInstName;
00603   Hrc_Latch_t *latch, *newLatch;
00604   array_t *actualInputArray, *newActualInputArray;
00605   array_t *actualOutputArray, *newActualOutputArray;
00606   int pFanout;
00607   boolean retVal;
00608 
00609   newMaster = Hrc_ModelReadMasterNode(newModelPtr);
00610 
00611   /* Add all Parent's variables to the new model.
00612      If a parent variable is an interface to the child, it
00613      will change and get merged with the child's correspoinding
00614      interface variable */
00615   
00616   Hrc_NodeForEachVariable(parent, gen, varName, var){
00617     if(st_lookup(parentVarTable, (char *) var, &newVar) == 0){
00618       /* not an interface to child - copy it */
00619       newVar = Var_VariableDup(var,newMaster);
00620       assert(newVar != NULL);
00621       Var_VariableResetAllTypes(newVar);
00622       st_insert(parentVarTable, (char *)var, (char *)newVar);
00623     }
00624     else {
00625       /* interface variable. Have to increment the number of
00626          fanouts */
00627       pFanout = Var_VariableReadNumFanoutTables(var);
00628       while(pFanout){
00629         Var_VariableIncrementNumFanoutTables(newVar);
00630         pFanout--;
00631       }
00632     }
00633   }
00634   
00635 
00636   /* Add all Parent's tables to new model */
00637   Hrc_NodeForEachNameTable(parent, i, tbl){
00638     /* copy the table */
00639     newTbl = Tbl_TableHardDup(tbl);
00640     /* Muck with its vars */
00641     Tbl_TableForEachInputVar(newTbl, index, var){
00642       retVal = st_lookup(parentVarTable, (char *)var, &newVar);
00643       assert(retVal);
00644       Tbl_TableSubstituteVar(newTbl,var,newVar);
00645     }
00646 
00647     Tbl_TableForEachOutputVar(newTbl, index, var){
00648       retVal = st_lookup(parentVarTable, (char *)var, &newVar);
00649       assert(retVal);
00650       Tbl_TableSubstituteVar(newTbl,var,newVar);
00651     }
00652 
00653     /* add it in! */
00654     Hrc_NodeAddNameTable(newMaster, newTbl);
00655   }
00656 
00657   /* Add all Parent's latches to the new model */
00658   Hrc_NodeForEachLatch( parent, gen, latchName, latch){
00659     /* muck with the variables */
00660     retVal = st_lookup(parentVarTable, (char *)Hrc_LatchReadInput(latch),
00661                        &(newLatchInput));
00662     assert(retVal);
00663     Var_VariableSetNS(newLatchInput);
00664     retVal = st_lookup(parentVarTable, (char *)Hrc_LatchReadOutput(latch),
00665                        &(newLatchOutput));
00666     assert(retVal);
00667     Var_VariableSetPS(newLatchOutput);
00668 
00669     /* get new latch */
00670     newLatch = Hrc_LatchCreate(newModelPtr, newLatchInput, newLatchOutput);
00671     assert(newLatch != NULL);
00672 
00673     /* copy reset table */
00674     resetTbl = Hrc_LatchReadResetTable(latch);
00675     assert(resetTbl != NULL);
00676     newResetTbl = Tbl_TableSoftDup(resetTbl);
00677     
00678     /* muck with reset table vars */
00679     Tbl_TableForEachInputVar(newResetTbl, index, var){
00680       retVal = st_lookup(parentVarTable, (char *)var, &newVar);
00681       assert(retVal);
00682       Tbl_TableSubstituteVar(newResetTbl,var,newVar);
00683     }
00684     Tbl_TableForEachOutputVar(newResetTbl, index, var){
00685       retVal = st_lookup(parentVarTable, (char *)var, &newVar);
00686       assert(retVal);
00687       Tbl_TableSubstituteVar(newResetTbl,var,newVar);
00688     }
00689 
00690     /* add table to latch */
00691     retVal = Hrc_LatchSetResetTable(newLatch,newResetTbl);
00692     assert(retVal);
00693     
00694     /* add it in! */
00695     Hrc_NodeAddLatch(newMaster, newLatch);
00696   }
00697 
00698   /* add all Parent's sub circuits  to master except "the" child's */
00699   Hrc_NodeForEachChild(parent, gen, curChildInstName, curChild) {
00700     /* do nothing for "the" child */
00701     if(curChild == child){
00702       continue;
00703     }
00704     actualInputArray = Hrc_NodeReadActualInputs(curChild);
00705     actualOutputArray = Hrc_NodeReadActualOutputs(curChild);
00706 
00707     newActualInputArray = array_alloc(Var_Variable_t *, 0);
00708     newActualOutputArray = array_alloc(Var_Variable_t *, 0);
00709 
00710     /* same story - var mucking */
00711     for ( i = 0; i < array_n(actualInputArray); i++){
00712       var = array_fetch(Var_Variable_t *, actualInputArray, i);
00713       retVal = st_lookup(parentVarTable, (char *)var, &newVar);
00714       assert(retVal);
00715       Var_VariableSetSI(newVar);
00716       array_insert_last(Var_Variable_t *, newActualInputArray, newVar);
00717     }
00718 
00719     for ( i = 0; i < array_n(actualOutputArray); i++){
00720       var = array_fetch(Var_Variable_t *, actualOutputArray, i);
00721       retVal = st_lookup(parentVarTable, (char *)var, &newVar);
00722       assert(retVal);
00723       Var_VariableSetSO(newVar);
00724       array_insert_last(Var_Variable_t *, newActualOutputArray, newVar);
00725     }
00726 
00727     /* add subcircuit to model */
00728     Hrc_ModelAddSubckt(newModelPtr,
00729                        Hrc_ManagerFindModelByName(hmgr,Hrc_NodeReadModelName(curChild)),
00730                        Hrc_NodeReadInstanceName(curChild),
00731                        newActualInputArray, newActualOutputArray);
00732   }
00733 
00734   /* add all formal inputs */
00735   Hrc_NodeForEachFormalInput( parent, i, var){
00736       retVal = st_lookup(parentVarTable, (char *)var, &newVar);
00737       assert(retVal);
00738       retVal = Hrc_NodeAddFormalInput(newMaster, newVar);
00739       Var_VariableSetPI(newVar);
00740       assert(retVal);
00741   }
00742 
00743   /* add all formal outputs */  
00744   Hrc_NodeForEachFormalOutput( parent, i, var){
00745       retVal = st_lookup(parentVarTable, (char *)var, &newVar);
00746       assert(retVal);
00747       retVal = Hrc_NodeAddFormalOutput(newMaster, newVar);
00748       Var_VariableSetPO(newVar);
00749       assert(retVal);
00750   }
00751 
00752   return(0);
00753 }
00754 
00755 #ifdef COLLAPSE_DEBUG
00756 int printVarTable( st_table *varTable)
00757 {
00758   st_generator *gen;
00759   Var_Variable_t *var, *newVar;
00760   
00761   st_foreach_item( varTable, gen, (char **) &var, (char **)&newVar){
00762     printf("address: %u : %15s -> %15s \n", (unsigned)var, Var_VariableReadName(var),
00763            Var_VariableReadName(newVar));
00764   }
00765 
00766   return(0);
00767 }
00768 #endif
00769