diff options
Diffstat (limited to 'src/aig/hop')
-rw-r--r-- | src/aig/hop/hop.h | 3 | ||||
-rw-r--r-- | src/aig/hop/hopDfs.c | 68 | ||||
-rw-r--r-- | src/aig/hop/hopObj.c | 4 |
3 files changed, 72 insertions, 3 deletions
diff --git a/src/aig/hop/hop.h b/src/aig/hop/hop.h index 12374a49..05e6471e 100644 --- a/src/aig/hop/hop.h +++ b/src/aig/hop/hop.h @@ -188,7 +188,7 @@ static inline Hop_Obj_t * Hop_ObjChild0Copy( Hop_Obj_t * pObj ) { assert( !Hop_ static inline Hop_Obj_t * Hop_ObjChild1Copy( Hop_Obj_t * pObj ) { assert( !Hop_IsComplement(pObj) ); return Hop_ObjFanin1(pObj)? Hop_NotCond((Hop_Obj_t *)Hop_ObjFanin1(pObj)->pData, Hop_ObjFaninC1(pObj)) : NULL; } static inline int Hop_ObjLevel( Hop_Obj_t * pObj ) { return pObj->nRefs; } static inline int Hop_ObjLevelNew( Hop_Obj_t * pObj ) { return 1 + Hop_ObjIsExor(pObj) + AIG_MAX(Hop_ObjFanin0(pObj)->nRefs, Hop_ObjFanin1(pObj)->nRefs); } -static inline int Hop_ObjFaninPhase( Hop_Obj_t * pObj ) { return Hop_IsComplement(pObj)? !Hop_Regular(pObj)->fPhase : pObj->fPhase; } +static inline int Hop_ObjPhaseCompl( Hop_Obj_t * pObj ) { return Hop_IsComplement(pObj)? !Hop_Regular(pObj)->fPhase : pObj->fPhase; } static inline void Hop_ObjClean( Hop_Obj_t * pObj ) { memset( pObj, 0, sizeof(Hop_Obj_t) ); } static inline int Hop_ObjWhatFanin( Hop_Obj_t * pObj, Hop_Obj_t * pFanin ) { @@ -284,6 +284,7 @@ extern int Hop_DagSize( Hop_Obj_t * pObj ); extern void Hop_ConeUnmark_rec( Hop_Obj_t * pObj ); extern Hop_Obj_t * Hop_Transfer( Hop_Man_t * pSour, Hop_Man_t * pDest, Hop_Obj_t * pObj, int nVars ); extern Hop_Obj_t * Hop_Compose( Hop_Man_t * p, Hop_Obj_t * pRoot, Hop_Obj_t * pFunc, int iVar ); +extern Hop_Obj_t * Hop_Remap( Hop_Man_t * p, Hop_Obj_t * pRoot, unsigned uSupp, int nVars ); /*=== hopMan.c ==========================================================*/ extern Hop_Man_t * Hop_ManStart(); extern Hop_Man_t * Hop_ManDup( Hop_Man_t * p ); diff --git a/src/aig/hop/hopDfs.c b/src/aig/hop/hopDfs.c index 49e5f221..d798bc35 100644 --- a/src/aig/hop/hopDfs.c +++ b/src/aig/hop/hopDfs.c @@ -392,6 +392,74 @@ Hop_Obj_t * Hop_Compose( Hop_Man_t * p, Hop_Obj_t * pRoot, Hop_Obj_t * pFunc, in return Hop_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) ); } +/**Function************************************************************* + + Synopsis [Composes the AIG (pRoot) with the function (pFunc) using PI var (iVar).] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Hop_Remap_rec( Hop_Man_t * p, Hop_Obj_t * pObj ) +{ + assert( !Hop_IsComplement(pObj) ); + if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) ) + return; + Hop_Remap_rec( p, Hop_ObjFanin0(pObj) ); + Hop_Remap_rec( p, Hop_ObjFanin1(pObj) ); + pObj->pData = Hop_And( p, Hop_ObjChild0Copy(pObj), Hop_ObjChild1Copy(pObj) ); + assert( !Hop_ObjIsMarkA(pObj) ); // loop detection + Hop_ObjSetMarkA( pObj ); +} + +/**Function************************************************************* + + Synopsis [Composes the AIG (pRoot) with the function (pFunc) using PI var (iVar).] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Hop_Obj_t * Hop_Remap( Hop_Man_t * p, Hop_Obj_t * pRoot, unsigned uSupp, int nVars ) +{ + Hop_Obj_t * pObj; + int i, k; + // quit if the PI variable is not defined + if ( nVars > Hop_ManPiNum(p) ) + { + printf( "Hop_Remap(): The number of variables (%d) is more than the manager size (%d).\n", nVars, Hop_ManPiNum(p) ); + return NULL; + } + // return if constant + if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) ) + return pRoot; + if ( uSupp == 0 ) + return Hop_NotCond( Hop_ManConst0(p), Hop_ObjPhaseCompl(pRoot) ); + // set the PI mapping + k = 0; + Hop_ManForEachPi( p, pObj, i ) + { + if ( i == nVars ) + break; + if ( uSupp & (1 << i) ) + pObj->pData = Hop_IthVar(p, k++); + else + pObj->pData = Hop_ManConst0(p); + } + assert( k > 0 && k < nVars ); + // recursively perform composition + Hop_Remap_rec( p, Hop_Regular(pRoot) ); + // clear the markings + Hop_ConeUnmark_rec( Hop_Regular(pRoot) ); + return Hop_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) ); +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/hop/hopObj.c b/src/aig/hop/hopObj.c index c8e70dd3..69f63ee6 100644 --- a/src/aig/hop/hopObj.c +++ b/src/aig/hop/hopObj.c @@ -73,7 +73,7 @@ Hop_Obj_t * Hop_ObjCreatePo( Hop_Man_t * p, Hop_Obj_t * pDriver ) else pObj->nRefs = Hop_ObjLevel( Hop_Regular(pDriver) ); // set the phase - pObj->fPhase = Hop_ObjFaninPhase(pDriver); + pObj->fPhase = Hop_ObjPhaseCompl(pDriver); // update node counters of the manager p->nObjs[AIG_PO]++; return pObj; @@ -136,7 +136,7 @@ void Hop_ObjConnect( Hop_Man_t * p, Hop_Obj_t * pObj, Hop_Obj_t * pFan0, Hop_Obj else pObj->nRefs = Hop_ObjLevelNew( pObj ); // set the phase - pObj->fPhase = Hop_ObjFaninPhase(pFan0) & Hop_ObjFaninPhase(pFan1); + pObj->fPhase = Hop_ObjPhaseCompl(pFan0) & Hop_ObjPhaseCompl(pFan1); // add the node to the structural hash table Hop_TableInsert( p, pObj ); } |