Commit 58e1041a by Alan Mishchenko

Modified command 'eliminate' to perform traditional 'eliminate -1'.

parent a33821ab
......@@ -511,6 +511,14 @@ int Abc_NodeCountAppearances( Abc_Obj_t * pFanin, Abc_Obj_t * pFanout )
assert( iFanin >= 0 && iFanin < Hop_ManPiNum(pMan) );
return Hop_ObjFanoutCount( (Hop_Obj_t *)pFanout->pData, Hop_IthVar(pMan, iFanin) );
}
int Abc_NodeCountAppearancesAll( Abc_Obj_t * pNode )
{
Abc_Obj_t * pFanout;
int i, Count = 0;
Abc_ObjForEachFanout( pNode, pFanout, i )
Count += Abc_NodeCountAppearances( pNode, pFanout );
return Count;
}
/**Function*************************************************************
......@@ -570,7 +578,7 @@ int Abc_NodeCollapse1( Abc_Obj_t * pFanin, Abc_Obj_t * pFanout, Vec_Ptr_t * vFan
Abc_NtkDeleteObj_rec( pFanout, 1 );
return 1;
}
int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose )
int Abc_NtkEliminate1One( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int fReverse, int fVerbose )
{
Vec_Ptr_t * vFanouts, * vFanins, * vNodes;
Abc_Obj_t * pNode, * pFanout;
......@@ -600,10 +608,10 @@ int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbos
if ( Abc_ObjFaninNum(pNode) > nMaxSize )
continue;
// skip nodes with more than one fanout
if ( Abc_ObjFanoutNum(pNode) != 1 )
continue;
// if ( Abc_ObjFanoutNum(pNode) != 1 )
// continue;
// skip nodes that appear in the FF of their fanout more than once
if ( Abc_NodeCountAppearances( pNode, Abc_ObjFanout(pNode, 0) ) != 1 )
if ( Abc_NodeCountAppearancesAll( pNode ) > ElimValue + 2 )
continue;
Abc_ObjForEachFanout( pNode, pFanout, k )
if ( Abc_NodeCollapseSuppSize(pNode, pFanout, vFanins) > nMaxSize )
......@@ -634,6 +642,20 @@ int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbos
ABC_FREE( pPermFanout );
return 1;
}
int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int fReverse, int fVerbose )
{
int i;
for ( i = 0; i < 3; i++ )
{
int nNodes = Abc_NtkNodeNum(pNtk);
// printf( "%d ", nNodes );
if ( !Abc_NtkEliminate1One(pNtk, ElimValue, nMaxSize, fReverse, fVerbose) )
return 0;
if ( nNodes == Abc_NtkNodeNum(pNtk) )
break;
}
return 1;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
......@@ -3668,23 +3668,36 @@ int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int nMaxSize;
int ElimValue;
int fGreedy;
int fReverse;
int fVerbose;
int c;
extern int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose );
extern int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose );
extern int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int fReverse, int fVerbose );
// set the defaults
nMaxSize = 30;
ElimValue = -1;
fGreedy = 0;
fReverse = 0;
fVerbose = 0;
Extra_UtilGetoptReset();
while ( (c = Extra_UtilGetopt(argc, argv, "Ngrvh")) != EOF )
while ( (c = Extra_UtilGetopt(argc, argv, "VNgrvh")) != EOF )
{
switch (c)
{
case 'V':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer that is -1 or larger.\n" );
goto usage;
}
ElimValue = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( ElimValue < -1 )
goto usage;
break;
case 'N':
if ( globalUtilOptind >= argc )
{
......@@ -3734,13 +3747,14 @@ int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( fGreedy )
Abc_NtkEliminate( pNtk, nMaxSize, fReverse, fVerbose );
else
Abc_NtkEliminate1( pNtk, nMaxSize, fReverse, fVerbose );
Abc_NtkEliminate1( pNtk, ElimValue, nMaxSize, fReverse, fVerbose );
return 0;
usage:
Abc_Print( -2, "usage: eliminate [-N <num>] [-grvh]\n");
Abc_Print( -2, "usage: eliminate [-VN <num>] [-grvh]\n");
Abc_Print( -2, "\t traditional \"eliminate -1\", which collapses the node into its fanout\n");
Abc_Print( -2, "\t if the node's variable appears in the fanout's factored form only once\n");
Abc_Print( -2, "\t-V <num> : the \"value\" parameter used by \"eliminate\" in SIS [default = %d]\n", ElimValue );
Abc_Print( -2, "\t-N <num> : the maximum node support after collapsing [default = %d]\n", nMaxSize );
Abc_Print( -2, "\t-g : toggle using greedy eliminate (without \"value\") [default = %s]\n", fGreedy? "yes": "no" );
Abc_Print( -2, "\t-r : use the reverse topological order [default = %s]\n", fReverse? "yes": "no" );
......
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