From c4322a0afd740d85fe850e0811d629627a062403 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 6 Dec 2017 10:31:21 -0800 Subject: Switch -a to use only AND-gates in 'twoexact' and 'lutexact'. --- src/sat/bmc/bmcMaj2.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src/sat/bmc/bmcMaj2.c') diff --git a/src/sat/bmc/bmcMaj2.c b/src/sat/bmc/bmcMaj2.c index 46f3f1f2..23b5cf41 100644 --- a/src/sat/bmc/bmcMaj2.c +++ b/src/sat/bmc/bmcMaj2.c @@ -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++ ) -- cgit v1.2.3