Skip to content

Commit 9478c17

Browse files
committed
Adding the dump of non-decomposable functions in "lutcasdec".
1 parent 5adfd00 commit 9478c17

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/base/abci/abc.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9248,11 +9248,11 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
92489248
{
92499249
extern Abc_Ntk_t * Abc_NtkLutCascadeGen( int nLutSize, int nStages, int nRails, int nShared, int fVerbose );
92509250
extern Abc_Ntk_t * Abc_NtkLutCascadeOne( Abc_Ntk_t * pNtk, int nLutSize, int nLuts, int nRails, int nIters, int nJRatio, int nZParam, int fXRail, int Seed, int fVerbose, int fVeryVerbose, char * pGuide, int nSubsets, int nBest );
9251-
extern void Abc_NtkLutCascadeFile( char * pFileName, int nVarNum, int nLutSize, int nLuts, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, int fPrintMyu, int fPrintLev, int fXRail, int nSubsets, int nBest );
9251+
extern void Abc_NtkLutCascadeFile( char * pFileName, int nVarNum, int nLutSize, int nLuts, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, int fPrintMyu, int fPrintLev, int fXRail, int nSubsets, int nBest, int fDump );
92529252
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes; char * pGuide = NULL, * pFileName = NULL;
9253-
int c, nVarNum = -1, nLutSize = 6, nStages = 8, nRails = 1, nShared = 2, Seed = 0, nIters = 10, nJRatio = -1, nZParam = 5, fGen = 0, fPrintMyu = 0, fPrintLev = 0, fXRail = 0, nSubsets = 0, nBest = 0, fVerbose = 0, fVeryVerbose = 0;
9253+
int c, nVarNum = -1, nLutSize = 6, nStages = 8, nRails = 1, nShared = 2, Seed = 0, nIters = 10, nJRatio = -1, nZParam = 5, fGen = 0, fPrintMyu = 0, fPrintLev = 0, fXRail = 0, nSubsets = 0, nBest = 0, fDump = 0, fVerbose = 0, fVeryVerbose = 0;
92549254
Extra_UtilGetoptReset();
9255-
while ( ( c = Extra_UtilGetopt( argc, argv, "KMRSCIZNGBFgmlxvwh" ) ) != EOF )
9255+
while ( ( c = Extra_UtilGetopt( argc, argv, "KMRSCIZNGBFgmlxdvwh" ) ) != EOF )
92569256
{
92579257
switch ( c )
92589258
{
@@ -9396,6 +9396,9 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
93969396
case 'x':
93979397
fXRail ^= 1;
93989398
break;
9399+
case 'd':
9400+
fDump ^= 1;
9401+
break;
93999402
case 'v':
94009403
fVerbose ^= 1;
94019404
break;
@@ -9415,7 +9418,7 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
94159418
Abc_Print( -1, "The number of variables should be given on the command line using switch \"-N <num>\".\n" );
94169419
return 1;
94179420
}
9418-
Abc_NtkLutCascadeFile( pFileName, nVarNum, nLutSize, nStages, nRails, nIters, nJRatio, nZParam, Seed, fVerbose, fVeryVerbose, fPrintMyu, fPrintLev, fXRail, nSubsets, nBest );
9421+
Abc_NtkLutCascadeFile( pFileName, nVarNum, nLutSize, nStages, nRails, nIters, nJRatio, nZParam, Seed, fVerbose, fVeryVerbose, fPrintMyu, fPrintLev, fXRail, nSubsets, nBest, fDump );
94199422
return 0;
94209423
}
94219424
if ( fGen )
@@ -9462,7 +9465,7 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
94629465
return 0;
94639466

94649467
usage:
9465-
Abc_Print( -2, "usage: lutcasdec [-KMRCSIZNGB <num>] [-F <file>] [-gmlxvwh]\n" );
9468+
Abc_Print( -2, "usage: lutcasdec [-KMRCSIZNGB <num>] [-F <file>] [-gmlxdvwh]\n" );
94669469
Abc_Print( -2, "\t decomposes the primary output functions into LUT cascades\n" );
94679470
Abc_Print( -2, "\t-K <num> : the number of LUT inputs [default = %d]\n", nLutSize );
94689471
Abc_Print( -2, "\t-M <num> : the maximum delay (the number of stages) [default = %d]\n", nStages );
@@ -9480,6 +9483,7 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
94809483
Abc_Print( -2, "\t-m : toggle printing column multiplicity statistics [default = %s]\n", fPrintMyu? "yes": "no" );
94819484
Abc_Print( -2, "\t-l : toggle printing level counting statistics [default = %s]\n", fPrintLev? "yes": "no" );
94829485
Abc_Print( -2, "\t-x : toggle using extended cascade decomposition [default = %s]\n", fXRail? "yes": "no" );
9486+
Abc_Print( -2, "\t-d : toggle dumping non-decomposable functions into a file [default = %s]\n", fDump? "yes": "no" );
94839487
Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
94849488
Abc_Print( -2, "\t-w : toggle additional verbose printout [default = %s]\n", fVeryVerbose? "yes": "no" );
94859489
Abc_Print( -2, "\t-h : print the command usage\n");

src/base/abci/abcCas.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,11 +1450,13 @@ Vec_Wrd_t * Abc_NtkLutCasReadTruths( char * pFileName, int nVarsOrig )
14501450
SeeAlso []
14511451
14521452
***********************************************************************/
1453-
void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int nStages, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, int fPrintMyu, int fPrintLev, int fXRail, int nSubsets, int nBest )
1453+
void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int nStages, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, int fPrintMyu, int fPrintLev, int fXRail, int nSubsets, int nBest, int fDump )
14541454
{
14551455
abctime clkStart = Abc_Clock();
14561456
int i, nErrors = 0, Sum = 0, nStageCount = 0, MyuMin = 0, nTotalLuts = 0, nWords = Abc_TtWordNum(nVarsOrig);
14571457
Vec_Wrd_t * vTruths = NULL;
1458+
char pFileNameOut[1000] = {0};
1459+
FILE * pFile = NULL;
14581460
if ( strstr(pFileName, ".txt") )
14591461
vTruths = Abc_NtkLutCasReadTruths( pFileName, nVarsOrig );
14601462
else
@@ -1501,7 +1503,7 @@ void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int n
15011503

15021504
word * pLuts = Abc_LutCascadeDec( p, NULL, pTruth, nVarsOrig, vVarIDs, nRails, nLutSize, nStages, (int)(Iter >= 0), nZParam, fXRail, fVeryVerbose, &nStageCount, &MyuMin, nSubsets, nBest );
15031505
Vec_IntFree( vVarIDs );
1504-
if ( MyuMin < 50 ) MyuStats[MyuMin]++, IterReal++;
1506+
if ( MyuMin < 50 && Iter == 0 ) MyuStats[MyuMin]++, IterReal++;
15051507
if ( pLuts == NULL ) {
15061508
if ( ++Iter < nIters ) {
15071509
i--;
@@ -1510,6 +1512,16 @@ void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int n
15101512
Iter = 0;
15111513
if ( fVerbose || fVeryVerbose )
15121514
printf( "Not decomposable.\n" );
1515+
if ( fDump ) {
1516+
if ( pFile == NULL ) {
1517+
sprintf( pFileNameOut, "%s_nd", pFileName );
1518+
pFile = fopen( pFileNameOut, "wb" );
1519+
}
1520+
char * pTtStr = ABC_CALLOC( char, (1 << (nVarsOrig-2)) + 1 );
1521+
Extra_PrintHexadecimalString( pTtStr, (unsigned *)pTruth, nVarsOrig );
1522+
fprintf( pFile, "%s\n", pTtStr );
1523+
ABC_FREE( pTtStr );
1524+
}
15131525
continue;
15141526
}
15151527
Iter = 0;
@@ -1559,6 +1571,10 @@ void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int n
15591571
printf( "Finished %d functions (%.2f LUTs / function; %.2f functions / sec). ",
15601572
nFuncs, 1.0*nTotalLuts/Sum, 1.0*nFuncs/(((double)(Abc_Clock() - clkStart))/((double)CLOCKS_PER_SEC)) );
15611573
Abc_PrintTime( 0, "Total time", Abc_Clock() - clkStart );
1574+
if ( pFile ) {
1575+
printf( "Finished dumping %d non-decomposable functions into file \"%s\".\n", nFuncs-Sum, pFileNameOut );
1576+
fclose( pFile );
1577+
}
15621578
}
15631579

15641580
/**Function*************************************************************

0 commit comments

Comments
 (0)