mirror of https://github.com/YosysHQ/abc.git
Dumping a binary file with truth tables in "if".
This commit is contained in:
parent
e29dcd9f32
commit
c5ceff2bee
|
|
@ -21492,7 +21492,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
If_ManSetDefaultPars( pPars );
|
||||
pPars->pLutLib = (If_LibLut_t *)Abc_FrameReadLibLut();
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRNTXYUZDEWSJqaflepmrsdbgxyzuojiktncvh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRNTXYUZDEWSJqalepmrsdbgxyzuojiktncfvh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -21703,9 +21703,9 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
case 'r':
|
||||
pPars->fExpRed ^= 1;
|
||||
break;
|
||||
case 'f':
|
||||
pPars->fFancy ^= 1;
|
||||
break;
|
||||
//case 'f':
|
||||
// pPars->fFancy ^= 1;
|
||||
// break;
|
||||
case 'l':
|
||||
pPars->fLatchPaths ^= 1;
|
||||
break;
|
||||
|
|
@ -21760,6 +21760,9 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
case 'c':
|
||||
pPars->fUseTtPerm ^= 1;
|
||||
break;
|
||||
case 'f':
|
||||
pPars->fDumpFile ^= 1;
|
||||
break;
|
||||
case 'v':
|
||||
pPars->fVerbose ^= 1;
|
||||
break;
|
||||
|
|
@ -22071,7 +22074,7 @@ usage:
|
|||
sprintf(LutSize, "library" );
|
||||
else
|
||||
sprintf(LutSize, "%d", pPars->nLutSize );
|
||||
Abc_Print( -2, "usage: if [-KCFAGRNTXYUZ num] [-DEW float] [-SJ str] [-qarlepmsdbgxyuojiktnczvh]\n" );
|
||||
Abc_Print( -2, "usage: if [-KCFAGRNTXYUZ num] [-DEW float] [-SJ str] [-qarlepmsdbgxyuojiktnczfvh]\n" );
|
||||
Abc_Print( -2, "\t performs FPGA technology mapping of the network\n" );
|
||||
Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
|
||||
Abc_Print( -2, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
|
||||
|
|
@ -22112,6 +22115,7 @@ usage:
|
|||
Abc_Print( -2, "\t-n : toggles computing DSDs of the cut functions [default = %s]\n", pPars->fUseDsd? "yes": "no" );
|
||||
Abc_Print( -2, "\t-c : toggles computing truth tables in a new way [default = %s]\n", pPars->fUseTtPerm? "yes": "no" );
|
||||
Abc_Print( -2, "\t-z : toggles deriving LUTs when mapping into LUT structures [default = %s]\n", pPars->fDeriveLuts? "yes": "no" );
|
||||
Abc_Print( -2, "\t-f : toggles dumping truth tables into a binary file [default = %s]\n", pPars->fDumpFile? "yes": "no" );
|
||||
Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
|
||||
Abc_Print( -2, "\t-h : prints the command usage\n");
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "base/abc/abc.h"
|
||||
#include "bool/dec/dec.h"
|
||||
#include "misc/extra/extra.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -165,7 +166,9 @@ int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, int nMinS
|
|||
pManRes->Log2Probs = Log2Probs;
|
||||
pManRes->Log2Divs = Log2Divs;
|
||||
pManRes->nProbs = 0;
|
||||
char pFileName[100]; sprintf( pFileName, "p%02dd%02dv%02d.bin", Log2Probs, nCutMax, Log2Divs );
|
||||
char * pName = Extra_FileNameGeneric(Extra_FileNameWithoutPath(pNtk->pName));
|
||||
char pFileName[100]; sprintf( pFileName, "p%02dd%02dv%02d_%s.bin", Log2Probs, nCutMax, Log2Divs, pName );
|
||||
ABC_FREE( pName );
|
||||
pManRes->pFile = fopen( pFileName, "wb" );
|
||||
if ( pManRes->pFile == NULL ) {
|
||||
printf( "Cannot open output file \"%s\".\n", pFileName );
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ struct If_Par_t_
|
|||
int fHashMapping; // perform AIG hashing after mapping
|
||||
int fUserLutDec; // perform Boolean decomposition during mapping
|
||||
int fUserLut2D; // perform Boolean decomposition during mapping
|
||||
int fDumpFile; // dumping truth tables into a file
|
||||
int fVerbose; // the verbosity flag
|
||||
int fVerboseTrace; // the verbosity flag
|
||||
char * pLutStruct; // LUT structure
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include "if.h"
|
||||
#include "misc/extra/extra.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -211,6 +212,44 @@ void If_ManRestart( If_Man_t * p )
|
|||
***********************************************************************/
|
||||
void If_ManStop( If_Man_t * p )
|
||||
{
|
||||
if ( p->pPars->fDumpFile && p->pPars->fTruth )
|
||||
{
|
||||
char pFileName[1000] = {0}, pBuffer[100];
|
||||
int nUnique = 0, nChunks = 0, nChunkSize = 1 << 10, nBytes = 0;
|
||||
for ( int i = 7; i <= p->pPars->nLutSize; i++ ) {
|
||||
nUnique = Vec_MemEntryNum(p->vTtMem[i]);
|
||||
nChunks = (nUnique + nChunkSize - 1) / nChunkSize;
|
||||
printf( "LutSize = %2d Unique = %7d Chunks = %7d\n", i, nUnique, nChunks );
|
||||
sprintf( pBuffer, "%s%02d_%02d", i == 7 ? "":"__", i, nChunks );
|
||||
strcat( pFileName, pBuffer );
|
||||
}
|
||||
char * pName = Extra_FileNameGeneric(Extra_FileNameWithoutPath(p->pName));
|
||||
sprintf( pBuffer, "__%s.bin", pName );
|
||||
ABC_FREE( pName );
|
||||
strcat( pFileName, pBuffer );
|
||||
FILE * pFile = fopen( pFileName, "wb" );
|
||||
if ( pFile == NULL )
|
||||
printf( "Cannot open file \"%s\" for writing.\n", pFileName );
|
||||
else {
|
||||
for ( int i = 7; i <= p->pPars->nLutSize; i++ ) {
|
||||
nUnique = Vec_MemEntryNum(p->vTtMem[i]);
|
||||
nChunks = (nUnique + nChunkSize - 1) / nChunkSize;
|
||||
word * pEntry; int k, Count = 0;
|
||||
int nEntrySize = Vec_MemEntrySize(p->vTtMem[i]);
|
||||
Vec_MemForEachEntry( p->vTtMem[i], pEntry, k )
|
||||
Count += fwrite( (unsigned *)pEntry, 1, sizeof(word) * nEntrySize, pFile );
|
||||
word * pZeros = ABC_CALLOC( word, nEntrySize );
|
||||
for ( ; k < nChunks * nChunkSize; k++ )
|
||||
Count += fwrite( (unsigned *)pZeros, 1, sizeof(word) * nEntrySize, pFile );
|
||||
ABC_FREE( pZeros );
|
||||
assert( Count == nChunks * nChunkSize * nEntrySize * sizeof(word) );
|
||||
nBytes += nChunks * nChunkSize * nEntrySize * sizeof(word);
|
||||
}
|
||||
fclose( pFile );
|
||||
printf( "Finished writing truth tables into file \"%s\" (%.3f MB).\n", pFileName, 1.0 * nBytes / (1<<20) );
|
||||
}
|
||||
}
|
||||
|
||||
extern void If_ManCacheAnalize( If_Man_t * p );
|
||||
int i;
|
||||
if ( p->pPars->fVerbose && p->vCutData )
|
||||
|
|
|
|||
Loading…
Reference in New Issue