mirror of https://github.com/YosysHQ/abc.git
Switch -a to use only AND-gates in 'twoexact' and 'lutexact'.
This commit is contained in:
parent
b258db83b8
commit
c4322a0afd
|
|
@ -8177,11 +8177,11 @@ usage:
|
|||
***********************************************************************/
|
||||
int Abc_CommandTwoExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
{
|
||||
extern void Exa_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int fVerbose );
|
||||
extern void Exa_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int fVerbose );
|
||||
int c, nVars = 4, nNodes = 3, fGlucose = 0, fVerbose = 1; char * pTtStr = NULL;
|
||||
extern void Exa_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int fOnlyAnd, int fVerbose );
|
||||
extern void Exa_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int fOnlyAnd, int fVerbose );
|
||||
int c, nVars = 4, nNodes = 3, fGlucose = 0, fOnlyAnd = 0, fVerbose = 1; char * pTtStr = NULL;
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "INgvh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "INagvh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -8207,6 +8207,9 @@ int Abc_CommandTwoExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
if ( nNodes < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'a':
|
||||
fOnlyAnd ^= 1;
|
||||
break;
|
||||
case 'g':
|
||||
fGlucose ^= 1;
|
||||
break;
|
||||
|
|
@ -8232,16 +8235,17 @@ int Abc_CommandTwoExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 1;
|
||||
}
|
||||
if ( fGlucose )
|
||||
Exa_ManExactSynthesis( pTtStr, nVars, nNodes, fVerbose );
|
||||
Exa_ManExactSynthesis( pTtStr, nVars, nNodes, fOnlyAnd, fVerbose );
|
||||
else
|
||||
Exa_ManExactSynthesis2( pTtStr, nVars, nNodes, fVerbose );
|
||||
Exa_ManExactSynthesis2( pTtStr, nVars, nNodes, fOnlyAnd, fVerbose );
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: twoexact [-IN <num>] [-fcgvh] <hex>\n" );
|
||||
Abc_Print( -2, "usage: twoexact [-IN <num>] [-fcagvh] <hex>\n" );
|
||||
Abc_Print( -2, "\t exact synthesis of multi-input function using two-input gates\n" );
|
||||
Abc_Print( -2, "\t-I <num> : the number of input variables [default = %d]\n", nVars );
|
||||
Abc_Print( -2, "\t-N <num> : the number of MAJ3 nodes [default = %d]\n", nNodes );
|
||||
Abc_Print( -2, "\t-a : toggle using only AND-gates (without XOR-gates) [default = %s]\n", fOnlyAnd ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-g : toggle using Glucose 3.0 by Gilles Audemard and Laurent Simon [default = %s]\n", fGlucose ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-h : print the command usage\n" );
|
||||
|
|
@ -8262,11 +8266,11 @@ usage:
|
|||
***********************************************************************/
|
||||
int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
{
|
||||
extern void Exa3_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int nLutSize, int fVerbose );
|
||||
extern void Exa3_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int nLutSize, int fVerbose );
|
||||
int c, nVars = 5, nNodes = 5, nLutSize = 3, fGlucose = 0, fVerbose = 1; char * pTtStr = NULL;
|
||||
extern void Exa3_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int nLutSize, int fOnlyAnd, int fVerbose );
|
||||
extern void Exa3_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int nLutSize, int fOnlyAnd, int fVerbose );
|
||||
int c, nVars = 5, nNodes = 5, nLutSize = 3, fGlucose = 0, fOnlyAnd = 0, fVerbose = 1; char * pTtStr = NULL;
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "INKgvh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "INKagvh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -8303,6 +8307,9 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
if ( nLutSize < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'a':
|
||||
fOnlyAnd ^= 1;
|
||||
break;
|
||||
case 'g':
|
||||
fGlucose ^= 1;
|
||||
break;
|
||||
|
|
@ -8333,17 +8340,18 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 1;
|
||||
}
|
||||
if ( fGlucose )
|
||||
Exa3_ManExactSynthesis( pTtStr, nVars, nNodes, nLutSize, fVerbose );
|
||||
Exa3_ManExactSynthesis( pTtStr, nVars, nNodes, nLutSize, fOnlyAnd, fVerbose );
|
||||
else
|
||||
Exa3_ManExactSynthesis2( pTtStr, nVars, nNodes, nLutSize, fVerbose );
|
||||
Exa3_ManExactSynthesis2( pTtStr, nVars, nNodes, nLutSize, fOnlyAnd, fVerbose );
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: lutexact [-INK <num>] [-fcgvh] <hex>\n" );
|
||||
Abc_Print( -2, "usage: lutexact [-INK <num>] [-fcagvh] <hex>\n" );
|
||||
Abc_Print( -2, "\t exact synthesis of multi-input function using two-input gates\n" );
|
||||
Abc_Print( -2, "\t-I <num> : the number of input variables [default = %d]\n", nVars );
|
||||
Abc_Print( -2, "\t-N <num> : the number of K-input nodes [default = %d]\n", nNodes );
|
||||
Abc_Print( -2, "\t-K <num> : the number of node fanins [default = %d]\n", nLutSize );
|
||||
Abc_Print( -2, "\t-a : toggle using only AND-gates when K = 2 [default = %s]\n", fOnlyAnd ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-g : toggle using Glucose 3.0 by Gilles Audemard and Laurent Simon [default = %s]\n", fGlucose ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-h : print the command usage\n" );
|
||||
|
|
|
|||
|
|
@ -431,9 +431,9 @@ int Exa_ManMarkup( Exa_Man_t * p )
|
|||
{
|
||||
int i, k, j;
|
||||
assert( p->nObjs <= MAJ_NOBJS );
|
||||
// assign variables for truth tables
|
||||
// assign functionality
|
||||
p->iVar = 1 + p->nNodes * 3;
|
||||
// assign variables for other nodes
|
||||
// assign connectivity variables
|
||||
for ( i = p->nVars; i < p->nObjs; i++ )
|
||||
{
|
||||
for ( k = 0; k < 2; k++ )
|
||||
|
|
@ -591,7 +591,7 @@ void Exa_ManPrintSolution( Exa_Man_t * p, int fCompl )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Exa_ManAddCnfStart( Exa_Man_t * p )
|
||||
int Exa_ManAddCnfStart( Exa_Man_t * p, int fOnlyAnd )
|
||||
{
|
||||
int pLits[MAJ_NOBJS], pLits2[2], i, j, k, n, m;
|
||||
// input constraints
|
||||
|
|
@ -637,6 +637,14 @@ int Exa_ManAddCnfStart( Exa_Man_t * p )
|
|||
if ( !bmcg_sat_solver_addclause( p->pSat, pLits, 3 ) )
|
||||
return 0;
|
||||
}
|
||||
if ( fOnlyAnd )
|
||||
{
|
||||
pLits[0] = Abc_Var2Lit( iVarStart, 1 );
|
||||
pLits[1] = Abc_Var2Lit( iVarStart+1, 1 );
|
||||
pLits[2] = Abc_Var2Lit( iVarStart+2, 0 );
|
||||
if ( !bmcg_sat_solver_addclause( p->pSat, pLits, 3 ) )
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// outputs should be used
|
||||
for ( i = 0; i < p->nObjs - 1; i++ )
|
||||
|
|
@ -703,7 +711,7 @@ int Exa_ManAddCnf( Exa_Man_t * p, int iMint )
|
|||
p->iVar += 3*p->nNodes;
|
||||
return 1;
|
||||
}
|
||||
void Exa_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int fVerbose )
|
||||
void Exa_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int fOnlyAnd, int fVerbose )
|
||||
{
|
||||
int i, status, iMint = 1;
|
||||
abctime clkTotal = Abc_Clock();
|
||||
|
|
@ -712,7 +720,7 @@ void Exa_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int fVerbose )
|
|||
assert( nVars <= 10 );
|
||||
p = Exa_ManAlloc( nVars, nNodes, pTruth );
|
||||
if ( pTruth[0] & 1 ) { fCompl = 1; Abc_TtNot( pTruth, p->nWords ); }
|
||||
status = Exa_ManAddCnfStart( p );
|
||||
status = Exa_ManAddCnfStart( p, fOnlyAnd );
|
||||
assert( status );
|
||||
printf( "Running exact synthesis for %d-input function with %d two-input gates...\n", p->nVars, p->nNodes );
|
||||
for ( i = 0; iMint != -1; i++ )
|
||||
|
|
@ -790,8 +798,9 @@ static int Exa3_ManMarkup( Exa3_Man_t * p )
|
|||
{
|
||||
int i, k, j;
|
||||
assert( p->nObjs <= MAJ_NOBJS );
|
||||
// assign variables for truth tables
|
||||
// assign functionality variables
|
||||
p->iVar = 1 + p->LutMask * p->nNodes;
|
||||
// assign connectivity variables
|
||||
for ( i = p->nVars; i < p->nObjs; i++ )
|
||||
{
|
||||
for ( k = 0; k < p->nLutSize; k++ )
|
||||
|
|
@ -961,7 +970,7 @@ static void Exa3_ManPrintSolution( Exa3_Man_t * p, int fCompl )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static int Exa3_ManAddCnfStart( Exa3_Man_t * p )
|
||||
static int Exa3_ManAddCnfStart( Exa3_Man_t * p, int fOnlyAnd )
|
||||
{
|
||||
int pLits[MAJ_NOBJS], pLits2[2], i, j, k, n, m;
|
||||
// input constraints
|
||||
|
|
@ -1009,6 +1018,14 @@ static int Exa3_ManAddCnfStart( Exa3_Man_t * p )
|
|||
if ( !bmcg_sat_solver_addclause( p->pSat, pLits, 3 ) )
|
||||
return 0;
|
||||
}
|
||||
if ( fOnlyAnd )
|
||||
{
|
||||
pLits[0] = Abc_Var2Lit( iVarStart, 1 );
|
||||
pLits[1] = Abc_Var2Lit( iVarStart+1, 1 );
|
||||
pLits[2] = Abc_Var2Lit( iVarStart+2, 0 );
|
||||
if ( !bmcg_sat_solver_addclause( p->pSat, pLits, 3 ) )
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// outputs should be used
|
||||
for ( i = 0; i < p->nObjs - 1; i++ )
|
||||
|
|
@ -1079,7 +1096,7 @@ static int Exa3_ManAddCnf( Exa3_Man_t * p, int iMint )
|
|||
p->iVar += (p->nLutSize+1)*p->nNodes;
|
||||
return 1;
|
||||
}
|
||||
void Exa3_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int nLutSize, int fVerbose )
|
||||
void Exa3_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int nLutSize, int fOnlyAnd, int fVerbose )
|
||||
{
|
||||
int i, status, iMint = 1;
|
||||
abctime clkTotal = Abc_Clock();
|
||||
|
|
@ -1089,7 +1106,7 @@ void Exa3_ManExactSynthesis( char * pTtStr, int nVars, int nNodes, int nLutSize,
|
|||
assert( nLutSize <= 6 );
|
||||
p = Exa3_ManAlloc( nVars, nNodes, nLutSize, pTruth );
|
||||
if ( pTruth[0] & 1 ) { fCompl = 1; Abc_TtNot( pTruth, p->nWords ); }
|
||||
status = Exa3_ManAddCnfStart( p );
|
||||
status = Exa3_ManAddCnfStart( p, fOnlyAnd );
|
||||
assert( status );
|
||||
printf( "Running exact synthesis for %d-input function with %d %d-input LUTs...\n", p->nVars, p->nNodes, p->nLutSize );
|
||||
for ( i = 0; iMint != -1; i++ )
|
||||
|
|
|
|||
|
|
@ -538,8 +538,9 @@ static int Exa_ManMarkup( Exa_Man_t * p )
|
|||
{
|
||||
int i, k, j;
|
||||
assert( p->nObjs <= MAJ_NOBJS );
|
||||
// assign variables for truth tables
|
||||
// assign functionality
|
||||
p->iVar = 1 + p->nNodes * 3;
|
||||
// assign connectivity variables
|
||||
for ( i = p->nVars; i < p->nObjs; i++ )
|
||||
{
|
||||
for ( k = 0; k < 2; k++ )
|
||||
|
|
@ -697,7 +698,7 @@ static void Exa_ManPrintSolution( Exa_Man_t * p, int fCompl )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static int Exa_ManAddCnfStart( Exa_Man_t * p )
|
||||
static int Exa_ManAddCnfStart( Exa_Man_t * p, int fOnlyAnd )
|
||||
{
|
||||
int pLits[MAJ_NOBJS], pLits2[2], i, j, k, n, m;
|
||||
// input constraints
|
||||
|
|
@ -743,6 +744,14 @@ static int Exa_ManAddCnfStart( Exa_Man_t * p )
|
|||
if ( !sat_solver_addclause( p->pSat, pLits, pLits+3 ) )
|
||||
return 0;
|
||||
}
|
||||
if ( fOnlyAnd )
|
||||
{
|
||||
pLits[0] = Abc_Var2Lit( iVarStart, 1 );
|
||||
pLits[1] = Abc_Var2Lit( iVarStart+1, 1 );
|
||||
pLits[2] = Abc_Var2Lit( iVarStart+2, 0 );
|
||||
if ( !sat_solver_addclause( p->pSat, pLits, pLits+3 ) )
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// outputs should be used
|
||||
for ( i = 0; i < p->nObjs - 1; i++ )
|
||||
|
|
@ -809,7 +818,7 @@ static int Exa_ManAddCnf( Exa_Man_t * p, int iMint )
|
|||
p->iVar += 3*p->nNodes;
|
||||
return 1;
|
||||
}
|
||||
void Exa_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int fVerbose )
|
||||
void Exa_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int fOnlyAnd, int fVerbose )
|
||||
{
|
||||
int i, status, iMint = 1;
|
||||
abctime clkTotal = Abc_Clock();
|
||||
|
|
@ -818,7 +827,7 @@ void Exa_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int fVerbose
|
|||
assert( nVars <= 10 );
|
||||
p = Exa_ManAlloc( nVars, nNodes, pTruth );
|
||||
if ( pTruth[0] & 1 ) { fCompl = 1; Abc_TtNot( pTruth, p->nWords ); }
|
||||
status = Exa_ManAddCnfStart( p );
|
||||
status = Exa_ManAddCnfStart( p, fOnlyAnd );
|
||||
assert( status );
|
||||
printf( "Running exact synthesis for %d-input function with %d two-input gates...\n", p->nVars, p->nNodes );
|
||||
for ( i = 0; iMint != -1; i++ )
|
||||
|
|
@ -898,8 +907,9 @@ static int Exa3_ManMarkup( Exa3_Man_t * p )
|
|||
{
|
||||
int i, k, j;
|
||||
assert( p->nObjs <= MAJ_NOBJS );
|
||||
// assign variables for truth tables
|
||||
// assign functionality variables
|
||||
p->iVar = 1 + p->LutMask * p->nNodes;
|
||||
// assign connectivity variables
|
||||
for ( i = p->nVars; i < p->nObjs; i++ )
|
||||
{
|
||||
for ( k = 0; k < p->nLutSize; k++ )
|
||||
|
|
@ -1079,7 +1089,7 @@ static void Exa3_ManPrintSolution( Exa3_Man_t * p, int fCompl )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static int Exa3_ManAddCnfStart( Exa3_Man_t * p )
|
||||
static int Exa3_ManAddCnfStart( Exa3_Man_t * p, int fOnlyAnd )
|
||||
{
|
||||
int pLits[MAJ_NOBJS], pLits2[2], i, j, k, n, m;
|
||||
// input constraints
|
||||
|
|
@ -1127,6 +1137,14 @@ static int Exa3_ManAddCnfStart( Exa3_Man_t * p )
|
|||
if ( !sat_solver_addclause( p->pSat, pLits, pLits+3 ) )
|
||||
return 0;
|
||||
}
|
||||
if ( fOnlyAnd )
|
||||
{
|
||||
pLits[0] = Abc_Var2Lit( iVarStart, 1 );
|
||||
pLits[1] = Abc_Var2Lit( iVarStart+1, 1 );
|
||||
pLits[2] = Abc_Var2Lit( iVarStart+2, 0 );
|
||||
if ( !sat_solver_addclause( p->pSat, pLits, pLits+3 ) )
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// outputs should be used
|
||||
for ( i = 0; i < p->nObjs - 1; i++ )
|
||||
|
|
@ -1196,7 +1214,7 @@ static int Exa3_ManAddCnf( Exa3_Man_t * p, int iMint )
|
|||
p->iVar += (p->nLutSize+1)*p->nNodes;
|
||||
return 1;
|
||||
}
|
||||
void Exa3_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int nLutSize, int fVerbose )
|
||||
void Exa3_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int nLutSize, int fOnlyAnd, int fVerbose )
|
||||
{
|
||||
int i, status, iMint = 1;
|
||||
abctime clkTotal = Abc_Clock();
|
||||
|
|
@ -1206,7 +1224,7 @@ void Exa3_ManExactSynthesis2( char * pTtStr, int nVars, int nNodes, int nLutSize
|
|||
assert( nLutSize <= 6 );
|
||||
p = Exa3_ManAlloc( nVars, nNodes, nLutSize, pTruth );
|
||||
if ( pTruth[0] & 1 ) { fCompl = 1; Abc_TtNot( pTruth, p->nWords ); }
|
||||
status = Exa3_ManAddCnfStart( p );
|
||||
status = Exa3_ManAddCnfStart( p, fOnlyAnd );
|
||||
assert( status );
|
||||
printf( "Running exact synthesis for %d-input function with %d %d-input LUTs...\n", p->nVars, p->nNodes, p->nLutSize );
|
||||
for ( i = 0; iMint != -1; i++ )
|
||||
|
|
|
|||
Loading…
Reference in New Issue