Skip to content

Commit 1a18c9a

Browse files
committed
: lutexact
1 parent fd74cb8 commit 1a18c9a

File tree

3 files changed

+57
-13
lines changed

3 files changed

+57
-13
lines changed

src/base/abci/abc.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10639,25 +10639,25 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
1063910639
Bmc_EsPar_t Pars, * pPars = &Pars;
1064010640
Bmc_EsParSetDefault( pPars );
1064110641
Extra_UtilGetoptReset();
10642-
while ( ( c = Extra_UtilGetopt( argc, argv, "INKTFUSYiaorfgvh" ) ) != EOF )
10642+
while ( ( c = Extra_UtilGetopt( argc, argv, "NMKTFUSYiaorfgdvh" ) ) != EOF )
1064310643
{
1064410644
switch ( c )
1064510645
{
10646-
case 'I':
10646+
case 'N':
1064710647
if ( globalUtilOptind >= argc )
1064810648
{
10649-
Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
10649+
Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
1065010650
goto usage;
1065110651
}
1065210652
pPars->nVars = atoi(argv[globalUtilOptind]);
1065310653
globalUtilOptind++;
1065410654
if ( pPars->nVars < 0 )
1065510655
goto usage;
1065610656
break;
10657-
case 'N':
10657+
case 'M':
1065810658
if ( globalUtilOptind >= argc )
1065910659
{
10660-
Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
10660+
Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
1066110661
goto usage;
1066210662
}
1066310663
pPars->nNodes = atoi(argv[globalUtilOptind]);
@@ -10743,6 +10743,9 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
1074310743
case 'g':
1074410744
pPars->fGlucose ^= 1;
1074510745
break;
10746+
case 'd':
10747+
pPars->fDumpBlif ^= 1;
10748+
break;
1074610749
case 'v':
1074710750
pPars->fVerbose ^= 1;
1074810751
break;
@@ -10803,10 +10806,10 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
1080310806
return 0;
1080410807

1080510808
usage:
10806-
Abc_Print( -2, "usage: lutexact [-INKTFUS <num>] [-Y string] [-iaorfgvh] <hex>\n" );
10809+
Abc_Print( -2, "usage: lutexact [-NMKTFUS <num>] [-Y string] [-iaorfgdvh] <hex>\n" );
1080710810
Abc_Print( -2, "\t exact synthesis of I-input function using N K-input gates\n" );
10808-
Abc_Print( -2, "\t-I <num> : the number of input variables [default = %d]\n", pPars->nVars );
10809-
Abc_Print( -2, "\t-N <num> : the number of K-input nodes [default = %d]\n", pPars->nNodes );
10811+
Abc_Print( -2, "\t-N <num> : the number of input variables [default = %d]\n", pPars->nVars );
10812+
Abc_Print( -2, "\t-M <num> : the number of K-input nodes [default = %d]\n", pPars->nNodes );
1081010813
Abc_Print( -2, "\t-K <num> : the number of node fanins [default = %d]\n", pPars->nLutSize );
1081110814
Abc_Print( -2, "\t-T <num> : the runtime limit in seconds [default = %d]\n", pPars->RuntimeLim );
1081210815
Abc_Print( -2, "\t-F <num> : the number of random functions to try [default = unused]\n" );
@@ -10819,6 +10822,7 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
1081910822
Abc_Print( -2, "\t-r : toggle synthesizing a single-rail cascade [default = %s]\n", pPars->fLutCascade ? "yes" : "no" );
1082010823
Abc_Print( -2, "\t-f : toggle fixing LUT inputs in cascade mapping [default = %s]\n", pPars->fLutInFixed ? "yes" : "no" );
1082110824
Abc_Print( -2, "\t-g : toggle using Glucose 3.0 by Gilles Audemard and Laurent Simon [default = %s]\n", pPars->fGlucose ? "yes" : "no" );
10825+
Abc_Print( -2, "\t-d : toggle dumping decomposed networks into BLIF files [default = %s]\n", pPars->fDumpBlif ? "yes" : "no" );
1082210826
Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose ? "yes" : "no" );
1082310827
Abc_Print( -2, "\t-h : print the command usage\n" );
1082410828
Abc_Print( -2, "\t<hex> : truth table in hex notation\n" );

src/sat/bmc/bmc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct Bmc_EsPar_t_
6969
int nRandFuncs;
7070
int nMintNum;
7171
int Seed;
72+
int fDumpBlif;
7273
int fVerbose;
7374
char * pTtStr;
7475
char * pSymStr;

src/sat/bmc/bmcMaj.c

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,21 +1642,40 @@ int Exa3_ManExactSynthesis( Bmc_EsPar_t * pPars )
16421642
else if ( status == GLUCOSE_UNDEC )
16431643
printf( "The solver timed out after %d sec.\n", pPars->RuntimeLim );
16441644
else
1645-
printf( "The problem has no solution.\n" );
1645+
printf( "The problem has no solution.\n" ), Res = 2;
16461646
printf( "Added = %d. Tried = %d. ", p->nUsed[1], p->nUsed[0] );
16471647
Abc_PrintTime( 1, "Total runtime", Abc_Clock() - clkTotal );
1648-
if ( iMint == -1 )
1648+
if ( iMint == -1 && pPars->fDumpBlif )
16491649
Exa3_ManDumpBlif( p, fCompl );
16501650
if ( pPars->pSymStr )
16511651
ABC_FREE( pPars->pTtStr );
16521652
Exa3_ManFree( p );
16531653
return Res;
16541654
}
1655+
1656+
char * Exa_TimeStamp()
1657+
{
1658+
static char Buffer[100];
1659+
time_t ltime;
1660+
struct tm *tm_info;
1661+
1662+
// Get the current time
1663+
time(&ltime);
1664+
tm_info = localtime(&ltime);
1665+
1666+
// Format the time as YYYY_MM_DD__HH_MM_SS
1667+
strftime(Buffer, sizeof(Buffer), "%Y_%m_%d__%H_%M_%S", tm_info);
1668+
1669+
return Buffer;
1670+
}
1671+
16551672
void Exa3_ManExactSynthesisRand( Bmc_EsPar_t * pPars )
16561673
{
1657-
int i, k, nDecs = 0, nWords = Abc_TtWordNum(pPars->nVars);
1674+
abctime clk = Abc_Clock();
1675+
int i, k, Status, nDecs[3] = {0}, nWords = Abc_TtWordNum(pPars->nVars);
16581676
word * pFun = ABC_ALLOC( word, nWords );
16591677
unsigned Rand0 = Abc_Random(1);
1678+
Vec_Str_t * vUndec = Vec_StrAlloc( 100 );
16601679
for ( i = 0; i < pPars->Seed; i++ )
16611680
Rand0 = Abc_Random(0);
16621681
for ( i = 0; i < pPars->nRandFuncs; i++ ) {
@@ -1680,11 +1699,31 @@ void Exa3_ManExactSynthesisRand( Bmc_EsPar_t * pPars )
16801699
printf( "\n" );
16811700
if ( pPars->fVerbose )
16821701
printf( "Truth table : %s\n", pPars->pTtStr );
1683-
nDecs += Exa3_ManExactSynthesis( pPars );
1702+
Status = Exa3_ManExactSynthesis( pPars );
1703+
nDecs[Status]++;
1704+
if ( Status == 0 ) // undecided
1705+
Vec_StrPrintF( vUndec, "%s\n", pPars->pTtStr );
16841706
ABC_FREE( pPars->pTtStr );
16851707
}
1686-
printf( "\nDecomposable are %d (out of %d) functions (%.2f %%).\n\n", nDecs, pPars->nRandFuncs, 100.0*nDecs/pPars->nRandFuncs );
1708+
printf( "\n" );
1709+
printf( "Decomposable are %6d (out of %6d) functions (%6.2f %%).\n", nDecs[1], pPars->nRandFuncs, 100.0*nDecs[1]/pPars->nRandFuncs );
1710+
printf( "Non-decomposable are %6d (out of %6d) functions (%6.2f %%).\n", nDecs[2], pPars->nRandFuncs, 100.0*nDecs[2]/pPars->nRandFuncs );
1711+
printf( "Undecided are %6d (out of %6d) functions (%6.2f %%).\n", nDecs[0], pPars->nRandFuncs, 100.0*nDecs[0]/pPars->nRandFuncs );
16871712
ABC_FREE( pFun );
1713+
if ( nDecs[0] > 0 ) {
1714+
char filename[1000];
1715+
sprintf( filename, "undecided_%d_out_of_F%d_with_N%d_M%d_K%d_U%d_S%d_T%d%s__%s.txt",
1716+
nDecs[0], pPars->nRandFuncs, pPars->nVars, pPars->nNodes, pPars->nLutSize,
1717+
pPars->nMintNum, pPars->Seed, pPars->RuntimeLim, pPars->fLutCascade ? "_r" : "", Exa_TimeStamp() );
1718+
FILE * pFile = fopen( filename, "wb" );
1719+
if ( pFile ) {
1720+
fwrite( Vec_StrArray(vUndec), 1, Vec_StrSize(vUndec), pFile );
1721+
fclose( pFile );
1722+
printf( "The resulting undecided functions were written into file \"%s\".\n", filename );
1723+
}
1724+
}
1725+
Abc_PrintTime( 1, "Total time", Abc_Clock() - clk );
1726+
Vec_StrFree( vUndec );
16881727
}
16891728

16901729

0 commit comments

Comments
 (0)