source: vis_dev/vis-2.3/src/tbl/tblTest.c @ 93

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

vis2.3

File size: 9.2 KB
Line 
1/**CFile***********************************************************************
2
3  FileName    [ tblTest.c ]
4
5  PackageName [ tbl ]
6
7  Synopsis    [ This package is used to manipulate the table data structure ]
8
9  Description [ The table data structure is used to store the information
10               contained in the blif_mv table. This structure supports all
11               constructs in blif_mv including  the recursive constructs.
12               This is consistent with the previous version of this data-
13               structure.]
14
15  SeeAlso     [ tbl.h, tblEntryUtil.c ]
16
17  Author      [ Gitanjali M. Swamy ]
18
19  Copyright   [Copyright (c) 1994-1996 The Regents of the Univ. of California.
20  All rights reserved.
21
22  Permission is hereby granted, without written agreement and without license
23  or royalty fees, to use, copy, modify, and distribute this software and its
24  documentation for any purpose, provided that the above copyright notice and
25  the following two paragraphs appear in all copies of this software.
26
27  IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
28  DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
29  OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
30  CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32  THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
33  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN
35  "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE
36  MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.]
37
38******************************************************************************/
39#include "tblInt.h"
40
41static char rcsid[] UNUSED = "$Id: tblTest.c,v 1.12 2009/04/11 02:01:29 fabio Exp $";
42
43/**AutomaticStart*************************************************************/
44
45/*---------------------------------------------------------------------------*/
46/* Static function prototypes                                                */
47/*---------------------------------------------------------------------------*/
48
49static int CommandTableTest(Hrc_Manager_t ** hmgr, int argc, char ** argv);
50static void TestTblPrint(Tbl_Table_t *table);
51
52/**AutomaticEnd***************************************************************/
53
54
55/*---------------------------------------------------------------------------*/
56/* Definition of exported functions                                          */
57/*---------------------------------------------------------------------------*/
58/**Function********************************************************************
59
60  Synopsis    [Initializes the table (Tbl) package.]
61
62  SideEffects []
63
64  SeeAlso     [Ntm_End]
65
66******************************************************************************/
67void
68Tbl_Init(void)
69{
70  Cmd_CommandAdd("_tbl_test", CommandTableTest, /* doesn't changes_network */0);
71}
72
73
74/**Function********************************************************************
75
76  Synopsis    [Ends the table (Tbl) package]
77
78  SideEffects []
79
80  SeeAlso     [Ntm_Init]
81
82******************************************************************************/
83void
84Tbl_End(void)
85{
86}
87
88/**Function********************************************************************
89
90  Synopsis    [com function for testing]
91
92  Description [This is an internal function, whose purpose is to help
93  the developer test code. It is not fixed in function.]
94
95  SideEffects []
96
97  CommandName [_tbl_test]
98  CommandSynopsis [test the functionality of the tbl package.]
99  CommandArguments [\[-h\] \[-v\]]
100  CommandDescription [Tests the functionality of the tbl package.<p>
101  Command options:<p>
102  <dl><dt> -h
103  <dd> Print the command usage.
104  </dl>
105  <dl><dt> -v
106  <dd> Verbose mode.
107  </dl>]
108
109  SeeAlso     []
110
111******************************************************************************/
112static int
113CommandTableTest(
114  Hrc_Manager_t ** hmgr,
115  int  argc,
116  char ** argv)
117{
118  int c;
119  Tbl_Table_t *table;
120  int i;
121  Hrc_Node_t * node;
122  boolean verbose UNUSED = FALSE;              /* default */
123 
124  /*
125   * Parse the command line.
126   */
127
128  util_getopt_reset();
129  while ((c = util_getopt(argc, argv, "vh")) != EOF) {
130    switch (c) {
131      case 'v':
132        verbose = 1;
133        break;
134      case 'h':
135        goto usage;
136      default:
137        goto usage;
138    }
139  }
140 
141  node = Hrc_ManagerReadRootNode(*hmgr);
142  if (node == NIL(Hrc_Node_t)) {
143    (void) fprintf(vis_stdout, "No file has been read in. Use read_blif_mv.\n");
144    return 1;
145  }
146   
147  Hrc_NodeForEachNameTable(node,i,table) {
148    if (i>0) {
149      fprintf(vis_stdout, "---------------------------\n") ;
150      Tbl_TableWriteBlifMvToFile (table, 0, vis_stdout) ;
151       
152      fprintf(vis_stdout, "---------------------------\n") ;
153     
154    }
155   
156/*    TestTblPrint(table);    */
157  }
158   
159  return 0;
160 
161  usage:
162  (void) fprintf(vis_stderr, "usage: _tbl_test [-h] [-v]\n");
163  (void) fprintf(vis_stderr, "   -h        print the command usage\n"); 
164  (void) fprintf(vis_stderr, "   -v        verbose\n");
165  return 1;             /* error exit */
166}
167
168/**Function********************************************************************
169
170  Synopsis    [Test Table  code]
171
172  Description []
173
174  SideEffects []
175
176  SeeAlso     []
177
178******************************************************************************/
179static void TestTblPrint(
180  Tbl_Table_t *table)
181{
182/*  array_t *check; */
183  mdd_manager    *mddMgr; 
184  Tbl_Table_t *newTable;
185  int             i;
186/* int j, offset; */ 
187/*   Mvf_Function_t *outMvf; */
188/*   Var_Variable_t *var; */
189/*   int             colNum; */
190/*   array_t        *faninMvfArray; */
191/*   array_t        *mvarValues; */
192/*   array_t        *totalSupportArray; */
193/*   int             numInputs; */
194 
195/*  int rowNumi, rowNumj; */
196/*  Tbl_Row_t *rowi, *rowj; */
197/*   boolean check; */
198
199  Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);
200  mddMgr = mdd_init_empty();
201  for(i=0; i < Tbl_TableReadNumOutputs(table); i++){
202    if (Tbl_TableTestIsOutputSpaceComplete(table, mddMgr) ) {
203      newTable =
204          Tbl_TableCreateTrueSupportTableForOutput(table,NIL(Mvf_Function_t), mddMgr,0,i,NIL(array_t));
205      printf(" NEW table for %d \n", i);
206      Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
207      printf("\n");
208    }
209   
210  }
211  mdd_quit(mddMgr);
212
213/*   Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);
214 *  printf(" Test 1\n"); 
215 *  mddMgr = mdd_init_empty();
216 *  for(i=0; i < Tbl_TableReadNumOutputs(table); i++){
217 *   newTable =
218 *       Tbl_TableCreateTrueSupportTableForOutput(table,NIL(Mvf_Function_t), mddMgr,0,i,NIL(array_t));
219 *   printf(" NEW table for %d \n", i);
220 *   Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
221 *   printf("\n");   
222 * }
223 *    mdd_quit(mddMgr);
224 *
225 *  printf(" Test 2\n");
226 *
227 *  mddMgr = mdd_init_empty();
228 *  for(i=0; i < Tbl_TableReadNumOutputs(table); i++){
229 *  mvarValues        = array_alloc(int, 0);
230 *  numInputs         = Tbl_TableReadNumInputs(table );
231 *  totalSupportArray = array_alloc(int, 0);
232 *  faninMvfArray     = array_alloc(Mvf_Function_t *, 0);
233 *
234 *  Tbl_TableForEachInputVar(table, colNum, var) {
235 *    array_insert_last(int, mvarValues, Var_VariableReadNumValues(var));
236 *  }
237 *  offset = array_n(mdd_ret_mvar_list(mddMgr));   
238 *  mdd_create_variables(mddMgr,mvarValues, NIL(array_t), NIL(array_t));
239 *  array_free(mvarValues);
240 *
241 *  for (j = 0; j < numInputs; j++) {
242 *    Mvf_Function_t *faninMvf = Mvf_FunctionCreateFromVariable(mddMgr, (j+offset));
243 *    array_insert_last(Mvf_Function_t *, faninMvfArray, faninMvf);
244 *  }
245 *
246 *  outMvf = Tbl_TableBuildMvfFromFanins(table, i, faninMvfArray, mddMgr);
247 *  Mvf_FunctionArrayFree(faninMvfArray);
248 *   newTable =
249 *       Tbl_TableCreateTrueSupportTableForOutput(table,outMvf, mddMgr,offset,i,NIL(array_t)); 
250 *   printf(" NEW table for %d \n", i);
251 *   Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
252 *   printf("\n");   
253 * }
254 *    mdd_quit(mddMgr);
255 */ 
256  /* testing hard and soft dups */
257   
258/*   newTable = Tbl_TableHardDup(table);
259 *  printf(" NEW table Hard\n");
260 *  Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
261 *  Tbl_TableSetEntryDc(newTable,Tbl_TableReadNumRows(table)-1,\
262 *                      Tbl_TableReadNumInputs(table)-1, 0);
263 *  printf(" NEW table Hard Modify\n");
264 *  Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
265 *  printf(" Old  table Hard Modify \n" );
266 *  Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);
267 *  Tbl_TableFree(newTable);
268 *
269 *  newTable = Tbl_TableSoftDup(table);
270 *  printf(" NEW table Soft\n");
271 *  Tbl_TableWriteBlifMvToFile(table,0,vis_stdout); 
272 *  printf(" NEW table Soft\n");
273 *  Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
274 *  Tbl_TableSetEntryDc(newTable,Tbl_TableReadNumRows(table)-1,\
275 *                      Tbl_TableReadNumInputs(table)-1, 0);
276 *  printf(" NEW table Soft Modify\n");
277 *  Tbl_TableWriteBlifMvToFile(newTable,0,vis_stdout);
278 *  printf(" Old  table Soft Modify \n" );
279 *  Tbl_TableWriteBlifMvToFile(table,0,vis_stdout);
280 *  Tbl_TableFree(newTable);
281 *   Tbl_TableFree(table);
282 */
283
284  /* testing row intersect */
285 
286/*   TblTableForEachRow(table,rowi,rowNumi) {
287 *     TblTableForEachRow(table,rowj,rowNumj) {
288 *       check = Tbl_RowInputIntersect(table,rowNumi, rowNumj);
289 *       printf("Rows %d and %d intersect = %d\n",rowNumi, rowNumj, check);
290 *     }
291 * }
292 */
293}
294
295
296
297
298
299
300
301
302
303
304
305
306
Note: See TracBrowser for help on using the repository browser.