00001
00021 #include "hop.h"
00022
00026
00030
00042 Hop_Man_t * Hop_ManStart()
00043 {
00044 Hop_Man_t * p;
00045
00046 p = ALLOC( Hop_Man_t, 1 );
00047 memset( p, 0, sizeof(Hop_Man_t) );
00048
00049 p->nTravIds = 1;
00050 p->fRefCount = 1;
00051 p->fCatchExor = 0;
00052
00053 p->vPis = Vec_PtrAlloc( 100 );
00054 p->vPos = Vec_PtrAlloc( 100 );
00055
00056 Hop_ManStartMemory( p );
00057
00058 p->pConst1 = Hop_ManFetchMemory( p );
00059 p->pConst1->Type = AIG_CONST1;
00060 p->pConst1->fPhase = 1;
00061 p->nCreated = 1;
00062
00063
00064 p->nTableSize = 10007;
00065 p->pTable = ALLOC( Hop_Obj_t *, p->nTableSize );
00066 memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize );
00067 return p;
00068 }
00069
00081 void Hop_ManStop( Hop_Man_t * p )
00082 {
00083 Hop_Obj_t * pObj;
00084 int i;
00085
00086 pObj = Hop_ManConst1(p);
00087 assert( !pObj->fMarkA && !pObj->fMarkB );
00088 Hop_ManForEachPi( p, pObj, i )
00089 assert( !pObj->fMarkA && !pObj->fMarkB );
00090 Hop_ManForEachPo( p, pObj, i )
00091 assert( !pObj->fMarkA && !pObj->fMarkB );
00092 Hop_ManForEachNode( p, pObj, i )
00093 assert( !pObj->fMarkA && !pObj->fMarkB );
00094
00095 if ( p->time1 ) { PRT( "time1", p->time1 ); }
00096 if ( p->time2 ) { PRT( "time2", p->time2 ); }
00097
00098 if ( p->vChunks ) Hop_ManStopMemory( p );
00099 if ( p->vPis ) Vec_PtrFree( p->vPis );
00100 if ( p->vPos ) Vec_PtrFree( p->vPos );
00101 if ( p->vObjs ) Vec_PtrFree( p->vObjs );
00102 free( p->pTable );
00103 free( p );
00104 }
00105
00117 int Hop_ManCleanup( Hop_Man_t * p )
00118 {
00119 Vec_Ptr_t * vObjs;
00120 Hop_Obj_t * pNode;
00121 int i, nNodesOld;
00122 assert( p->fRefCount );
00123 nNodesOld = Hop_ManNodeNum(p);
00124
00125 vObjs = Vec_PtrAlloc( 100 );
00126 Hop_ManForEachNode( p, pNode, i )
00127 if ( Hop_ObjRefs(pNode) == 0 )
00128 Vec_PtrPush( vObjs, pNode );
00129
00130 Vec_PtrForEachEntry( vObjs, pNode, i )
00131 Hop_ObjDelete_rec( p, pNode );
00132 Vec_PtrFree( vObjs );
00133 return nNodesOld - Hop_ManNodeNum(p);
00134 }
00135
00147 void Hop_ManPrintStats( Hop_Man_t * p )
00148 {
00149 printf( "PI/PO = %d/%d. ", Hop_ManPiNum(p), Hop_ManPoNum(p) );
00150 printf( "A = %7d. ", Hop_ManAndNum(p) );
00151 printf( "X = %5d. ", Hop_ManExorNum(p) );
00152 printf( "Cre = %7d. ", p->nCreated );
00153 printf( "Del = %7d. ", p->nDeleted );
00154 printf( "Lev = %3d. ", Hop_ManCountLevels(p) );
00155 printf( "\n" );
00156 }
00157
00158
00159
00163
00164