Commit 86f76e95 by Alan Mishchenko

Expriments with functions (bug fixes).

parent 36f33bc7
...@@ -499,11 +499,12 @@ void Dau_ExactNpnPrint( Vec_Mem_t * vTtMem, Vec_Int_t * vNodSup, int nVars, int ...@@ -499,11 +499,12 @@ void Dau_ExactNpnPrint( Vec_Mem_t * vTtMem, Vec_Int_t * vNodSup, int nVars, int
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping, int nFronts ) void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping, int nFronts, abctime clk )
{ {
FILE * pFile; FILE * pFile;
char FileName[100]; char FileName[100];
int i, nWords = Abc_TtWordNum(nInputs); int i, nWords = Abc_TtWordNum(nInputs);
/*
// functions // functions
sprintf( FileName, "fun%d%d.ttd", nInputs, nVars ); sprintf( FileName, "fun%d%d.ttd", nInputs, nVars );
pFile = fopen( FileName, "wb" ); pFile = fopen( FileName, "wb" );
...@@ -511,6 +512,7 @@ void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt ...@@ -511,6 +512,7 @@ void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt
fwrite( Vec_MemReadEntry(vTtMemA, i), 8, nWords, pFile ); fwrite( Vec_MemReadEntry(vTtMemA, i), 8, nWords, pFile );
fwrite( Vec_IntArray(vMapping), 4, Vec_IntSize(vMapping), pFile ); fwrite( Vec_IntArray(vMapping), 4, Vec_IntSize(vMapping), pFile );
fclose( pFile ); fclose( pFile );
*/
// NPN classes // NPN classes
sprintf( FileName, "npn%d%d.ttd", nInputs, nVars ); sprintf( FileName, "npn%d%d.ttd", nInputs, nVars );
pFile = fopen( FileName, "wb" ); pFile = fopen( FileName, "wb" );
...@@ -518,14 +520,17 @@ void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt ...@@ -518,14 +520,17 @@ void Dau_TablesSave( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt
fwrite( Vec_MemReadEntry(vTtMem, i), 8, nWords, pFile ); fwrite( Vec_MemReadEntry(vTtMem, i), 8, nWords, pFile );
fwrite( Vec_IntArray(vNodSup), 4, Vec_IntSize(vNodSup), pFile ); fwrite( Vec_IntArray(vNodSup), 4, Vec_IntSize(vNodSup), pFile );
fclose( pFile ); fclose( pFile );
printf( "Dumped files with %10d functions and %10d classes after exploring %10d frontiers.\n", // printf( "Dumped files with %10d functions and %10d classes after exploring %10d frontiers.\n",
Vec_IntSize(vMapping), Vec_IntSize(vNodSup), nFronts ); // Vec_IntSize(vMapping), Vec_IntSize(vNodSup), nFronts );
printf( "Dumped file \"%s\" with %10d classes after exploring %10d frontiers. ",
FileName, Vec_IntSize(vNodSup), nFronts );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
fflush(stdout); fflush(stdout);
} }
void Dau_TablesLoad( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping ) void Dau_TablesLoad( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping )
{ {
char FileName1[100], FileName2[100]; char FileName1[100], FileName2[100];
int i, FileSize1, FileSize2, nWords = Abc_TtWordNum(nInputs); int i, RetValue, FileSize1, FileSize2, nWords = Abc_TtWordNum(nInputs);
// functions // functions
sprintf( FileName1, "fun%d%d.ttd", nInputs, nVars ); sprintf( FileName1, "fun%d%d.ttd", nInputs, nVars );
FileSize1 = Extra_FileSize( FileName1 ); FileSize1 = Extra_FileSize( FileName1 );
...@@ -537,11 +542,11 @@ void Dau_TablesLoad( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt ...@@ -537,11 +542,11 @@ void Dau_TablesLoad( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt
assert( FileSize1 % 12 == 0 ); assert( FileSize1 % 12 == 0 );
for ( i = 0; i < nEntries; i++ ) for ( i = 0; i < nEntries; i++ )
{ {
fread( &uTruth, 8, nWords, pFile ); RetValue = fread( &uTruth, 8, nWords, pFile );
Vec_MemHashInsert( vTtMem, &uTruth ); Vec_MemHashInsert( vTtMem, &uTruth );
} }
Vec_IntFill( vNodSup, nEntries, -1 ); Vec_IntFill( vNodSup, nEntries, -1 );
fread( Vec_IntArray(vNodSup), 4, Vec_IntSize(vNodSup), pFile ); RetValue = fread( Vec_IntArray(vNodSup), 4, Vec_IntSize(vNodSup), pFile );
fclose( pFile ); fclose( pFile );
} }
// classes // classes
...@@ -555,13 +560,14 @@ void Dau_TablesLoad( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt ...@@ -555,13 +560,14 @@ void Dau_TablesLoad( int nInputs, int nVars, Vec_Mem_t * vTtMem, Vec_Mem_t * vTt
assert( FileSize2 % 12 == 0 ); assert( FileSize2 % 12 == 0 );
for ( i = 0; i < nEntries; i++ ) for ( i = 0; i < nEntries; i++ )
{ {
fread( &uTruth, 8, nWords, pFile ); RetValue = fread( &uTruth, 8, nWords, pFile );
Vec_MemHashInsert( vTtMemA, &uTruth ); Vec_MemHashInsert( vTtMemA, &uTruth );
} }
Vec_IntFill( vMapping, nEntries, -1 ); Vec_IntFill( vMapping, nEntries, -1 );
fread( Vec_IntArray(vMapping), 4, Vec_IntSize(vMapping), pFile ); RetValue = fread( Vec_IntArray(vMapping), 4, Vec_IntSize(vMapping), pFile );
fclose( pFile ); fclose( pFile );
} }
RetValue = 0;
if ( FileSize1 ) if ( FileSize1 )
printf( "Loaded file \"%s\" with %10d functions and file \"%s\" with %10d classes.\n", printf( "Loaded file \"%s\" with %10d functions and file \"%s\" with %10d classes.\n",
FileName1, FileSize1, FileName2, FileSize2 ); FileName1, FileSize1, FileName2, FileSize2 );
...@@ -599,7 +605,7 @@ int Dau_PrintStats( int nNodes, int nInputs, int nVars, Vec_Int_t * vNodSup, int ...@@ -599,7 +605,7 @@ int Dau_PrintStats( int nNodes, int nInputs, int nVars, Vec_Int_t * vNodSup, int
return nNew; return nNew;
} }
int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInputs, int nVars0, int nVars, int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInputs, int nVars0, int nVars,
Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping, int nFronts ) Vec_Mem_t * vTtMem, Vec_Mem_t * vTtMemA, Vec_Int_t * vNodSup, Vec_Int_t * vMapping, int nFronts, abctime clk )
{ {
int DumpDelta = 1000000; int DumpDelta = 1000000;
// int DumpDelta = 125000000; // int DumpDelta = 125000000;
...@@ -619,8 +625,7 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp ...@@ -619,8 +625,7 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp
if ( nEntries == Vec_MemEntryNum(vTtMem) ) // found in the table - not new if ( nEntries == Vec_MemEntryNum(vTtMem) ) // found in the table - not new
{ {
//if ( Vec_IntSize(vMapping) % DumpDelta == 0 ) //if ( Vec_IntSize(vMapping) % DumpDelta == 0 )
//if ( Vec_IntSize(vNodSup) % DumpDelta == 0 ) // Dau_TablesSave( nInputs, nVars0, vTtMem, vTtMemA, vNodSup, vMapping, nFronts, clk );
// Dau_TablesSave( nInputs, nVars0, vTtMem, vTtMemA, vNodSup, vMapping, nFronts );
return 0; return 0;
} }
Phase = 0; Phase = 0;
...@@ -630,7 +635,7 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp ...@@ -630,7 +635,7 @@ int Dau_InsertFunction( Abc_TtHieMan_t * pMan, word * pCur, int nNodes, int nInp
assert( Vec_MemEntryNum(vTtMem) == Vec_IntSize(vNodSup) ); assert( Vec_MemEntryNum(vTtMem) == Vec_IntSize(vNodSup) );
//if ( Vec_IntSize(vMapping) % DumpDelta == 0 ) //if ( Vec_IntSize(vMapping) % DumpDelta == 0 )
if ( Vec_IntSize(vNodSup) % DumpDelta == 0 ) if ( Vec_IntSize(vNodSup) % DumpDelta == 0 )
Dau_TablesSave( nInputs, nVars0, vTtMem, vTtMemA, vNodSup, vMapping, nFronts ); Dau_TablesSave( nInputs, nVars0, vTtMem, vTtMemA, vNodSup, vMapping, nFronts, clk );
return 1; return 1;
} }
} }
...@@ -693,16 +698,16 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -693,16 +698,16 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
{ {
tGate = s_Truths6[v] & s_Truths6[nSupp]; tGate = s_Truths6[v] & s_Truths6[nSupp];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
} }
else else
{ {
tGate = s_Truths6[v] ^ s_Truths6[nSupp]; tGate = s_Truths6[v] ^ s_Truths6[nSupp];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp+1, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
} }
} }
nSteps += 3; nSteps += 3;
...@@ -716,23 +721,23 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -716,23 +721,23 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
{ {
tGate = s_Truths6[v] & s_Truths6[k]; tGate = s_Truths6[v] & s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tGate = s_Truths6[v] & ~s_Truths6[k]; tGate = s_Truths6[v] & ~s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
} }
else else
{ {
tGate = s_Truths6[v] ^ s_Truths6[k]; tGate = s_Truths6[v] ^ s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
} }
nSteps += 5; nSteps += 5;
} }
...@@ -747,37 +752,37 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -747,37 +752,37 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
{ {
tGate = s_Truths6[m] & s_Truths6[k]; tGate = s_Truths6[m] & s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tGate = s_Truths6[m] & ~s_Truths6[k]; tGate = s_Truths6[m] & ~s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tGate = ~s_Truths6[m] & s_Truths6[k]; tGate = ~s_Truths6[m] & s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tGate = ~s_Truths6[m] & ~s_Truths6[k]; tGate = ~s_Truths6[m] & ~s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
tCur = (tGate & Cof0) | (~tGate & Cof1); tCur = (tGate & Cof0) | (~tGate & Cof1);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
} }
else else
{ {
tGate = s_Truths6[m] ^ s_Truths6[k]; tGate = s_Truths6[m] ^ s_Truths6[k];
tCur = (tGate & Cof1) | (~tGate & Cof0); tCur = (tGate & Cof1) | (~tGate & Cof0);
Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry ); Dau_InsertFunction( pMan, &tCur, n, nInputs, nVars, nSupp, vTtMem, vTtMemA, vNodSup, vMapping, Entry, clk );
} }
nSteps += 9; nSteps += 9;
} }
...@@ -790,7 +795,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose ) ...@@ -790,7 +795,7 @@ void Dau_FunctionEnum( int nInputs, int nVars, int fVerbose )
if ( nNew == 0 ) if ( nNew == 0 )
break; break;
} }
Dau_TablesSave( nInputs, nVars, vTtMem, vTtMemA, vNodSup, vMapping, Vec_IntSize(vNodSup) ); Dau_TablesSave( nInputs, nVars, vTtMem, vTtMemA, vNodSup, vMapping, Vec_IntSize(vNodSup), clk );
Abc_PrintTime( 1, "Total time", Abc_Clock() - clk ); Abc_PrintTime( 1, "Total time", Abc_Clock() - clk );
//Dau_ExactNpnPrint( vTtMem, vTtMemA, vNodSup, nVars, nInputs, n ); //Dau_ExactNpnPrint( vTtMem, vTtMemA, vNodSup, nVars, nInputs, n );
Abc_TtHieManStop( pMan ); Abc_TtHieManStop( pMan );
......
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