Skip to content

Commit

Permalink
Updating "lutexact" to support single-rail LUT cascade.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanminko committed Aug 12, 2024
1 parent 807f6dd commit 81fcf84
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/base/abci/abc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9804,7 +9804,7 @@ 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, "INKTiaogvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "INKTiaocgvh" ) ) != EOF )
{
switch ( c )
{
Expand Down Expand Up @@ -9861,6 +9861,9 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'o':
pPars->fFewerVars ^= 1;
break;
case 'c':
pPars->fLutCascade ^= 1;
break;
case 'g':
pPars->fGlucose ^= 1;
break;
Expand Down Expand Up @@ -9907,7 +9910,7 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;

usage:
Abc_Print( -2, "usage: lutexact [-INKT <num>] [-iaogvh] <hex>\n" );
Abc_Print( -2, "usage: lutexact [-INKT <num>] [-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 );
Expand All @@ -9916,6 +9919,7 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
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" );
Abc_Print( -2, "\t-o : toggle using additional optimizations [default = %s]\n", pPars->fFewerVars ? "yes" : "no" );
Abc_Print( -2, "\t-c : toggle synthesizing a single-rail cascade [default = %s]\n", pPars->fLutCascade ? "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-v : toggle verbose printout [default = %s]\n", pPars->fVerbose ? "yes" : "no" );
Abc_Print( -2, "\t-h : print the command usage\n" );
Expand Down
4 changes: 3 additions & 1 deletion src/sat/bmc/bmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct Bmc_EsPar_t_
int fFewerVars;
int fQuadrEnc;
int fUniqFans;
int fLutCascade;
int RuntimeLim;
int fVerbose;
char * pTtStr;
Expand All @@ -84,7 +85,8 @@ static inline void Bmc_EsParSetDefault( Bmc_EsPar_t * pPars )
pPars->fEnumSols = 0;
pPars->fFewerVars = 0;
pPars->fQuadrEnc = 0;
pPars->fUniqFans = 0;
pPars->fUniqFans = 0;
pPars->fLutCascade = 0;
pPars->RuntimeLim = 0;
pPars->fVerbose = 1;
}
Expand Down
75 changes: 75 additions & 0 deletions src/sat/bmc/bmcMaj.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "sat/glucose/AbcGlucose.h"
#include "aig/miniaig/miniaig.h"
#include "base/io/ioResub.h"
#include "base/main/main.h"
#include "base/cmd/cmd.h"

ABC_NAMESPACE_IMPL_START

Expand Down Expand Up @@ -1045,6 +1047,23 @@ static int Exa3_ManMarkup( Exa3_Man_t * p )
// assign connectivity variables
for ( i = p->nVars; i < p->nObjs; i++ )
{
if ( p->pPars->fLutCascade )
{
if ( i > p->nVars )
{
Vec_WecPush( p->vOutLits, i-1, Abc_Var2Lit(p->iVar, 0) );
p->VarMarks[i][0][i-1] = p->iVar++;
}
for ( k = (int)(i > p->nVars); k < p->nLutSize; k++ )
{
for ( j = 0; j < p->nVars - k + (int)(i > p->nVars); j++ )
{
Vec_WecPush( p->vOutLits, j, Abc_Var2Lit(p->iVar, 0) );
p->VarMarks[i][k][j] = p->iVar++;
}
}
continue;
}
for ( k = 0; k < p->nLutSize; k++ )
{
if ( p->pPars->fFewerVars && i == p->nObjs - 1 && k == 0 )
Expand Down Expand Up @@ -3916,6 +3935,62 @@ void Exa_ManExactSynthesis7( Bmc_EsPar_t * pPars, int GateSize )
Abc_PrintTime( 1, "Total runtime", Abc_Clock() - clkTotal );
}

/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Exa_NpnCascadeTest()
{
char Buffer[100];
char Command[1000]; int i;
FILE * pFile = fopen( "npn3.txt", "r" );
for ( i = 0; i < 14; i++ )
// FILE * pFile = fopen( "npn4.txt", "r" );
// for ( i = 0; i < 222; i++ )
// FILE * pFile = fopen( "npn5.txt", "r" );
// for ( i = 0; i < 616126; i++ )
{
int Value = fscanf( pFile, "%s", Buffer );
assert( Value == 1 );
if ( i == 0 ) continue;
if ( Buffer[strlen(Buffer)-1] == '\n' )
Buffer[strlen(Buffer)-1] = '\0';
if ( Buffer[strlen(Buffer)-1] == '\r' )
Buffer[strlen(Buffer)-1] = '\0';
sprintf( Command, "lutexact -I 3 -N 2 -K 2 -gvc %s", Buffer+2 );
printf( "\nNPN class %6d : Command \"%s\":\n", i, Command );
if ( Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ) )
{
fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
return;
}
}
fclose( pFile );
}
void Exa_NpnCascadeTest6()
{
char Command[1000]; int i;
Abc_Random(1);
for ( i = 0; i < 10000; i++ )
{
word Truth = Abc_RandomW(0);
sprintf( Command, "lutexact -I 6 -N 2 -K 5 -gvc %016lx", Truth );
printf( "\nIter %4d : Command \"%s\":\n", i, Command );
if ( Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ) )
{
fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
return;
}
}
}

////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
Expand Down
17 changes: 17 additions & 0 deletions src/sat/bmc/bmcMaj2.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,23 @@ static int Exa3_ManMarkup( Exa3_Man_t * p )
// assign connectivity variables
for ( i = p->nVars; i < p->nObjs; i++ )
{
if ( p->pPars->fLutCascade )
{
if ( i > p->nVars )
{
Vec_WecPush( p->vOutLits, i-1, Abc_Var2Lit(p->iVar, 0) );
p->VarMarks[i][0][i-1] = p->iVar++;
}
for ( k = (int)(i > p->nVars); k < p->nLutSize; k++ )
{
for ( j = 0; j < p->nVars - k + (int)(i > p->nVars); j++ )
{
Vec_WecPush( p->vOutLits, j, Abc_Var2Lit(p->iVar, 0) );
p->VarMarks[i][k][j] = p->iVar++;
}
}
continue;
}
for ( k = 0; k < p->nLutSize; k++ )
{
if ( p->pPars->fFewerVars && i == p->nObjs - 1 && k == 0 )
Expand Down

0 comments on commit 81fcf84

Please sign in to comment.