Commit 423d929d by Alan Mishchenko

QBF-based code generation (extending beyond 32 bits).

parent de82737e
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "sat/bsat/satStore.h" #include "sat/bsat/satStore.h"
#include "misc/extra/extra.h" #include "misc/extra/extra.h"
#include "sat/glucose/AbcGlucose.h" #include "sat/glucose/AbcGlucose.h"
#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
...@@ -282,7 +283,7 @@ Gia_Man_t * Gia_Gen2CreateMiter( int nLutSize, int nLutNum ) ...@@ -282,7 +283,7 @@ Gia_Man_t * Gia_Gen2CreateMiter( int nLutSize, int nLutNum )
pNew = Gia_ManCleanup( pTemp = pNew ); pNew = Gia_ManCleanup( pTemp = pNew );
Gia_ManStop( pTemp ); Gia_ManStop( pTemp );
printf( "Generated QBF miter with %d parameters, %d functional variables, and %d AIG nodes.\n", printf( "Generated QBF miter with %d parameters, %d functional variables, and %d AIG nodes.\n",
nLutNum * (1 << nLutSize), 2*nLutNum, Gia_ManAndNum(pNew) ); nLutNum * (1 << nLutSize), 2*nLutSize, Gia_ManAndNum(pNew) );
return pNew; return pNew;
} }
int Gia_Gen2CodeOne( int nLutSize, int nLutNum, Vec_Int_t * vCode, int x ) int Gia_Gen2CodeOne( int nLutSize, int nLutNum, Vec_Int_t * vCode, int x )
...@@ -293,6 +294,15 @@ int Gia_Gen2CodeOne( int nLutSize, int nLutNum, Vec_Int_t * vCode, int x ) ...@@ -293,6 +294,15 @@ int Gia_Gen2CodeOne( int nLutSize, int nLutNum, Vec_Int_t * vCode, int x )
Code |= (1 << k); Code |= (1 << k);
return Code; return Code;
} }
word * Gia_Gen2CodeOneP( int nLutSize, int nLutNum, Vec_Int_t * vCode, int x )
{
word * pRes = ABC_CALLOC( word, Abc_Bit6WordNum(nLutNum) );
int k;
for ( k = 0; k < nLutNum; k++ )
if ( Vec_IntEntry(vCode, k*(1 << nLutSize)+x) )
Abc_InfoSetBit( (unsigned *)pRes, k );
return pRes;
}
void Gia_Gen2CodePrint( int nLutSize, int nLutNum, Vec_Int_t * vCode ) void Gia_Gen2CodePrint( int nLutSize, int nLutNum, Vec_Int_t * vCode )
{ {
// |<-- PVars(0)-->|...|<-- PVars(nLutNum-1)-->| // |<-- PVars(0)-->|...|<-- PVars(nLutNum-1)-->|
...@@ -300,13 +310,15 @@ void Gia_Gen2CodePrint( int nLutSize, int nLutNum, Vec_Int_t * vCode ) ...@@ -300,13 +310,15 @@ void Gia_Gen2CodePrint( int nLutSize, int nLutNum, Vec_Int_t * vCode )
printf( "%d-input %d-output code table:\n", nLutSize, nLutNum ); printf( "%d-input %d-output code table:\n", nLutSize, nLutNum );
for ( i = 0; i < (1 << nLutSize); i++ ) for ( i = 0; i < (1 << nLutSize); i++ )
{ {
int Code = Gia_Gen2CodeOne( nLutSize, nLutNum, vCode, i ); word * CodeX = Gia_Gen2CodeOneP( nLutSize, nLutNum, vCode, i );
printf( "%3d ", i ); printf( "%3d ", i );
Extra_PrintBinary( stdout, (unsigned *)&i, nLutSize ); Extra_PrintBinary( stdout, (unsigned *)&i, nLutSize );
printf( " --> " ); printf( " --> " );
printf( "%3d ", Code ); if ( nLutNum <= 16 )
Extra_PrintBinary( stdout, (unsigned *)&Code, nLutNum ); printf( "%5d ", (int)CodeX[0] );
Extra_PrintBinary( stdout, (unsigned *)CodeX, nLutNum );
printf( "\n" ); printf( "\n" );
ABC_FREE( CodeX );
} }
// create several different pairs // create several different pairs
srand( time(NULL) ); srand( time(NULL) );
...@@ -314,41 +326,48 @@ void Gia_Gen2CodePrint( int nLutSize, int nLutNum, Vec_Int_t * vCode ) ...@@ -314,41 +326,48 @@ void Gia_Gen2CodePrint( int nLutSize, int nLutNum, Vec_Int_t * vCode )
for ( n = 0; n < nPairs; n++ ) for ( n = 0; n < nPairs; n++ )
{ {
unsigned MaskIn = Abc_InfoMask( nLutSize ); unsigned MaskIn = Abc_InfoMask( nLutSize );
unsigned MaskOut = Abc_InfoMask( nLutNum ); int NumX = 0, NumY = 0, NumXY, nWords = Abc_Bit6WordNum(nLutNum);
int CodeX, CodeY, CodeXY, CodeXCodeY; word * CodeX, * CodeY, * CodeXY;
int NumX = 0, NumY = 0, NumXY; word * CodeXCodeY = ABC_CALLOC( word, nWords );
while ( NumX == NumY ) while ( NumX == NumY )
{ {
NumX = rand() % (1 << nLutSize); NumX = rand() % (1 << nLutSize);
NumY = rand() % (1 << nLutSize); NumY = rand() % (1 << nLutSize);
NumXY = MaskIn & ~(NumX & NumY); NumXY = MaskIn & ~(NumX & NumY);
} }
CodeX = Gia_Gen2CodeOne( nLutSize, nLutNum, vCode, NumX ); CodeX = Gia_Gen2CodeOneP( nLutSize, nLutNum, vCode, NumX );
CodeY = Gia_Gen2CodeOne( nLutSize, nLutNum, vCode, NumY ); CodeY = Gia_Gen2CodeOneP( nLutSize, nLutNum, vCode, NumY );
CodeXY = Gia_Gen2CodeOne( nLutSize, nLutNum, vCode, NumXY ); CodeXY = Gia_Gen2CodeOneP( nLutSize, nLutNum, vCode, NumXY );
CodeXCodeY = MaskOut & ~(CodeX & CodeY); Abc_TtAnd( CodeXCodeY, CodeX, CodeY, nWords, 1 );
if ( nLutNum < 64*nWords )
CodeXCodeY[nWords-1] &= Abc_Tt6Mask(nLutNum % 64);
printf( "%2d :", n ); printf( "%2d :", n );
printf( " x =%3d ", NumX ); printf( " x =%3d ", NumX );
Extra_PrintBinary( stdout,(unsigned *) &NumX, nLutSize ); Extra_PrintBinary( stdout,(unsigned *) &NumX, nLutSize );
printf( " y =%3d ", NumY ); printf( " y =%3d ", NumY );
Extra_PrintBinary( stdout, (unsigned *)&NumY, nLutSize ); Extra_PrintBinary( stdout, (unsigned *)&NumY, nLutSize );
printf( " nand =%3d ", NumXY ); printf( " nand =%3d ", NumXY );
Extra_PrintBinary( stdout, (unsigned *)&NumXY, nLutSize ); Extra_PrintBinary( stdout, (unsigned *)&NumXY, nLutSize );
printf( " " ); printf( " " );
printf( " c(x) =%3d ", CodeX ); printf( " c(x) = " );
Extra_PrintBinary( stdout, (unsigned *)&CodeX, nLutNum ); Extra_PrintBinary( stdout, (unsigned *)CodeX, nLutNum );
printf( " c(y) =%3d ", CodeY ); printf( " c(y) = " );
Extra_PrintBinary( stdout, (unsigned *)&CodeY, nLutNum ); Extra_PrintBinary( stdout, (unsigned *)CodeY, nLutNum );
printf( " c(nand) =%3d ", CodeXY ); printf( " c(nand) = " );
Extra_PrintBinary( stdout, (unsigned *)&CodeXY, nLutNum ); Extra_PrintBinary( stdout, (unsigned *)CodeXY, nLutNum );
printf( " nand(c(x), c(y)) =%3d ", CodeXCodeY ); printf( " nand(c(x),c(y)) = " );
Extra_PrintBinary( stdout, (unsigned *)&CodeXCodeY, nLutNum ); Extra_PrintBinary( stdout, (unsigned *)CodeXCodeY, nLutNum );
printf( " " ); printf( " " );
printf( "%s", CodeXCodeY == CodeXY ? "yes" : "no" ); printf( "%s", Abc_TtEqual(CodeXCodeY, CodeXY, nWords) ? "yes" : "no" );
printf( "\n" ); printf( "\n" );
ABC_FREE( CodeX );
ABC_FREE( CodeY );
ABC_FREE( CodeXY );
ABC_FREE( CodeXCodeY );
} }
} }
void Gia_Gen2CodeTest() void Gia_Gen2CodeTest()
......
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