summaryrefslogtreecommitdiffstats
path: root/src/aig/gia/giaUtil.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2009-04-10 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2009-04-10 08:01:00 -0700
commitccd1b57264d3bf1514410747cdcf6e4731ac7f2a (patch)
tree17993c239735ee63c4e8ed69cb1c3df7eacecc6d /src/aig/gia/giaUtil.c
parentdf6fdd1dffd8ce83dfc4a7868ebdd25241f8f24b (diff)
downloadabc-ccd1b57264d3bf1514410747cdcf6e4731ac7f2a.tar.gz
abc-ccd1b57264d3bf1514410747cdcf6e4731ac7f2a.tar.bz2
abc-ccd1b57264d3bf1514410747cdcf6e4731ac7f2a.zip
Version abc90410
Diffstat (limited to 'src/aig/gia/giaUtil.c')
-rw-r--r--src/aig/gia/giaUtil.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/aig/gia/giaUtil.c b/src/aig/gia/giaUtil.c
index 5716c1a0..54bc98dd 100644
--- a/src/aig/gia/giaUtil.c
+++ b/src/aig/gia/giaUtil.c
@@ -858,6 +858,114 @@ int Gia_NodeMffcSize( Gia_Man_t * p, Gia_Obj_t * pNode )
return ConeSize1;
}
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if AIG has choices.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManHasChoices( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, Counter1 = 0, Counter2 = 0;
+ int nFailNoRepr = 0;
+ int nFailHaveRepr = 0;
+ int nChoiceNodes = 0;
+ int nChoices = 0;
+ if ( p->pReprs == NULL || p->pNexts == NULL )
+ return 0;
+ // check if there are any representatives
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ if ( Gia_ObjReprObj( p, Gia_ObjId(p, pObj) ) )
+ Counter1++;
+ if ( Gia_ObjNext( p, Gia_ObjId(p, pObj) ) )
+ Counter2++;
+ }
+ if ( Counter1 == 0 )
+ {
+ printf( "Warning: AIG has repr data-strucure but not reprs.\n" );
+ return 0;
+ }
+// printf( "%d nodes have reprs.\n", Counter1 );
+// printf( "%d nodes have nexts.\n", Counter2 );
+ // check if there are any internal nodes without fanout
+ // make sure all nodes without fanout have representatives
+ // make sure all nodes with fanout have no representatives
+ ABC_FREE( p->pRefs );
+ Gia_ManCreateRefs( p );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ if ( Gia_ObjRefs(p, pObj) == 0 )
+ {
+ if ( Gia_ObjReprObj( p, Gia_ObjId(p, pObj) ) == NULL )
+ nFailNoRepr++;
+ else
+ nChoices++;
+ }
+ else
+ {
+ if ( Gia_ObjReprObj( p, Gia_ObjId(p, pObj) ) != NULL )
+ nFailHaveRepr++;
+ if ( Gia_ObjNextObj( p, Gia_ObjId(p, pObj) ) != NULL )
+ nChoiceNodes++;
+ }
+ if ( Gia_ObjReprObj( p, i ) )
+ assert( Gia_ObjRepr(p, i) < i );
+ }
+ if ( nChoices == 0 )
+ return 0;
+ if ( nFailNoRepr )
+ {
+ printf( "Gia_ManHasChoices(): Error: %d internal nodes have no fanout and no repr.\n", nFailNoRepr );
+// return 0;
+ }
+ if ( nFailHaveRepr )
+ {
+ printf( "Gia_ManHasChoices(): Error: %d internal nodes have both fanout and repr.\n", nFailHaveRepr );
+// return 0;
+ }
+// printf( "Gia_ManHasChoices(): AIG has %d choice nodes with %d choices.\n", nChoiceNodes, nChoices );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if AIG has dangling nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManHasDandling( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, Counter = 0;
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ pObj->fMark0 = 0;
+ if ( Gia_ObjIsAnd(pObj) )
+ {
+ Gia_ObjFanin0(pObj)->fMark0 = 1;
+ Gia_ObjFanin1(pObj)->fMark0 = 1;
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ Gia_ObjFanin0(pObj)->fMark0 = 1;
+ }
+ Gia_ManForEachAnd( p, pObj, i )
+ Counter += !pObj->fMark0;
+ Gia_ManCleanMark0( p );
+ return Counter;
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////