diff options
Diffstat (limited to 'src/aig')
-rw-r--r-- | src/aig/gia/gia.h | 2 | ||||
-rw-r--r-- | src/aig/gia/giaBalance.c | 19 | ||||
-rw-r--r-- | src/aig/gia/giaUtil.c | 48 |
3 files changed, 64 insertions, 5 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index b10a0677..4d1e2f26 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -1229,6 +1229,8 @@ extern void Gia_ManSetPhase1( Gia_Man_t * p ); extern void Gia_ManCleanPhase( Gia_Man_t * p ); extern int Gia_ManCheckCoPhase( 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_ManRequiredLevel( Gia_Man_t * p ); extern void Gia_ManCreateValueRefs( Gia_Man_t * p ); diff --git a/src/aig/gia/giaBalance.c b/src/aig/gia/giaBalance.c index 80888d29..d3bb8407 100644 --- a/src/aig/gia/giaBalance.c +++ b/src/aig/gia/giaBalance.c @@ -521,9 +521,6 @@ void Dam_ManCreatePairs( Dam_Man_t * p, int fVerbose ) int nPairsAll = 0, nPairsTried = 0, nPairsUsed = 0, nPairsXor = 0; int nDivsAll = 0, nDivsUsed = 0, nDivsXor = 0; 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; vDivs = Vec_IntAlloc( Gia_ManObjNum(p->pGia) ); vHash = Hash_IntManStart( Gia_ManObjNum(p->pGia)/2 ); @@ -711,7 +708,10 @@ Gia_Man_t * Dam_ManMultiAig( Dam_Man_t * pMan ) Gia_ManFillValue( p ); Gia_ManConst0(p)->Value = 0; Gia_ManForEachCi( p, pObj, i ) + { pObj->Value = Gia_ManAppendCi( pNew ); + Vec_IntWriteEntry( pNew->vLevels, Abc_Lit2Var(pObj->Value), Gia_ObjLevel(p, pObj) ); + } // create internal nodes Gia_ManHashStart( pNew ); Gia_ManForEachCo( p, pObj, i ) @@ -912,12 +912,15 @@ void Dam_ManUpdate( Dam_Man_t * p, int iDiv ) 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; Dam_Man_t * p; int i, iDiv; 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 ); 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 Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax, int fVerbose, int fVeryVerbose ) { 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 pNew0 = Gia_ManHasMapping(p) ? (Gia_Man_t *)Dsm_ManDeriveGia(p, 0) : p; if ( fVerbose ) Gia_ManPrintStats( pNew0, NULL ); @@ -954,9 +962,10 @@ Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax, if ( fVerbose ) Gia_ManPrintStats( pNew, NULL ); if ( pNew0 != p ) Gia_ManStop( pNew0 ); // perform the operation - pNew1 = Dam_ManAreaBalanceInt( pNew, nNewNodesMax, fVerbose, fVeryVerbose ); + pNew1 = Dam_ManAreaBalanceInt( pNew, vCiLevels, nNewNodesMax, fVerbose, fVeryVerbose ); if ( fVerbose ) Gia_ManPrintStats( pNew1, NULL ); Gia_ManStop( pNew ); + Vec_IntFree( vCiLevels ); // derive the final result pNew2 = Gia_ManDupNoMuxes( pNew1 ); if ( fVerbose ) Gia_ManPrintStats( pNew2, NULL ); diff --git a/src/aig/gia/giaUtil.c b/src/aig/gia/giaUtil.c index f97dfc86..353edb86 100644 --- a/src/aig/gia/giaUtil.c +++ b/src/aig/gia/giaUtil.c @@ -508,6 +508,54 @@ int Gia_ManLevelNum( Gia_Man_t * p ) /**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.] Description [] |