Commit 103fa663 by Alan Mishchenko

More accurate level calculation in AIG balancing.

parent 1c564752
...@@ -1229,6 +1229,8 @@ extern void Gia_ManSetPhase1( Gia_Man_t * p ); ...@@ -1229,6 +1229,8 @@ extern void Gia_ManSetPhase1( Gia_Man_t * p );
extern void Gia_ManCleanPhase( Gia_Man_t * p ); extern void Gia_ManCleanPhase( Gia_Man_t * p );
extern int Gia_ManCheckCoPhase( Gia_Man_t * p ); extern int Gia_ManCheckCoPhase( Gia_Man_t * p );
extern int Gia_ManLevelNum( Gia_Man_t * p ); extern int Gia_ManLevelNum( Gia_Man_t * p );
extern Vec_Int_t * Gia_ManGetCiLevels( Gia_Man_t * p );
extern int Gia_ManSetLevels( Gia_Man_t * p, Vec_Int_t * vCiLevels );
extern Vec_Int_t * Gia_ManReverseLevel( Gia_Man_t * p ); extern Vec_Int_t * Gia_ManReverseLevel( Gia_Man_t * p );
extern Vec_Int_t * Gia_ManRequiredLevel( Gia_Man_t * p ); extern Vec_Int_t * Gia_ManRequiredLevel( Gia_Man_t * p );
extern void Gia_ManCreateValueRefs( Gia_Man_t * p ); extern void Gia_ManCreateValueRefs( Gia_Man_t * p );
......
...@@ -521,9 +521,6 @@ void Dam_ManCreatePairs( Dam_Man_t * p, int fVerbose ) ...@@ -521,9 +521,6 @@ void Dam_ManCreatePairs( Dam_Man_t * p, int fVerbose )
int nPairsAll = 0, nPairsTried = 0, nPairsUsed = 0, nPairsXor = 0; int nPairsAll = 0, nPairsTried = 0, nPairsUsed = 0, nPairsXor = 0;
int nDivsAll = 0, nDivsUsed = 0, nDivsXor = 0; int nDivsAll = 0, nDivsUsed = 0, nDivsXor = 0;
Dam_ManCollectSets( p ); Dam_ManCollectSets( p );
p->nLevelMax = Gia_ManLevelNum( p->pGia );
p->vNodLevR = Gia_ManReverseLevel( p->pGia );
Vec_IntFillExtra( p->pGia->vLevels, 3*Gia_ManObjNum(p->pGia)/2, 0 );
vSuper = p->pGia->vSuper; vSuper = p->pGia->vSuper;
vDivs = Vec_IntAlloc( Gia_ManObjNum(p->pGia) ); vDivs = Vec_IntAlloc( Gia_ManObjNum(p->pGia) );
vHash = Hash_IntManStart( Gia_ManObjNum(p->pGia)/2 ); vHash = Hash_IntManStart( Gia_ManObjNum(p->pGia)/2 );
...@@ -711,7 +708,10 @@ Gia_Man_t * Dam_ManMultiAig( Dam_Man_t * pMan ) ...@@ -711,7 +708,10 @@ Gia_Man_t * Dam_ManMultiAig( Dam_Man_t * pMan )
Gia_ManFillValue( p ); Gia_ManFillValue( p );
Gia_ManConst0(p)->Value = 0; Gia_ManConst0(p)->Value = 0;
Gia_ManForEachCi( p, pObj, i ) Gia_ManForEachCi( p, pObj, i )
{
pObj->Value = Gia_ManAppendCi( pNew ); pObj->Value = Gia_ManAppendCi( pNew );
Vec_IntWriteEntry( pNew->vLevels, Abc_Lit2Var(pObj->Value), Gia_ObjLevel(p, pObj) );
}
// create internal nodes // create internal nodes
Gia_ManHashStart( pNew ); Gia_ManHashStart( pNew );
Gia_ManForEachCo( p, pObj, i ) Gia_ManForEachCo( p, pObj, i )
...@@ -912,12 +912,15 @@ void Dam_ManUpdate( Dam_Man_t * p, int iDiv ) ...@@ -912,12 +912,15 @@ void Dam_ManUpdate( Dam_Man_t * p, int iDiv )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Gia_Man_t * Dam_ManAreaBalanceInt( Gia_Man_t * pGia, int nNewNodesMax, int fVerbose, int fVeryVerbose ) Gia_Man_t * Dam_ManAreaBalanceInt( Gia_Man_t * pGia, Vec_Int_t * vCiLevels, int nNewNodesMax, int fVerbose, int fVeryVerbose )
{ {
Gia_Man_t * pNew; Gia_Man_t * pNew;
Dam_Man_t * p; Dam_Man_t * p;
int i, iDiv; int i, iDiv;
p = Dam_ManAlloc( pGia ); p = Dam_ManAlloc( pGia );
p->nLevelMax = Gia_ManSetLevels( p->pGia, vCiLevels );
p->vNodLevR = Gia_ManReverseLevel( p->pGia );
Vec_IntFillExtra( p->pGia->vLevels, 3*Gia_ManObjNum(p->pGia)/2, 0 );
Dam_ManCreatePairs( p, fVerbose ); Dam_ManCreatePairs( p, fVerbose );
for ( i = 0; i < nNewNodesMax && Vec_QueTopPriority(p->vQue) >= 2; i++ ) for ( i = 0; i < nNewNodesMax && Vec_QueTopPriority(p->vQue) >= 2; i++ )
{ {
...@@ -946,6 +949,11 @@ Gia_Man_t * Dam_ManAreaBalanceInt( Gia_Man_t * pGia, int nNewNodesMax, int fVerb ...@@ -946,6 +949,11 @@ Gia_Man_t * Dam_ManAreaBalanceInt( Gia_Man_t * pGia, int nNewNodesMax, int fVerb
Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax, int fVerbose, int fVeryVerbose ) Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax, int fVerbose, int fVeryVerbose )
{ {
Gia_Man_t * pNew0, * pNew, * pNew1, * pNew2; Gia_Man_t * pNew0, * pNew, * pNew1, * pNew2;
Vec_Int_t * vCiLevels;
// determine CI levels
if ( p->pManTime && p->vLevels == NULL )
Gia_ManLevelWithBoxes( p );
vCiLevels = Gia_ManGetCiLevels( p );
// get the starting manager // get the starting manager
pNew0 = Gia_ManHasMapping(p) ? (Gia_Man_t *)Dsm_ManDeriveGia(p, 0) : p; pNew0 = Gia_ManHasMapping(p) ? (Gia_Man_t *)Dsm_ManDeriveGia(p, 0) : p;
if ( fVerbose ) Gia_ManPrintStats( pNew0, NULL ); if ( fVerbose ) Gia_ManPrintStats( pNew0, NULL );
...@@ -954,9 +962,10 @@ Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax, ...@@ -954,9 +962,10 @@ Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax,
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL ); if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
if ( pNew0 != p ) Gia_ManStop( pNew0 ); if ( pNew0 != p ) Gia_ManStop( pNew0 );
// perform the operation // perform the operation
pNew1 = Dam_ManAreaBalanceInt( pNew, nNewNodesMax, fVerbose, fVeryVerbose ); pNew1 = Dam_ManAreaBalanceInt( pNew, vCiLevels, nNewNodesMax, fVerbose, fVeryVerbose );
if ( fVerbose ) Gia_ManPrintStats( pNew1, NULL ); if ( fVerbose ) Gia_ManPrintStats( pNew1, NULL );
Gia_ManStop( pNew ); Gia_ManStop( pNew );
Vec_IntFree( vCiLevels );
// derive the final result // derive the final result
pNew2 = Gia_ManDupNoMuxes( pNew1 ); pNew2 = Gia_ManDupNoMuxes( pNew1 );
if ( fVerbose ) Gia_ManPrintStats( pNew2, NULL ); if ( fVerbose ) Gia_ManPrintStats( pNew2, NULL );
......
...@@ -508,6 +508,54 @@ int Gia_ManLevelNum( Gia_Man_t * p ) ...@@ -508,6 +508,54 @@ int Gia_ManLevelNum( Gia_Man_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Assigns levels using CI level information.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Gia_ManGetCiLevels( Gia_Man_t * p )
{
Vec_Int_t * vCiLevels;
Gia_Obj_t * pObj;
int i;
if ( p->vLevels == NULL )
return NULL;
vCiLevels = Vec_IntAlloc( Gia_ManCiNum(p) );
Gia_ManForEachCi( p, pObj, i )
Vec_IntPush( vCiLevels, Gia_ObjLevel(p, pObj) );
return vCiLevels;
}
int Gia_ManSetLevels( Gia_Man_t * p, Vec_Int_t * vCiLevels )
{
Gia_Obj_t * pObj;
int i;
if ( vCiLevels == NULL )
return Gia_ManLevelNum( p );
Gia_ManCleanLevels( p, Gia_ManObjNum(p) );
p->nLevels = 0;
Gia_ManForEachCi( p, pObj, i )
{
Gia_ObjSetLevel( p, pObj, Vec_IntEntry(vCiLevels, i) );
p->nLevels = Abc_MaxInt( p->nLevels, Gia_ObjLevel(p, pObj) );
}
Gia_ManForEachObj( p, pObj, i )
{
if ( Gia_ObjIsAnd(pObj) )
Gia_ObjSetGateLevel( p, pObj );
else if ( Gia_ObjIsCo(pObj) )
Gia_ObjSetCoLevel( p, pObj );
else continue;
p->nLevels = Abc_MaxInt( p->nLevels, Gia_ObjLevel(p, pObj) );
}
return p->nLevels;
}
/**Function*************************************************************
Synopsis [Compute reverse levels.] Synopsis [Compute reverse levels.]
Description [] Description []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment