Commit 0d802453 by Alan Mishchenko

Adding reverse order to 'addbuffs'.

parent f16457aa
...@@ -2030,7 +2030,7 @@ Abc_Obj_t * Abc_NtkAddBuffsOne( Vec_Ptr_t * vBuffs, Abc_Obj_t * pFanin, int Leve ...@@ -2030,7 +2030,7 @@ Abc_Obj_t * Abc_NtkAddBuffsOne( Vec_Ptr_t * vBuffs, Abc_Obj_t * pFanin, int Leve
} }
return pBuffer; return pBuffer;
} }
Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fVerbose ) Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fReverse, int fVerbose )
{ {
Vec_Ptr_t * vBuffs; Vec_Ptr_t * vBuffs;
Abc_Ntk_t * pNtk = Abc_NtkDup( pNtkInit ); Abc_Ntk_t * pNtk = Abc_NtkDup( pNtkInit );
...@@ -2038,6 +2038,21 @@ Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fVerbose ) ...@@ -2038,6 +2038,21 @@ Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fVerbose )
int i, k, nLevelMax = Abc_NtkLevel( pNtk ); int i, k, nLevelMax = Abc_NtkLevel( pNtk );
Abc_NtkForEachCo( pNtk, pObj, i ) Abc_NtkForEachCo( pNtk, pObj, i )
pObj->Level = nLevelMax + 1; pObj->Level = nLevelMax + 1;
if ( fReverse )
{
Vec_Ptr_t * vNodes = Abc_NtkDfs( pNtk, 1 );
assert( nLevelMax < (1<<18) );
Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pObj, i )
{
pObj->Level = (1<<18);
Abc_ObjForEachFanout( pObj, pFanin, k )
pObj->Level = Abc_MinInt( pFanin->Level - 1, pObj->Level );
assert( pObj->Level > 0 );
}
Vec_PtrFree( vNodes );
Abc_NtkForEachCi( pNtk, pObj, i )
pObj->Level = 0;
}
vBuffs = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) * (nLevelMax + 1) ); vBuffs = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) * (nLevelMax + 1) );
Abc_NtkForEachObj( pNtk, pObj, i ) Abc_NtkForEachObj( pNtk, pObj, i )
{ {
......
...@@ -4550,17 +4550,22 @@ usage: ...@@ -4550,17 +4550,22 @@ usage:
***********************************************************************/ ***********************************************************************/
int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
extern Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtk, int fVerbose ); extern Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtk, int fReverse, int fVerbose );
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Ntk_t * pNtkRes; Abc_Ntk_t * pNtkRes;
int c, fVerbose; int c, fVerbose;
int fReverse;
fReverse = 0;
fVerbose = 0; fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
case 'r':
fReverse ^= 1;
break;
case 'v': case 'v':
fVerbose ^= 1; fVerbose ^= 1;
break; break;
...@@ -4583,7 +4588,7 @@ int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -4583,7 +4588,7 @@ int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
// modify the current network // modify the current network
pNtkRes = Abc_NtkAddBuffs( pNtk, fVerbose ); pNtkRes = Abc_NtkAddBuffs( pNtk, fReverse, fVerbose );
if ( pNtkRes == NULL ) if ( pNtkRes == NULL )
{ {
Abc_Print( -1, "The command has failed.\n" ); Abc_Print( -1, "The command has failed.\n" );
...@@ -4594,8 +4599,9 @@ int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -4594,8 +4599,9 @@ int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: addbuffs [-vh]\n" ); Abc_Print( -2, "usage: addbuffs [-rvh]\n" );
Abc_Print( -2, "\t adds buffers to create balanced CI/CO paths\n" ); Abc_Print( -2, "\t adds buffers to create balanced CI/CO paths\n" );
Abc_Print( -2, "\t-r : toggle reversing the levelized order [default = %s]\n", fReverse? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n"); Abc_Print( -2, "\t-h : print the command usage\n");
return 1; return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment