Skip to content

Commit 6a03162

Browse files
committed
Supporting random seed in "lutexact".
1 parent 59bb4de commit 6a03162

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

src/base/abci/abc.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10548,7 +10548,7 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
1054810548
Bmc_EsPar_t Pars, * pPars = &Pars;
1054910549
Bmc_EsParSetDefault( pPars );
1055010550
Extra_UtilGetoptReset();
10551-
while ( ( c = Extra_UtilGetopt( argc, argv, "INKTSFMiaocgvh" ) ) != EOF )
10551+
while ( ( c = Extra_UtilGetopt( argc, argv, "INKTFMSYiaocgvh" ) ) != EOF )
1055210552
{
1055310553
switch ( c )
1055410554
{
@@ -10596,15 +10596,6 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
1059610596
if ( pPars->RuntimeLim < 0 )
1059710597
goto usage;
1059810598
break;
10599-
case 'S':
10600-
if ( globalUtilOptind >= argc )
10601-
{
10602-
Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
10603-
goto usage;
10604-
}
10605-
pPars->pSymStr = argv[globalUtilOptind];
10606-
globalUtilOptind++;
10607-
break;
1060810599
case 'F':
1060910600
if ( globalUtilOptind >= argc )
1061010601
{
@@ -10623,6 +10614,26 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
1062310614
pPars->nMintNum = atoi(argv[globalUtilOptind]);
1062410615
globalUtilOptind++;
1062510616
break;
10617+
case 'S':
10618+
if ( globalUtilOptind >= argc )
10619+
{
10620+
Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
10621+
goto usage;
10622+
}
10623+
pPars->Seed = atoi(argv[globalUtilOptind]);
10624+
globalUtilOptind++;
10625+
if ( pPars->Seed < 0 )
10626+
goto usage;
10627+
break;
10628+
case 'Y':
10629+
if ( globalUtilOptind >= argc )
10630+
{
10631+
Abc_Print( -1, "Command line switch \"-Y\" should be followed by a string.\n" );
10632+
goto usage;
10633+
}
10634+
pPars->pSymStr = argv[globalUtilOptind];
10635+
globalUtilOptind++;
10636+
break;
1062610637
case 'i':
1062710638
pPars->fUseIncr ^= 1;
1062810639
break;
@@ -10690,15 +10701,16 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
1069010701
return 0;
1069110702

1069210703
usage:
10693-
Abc_Print( -2, "usage: lutexact [-INKTFM <num>] [-S string] [-iaocgvh] <hex>\n" );
10704+
Abc_Print( -2, "usage: lutexact [-INKTFMS <num>] [-Y string] [-iaocgvh] <hex>\n" );
1069410705
Abc_Print( -2, "\t exact synthesis of I-input function using N K-input gates\n" );
1069510706
Abc_Print( -2, "\t-I <num> : the number of input variables [default = %d]\n", pPars->nVars );
1069610707
Abc_Print( -2, "\t-N <num> : the number of K-input nodes [default = %d]\n", pPars->nNodes );
1069710708
Abc_Print( -2, "\t-K <num> : the number of node fanins [default = %d]\n", pPars->nLutSize );
1069810709
Abc_Print( -2, "\t-T <num> : the runtime limit in seconds [default = %d]\n", pPars->RuntimeLim );
1069910710
Abc_Print( -2, "\t-F <num> : the number of random functions to try [default = unused]\n" );
1070010711
Abc_Print( -2, "\t-M <num> : the number of positive minterms in the random function [default = unused]\n" );
10701-
Abc_Print( -2, "\t-S <str> : charasteristic string of a symmetric function [default = %d]\n", pPars->pSymStr );
10712+
Abc_Print( -2, "\t-S <num> : the random seed for random function generation with -F <num> [default = %d]\n", pPars->Seed );
10713+
Abc_Print( -2, "\t-Y <str> : charasteristic string of a symmetric function [default = %d]\n", pPars->pSymStr );
1070210714
Abc_Print( -2, "\t-i : toggle using incremental solving [default = %s]\n", pPars->fUseIncr ? "yes" : "no" );
1070310715
Abc_Print( -2, "\t-a : toggle using only AND-gates when K = 2 [default = %s]\n", pPars->fOnlyAnd ? "yes" : "no" );
1070410716
Abc_Print( -2, "\t-o : toggle using additional optimizations [default = %s]\n", pPars->fFewerVars ? "yes" : "no" );

src/sat/bmc/bmc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct Bmc_EsPar_t_
6767
int RuntimeLim;
6868
int nRandFuncs;
6969
int nMintNum;
70+
int Seed;
7071
int fVerbose;
7172
char * pTtStr;
7273
char * pSymStr;

src/sat/bmc/bmcMaj.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,18 +1580,19 @@ int Exa3_ManExactSynthesis( Bmc_EsPar_t * pPars )
15801580
void Exa3_ManExactSynthesisRand( Bmc_EsPar_t * pPars )
15811581
{
15821582
int i, k, nDecs = 0, nWords = Abc_TtWordNum(pPars->nVars);
1583-
word * pFun = ABC_ALLOC( word, nWords );
1584-
Abc_Random(1);
1585-
printf( "\n" );
1583+
word * pFun = ABC_ALLOC( word, nWords );
1584+
unsigned Rand0 = Abc_Random(1);
1585+
for ( i = 0; i < pPars->Seed; i++ )
1586+
Rand0 = Abc_Random(0);
15861587
for ( i = 0; i < pPars->nRandFuncs; i++ ) {
15871588
if ( pPars->nMintNum == 0 )
15881589
for ( k = 0; k < nWords; k++ )
1589-
pFun[k] = Abc_RandomW(0);
1590+
pFun[k] = Rand0 ^ Abc_RandomW(0);
15901591
else {
15911592
Abc_TtClear( pFun, nWords );
15921593
for ( k = 0; k < pPars->nMintNum; k++ ) {
15931594
int iMint = 0;
1594-
do iMint = Abc_Random(0) % (1 << pPars->nVars);
1595+
do iMint = (Rand0 ^ Abc_Random(0)) % (1 << pPars->nVars);
15951596
while ( Abc_TtGetBit(pFun, iMint) );
15961597
Abc_TtSetBit( pFun, iMint );
15971598
}
@@ -1607,7 +1608,7 @@ void Exa3_ManExactSynthesisRand( Bmc_EsPar_t * pPars )
16071608
nDecs += Exa3_ManExactSynthesis( pPars );
16081609
ABC_FREE( pPars->pTtStr );
16091610
}
1610-
printf( "Decomposable are %d (out of %d) functions (%.2f %%).\n", nDecs, pPars->nRandFuncs, 100.0*nDecs/pPars->nRandFuncs );
1611+
printf( "\nDecomposable are %d (out of %d) functions (%.2f %%).\n", nDecs, pPars->nRandFuncs, 100.0*nDecs/pPars->nRandFuncs );
16111612
ABC_FREE( pFun );
16121613
}
16131614

0 commit comments

Comments
 (0)