mirror of https://github.com/YosysHQ/abc.git
: lutexact
This commit is contained in:
parent
fd74cb8e8a
commit
1a18c9a3d8
|
|
@ -10639,14 +10639,14 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Bmc_EsPar_t Pars, * pPars = &Pars;
|
||||
Bmc_EsParSetDefault( pPars );
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "INKTFUSYiaorfgvh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "NMKTFUSYiaorfgdvh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
case 'I':
|
||||
case 'N':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
|
||||
Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
|
||||
goto usage;
|
||||
}
|
||||
pPars->nVars = atoi(argv[globalUtilOptind]);
|
||||
|
|
@ -10654,10 +10654,10 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
if ( pPars->nVars < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'N':
|
||||
case 'M':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
|
||||
Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
|
||||
goto usage;
|
||||
}
|
||||
pPars->nNodes = atoi(argv[globalUtilOptind]);
|
||||
|
|
@ -10743,6 +10743,9 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
case 'g':
|
||||
pPars->fGlucose ^= 1;
|
||||
break;
|
||||
case 'd':
|
||||
pPars->fDumpBlif ^= 1;
|
||||
break;
|
||||
case 'v':
|
||||
pPars->fVerbose ^= 1;
|
||||
break;
|
||||
|
|
@ -10803,10 +10806,10 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: lutexact [-INKTFUS <num>] [-Y string] [-iaorfgvh] <hex>\n" );
|
||||
Abc_Print( -2, "usage: lutexact [-NMKTFUS <num>] [-Y string] [-iaorfgdvh] <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-N <num> : the number of input variables [default = %d]\n", pPars->nVars );
|
||||
Abc_Print( -2, "\t-M <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-F <num> : the number of random functions to try [default = unused]\n" );
|
||||
|
|
@ -10819,6 +10822,7 @@ usage:
|
|||
Abc_Print( -2, "\t-r : toggle synthesizing a single-rail cascade [default = %s]\n", pPars->fLutCascade ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-f : toggle fixing LUT inputs in cascade mapping [default = %s]\n", pPars->fLutInFixed ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-g : toggle using Glucose 3.0 by Gilles Audemard and Laurent Simon [default = %s]\n", pPars->fGlucose ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-d : toggle dumping decomposed networks into BLIF files [default = %s]\n", pPars->fDumpBlif ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-h : print the command usage\n" );
|
||||
Abc_Print( -2, "\t<hex> : truth table in hex notation\n" );
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ struct Bmc_EsPar_t_
|
|||
int nRandFuncs;
|
||||
int nMintNum;
|
||||
int Seed;
|
||||
int fDumpBlif;
|
||||
int fVerbose;
|
||||
char * pTtStr;
|
||||
char * pSymStr;
|
||||
|
|
|
|||
|
|
@ -1642,21 +1642,40 @@ int Exa3_ManExactSynthesis( Bmc_EsPar_t * pPars )
|
|||
else if ( status == GLUCOSE_UNDEC )
|
||||
printf( "The solver timed out after %d sec.\n", pPars->RuntimeLim );
|
||||
else
|
||||
printf( "The problem has no solution.\n" );
|
||||
printf( "The problem has no solution.\n" ), Res = 2;
|
||||
printf( "Added = %d. Tried = %d. ", p->nUsed[1], p->nUsed[0] );
|
||||
Abc_PrintTime( 1, "Total runtime", Abc_Clock() - clkTotal );
|
||||
if ( iMint == -1 )
|
||||
if ( iMint == -1 && pPars->fDumpBlif )
|
||||
Exa3_ManDumpBlif( p, fCompl );
|
||||
if ( pPars->pSymStr )
|
||||
ABC_FREE( pPars->pTtStr );
|
||||
Exa3_ManFree( p );
|
||||
return Res;
|
||||
}
|
||||
|
||||
char * Exa_TimeStamp()
|
||||
{
|
||||
static char Buffer[100];
|
||||
time_t ltime;
|
||||
struct tm *tm_info;
|
||||
|
||||
// Get the current time
|
||||
time(<ime);
|
||||
tm_info = localtime(<ime);
|
||||
|
||||
// Format the time as YYYY_MM_DD__HH_MM_SS
|
||||
strftime(Buffer, sizeof(Buffer), "%Y_%m_%d__%H_%M_%S", tm_info);
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
void Exa3_ManExactSynthesisRand( Bmc_EsPar_t * pPars )
|
||||
{
|
||||
int i, k, nDecs = 0, nWords = Abc_TtWordNum(pPars->nVars);
|
||||
abctime clk = Abc_Clock();
|
||||
int i, k, Status, nDecs[3] = {0}, nWords = Abc_TtWordNum(pPars->nVars);
|
||||
word * pFun = ABC_ALLOC( word, nWords );
|
||||
unsigned Rand0 = Abc_Random(1);
|
||||
Vec_Str_t * vUndec = Vec_StrAlloc( 100 );
|
||||
for ( i = 0; i < pPars->Seed; i++ )
|
||||
Rand0 = Abc_Random(0);
|
||||
for ( i = 0; i < pPars->nRandFuncs; i++ ) {
|
||||
|
|
@ -1680,11 +1699,31 @@ void Exa3_ManExactSynthesisRand( Bmc_EsPar_t * pPars )
|
|||
printf( "\n" );
|
||||
if ( pPars->fVerbose )
|
||||
printf( "Truth table : %s\n", pPars->pTtStr );
|
||||
nDecs += Exa3_ManExactSynthesis( pPars );
|
||||
Status = Exa3_ManExactSynthesis( pPars );
|
||||
nDecs[Status]++;
|
||||
if ( Status == 0 ) // undecided
|
||||
Vec_StrPrintF( vUndec, "%s\n", pPars->pTtStr );
|
||||
ABC_FREE( pPars->pTtStr );
|
||||
}
|
||||
printf( "\nDecomposable are %d (out of %d) functions (%.2f %%).\n\n", nDecs, pPars->nRandFuncs, 100.0*nDecs/pPars->nRandFuncs );
|
||||
printf( "\n" );
|
||||
printf( "Decomposable are %6d (out of %6d) functions (%6.2f %%).\n", nDecs[1], pPars->nRandFuncs, 100.0*nDecs[1]/pPars->nRandFuncs );
|
||||
printf( "Non-decomposable are %6d (out of %6d) functions (%6.2f %%).\n", nDecs[2], pPars->nRandFuncs, 100.0*nDecs[2]/pPars->nRandFuncs );
|
||||
printf( "Undecided are %6d (out of %6d) functions (%6.2f %%).\n", nDecs[0], pPars->nRandFuncs, 100.0*nDecs[0]/pPars->nRandFuncs );
|
||||
ABC_FREE( pFun );
|
||||
if ( nDecs[0] > 0 ) {
|
||||
char filename[1000];
|
||||
sprintf( filename, "undecided_%d_out_of_F%d_with_N%d_M%d_K%d_U%d_S%d_T%d%s__%s.txt",
|
||||
nDecs[0], pPars->nRandFuncs, pPars->nVars, pPars->nNodes, pPars->nLutSize,
|
||||
pPars->nMintNum, pPars->Seed, pPars->RuntimeLim, pPars->fLutCascade ? "_r" : "", Exa_TimeStamp() );
|
||||
FILE * pFile = fopen( filename, "wb" );
|
||||
if ( pFile ) {
|
||||
fwrite( Vec_StrArray(vUndec), 1, Vec_StrSize(vUndec), pFile );
|
||||
fclose( pFile );
|
||||
printf( "The resulting undecided functions were written into file \"%s\".\n", filename );
|
||||
}
|
||||
}
|
||||
Abc_PrintTime( 1, "Total time", Abc_Clock() - clk );
|
||||
Vec_StrFree( vUndec );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue