00001
00021 #include "cswInt.h"
00022
00026
00030
00042 Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVerbose )
00043 {
00044 Csw_Man_t * p;
00045 Aig_Obj_t * pObj;
00046 int i;
00047 assert( nCutsMax >= 2 );
00048 assert( nLeafMax <= 16 );
00049
00050 p = ALLOC( Csw_Man_t, 1 );
00051 memset( p, 0, sizeof(Csw_Man_t) );
00052 p->nCutsMax = nCutsMax;
00053 p->nLeafMax = nLeafMax;
00054 p->fVerbose = fVerbose;
00055 p->pManAig = pMan;
00056
00057 p->pManRes = Aig_ManStartFrom( pMan );
00058 assert( Aig_ManPiNum(p->pManAig) == Aig_ManPiNum(p->pManRes) );
00059
00060 p->pnRefs = ALLOC( int, Aig_ManObjNumMax(pMan) );
00061 p->pEquiv = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pMan) );
00062 p->pCuts = ALLOC( Csw_Cut_t *, Aig_ManObjNumMax(pMan) );
00063 memset( p->pCuts, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pMan) );
00064 memset( p->pnRefs, 0, sizeof(int) * Aig_ManObjNumMax(pMan) );
00065
00066 p->nTruthWords = Aig_TruthWordNum(nLeafMax);
00067 p->nCutSize = sizeof(Csw_Cut_t) + sizeof(int) * nLeafMax + sizeof(unsigned) * p->nTruthWords;
00068 p->pMemCuts = Aig_MmFixedStart( p->nCutSize * p->nCutsMax, 512 );
00069
00070 p->nTableSize = Aig_PrimeCudd( Aig_ManNodeNum(pMan) * p->nCutsMax / 2 );
00071 p->pTable = ALLOC( Csw_Cut_t *, p->nTableSize );
00072 memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
00073
00074 Csw_ObjSetEquiv( p, Aig_ManConst1(p->pManAig), Aig_ManConst1(p->pManRes) );
00075 Aig_ManForEachPi( p->pManAig, pObj, i )
00076 Csw_ObjSetEquiv( p, pObj, Aig_ManPi(p->pManRes, i) );
00077
00078 p->puTemp[0] = ALLOC( unsigned, 4 * p->nTruthWords );
00079 p->puTemp[1] = p->puTemp[0] + p->nTruthWords;
00080 p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
00081 p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
00082 return p;
00083 }
00084
00096 void Csw_ManStop( Csw_Man_t * p )
00097 {
00098 if ( p->fVerbose )
00099 {
00100 int nNodesBeg = Aig_ManNodeNum(p->pManAig);
00101 int nNodesEnd = Aig_ManNodeNum(p->pManRes);
00102 printf( "Beg = %7d. End = %7d. (%6.2f %%) Try = %7d. Cuts = %8d.\n",
00103 nNodesBeg, nNodesEnd, 100.0*(nNodesBeg-nNodesEnd)/nNodesBeg,
00104 p->nNodesTried, Csw_TableCountCuts( p ) );
00105 printf( "Triv0 = %6d. Triv1 = %6d. Triv2 = %6d. Cut-replace = %6d.\n",
00106 p->nNodesTriv0, p->nNodesTriv1, p->nNodesTriv2, p->nNodesCuts );
00107 PRTP( "Cuts ", p->timeCuts, p->timeTotal );
00108 PRTP( "Hashing ", p->timeHash, p->timeTotal );
00109 PRTP( "Other ", p->timeOther, p->timeTotal );
00110 PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
00111 }
00112 free( p->puTemp[0] );
00113 Aig_MmFixedStop( p->pMemCuts, 0 );
00114 free( p->pnRefs );
00115 free( p->pEquiv );
00116 free( p->pCuts );
00117 free( p->pTable );
00118 free( p );
00119 }
00120
00124
00125