diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2017-12-06 10:31:21 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2017-12-06 10:31:21 -0800 |
commit | c4322a0afd740d85fe850e0811d629627a062403 (patch) | |
tree | da2f6bae8ac6c2c766bcf80ae8032f082832851f /src/sat/bmc | |
parent | b258db83b8b9becc444baf11732597c000651020 (diff) | |
download | abc-c4322a0afd740d85fe850e0811d629627a062403.tar.gz abc-c4322a0afd740d85fe850e0811d629627a062403.tar.bz2 abc-c4322a0afd740d85fe850e0811d629627a062403.zip |
Switch -a to use only AND-gates in 'twoexact' and 'lutexact'.
Diffstat (limited to 'src/sat/bmc')
-rw-r--r-- | src/sat/bmc/bmcMaj.c | 35 | ||||
-rw-r--r-- | src/sat/bmc/bmcMaj2.c | 34 |
2 files changed, 52 insertions, 17 deletions
diff --git a/src/sat/bmc/bmcMaj.c b/src/sat/bmc/bmcMaj.c index 0b09e311..4f5dadef 100644 --- a/src/sat/bmc/bmcMaj.c +++ b/src/sat/bmc/bmcMaj.c @@ -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++ ) 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++ ) |