Commit 5f976129 by Alan Mishchenko

Imporvements to 'eliminate'.

parent e731d3b1
......@@ -106,8 +106,8 @@ Gia_Man_t * Gia_ManMapShrink4( Gia_Man_t * p, int fKeepLevel, int fVerbose )
// change from node IDs to their literals
Gia_ManForEachObjVec( vLeaves, p, pFanin, k )
{
assert( Gia_ObjValue(pFanin) != ~0 );
Vec_IntWriteEntry( vLeaves, k, Gia_ObjValue(pFanin) );
// assert( Gia_ObjValue(pFanin) != ~0 );
Vec_IntWriteEntry( vLeaves, k, Gia_ObjValue(pFanin) != ~0 ? Gia_ObjValue(pFanin) : 0 );
}
// derive new structre
if ( Gia_ManTruthIsConst0(pTruth, Vec_IntSize(vLeaves)) )
......
......@@ -326,7 +326,8 @@ extern void Hop_TableDelete( Hop_Man_t * p, Hop_Obj_t * pObj );
extern int Hop_TableCountEntries( Hop_Man_t * p );
extern void Hop_TableProfile( Hop_Man_t * p );
/*=== hopTruth.c ========================================================*/
unsigned * Hop_ManConvertAigToTruth( Hop_Man_t * p, Hop_Obj_t * pRoot, int nVars, Vec_Int_t * vTruth, int fMsbFirst );
extern unsigned * Hop_ManConvertAigToTruth( Hop_Man_t * p, Hop_Obj_t * pRoot, int nVars, Vec_Int_t * vTruth, int fMsbFirst );
extern word Hop_ManComputeTruth6( Hop_Man_t * p, Hop_Obj_t * pObj, int nVars );
/*=== hopUtil.c =========================================================*/
extern void Hop_ManIncrementTravId( Hop_Man_t * p );
extern void Hop_ManCleanData( Hop_Man_t * p );
......
......@@ -218,6 +218,53 @@ unsigned * Hop_ManConvertAigToTruth( Hop_Man_t * p, Hop_Obj_t * pRoot, int nVars
return pTruth;
}
/**Function*************************************************************
Synopsis [Compute truth table.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static word Truth[8] =
{
ABC_CONST(0xAAAAAAAAAAAAAAAA),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF)
};
word Hop_ManComputeTruth6_rec( Hop_Man_t * p, Hop_Obj_t * pObj )
{
word Truth0, Truth1;
if ( Hop_ObjIsPi(pObj) )
return Truth[pObj->iData];
assert( Hop_ObjIsNode(pObj) );
Truth0 = Hop_ManComputeTruth6_rec( p, Hop_ObjFanin0(pObj) );
Truth1 = Hop_ManComputeTruth6_rec( p, Hop_ObjFanin1(pObj) );
Truth0 = Hop_ObjFaninC0(pObj) ? ~Truth0 : Truth0;
Truth1 = Hop_ObjFaninC1(pObj) ? ~Truth1 : Truth1;
return Truth0 & Truth1;
}
word Hop_ManComputeTruth6( Hop_Man_t * p, Hop_Obj_t * pObj, int nVars )
{
word Truth;
int i;
if ( Hop_ObjIsConst1( Hop_Regular(pObj) ) )
return Hop_IsComplement(pObj) ? 0 : ~(word)0;
for ( i = 0; i < nVars; i++ )
Hop_ManPi( p, i )->iData = i;
Truth = Hop_ManComputeTruth6_rec( p, Hop_Regular(pObj) );
return Hop_IsComplement(pObj) ? ~Truth : Truth;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -578,6 +578,22 @@ int Abc_NodeCollapse1( Abc_Obj_t * pFanin, Abc_Obj_t * pFanout, Vec_Ptr_t * vFan
Abc_NtkDeleteObj_rec( pFanout, 1 );
return 1;
}
int Abc_NodeIsExor( Abc_Obj_t * pNode )
{
Hop_Man_t * pMan;
word Truth;
if ( Abc_ObjFaninNum(pNode) < 3 || Abc_ObjFaninNum(pNode) > 6 )
return 0;
pMan = (Hop_Man_t *)pNode->pNtk->pManFunc;
Truth = Hop_ManComputeTruth6( pMan, (Hop_Obj_t *)pNode->pData, Abc_ObjFaninNum(pNode) );
if ( Truth == 0x6666666666666666 || Truth == 0x9999999999999999 ||
Truth == 0x9696969696969696 || Truth == 0x6969696969696969 ||
Truth == 0x6996699669966996 || Truth == 0x9669966996699669 ||
Truth == 0x9669699696696996 || Truth == 0x6996966969969669 ||
Truth == 0x6996966996696996 || Truth == 0x9669699669969669 )
return 1;
return 0;
}
int Abc_NtkEliminate1One( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int fReverse, int fVerbose )
{
Vec_Ptr_t * vFanouts, * vFanins, * vNodes;
......@@ -607,6 +623,8 @@ int Abc_NtkEliminate1One( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int fRe
continue;
if ( Abc_ObjFaninNum(pNode) > nMaxSize )
continue;
if ( Abc_NodeIsExor(pNode) )
continue;
// skip nodes with more than one fanout
// if ( Abc_ObjFanoutNum(pNode) != 1 )
// continue;
......@@ -642,10 +660,10 @@ int Abc_NtkEliminate1One( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int fRe
ABC_FREE( pPermFanout );
return 1;
}
int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int fReverse, int fVerbose )
int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int nIterMax, int fReverse, int fVerbose )
{
int i;
for ( i = 0; i < 3; i++ )
for ( i = 0; i < nIterMax; i++ )
{
int nNodes = Abc_NtkNodeNum(pNtk);
// printf( "%d ", nNodes );
......
......@@ -3746,23 +3746,25 @@ usage:
int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int nMaxSize;
int ElimValue;
int nMaxSize;
int nIterMax;
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 ElimValue, int nMaxSize, int fReverse, int fVerbose );
extern int Abc_NtkEliminate1( Abc_Ntk_t * pNtk, int ElimValue, int nMaxSize, int nIterMax, int fReverse, int fVerbose );
// set the defaults
nMaxSize = 30;
ElimValue = -1;
nMaxSize = 12;
nIterMax = 1;
fGreedy = 0;
fReverse = 0;
fVerbose = 0;
Extra_UtilGetoptReset();
while ( (c = Extra_UtilGetopt(argc, argv, "VNgrvh")) != EOF )
while ( (c = Extra_UtilGetopt(argc, argv, "VNIgrvh")) != EOF )
{
switch (c)
{
......@@ -3788,6 +3790,17 @@ int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nMaxSize <= 0 )
goto usage;
break;
case 'I':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
goto usage;
}
nIterMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nIterMax <= 0 )
goto usage;
break;
case 'g':
fGreedy ^= 1;
break;
......@@ -3826,15 +3839,16 @@ int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( fGreedy )
Abc_NtkEliminate( pNtk, nMaxSize, fReverse, fVerbose );
else
Abc_NtkEliminate1( pNtk, ElimValue, nMaxSize, fReverse, fVerbose );
Abc_NtkEliminate1( pNtk, ElimValue, nMaxSize, nIterMax, fReverse, fVerbose );
return 0;
usage:
Abc_Print( -2, "usage: eliminate [-VN <num>] [-grvh]\n");
Abc_Print( -2, "usage: eliminate [-VNI <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-I <num> : the maximum number of iterations [default = %d]\n", nIterMax );
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" );
Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", fVerbose? "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