Commit c4839c92 by Alan Mishchenko

Fixing 'read_truth' to read a constant truth table

parent c2517679
......@@ -984,13 +984,24 @@ char * Abc_SopFromTruthBin( char * pTruth )
if ( Digit == 1 )
Vec_IntPush( vMints, nTruthSize - 1 - i );
}
/*
if ( Vec_IntSize( vMints ) == 0 || Vec_IntSize( vMints ) == nTruthSize )
{
Vec_IntFree( vMints );
printf( "Cannot create constant function.\n" );
return NULL;
}
*/
if ( Vec_IntSize(vMints) == 0 || Vec_IntSize(vMints) == (1 << nVars) )
{
pSopCover = ABC_ALLOC( char, 4 );
pSopCover[0] = ' ';
pSopCover[1] = '0' + (Vec_IntSize(vMints) > 0);
pSopCover[2] = '\n';
pSopCover[3] = 0;
}
else
{
// create the SOP representation of the minterms
Length = Vec_IntSize(vMints) * (nVars + 3);
pSopCover = ABC_ALLOC( char, Length + 1 );
......@@ -999,7 +1010,7 @@ char * Abc_SopFromTruthBin( char * pTruth )
{
pCube = pSopCover + i * (nVars + 3);
for ( b = 0; b < nVars; b++ )
// if ( Mint & (1 << (nVars-1-b)) )
// if ( Mint & (1 << (nVars-1-b)) )
if ( Mint & (1 << b) )
pCube[b] = '1';
else
......@@ -1008,6 +1019,7 @@ char * Abc_SopFromTruthBin( char * pTruth )
pCube[nVars + 1] = '1';
pCube[nVars + 2] = '\n';
}
}
Vec_IntFree( vMints );
return pSopCover;
}
......@@ -1074,6 +1086,16 @@ char * Abc_SopFromTruthHex( char * pTruth )
}
// create the SOP representation of the minterms
if ( Vec_IntSize(vMints) == 0 || Vec_IntSize(vMints) == (1 << nVars) )
{
pSopCover = ABC_ALLOC( char, 4 );
pSopCover[0] = ' ';
pSopCover[1] = '0' + (Vec_IntSize(vMints) > 0);
pSopCover[2] = '\n';
pSopCover[3] = 0;
}
else
{
Length = Vec_IntSize(vMints) * (nVars + 3);
pSopCover = ABC_ALLOC( char, Length + 1 );
pSopCover[Length] = 0;
......@@ -1081,7 +1103,7 @@ char * Abc_SopFromTruthHex( char * pTruth )
{
pCube = pSopCover + i * (nVars + 3);
for ( b = 0; b < nVars; b++ )
// if ( Mint & (1 << (nVars-1-b)) )
// if ( Mint & (1 << (nVars-1-b)) )
if ( Mint & (1 << b) )
pCube[b] = '1';
else
......@@ -1090,21 +1112,8 @@ char * Abc_SopFromTruthHex( char * pTruth )
pCube[nVars + 1] = '1';
pCube[nVars + 2] = '\n';
}
/*
// create TT representation
{
extern void Bdc_ManDecomposeTest( unsigned uTruth, int nVars );
unsigned uTruth = 0;
int nVarsAll = 4;
assert( nVarsAll == 4 );
assert( nVars <= nVarsAll );
Vec_IntForEachEntry( vMints, Mint, i )
uTruth |= (1 << Mint);
// uTruth = uTruth | (uTruth << 8) | (uTruth << 16) | (uTruth << 24);
uTruth = uTruth | (uTruth << 16);
Bdc_ManDecomposeTest( uTruth, nVarsAll );
}
*/
Vec_IntFree( vMints );
return pSopCover;
}
......
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