source: vis_dev/cusp-1.1/src/aig/aigCmd.c @ 98

Last change on this file since 98 was 12, checked in by cecile, 13 years ago

cusp added

File size: 5.7 KB
RevLine 
[12]1/**CFile***********************************************************************
2
3  FileName    [AigCmd.c]
4
5  PackageName [Aig]
6
7  Synopsis    [Functions to initialize and shut down the Aig manager.]
8
9  Author      [Mohammad Awedh]
10
11  Copyright [ This file was created at the University of Colorado at
12  Boulder.  The University of Colorado at Boulder makes no warranty
13  about the suitability of this software for any purpose.  It is
14  presented on an AS IS basis.]
15
16******************************************************************************/
17
18#include "aig.h"
19#include "aigInt.h"
20
21static char rcsid[] UNUSED = "$Id: aigCmd.c,v 1.1.1.1 2008-11-14 20:40:11 hhkim Exp $";
22
23/*---------------------------------------------------------------------------*/
24/* Constant declarations                                                     */
25/*---------------------------------------------------------------------------*/
26
27
28/*---------------------------------------------------------------------------*/
29/* Stucture declarations                                                     */
30/*---------------------------------------------------------------------------*/
31
32
33/*---------------------------------------------------------------------------*/
34/* Type declarations                                                         */
35/*---------------------------------------------------------------------------*/
36
37
38/*---------------------------------------------------------------------------*/
39/* Variable declarations                                                     */
40/*---------------------------------------------------------------------------*/
41
42/*---------------------------------------------------------------------------*/
43/* Macro declarations                                                        */
44/*---------------------------------------------------------------------------*/
45
46
47/**AutomaticStart*************************************************************/
48
49/*---------------------------------------------------------------------------*/
50/* Static function prototypes                                                */
51/*---------------------------------------------------------------------------*/
52
53/**AutomaticEnd***************************************************************/
54
55
56/*---------------------------------------------------------------------------*/
57/* Definition of exported functions                                          */
58/*---------------------------------------------------------------------------*/
59
60/**Function********************************************************************
61
62  Synopsis    [Creates a new Aig manager.]
63
64  Description [Creates a new Aig manager, Create a NodeArray of size equal to
65  maxSize * AigNodeSize. Returns a pointer to the manager if successful;
66  NULL otherwise.]
67
68  SideEffects [None]
69
70  SeeAlso     []
71
72******************************************************************************/
73Aig_Manager_t *
74Aig_initAig(
75  int maxSize /* maximum number of nodes in the AIG graph*/
76)
77{
78  int i;
79 
80  Aig_Manager_t *bm = ALLOC(Aig_Manager_t,1);
81 
82  maxSize = maxSize * AigNodeSize;  /* each node is a size of AigNodeSize */
83  if (bm == NIL( Aig_Manager_t)){
84    return bm;
85  }
86 
87  maxSize = (maxSize/AigNodeSize)*AigNodeSize;
88  if (maxSize >  AigArrayMaxSize ) {
89  }
90  bm->NodesArray = ALLOC(AigEdge_t, maxSize);
91  bm->maxNodesArraySize = maxSize;
92  bm->nodesArraySize = AigFirstNodeIndex;
93 
94  fanout(0) = 0;
95  canonical(0) = 0;
96  flags(0) = 0;
97  aig_value(0) = 2;
98  aig_next(0) = Aig_NULL;
99 
100  bm->SymbolTable = st_init_table(strcmp,st_strhash);
101  bm->nameList = ALLOC(char *, bm->maxNodesArraySize/AigNodeSize);
102  bm->HashTable =  ALLOC(AigEdge_t, Aig_HashTableSize);
103 
104  for (i=0; i<Aig_HashTableSize; i++)
105    bm->HashTable[i]= Aig_NULL; 
106 
107  bm->timeframe = 0;
108  bm->timeframeWOI = 0;
109 
110  return(bm);
111
112} /* end of Aig_Init */
113
114/**Function********************************************************************
115
116  Synopsis [Quit Aig manager]
117
118  SideEffects []
119
120  SeeAlso     []
121
122******************************************************************************/
123void
124Aig_quit(
125  Aig_Manager_t *bm)
126{
127  int           i;
128  char          *name;
129  st_generator  *stGen;
130  AigEdge_t    varIndex;
131
132  /**
133  if (bm->mVarList != NIL(array_t)){
134    array_free(bm->mVarList);
135  }
136  if (bm->bVarList != NIL(array_t)){
137    array_free(bm->bVarList);
138  }
139  **/
140
141  FREE(bm->HashTable);
142  st_foreach_item(bm->SymbolTable, stGen, &name, &varIndex) {
143    FREE(name);
144  }
145  st_free_table(bm->SymbolTable);
146  /* i is too small to represent 80000
147  for (i=0; i< bm->maxNodesArraySize/AigNodeSize ; i++){
148    FREE(bm->nameList[i]);
149  }
150  */
151  for (i=AigFirstNodeIndex ; i< bm->nodesArraySize ; i+=AigNodeSize){
152    if (fanout(i)) free((AigEdge_t *) fanout(i));
153  }
154
155  if (bm->nameList) FREE(bm->nameList);
156  if (bm->NodesArray) FREE(bm->NodesArray);
157
158  bm->nameList = 0;
159  bm->NodesArray = 0;
160  bm->timeframe = 0;
161  bm->timeframeWOI = 0;
162
163  if (bm) {
164    FREE(bm);
165  }
166
167  bm = 0;
168}
169
170/**Function********************************************************************
171
172  Synopsis    []
173
174  Description []
175
176  SideEffects [None]
177
178  SeeAlso     []
179
180******************************************************************************/
181void 
182Aig_NodePrint(
183   Aig_Manager_t  *bm,
184   AigEdge_t node)
185{
186
187  if (node == Aig_Zero){
188    printf("0");
189    return;
190  }
191  if (node == Aig_One){
192    printf("1");
193    return;
194  } 
195 
196  if (Aig_IsInverted(node)){
197    printf(" NOT(");
198  }
199 
200  if ( rightChild(node) == Aig_NULL){
201    printf("Var Node");
202    if (Aig_IsInverted(node)){
203      printf(")");
204    }
205    return;
206  }
207  printf("(");
208  Aig_NodePrint(bm, leftChild(node));
209  printf("AND");
210  Aig_NodePrint(bm, rightChild(node));
211  printf(")");
212  if (Aig_IsInverted(node)){
213    printf(")");
214  }
215}
Note: See TracBrowser for help on using the repository browser.