Commit c4839c92 by Alan Mishchenko

Fixing 'read_truth' to read a constant truth table

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