abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hopMan.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [hopMan.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Minimalistic And-Inverter Graph package.]
8 
9  Synopsis [AIG manager.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - May 11, 2006.]
16 
17  Revision [$Id: hopMan.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "hop.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Starts the AIG manager.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
46 {
47  Hop_Man_t * p;
48  // start the manager
49  p = ABC_ALLOC( Hop_Man_t, 1 );
50  memset( p, 0, sizeof(Hop_Man_t) );
51  // perform initializations
52  p->nTravIds = 1;
53  p->fRefCount = 1;
54  p->fCatchExor = 0;
55  // allocate arrays for nodes
56  p->vPis = Vec_PtrAlloc( 100 );
57  p->vPos = Vec_PtrAlloc( 100 );
58  // prepare the internal memory manager
59  Hop_ManStartMemory( p );
60  // create the constant node
61  p->pConst1 = Hop_ManFetchMemory( p );
62  p->pConst1->Type = AIG_CONST1;
63  p->pConst1->fPhase = 1;
64  p->nCreated = 1;
65  // start the table
66 // p->nTableSize = 107;
67  p->nTableSize = 10007;
68  p->pTable = ABC_ALLOC( Hop_Obj_t *, p->nTableSize );
69  memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize );
70  return p;
71 }
72 
73 /**Function*************************************************************
74 
75  Synopsis [Stops the AIG manager.]
76 
77  Description []
78 
79  SideEffects []
80 
81  SeeAlso []
82 
83 ***********************************************************************/
85 {
86  Hop_Obj_t * pObj;
87  int i;
88  // make sure the nodes have clean marks
89  pObj = Hop_ManConst1(p);
90  assert( !pObj->fMarkA && !pObj->fMarkB );
91  Hop_ManForEachPi( p, pObj, i )
92  assert( !pObj->fMarkA && !pObj->fMarkB );
93  Hop_ManForEachPo( p, pObj, i )
94  assert( !pObj->fMarkA && !pObj->fMarkB );
95  Hop_ManForEachNode( p, pObj, i )
96  assert( !pObj->fMarkA && !pObj->fMarkB );
97  // print time
98  if ( p->time1 ) { ABC_PRT( "time1", p->time1 ); }
99  if ( p->time2 ) { ABC_PRT( "time2", p->time2 ); }
100 // Hop_TableProfile( p );
101  if ( p->vChunks ) Hop_ManStopMemory( p );
102  if ( p->vPis ) Vec_PtrFree( p->vPis );
103  if ( p->vPos ) Vec_PtrFree( p->vPos );
104  if ( p->vObjs ) Vec_PtrFree( p->vObjs );
105  ABC_FREE( p->pTable );
106  ABC_FREE( p );
107 }
108 
109 /**Function*************************************************************
110 
111  Synopsis [Returns the number of dangling nodes removed.]
112 
113  Description []
114 
115  SideEffects []
116 
117  SeeAlso []
118 
119 ***********************************************************************/
121 {
122  Vec_Ptr_t * vObjs;
123  Hop_Obj_t * pNode;
124  int i, nNodesOld;
125  assert( p->fRefCount );
126  nNodesOld = Hop_ManNodeNum(p);
127  // collect roots of dangling nodes
128  vObjs = Vec_PtrAlloc( 100 );
129  Hop_ManForEachNode( p, pNode, i )
130  if ( Hop_ObjRefs(pNode) == 0 )
131  Vec_PtrPush( vObjs, pNode );
132  // recursively remove dangling nodes
133  Vec_PtrForEachEntry( Hop_Obj_t *, vObjs, pNode, i )
134  Hop_ObjDelete_rec( p, pNode );
135  Vec_PtrFree( vObjs );
136  return nNodesOld - Hop_ManNodeNum(p);
137 }
138 
139 /**Function*************************************************************
140 
141  Synopsis [Stops the AIG manager.]
142 
143  Description []
144 
145  SideEffects []
146 
147  SeeAlso []
148 
149 ***********************************************************************/
151 {
152  printf( "PI/PO = %d/%d. ", Hop_ManPiNum(p), Hop_ManPoNum(p) );
153  printf( "A = %7d. ", Hop_ManAndNum(p) );
154  printf( "X = %5d. ", Hop_ManExorNum(p) );
155  printf( "Cre = %7d. ", p->nCreated );
156  printf( "Del = %7d. ", p->nDeleted );
157  printf( "Lev = %3d. ", Hop_ManCountLevels(p) );
158  printf( "\n" );
159 }
160 
161 
162 
163 ////////////////////////////////////////////////////////////////////////
164 /// END OF FILE ///
165 ////////////////////////////////////////////////////////////////////////
166 
167 
169 
char * memset()
ABC_NAMESPACE_IMPL_START Hop_Man_t * Hop_ManStart()
DECLARATIONS ///.
Definition: hopMan.c:45
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Hop_ObjRefs(Hop_Obj_t *pObj)
Definition: hop.h:176
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachNode(p, pObj, i)
Definition: hop.h:265
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
void Hop_ObjDelete_rec(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopObj.c:214
#define Hop_ManForEachPo(p, pObj, i)
Definition: hop.h:262
int Hop_ManCountLevels(Hop_Man_t *p)
Definition: hopDfs.c:116
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Hop_ManStartMemory(Hop_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: hopMem.c:49
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Hop_ManPoNum(Hop_Man_t *p)
Definition: hop.h:146
Definition: hop.h:65
void Hop_ManStop(Hop_Man_t *p)
Definition: hopMan.c:84
unsigned int fMarkA
Definition: hop.h:77
void Hop_ManPrintStats(Hop_Man_t *p)
Definition: hopMan.c:150
static int Hop_ManAndNum(Hop_Man_t *p)
Definition: hop.h:147
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static Hop_Obj_t * Hop_ManFetchMemory(Hop_Man_t *p)
Definition: hop.h:230
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static int Hop_ManExorNum(Hop_Man_t *p)
Definition: hop.h:148
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Definition: hop.h:56
#define assert(ex)
Definition: util_old.h:213
int Hop_ManCleanup(Hop_Man_t *p)
Definition: hopMan.c:120
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
unsigned int fMarkB
Definition: hop.h:78
static int Hop_ManNodeNum(Hop_Man_t *p)
Definition: hop.h:149
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145
void Hop_ManStopMemory(Hop_Man_t *p)
Definition: hopMem.c:66