VIS

src/tbl/tblTest.c

Go to the documentation of this file.
00001 
00039 #include "tblInt.h"
00040 
00041 static char rcsid[] UNUSED = "$Id: tblTest.c,v 1.12 2009/04/11 02:01:29 fabio Exp $";
00042 
00045 /*---------------------------------------------------------------------------*/
00046 /* Static function prototypes                                                */
00047 /*---------------------------------------------------------------------------*/
00048 
00049 static int CommandTableTest(Hrc_Manager_t ** hmgr, int argc, char ** argv);
00050 static void TestTblPrint(Tbl_Table_t *table);
00051 
00055 /*---------------------------------------------------------------------------*/
00056 /* Definition of exported functions                                          */
00057 /*---------------------------------------------------------------------------*/
00067 void
00068 Tbl_Init(void)
00069 {
00070   Cmd_CommandAdd("_tbl_test", CommandTableTest, /* doesn't changes_network */0);
00071 }
00072 
00073 
00083 void
00084 Tbl_End(void)
00085 {
00086 }
00087 
00112 static int
00113 CommandTableTest(
00114   Hrc_Manager_t ** hmgr,
00115   int  argc,
00116   char ** argv)
00117 {
00118   int c;
00119   Tbl_Table_t *table;
00120   int i;
00121   Hrc_Node_t * node;
00122   boolean verbose UNUSED = FALSE;              /* default */
00123   
00124   /*
00125    * Parse the command line.
00126    */
00127 
00128   util_getopt_reset();
00129   while ((c = util_getopt(argc, argv, "vh")) != EOF) {
00130     switch (c) {
00131       case 'v':
00132         verbose = 1;
00133         break;
00134       case 'h':
00135         goto usage;
00136       default:
00137         goto usage;
00138     }
00139   }
00140   
00141   node = Hrc_ManagerReadRootNode(*hmgr);
00142   if (node == NIL(Hrc_Node_t)) {
00143     (void) fprintf(vis_stdout, "No file has been read in. Use read_blif_mv.\n");
00144     return 1;
00145   }
00146     
00147   Hrc_NodeForEachNameTable(node,i,table) {
00148     if (i>0) {
00149       fprintf(vis_stdout, "---------------------------\n") ;
00150       Tbl_TableWriteBlifMvToFile (table, 0, vis_stdout) ;
00151         
00152       fprintf(vis_stdout, "---------------------------\n") ;
00153       
00154     }
00155     
00156 /*    TestTblPrint(table);    */
00157   }
00158     
00159   return 0;
00160   
00161   usage:
00162   (void) fprintf(vis_stderr, "usage: _tbl_test [-h] [-v]\n");
00163   (void) fprintf(vis_stderr, "   -h        print the command usage\n");  
00164   (void) fprintf(vis_stderr, "   -v        verbose\n");
00165   return 1;             /* error exit */
00166 }
00167 
00179 static void TestTblPrint(
00180   Tbl_Table_t *table)
00181 {
00182 /*  array_t *check; */
00183   mdd_manager    *mddMgr; 
00184   Tbl_Table_t *newTable;
00185   int             i;
00186 /* int j, offset; */  
00187 /*   Mvf_Function_t *outMvf; */
00188 /*   Var_Variable_t *var; */
00189 /*   int             colNum; */
00190 /*   array_t        *faninMvfArray; */
00191 /*   array_t        *mvarValues; */
00192 /*   array_t        *totalSupportArray; */
00193 /*   int             numInputs; */
00194   
00195 /*  int rowNumi, rowNumj; */
00196 /*  Tbl_Row_t *rowi, *rowj; */
00197 /*   boolean check; */
00198 
00199   Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);
00200   mddMgr = mdd_init_empty();
00201   for(i=0; i < Tbl_TableReadNumOutputs(table); i++){
00202     if (Tbl_TableTestIsOutputSpaceComplete(table, mddMgr) ) {
00203       newTable =
00204           Tbl_TableCreateTrueSupportTableForOutput(table,NIL(Mvf_Function_t), mddMgr,0,i,NIL(array_t));
00205       printf(" NEW table for %d \n", i);
00206       Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
00207       printf("\n");
00208     }
00209     
00210   }
00211   mdd_quit(mddMgr);
00212 
00213 /*   Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);
00214  *  printf(" Test 1\n");  
00215  *  mddMgr = mdd_init_empty();
00216  *  for(i=0; i < Tbl_TableReadNumOutputs(table); i++){
00217  *   newTable =
00218  *       Tbl_TableCreateTrueSupportTableForOutput(table,NIL(Mvf_Function_t), mddMgr,0,i,NIL(array_t));
00219  *   printf(" NEW table for %d \n", i);
00220  *   Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
00221  *   printf("\n");    
00222  * }
00223  *    mdd_quit(mddMgr);
00224  *
00225  *  printf(" Test 2\n");
00226  *
00227  *  mddMgr = mdd_init_empty();
00228  *  for(i=0; i < Tbl_TableReadNumOutputs(table); i++){
00229  *  mvarValues        = array_alloc(int, 0);
00230  *  numInputs         = Tbl_TableReadNumInputs(table );
00231  *  totalSupportArray = array_alloc(int, 0);
00232  *  faninMvfArray     = array_alloc(Mvf_Function_t *, 0);
00233  *
00234  *  Tbl_TableForEachInputVar(table, colNum, var) {
00235  *    array_insert_last(int, mvarValues, Var_VariableReadNumValues(var));
00236  *  }
00237  *  offset = array_n(mdd_ret_mvar_list(mddMgr));    
00238  *  mdd_create_variables(mddMgr,mvarValues, NIL(array_t), NIL(array_t));
00239  *  array_free(mvarValues);
00240  *
00241  *  for (j = 0; j < numInputs; j++) {
00242  *    Mvf_Function_t *faninMvf = Mvf_FunctionCreateFromVariable(mddMgr, (j+offset));
00243  *    array_insert_last(Mvf_Function_t *, faninMvfArray, faninMvf);
00244  *  }
00245  *
00246  *  outMvf = Tbl_TableBuildMvfFromFanins(table, i, faninMvfArray, mddMgr);
00247  *  Mvf_FunctionArrayFree(faninMvfArray);
00248  *   newTable =
00249  *       Tbl_TableCreateTrueSupportTableForOutput(table,outMvf, mddMgr,offset,i,NIL(array_t));  
00250  *   printf(" NEW table for %d \n", i);
00251  *   Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
00252  *   printf("\n");    
00253  * }
00254  *    mdd_quit(mddMgr);
00255  */  
00256   /* testing hard and soft dups */
00257    
00258 /*   newTable = Tbl_TableHardDup(table);
00259  *  printf(" NEW table Hard\n");
00260  *  Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
00261  *  Tbl_TableSetEntryDc(newTable,Tbl_TableReadNumRows(table)-1,\
00262  *                      Tbl_TableReadNumInputs(table)-1, 0);
00263  *  printf(" NEW table Hard Modify\n");
00264  *  Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
00265  *  printf(" Old  table Hard Modify \n" );
00266  *  Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);
00267  *  Tbl_TableFree(newTable); 
00268  * 
00269  *  newTable = Tbl_TableSoftDup(table);
00270  *  printf(" NEW table Soft\n");
00271  *  Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);  
00272  *  printf(" NEW table Soft\n");
00273  *  Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
00274  *  Tbl_TableSetEntryDc(newTable,Tbl_TableReadNumRows(table)-1,\
00275  *                      Tbl_TableReadNumInputs(table)-1, 0);
00276  *  printf(" NEW table Soft Modify\n");
00277  *  Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
00278  *  printf(" Old  table Soft Modify \n" );
00279  *  Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);
00280  *  Tbl_TableFree(newTable);
00281  *   Tbl_TableFree(table);
00282  */
00283 
00284   /* testing row intersect */
00285   
00286 /*   TblTableForEachRow(table,rowi,rowNumi) {
00287  *     TblTableForEachRow(table,rowj,rowNumj) {
00288  *       check = Tbl_RowInputIntersect(table,rowNumi, rowNumj);
00289  *       printf("Rows %d and %d intersect = %d\n",rowNumi, rowNumj, check);
00290  *     }
00291  * }
00292  */
00293 }
00294 
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00302 
00303 
00304 
00305 
00306