Skip to content

Commit

Permalink
Adding generation of random functions to "lutexact"
Browse files Browse the repository at this point in the history
  • Loading branch information
alanminko committed Nov 6, 2024
1 parent ecd9480 commit 091ff4e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/base/abci/abc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9805,11 +9805,12 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern void Exa3_ManExactSynthesis( Bmc_EsPar_t * pPars );
extern void Exa3_ManExactSynthesis2( Bmc_EsPar_t * pPars );
extern void Exa3_ManExactSynthesisRand( Bmc_EsPar_t * pPars );
int c;
Bmc_EsPar_t Pars, * pPars = &Pars;
Bmc_EsParSetDefault( pPars );
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "INKTSiaocgvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "INKTSRiaocgvh" ) ) != EOF )
{
switch ( c )
{
Expand Down Expand Up @@ -9866,6 +9867,15 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->pSymStr = argv[globalUtilOptind];
globalUtilOptind++;
break;
case 'R':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-R\" should be followed by a file name.\n" );
goto usage;
}
pPars->nRandFuncs = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
break;
case 'i':
pPars->fUseIncr ^= 1;
break;
Expand All @@ -9892,7 +9902,7 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( argc == globalUtilOptind + 1 )
pPars->pTtStr = argv[globalUtilOptind];
if ( pPars->pTtStr == NULL && pPars->pSymStr == NULL )
if ( pPars->pTtStr == NULL && pPars->pSymStr == NULL && pPars->nRandFuncs == 0 )
{
Abc_Print( -1, "Truth table should be given on the command line.\n" );
return 1;
Expand Down Expand Up @@ -9922,19 +9932,24 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Node size should not be more than 6 inputs.\n" );
return 1;
}
if ( pPars->fGlucose )
if ( pPars->nRandFuncs ) {
pPars->fGlucose = 1;
Exa3_ManExactSynthesisRand( pPars );
}
else if ( pPars->fGlucose )
Exa3_ManExactSynthesis( pPars );
else
Exa3_ManExactSynthesis2( pPars );
return 0;

usage:
Abc_Print( -2, "usage: lutexact [-INKT <num>] [-S string] [-iaocgvh] <hex>\n" );
Abc_Print( -2, "usage: lutexact [-INKTR <num>] [-S string] [-iaocgvh] <hex>\n" );
Abc_Print( -2, "\t exact synthesis of I-input function using N K-input gates\n" );
Abc_Print( -2, "\t-I <num> : the number of input variables [default = %d]\n", pPars->nVars );
Abc_Print( -2, "\t-N <num> : the number of K-input nodes [default = %d]\n", pPars->nNodes );
Abc_Print( -2, "\t-K <num> : the number of node fanins [default = %d]\n", pPars->nLutSize );
Abc_Print( -2, "\t-T <num> : the runtime limit in seconds [default = %d]\n", pPars->RuntimeLim );
Abc_Print( -2, "\t-R <num> : the number of random functions to try [default = unused]\n" );
Abc_Print( -2, "\t-S <str> : charasteristic string of a symmetric function [default = %d]\n", pPars->pSymStr );
Abc_Print( -2, "\t-i : toggle using incremental solving [default = %s]\n", pPars->fUseIncr ? "yes" : "no" );
Abc_Print( -2, "\t-a : toggle using only AND-gates when K = 2 [default = %s]\n", pPars->fOnlyAnd ? "yes" : "no" );
Expand Down
1 change: 1 addition & 0 deletions src/sat/bmc/bmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct Bmc_EsPar_t_
int fUniqFans;
int fLutCascade;
int RuntimeLim;
int nRandFuncs;
int fVerbose;
char * pTtStr;
char * pSymStr;
Expand Down
17 changes: 17 additions & 0 deletions src/sat/bmc/bmcMaj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,23 @@ void Exa3_ManExactSynthesis( Bmc_EsPar_t * pPars )
ABC_FREE( pPars->pTtStr );
Exa3_ManFree( p );
}
void Exa3_ManExactSynthesisRand( Bmc_EsPar_t * pPars )
{
int i, k, nWords = Abc_TtWordNum(pPars->nVars);
word * pFun = ABC_ALLOC( word, nWords );
Abc_RandomW(1);
for ( i = 0; i < pPars->nRandFuncs; i++ ) {
for ( k = 0; k < nWords; k++ )
pFun[k] = Abc_RandomW(0);
pPars->pTtStr = ABC_CALLOC( char, pPars->nVars > 2 ? (1 << (pPars->nVars-2)) + 1 : 2 );
Extra_PrintHexadecimalString( pPars->pTtStr, (unsigned *)pFun, pPars->nVars );
printf( "Generated random function: %s\n", pPars->pTtStr );
Exa3_ManExactSynthesis( pPars );
ABC_FREE( pPars->pTtStr );
}
ABC_FREE( pFun );
}


/**Function*************************************************************
Expand Down

0 comments on commit 091ff4e

Please sign in to comment.