summaryrefslogtreecommitdiffstats
path: root/src/opt/rwr/rwrUtil.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2005-08-17 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2005-08-17 08:01:00 -0700
commit6e496de7ff1a1f9b6f0babc8efb0a13379242505 (patch)
tree3abc09837e77c60f932a7b6e2c227b217a1936f6 /src/opt/rwr/rwrUtil.c
parent9b3fa55b8a6fca4fb75e0bbc9a8d52c5ab3c11e4 (diff)
downloadabc-6e496de7ff1a1f9b6f0babc8efb0a13379242505.tar.gz
abc-6e496de7ff1a1f9b6f0babc8efb0a13379242505.tar.bz2
abc-6e496de7ff1a1f9b6f0babc8efb0a13379242505.zip
Version abc50817
Diffstat (limited to 'src/opt/rwr/rwrUtil.c')
-rw-r--r--src/opt/rwr/rwrUtil.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/opt/rwr/rwrUtil.c b/src/opt/rwr/rwrUtil.c
new file mode 100644
index 00000000..ae8665ef
--- /dev/null
+++ b/src/opt/rwr/rwrUtil.c
@@ -0,0 +1,102 @@
+/**CFile****************************************************************
+
+ FileName [rwrUtil.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [DAG-aware AIG rewriting package.]
+
+ Synopsis [Various utilities.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: rwrUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "rwr.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Creates the array of fanout counters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Rwt_NtkFanoutCounters( Abc_Ntk_t * pNtk )
+{
+ Vec_Int_t * vFanNums;
+ Abc_Obj_t * pObj;
+ int i;
+ vFanNums = Vec_IntAlloc( 0 );
+ Vec_IntFill( vFanNums, Abc_NtkObjNumMax(pNtk), -1 );
+ Abc_NtkForEachObj( pNtk, pObj, i )
+ if ( Abc_ObjIsNode( pObj ) )
+ Vec_IntWriteEntry( vFanNums, i, Abc_ObjFanoutNum(pObj) );
+ return vFanNums;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the array of required times.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Rwt_NtkRequiredLevels( Abc_Ntk_t * pNtk )
+{
+ Vec_Int_t * vReqTimes;
+ Vec_Ptr_t * vNodes;
+ Abc_Obj_t * pObj, * pFanout;
+ int i, k, nLevelsMax, nLevelsCur;
+ // start the required times
+ vReqTimes = Vec_IntAlloc( 0 );
+ Vec_IntFill( vReqTimes, Abc_NtkObjNumMax(pNtk), ABC_INFINITY );
+ // compute levels in reverse topological order
+ Abc_NtkForEachCo( pNtk, pObj, i )
+ Vec_IntWriteEntry( vReqTimes, pObj->Id, 0 );
+ vNodes = Abc_NtkDfsReverse( pNtk );
+ Vec_PtrForEachEntry( vNodes, pObj, i )
+ {
+ nLevelsCur = 0;
+ Abc_ObjForEachFanout( pObj, pFanout, k )
+ if ( nLevelsCur < Vec_IntEntry(vReqTimes, pFanout->Id) )
+ nLevelsCur = Vec_IntEntry(vReqTimes, pFanout->Id);
+ Vec_IntWriteEntry( vReqTimes, pObj->Id, nLevelsCur + 1 );
+ }
+ Vec_PtrFree( vNodes );
+ // convert levels into required times: RetTime = NumLevels + 1 - Level
+ nLevelsMax = Abc_AigGetLevelNum(pNtk) + 1;
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ Vec_IntWriteEntry( vReqTimes, pObj->Id, nLevelsMax - Vec_IntEntry(vReqTimes, pObj->Id) );
+// Abc_NtkForEachNode( pNtk, pObj, i )
+// printf( "(%d,%d)", pObj->Level, Vec_IntEntry(vReqTimes, pObj->Id) );
+// printf( "\n" );
+ return vReqTimes;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+