Commit e293489f by Alan Mishchenko

Preprocessing for multi-output PLA tables.

parent 6c3f1911
...@@ -34,6 +34,55 @@ static Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros ); ...@@ -34,6 +34,55 @@ static Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros );
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Checks if cubes are distance-1.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Io_ReadPlaPrintCube( word * p, int nVars )
{
char Symbs[3] = {'-', '0', '1'}; int v;
for ( v = 0; v < nVars; v++ )
printf( "%c", Symbs[Abc_TtGetQua(p, v)] );
printf( "\n" );
}
/**Function*************************************************************
Synopsis [Checks if cubes are distance-1.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Io_ReadPlaDistance1( word * p, word * q, int nWords )
{
word Test; int c, fFound = 0;
for ( c = 0; c < nWords; c++ )
{
if ( p[c] == q[c] )
continue;
if ( fFound )
return 0;
// check if the number of 1s is one
// Test = ((p[c] ^ q[c]) & ((p[c] ^ q[c]) >> 1)) & ABC_CONST(0x5555555555555555); // exactly one 0/1 literal (but may be -/0 or -/1)
Test = ((p[c] ^ q[c]) | ((p[c] ^ q[c]) >> 1)) & ABC_CONST(0x5555555555555555);
if ( !Abc_TtOnlyOneOne(Test) )
return 0;
fFound = 1;
}
return fFound;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -88,6 +137,34 @@ int Io_ReadPlaRemoveMarked( word ** pCs, int nCubes, int nWords, Vec_Bit_t * vMa ...@@ -88,6 +137,34 @@ int Io_ReadPlaRemoveMarked( word ** pCs, int nCubes, int nWords, Vec_Bit_t * vMa
} }
return c; return c;
} }
int Io_ReadPlaCountDistance1( word ** pCs, int nCubes, int nWords, Vec_Bit_t * vMarks )
{
int c1, c2, Res, Counter = 0;
Vec_BitFill( vMarks, nCubes, 0 );
for ( c1 = 0; c1 < nCubes; c1++ )
if ( !Vec_BitEntry(vMarks, c1) )
for ( c2 = c1 + 1; c2 < nCubes; c2++ )
if ( !Vec_BitEntry(vMarks, c2) )
{
Res = Io_ReadPlaDistance1( pCs[c1], pCs[c2], nWords );
if ( !Res )
continue;
/*
if ( Counter % 100 )
{
printf( "\n" );
Io_ReadPlaPrintCube( pCs[c1], 32 * nWords );
Io_ReadPlaPrintCube( pCs[c2], 32 * nWords );
printf( "\n" );
}
*/
Abc_TtAnd( pCs[c1], pCs[c1], pCs[c2], nWords, 0 );
Vec_BitWriteEntry( vMarks, c2, 1 );
Counter++;
break;
}
return Counter;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -125,16 +202,12 @@ word ** Io_ReadPlaCubeSetup( Vec_Str_t * vSop ) ...@@ -125,16 +202,12 @@ word ** Io_ReadPlaCubeSetup( Vec_Str_t * vSop )
} }
void Io_ReadPlaCubeSetdown( Vec_Str_t * vSop, word ** pCs, int nCubes, int nVars ) void Io_ReadPlaCubeSetdown( Vec_Str_t * vSop, word ** pCs, int nCubes, int nVars )
{ {
char Symbs[3] = {'-', '0', '1'}; char Symbs[3] = {'-', '0', '1'}; int c, v;
int c, v, Lit;
Vec_StrClear( vSop ); Vec_StrClear( vSop );
for ( c = 0; c < nCubes; c++ ) for ( c = 0; c < nCubes; c++ )
{ {
for ( v = 0; v < nVars && ((Lit = Abc_TtGetQua(pCs[c], v)), 1); v++ ) for ( v = 0; v < nVars; v++ )
{ Vec_StrPush( vSop, Symbs[Abc_TtGetQua(pCs[c], v)] );
assert( Lit < 3 );
Vec_StrPush( vSop, Symbs[Lit] );
}
Vec_StrPrintStr( vSop, " 1\n" ); Vec_StrPrintStr( vSop, " 1\n" );
} }
Vec_StrPush( vSop, 0 ); Vec_StrPush( vSop, 0 );
...@@ -144,24 +217,22 @@ void Io_ReadPlaCubePreprocess( Vec_Str_t * vSop, int iCover, int fVerbose ) ...@@ -144,24 +217,22 @@ void Io_ReadPlaCubePreprocess( Vec_Str_t * vSop, int iCover, int fVerbose )
word ** pCs = Io_ReadPlaCubeSetup( vSop ); word ** pCs = Io_ReadPlaCubeSetup( vSop );
int nCubes = Abc_SopGetCubeNum( Vec_StrArray(vSop) ); int nCubes = Abc_SopGetCubeNum( Vec_StrArray(vSop) );
int nVars = Abc_SopGetVarNum( Vec_StrArray(vSop) ); int nVars = Abc_SopGetVarNum( Vec_StrArray(vSop) );
int nWords = Abc_Bit6WordNum( 2*nVars ), nCubesNew; int nWords = Abc_Bit6WordNum( 2*nVars );
int nCubesNew, Count;
Vec_Bit_t * vMarks = Vec_BitStart( nCubes ); Vec_Bit_t * vMarks = Vec_BitStart( nCubes );
if ( fVerbose ) if ( fVerbose )
printf( "Cover %5d : V =%5d C =%5d P =%9d ", iCover, nVars, nCubes, nCubes*nCubes/2 ); printf( "Cover %5d : V =%5d C =%5d P =%9d ", iCover, nVars, nCubes, nCubes*nCubes/2 );
// check identical do
Io_ReadPlaMarkIdentical( pCs, nCubes, nWords, vMarks ); {
nCubesNew = Io_ReadPlaRemoveMarked( pCs, nCubes, nWords, vMarks ); // remove contained
if ( fVerbose ) Io_ReadPlaMarkContained( pCs, nCubes, nWords, vMarks );
printf( " Equal =%5d", nCubes - nCubesNew ); nCubesNew = Io_ReadPlaRemoveMarked( pCs, nCubes, nWords, vMarks );
nCubes = nCubesNew; if ( fVerbose )
// check contained printf( " C =%5d", nCubes - nCubesNew );
Io_ReadPlaMarkContained( pCs, nCubes, nWords, vMarks ); nCubes = nCubesNew;
nCubesNew = Io_ReadPlaRemoveMarked( pCs, nCubes, nWords, vMarks ); // merge distance-1
if ( fVerbose ) Count = Io_ReadPlaCountDistance1( pCs, nCubes, nWords, vMarks );
printf( " Contain =%5d", nCubes - nCubesNew ); } while ( Count );
nCubes = nCubesNew;
// check distance-1
// translate // translate
Io_ReadPlaCubeSetdown( vSop, pCs, nCubes, nVars ); Io_ReadPlaCubeSetdown( vSop, pCs, nCubes, nVars );
// finalize // finalize
......
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