summaryrefslogtreecommitdiffstats
path: root/src/aig/gia/giaChoice.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-10-24 17:39:38 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-10-24 17:39:38 -0700
commit6b96d9a84e1356295c8c25588915701bd9160001 (patch)
tree620261ecac8299bd3b259a11bef7b513efefb7a4 /src/aig/gia/giaChoice.c
parent5cd1396b3d752c968cd558f02625ce5f12688415 (diff)
downloadabc-6b96d9a84e1356295c8c25588915701bd9160001.tar.gz
abc-6b96d9a84e1356295c8c25588915701bd9160001.tar.bz2
abc-6b96d9a84e1356295c8c25588915701bd9160001.zip
Integrating GIA with LUT mapping.
Diffstat (limited to 'src/aig/gia/giaChoice.c')
-rw-r--r--src/aig/gia/giaChoice.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/aig/gia/giaChoice.c b/src/aig/gia/giaChoice.c
index 85f0a372..ca2acb28 100644
--- a/src/aig/gia/giaChoice.c
+++ b/src/aig/gia/giaChoice.c
@@ -20,6 +20,7 @@
#include "gia.h"
#include "giaAig.h"
+#include "misc/tim/tim.h"
ABC_NAMESPACE_IMPL_START
@@ -261,6 +262,108 @@ int Gia_ManHasChoices( Gia_Man_t * p )
return 1;
}
+
+/**Function*************************************************************
+
+ Synopsis [Computes levels for AIG with choices and white boxes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManChoiceLevel_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
+ Gia_Obj_t * pNext;
+ int i, iBox, iTerm1, nTerms, LevelMax = 0;
+ if ( Gia_ObjIsTravIdCurrent( p, pObj ) )
+ return;
+ Gia_ObjSetTravIdCurrent( p, pObj );
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ if ( pManTime )
+ {
+ iBox = Tim_ManBoxForCi( pManTime, Gia_ObjCioId(pObj) );
+ if ( iBox >= 0 ) // this is not a true PI
+ {
+ iTerm1 = Tim_ManBoxInputFirst( pManTime, iBox );
+ nTerms = Tim_ManBoxInputNum( pManTime, iBox );
+ for ( i = 0; i < nTerms; i++ )
+ {
+ pNext = Gia_ManCo( p, iTerm1 + i );
+ Gia_ManChoiceLevel_rec( p, pNext );
+ if ( LevelMax < Gia_ObjLevel(p, pNext) )
+ LevelMax = Gia_ObjLevel(p, pNext);
+ }
+ LevelMax++;
+ }
+ }
+// Abc_Print( 1, "%d ", pObj->Level );
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ {
+ pNext = Gia_ObjFanin0(pObj);
+ Gia_ManChoiceLevel_rec( p, pNext );
+ if ( LevelMax < Gia_ObjLevel(p, pNext) )
+ LevelMax = Gia_ObjLevel(p, pNext);
+ }
+ else if ( Gia_ObjIsAnd(pObj) )
+ {
+ // get the maximum level of the two fanins
+ pNext = Gia_ObjFanin0(pObj);
+ Gia_ManChoiceLevel_rec( p, pNext );
+ if ( LevelMax < Gia_ObjLevel(p, pNext) )
+ LevelMax = Gia_ObjLevel(p, pNext);
+ pNext = Gia_ObjFanin1(pObj);
+ Gia_ManChoiceLevel_rec( p, pNext );
+ if ( LevelMax < Gia_ObjLevel(p, pNext) )
+ LevelMax = Gia_ObjLevel(p, pNext);
+ LevelMax++;
+
+ // get the level of the nodes in the choice node
+ if ( p->pSibls && (pNext = Gia_ObjSiblObj(p, Gia_ObjId(p, pObj))) )
+ {
+ Gia_ManChoiceLevel_rec( p, pNext );
+ if ( LevelMax < Gia_ObjLevel(p, pNext) )
+ LevelMax = Gia_ObjLevel(p, pNext);
+ }
+ }
+ else if ( !Gia_ObjIsConst0(pObj) )
+ assert( 0 );
+ Gia_ObjSetLevel( p, pObj, LevelMax );
+}
+int Gia_ManChoiceLevel( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, LevelMax = 0;
+// assert( Gia_ManRegNum(p) == 0 );
+ Gia_ManCleanLevels( p, Gia_ManObjNum(p) );
+ Gia_ManIncrementTravId( p );
+ Gia_ManForEachCo( p, pObj, i )
+ {
+ Gia_ManChoiceLevel_rec( p, pObj );
+ if ( LevelMax < Gia_ObjLevel(p, pObj) )
+ LevelMax = Gia_ObjLevel(p, pObj);
+ }
+ // account for dangling boxes
+ Gia_ManForEachCi( p, pObj, i )
+ {
+ Gia_ManChoiceLevel_rec( p, pObj );
+ if ( LevelMax < Gia_ObjLevel(p, pObj) )
+ LevelMax = Gia_ObjLevel(p, pObj);
+// Abc_Print( 1, "%d ", Gia_ObjLevel(p, pObj) );
+ }
+// Abc_Print( 1, "\n" );
+ Gia_ManForEachAnd( p, pObj, i )
+ assert( Gia_ObjLevel(p, pObj) > 0 );
+// printf( "Max level %d\n", LevelMax );
+ return LevelMax;
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////