Commit 92ad58ff by Alan Mishchenko

Adding iterative refinement to 'addbuffs'.

parent 7e21f012
......@@ -2072,7 +2072,7 @@ Abc_Obj_t * Abc_NtkAddBuffsOne( Vec_Ptr_t * vBuffs, Abc_Obj_t * pFanin, int Leve
}
return pBuffer;
}
Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fReverse, int nImprove, int fVerbose )
Abc_Ntk_t * Abc_NtkAddBuffsInt( Abc_Ntk_t * pNtkInit, int fReverse, int nImprove, int fVerbose )
{
Vec_Ptr_t * vBuffs;
Abc_Ntk_t * pNtk = Abc_NtkDup( pNtkInit );
......@@ -2120,7 +2120,7 @@ Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fReverse, int nImprove, i
}
}
if ( fVerbose )
printf( "Shifted %d nodes down with total gain %d.\n", Counter, TotalGain );
printf( "Shifted %5d nodes down with total gain %5d.\n", Counter, TotalGain );
if ( Counter == 0 )
break;
}
......@@ -2155,7 +2155,7 @@ Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fReverse, int nImprove, i
}
}
if ( fVerbose )
printf( "Shifted %d nodes up with total gain %d.\n", Counter, TotalGain );
printf( "Shifted %5d nodes up with total gain %5d.\n", Counter, TotalGain );
if ( Counter == 0 )
break;
}
......@@ -2182,6 +2182,27 @@ Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fReverse, int nImprove, i
pObj->Level = 0;
return pNtk;
}
Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fDirect, int fReverse, int nImprove, int fVerbose )
{
Abc_Ntk_t * pNtkD, * pNtkR;
if ( fDirect )
return Abc_NtkAddBuffsInt( pNtkInit, 0, nImprove, fVerbose );
if ( fReverse )
return Abc_NtkAddBuffsInt( pNtkInit, 1, nImprove, fVerbose );
pNtkD = Abc_NtkAddBuffsInt( pNtkInit, 0, nImprove, fVerbose );
pNtkR = Abc_NtkAddBuffsInt( pNtkInit, 1, nImprove, fVerbose );
if ( Abc_NtkNodeNum(pNtkD) < Abc_NtkNodeNum(pNtkR) )
{
Abc_NtkDelete( pNtkR );
return pNtkD;
}
else
{
Abc_NtkDelete( pNtkD );
return pNtkR;
}
}
/**Function*************************************************************
......
......@@ -4550,18 +4550,20 @@ usage:
***********************************************************************/
int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtk, int fReverse, int nImprove, int fVerbose );
extern Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtk, int fDirect, int fReverse, int nImprove, int fVerbose );
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Ntk_t * pNtkRes;
int c, fVerbose;
int fDirect;
int fReverse;
int nImprove;
int c, fVerbose;
nImprove = 1000;
fDirect = 0;
fReverse = 0;
nImprove = 1000;
fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Irvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "Idrvh" ) ) != EOF )
{
switch ( c )
{
......@@ -4576,6 +4578,9 @@ int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nImprove < 0 )
goto usage;
break;
case 'd':
fDirect ^= 1;
break;
case 'r':
fReverse ^= 1;
break;
......@@ -4601,7 +4606,7 @@ int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv )
}
// modify the current network
pNtkRes = Abc_NtkAddBuffs( pNtk, fReverse, nImprove, fVerbose );
pNtkRes = Abc_NtkAddBuffs( pNtk, fDirect, fReverse, nImprove, fVerbose );
if ( pNtkRes == NULL )
{
Abc_Print( -1, "The command has failed.\n" );
......@@ -4612,10 +4617,11 @@ int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
Abc_Print( -2, "usage: addbuffs [-I num] [-rvh]\n" );
Abc_Print( -2, "usage: addbuffs [-I num] [-drvh]\n" );
Abc_Print( -2, "\t adds buffers to create balanced CI/CO paths\n" );
Abc_Print( -2, "\t-I <num> : the number of refinement iterations [default = %d]\n", nImprove );
Abc_Print( -2, "\t-r : toggle reversing the levelized order [default = %s]\n", fReverse? "yes": "no" );
Abc_Print( -2, "\t-d : toggle using only CI-to-CO levelized order [default = %s]\n", fDirect? "yes": "no" );
Abc_Print( -2, "\t-r : toggle using only CO-to-C1 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-h : print the command usage\n");
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