summaryrefslogtreecommitdiffstats
path: root/src/aig/hop
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2013-04-28 15:02:03 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2013-04-28 15:02:03 -0700
commit48d867f77db72b70371a08f99e2e8771bbf007ff (patch)
treebf0c72f934b6755d05260c7f68d3f77897947ffb /src/aig/hop
parent8db0b9c0c6520071e51cc660ac0436ec9ee79571 (diff)
downloadabc-48d867f77db72b70371a08f99e2e8771bbf007ff.tar.gz
abc-48d867f77db72b70371a08f99e2e8771bbf007ff.tar.bz2
abc-48d867f77db72b70371a08f99e2e8771bbf007ff.zip
Modified command 'eliminate' to perform traditional 'eliminate -1'.
Diffstat (limited to 'src/aig/hop')
-rw-r--r--src/aig/hop/hop.h2
-rw-r--r--src/aig/hop/hopDfs.c65
2 files changed, 67 insertions, 0 deletions
diff --git a/src/aig/hop/hop.h b/src/aig/hop/hop.h
index 1e991b38..d8ce8062 100644
--- a/src/aig/hop/hop.h
+++ b/src/aig/hop/hop.h
@@ -281,11 +281,13 @@ extern Vec_Ptr_t * Hop_ManDfsNode( Hop_Man_t * p, Hop_Obj_t * pNode );
extern int Hop_ManCountLevels( Hop_Man_t * p );
extern void Hop_ManCreateRefs( Hop_Man_t * p );
extern int Hop_DagSize( Hop_Obj_t * pObj );
+extern int Hop_ObjFanoutCount( Hop_Obj_t * pObj, Hop_Obj_t * pPivot );
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_Complement( Hop_Man_t * p, Hop_Obj_t * pRoot, int iVar );
extern Hop_Obj_t * Hop_Remap( Hop_Man_t * p, Hop_Obj_t * pRoot, unsigned uSupp, int nVars );
+extern Hop_Obj_t * Hop_Permute( Hop_Man_t * p, Hop_Obj_t * pRoot, int nRootVars, int * pPermute );
/*=== 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 e8ca970f..0706382f 100644
--- a/src/aig/hop/hopDfs.c
+++ b/src/aig/hop/hopDfs.c
@@ -286,6 +286,38 @@ int Hop_DagSize( Hop_Obj_t * pObj )
/**Function*************************************************************
+ Synopsis [Counts how many fanout the given node has.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Hop_ObjFanoutCount_rec( Hop_Obj_t * pObj, Hop_Obj_t * pPivot )
+{
+ int Counter;
+ assert( !Hop_IsComplement(pObj) );
+ if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
+ return (int)(pObj == pPivot);
+ Counter = Hop_ObjFanoutCount_rec( Hop_ObjFanin0(pObj), pPivot ) +
+ Hop_ObjFanoutCount_rec( Hop_ObjFanin1(pObj), pPivot );
+ assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
+ Hop_ObjSetMarkA( pObj );
+ return Counter;
+}
+int Hop_ObjFanoutCount( Hop_Obj_t * pObj, Hop_Obj_t * pPivot )
+{
+ int Counter;
+ assert( !Hop_IsComplement(pPivot) );
+ Counter = Hop_ObjFanoutCount_rec( Hop_Regular(pObj), pPivot );
+ Hop_ConeUnmark_rec( Hop_Regular(pObj) );
+ return Counter;
+}
+
+/**Function*************************************************************
+
Synopsis [Transfers the AIG from one manager into another.]
Description []
@@ -517,6 +549,39 @@ Hop_Obj_t * Hop_Remap( Hop_Man_t * p, Hop_Obj_t * pRoot, unsigned uSupp, int nVa
return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
+/**Function*************************************************************
+
+ Synopsis [Permute the AIG according to the given permutation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Hop_Obj_t * Hop_Permute( Hop_Man_t * p, Hop_Obj_t * pRoot, int nRootVars, int * pPermute )
+{
+ Hop_Obj_t * pObj;
+ int i;
+ // return if constant
+ if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
+ return pRoot;
+ // create mapping
+ Hop_ManForEachPi( p, pObj, i )
+ {
+ if ( i == nRootVars )
+ break;
+ assert( pPermute[i] >= 0 && pPermute[i] < Hop_ManPiNum(p) );
+ pObj->pData = Hop_IthVar( p, pPermute[i] );
+ }
+ // recursively perform composition
+ Hop_Remap_rec( p, Hop_Regular(pRoot) );
+ // clear the markings
+ Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
+ return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////