mirror of https://github.com/YosysHQ/abc.git
Merged alanmi/abc into default
This commit is contained in:
commit
d971505402
|
|
@ -1743,6 +1743,14 @@ SOURCE=.\src\sat\bsat\satSolver2i.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\bsat\satSolver3.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\bsat\satSolver3.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\bsat\satStore.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ ABC_NAMESPACE_IMPL_START
|
|||
|
||||
|
||||
#define ISO_MASK 0xFF
|
||||
static int s_256Primes[ISO_MASK+1] =
|
||||
static unsigned int s_256Primes[ISO_MASK+1] =
|
||||
{
|
||||
0x984b6ad9,0x18a6eed3,0x950353e2,0x6222f6eb,0xdfbedd47,0xef0f9023,0xac932a26,0x590eaf55,
|
||||
0x97d0a034,0xdc36cd2e,0x22736b37,0xdc9066b0,0x2eb2f98b,0x5d9c7baf,0x85747c9e,0x8aca1055,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ ABC_NAMESPACE_IMPL_START
|
|||
|
||||
|
||||
#define ISO_MASK 0xFF
|
||||
static int s_256Primes[ISO_MASK+1] =
|
||||
static unsigned int s_256Primes[ISO_MASK+1] =
|
||||
{
|
||||
0x984b6ad9,0x18a6eed3,0x950353e2,0x6222f6eb,0xdfbedd47,0xef0f9023,0xac932a26,0x590eaf55,
|
||||
0x97d0a034,0xdc36cd2e,0x22736b37,0xdc9066b0,0x2eb2f98b,0x5d9c7baf,0x85747c9e,0x8aca1055,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,136 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [giaSatoko.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName [Scalable AIG package.]
|
||||
|
||||
Synopsis [Interface to Satoko solver.]
|
||||
|
||||
Author [Alan Mishchenko, Bruno Schmitt]
|
||||
|
||||
Affiliation [UC Berkeley]
|
||||
|
||||
Date [Ver. 1.0. Started - June 20, 2005.]
|
||||
|
||||
Revision [$Id: giaSatoko.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#include "gia.h"
|
||||
#include "sat/cnf/cnf.h"
|
||||
#include "sat/bsat/satSolver3.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
sat_solver3 * Gia_ManSat3Init( Cnf_Dat_t * pCnf )
|
||||
{
|
||||
sat_solver3 * pSat = sat_solver3_new();
|
||||
int i;
|
||||
//sat_solver_setnvars( pSat, p->nVars );
|
||||
for ( i = 0; i < pCnf->nClauses; i++ )
|
||||
{
|
||||
if ( !sat_solver3_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
|
||||
{
|
||||
sat_solver3_delete( pSat );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return pSat;
|
||||
}
|
||||
void Gia_ManSat3Report( int iOutput, int status, abctime clk )
|
||||
{
|
||||
if ( iOutput >= 0 )
|
||||
Abc_Print( 1, "Output %6d : ", iOutput );
|
||||
else
|
||||
Abc_Print( 1, "Total: " );
|
||||
|
||||
if ( status == l_Undef )
|
||||
Abc_Print( 1, "UNDECIDED " );
|
||||
else if ( status == l_True )
|
||||
Abc_Print( 1, "SATISFIABLE " );
|
||||
else
|
||||
Abc_Print( 1, "UNSATISFIABLE " );
|
||||
|
||||
Abc_PrintTime( 1, "Time", clk );
|
||||
}
|
||||
sat_solver3 * Gia_ManSat3Create( Gia_Man_t * p )
|
||||
{
|
||||
Cnf_Dat_t * pCnf = (Cnf_Dat_t *)Mf_ManGenerateCnf( p, 8, 0, 1, 0, 0 );
|
||||
sat_solver3 * pSat = Gia_ManSat3Init( pCnf );
|
||||
int status = pSat ? sat_solver3_simplify(pSat) : 0;
|
||||
Cnf_DataFree( pCnf );
|
||||
if ( status )
|
||||
return pSat;
|
||||
if ( pSat )
|
||||
sat_solver3_delete( pSat );
|
||||
return NULL;
|
||||
}
|
||||
int Gia_ManSat3CallOne( Gia_Man_t * p, int iOutput )
|
||||
{
|
||||
abctime clk = Abc_Clock();
|
||||
sat_solver3 * pSat;
|
||||
int status, Cost = 0;
|
||||
|
||||
pSat = Gia_ManSat3Create( p );
|
||||
if ( pSat )
|
||||
{
|
||||
status = sat_solver3_solve( pSat, NULL, NULL, 0, 0, 0, 0 );
|
||||
Cost = (unsigned)pSat->stats.conflicts;
|
||||
sat_solver3_delete( pSat );
|
||||
}
|
||||
else
|
||||
status = l_False;
|
||||
|
||||
Gia_ManSat3Report( iOutput, status, Abc_Clock() - clk );
|
||||
return Cost;
|
||||
}
|
||||
void Gia_ManSat3Call( Gia_Man_t * p, int fSplit )
|
||||
{
|
||||
Gia_Man_t * pOne;
|
||||
Gia_Obj_t * pRoot;
|
||||
int i;
|
||||
if ( fSplit )
|
||||
{
|
||||
abctime clk = Abc_Clock();
|
||||
Gia_ManForEachCo( p, pRoot, i )
|
||||
{
|
||||
pOne = Gia_ManDupDfsCone( p, pRoot );
|
||||
Gia_ManSat3CallOne( pOne, i );
|
||||
Gia_ManStop( pOne );
|
||||
}
|
||||
Abc_PrintTime( 1, "Total time", Abc_Clock() - clk );
|
||||
return;
|
||||
}
|
||||
Gia_ManSat3CallOne( p, -1 );
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
||||
|
|
@ -60,6 +60,7 @@ SRC += src/aig/gia/giaAig.c \
|
|||
src/aig/gia/giaSatLut.c \
|
||||
src/aig/gia/giaSatMap.c \
|
||||
src/aig/gia/giaSatoko.c \
|
||||
src/aig/gia/giaSat3.c \
|
||||
src/aig/gia/giaScl.c \
|
||||
src/aig/gia/giaScript.c \
|
||||
src/aig/gia/giaShow.c \
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ static int s_1kPrimes[ISO_MASK+1] = {
|
|||
*/
|
||||
|
||||
#define ISO_MASK 0x3FF
|
||||
static int s_1kPrimes[ISO_MASK+1] =
|
||||
static unsigned int s_1kPrimes[ISO_MASK+1] =
|
||||
//#define ISO_MASK 0xFF
|
||||
//static int s_1kPrimes[0x3FF+1] =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -313,6 +313,7 @@ static int Abc_CommandDSat ( Abc_Frame_t * pAbc, int argc, cha
|
|||
static int Abc_CommandXSat ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandSatoko ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandAbc9Satoko ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandAbc9Sat3 ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandPSat ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandProve ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
static int Abc_CommandIProve ( Abc_Frame_t * pAbc, int argc, char ** argv );
|
||||
|
|
@ -965,6 +966,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
|
|||
Cmd_CommandAdd( pAbc, "Verification", "xsat", Abc_CommandXSat, 0 );
|
||||
Cmd_CommandAdd( pAbc, "Verification", "satoko", Abc_CommandSatoko, 0 );
|
||||
Cmd_CommandAdd( pAbc, "Verification", "&satoko", Abc_CommandAbc9Satoko, 0 );
|
||||
Cmd_CommandAdd( pAbc, "Verification", "&sat3", Abc_CommandAbc9Sat3, 0 );
|
||||
Cmd_CommandAdd( pAbc, "Verification", "psat", Abc_CommandPSat, 0 );
|
||||
Cmd_CommandAdd( pAbc, "Verification", "prove", Abc_CommandProve, 1 );
|
||||
Cmd_CommandAdd( pAbc, "Verification", "iprove", Abc_CommandIProve, 1 );
|
||||
|
|
@ -23554,6 +23556,74 @@ usage:
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Abc_CommandAbc9Sat3( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||
{
|
||||
extern void Gia_ManSat3Call( Gia_Man_t * p, int fSplit );
|
||||
int c, fSplit = 0, fIncrem = 0;
|
||||
|
||||
satoko_opts_t opts;
|
||||
satoko_default_opts(&opts);
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "Csivh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
case 'C':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
|
||||
goto usage;
|
||||
}
|
||||
opts.conf_limit = atoi(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
if ( opts.conf_limit < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 's':
|
||||
fSplit ^= 1;
|
||||
break;
|
||||
case 'i':
|
||||
fIncrem ^= 1;
|
||||
break;
|
||||
case 'v':
|
||||
opts.verbose ^= 1;
|
||||
break;
|
||||
case 'h':
|
||||
goto usage;
|
||||
|
||||
default:
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
if ( pAbc->pGia == NULL )
|
||||
{
|
||||
Abc_Print( -1, "Abc_CommandAbc9Sat3(): There is no AIG.\n" );
|
||||
return 1;
|
||||
}
|
||||
Gia_ManSat3Call( pAbc->pGia, fSplit );
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: &sat3 [-C num] [-sivh]\n" );
|
||||
Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", opts.conf_limit );
|
||||
Abc_Print( -2, "\t-s : split multi-output miter into individual outputs [default = %s]\n", fSplit? "yes": "no" );
|
||||
Abc_Print( -2, "\t-i : split multi-output miter and solve incrementally [default = %s]\n", fIncrem? "yes": "no" );
|
||||
Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", opts.verbose? "yes": "no" );
|
||||
Abc_Print( -2, "\t-h : print the command usage\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
/// BASIC TYPES ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
typedef struct Abc_Frame_t_ Abc_Frame_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -93,6 +95,7 @@ extern ABC_DLL void Abc_NtkPrintMiniMapping( int * pArray );
|
|||
extern ABC_DLL int Abc_FrameReadProbStatus( Abc_Frame_t * pAbc );
|
||||
extern ABC_DLL void * Abc_FrameReadCex( Abc_Frame_t * pAbc );
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ struct Wlc_Par_t_
|
|||
int fPdra; // Use pdr -nct
|
||||
int fProofRefine; // Use proof-based refinement
|
||||
int fHybrid; // Use a hybrid of CBR and PBR
|
||||
int fCheckCombUnsat; // Check if ABS becomes comb. unsat
|
||||
int fVerbose; // verbose output
|
||||
int fPdrVerbose; // verbose output
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "wlc.h"
|
||||
#include "proof/pdr/pdr.h"
|
||||
#include "proof/pdr/pdrInt.h"
|
||||
#include "proof/ssw/ssw.h"
|
||||
#include "aig/gia/giaAig.h"
|
||||
#include "sat/bmc/bmc.h"
|
||||
|
||||
|
|
@ -33,6 +34,9 @@ ABC_NAMESPACE_IMPL_START
|
|||
extern Vec_Vec_t * IPdr_ManSaveClauses( Pdr_Man_t * p, int fDropLast );
|
||||
extern int IPdr_ManRestore( Pdr_Man_t * p, Vec_Vec_t * vClauses, Vec_Int_t * vMap );
|
||||
extern int IPdr_ManSolveInt( Pdr_Man_t * p, int fCheckClauses, int fPushClauses );
|
||||
extern int IPdr_ManCheckCombUnsat( Pdr_Man_t * p );
|
||||
extern int IPdr_ManReduceClauses( Pdr_Man_t * p, Vec_Vec_t * vClauses );
|
||||
extern void IPdr_ManPrintClauses( Vec_Vec_t * vClauses, int kStart, int nRegs );
|
||||
|
||||
typedef struct Int_Pair_t_ Int_Pair_t;
|
||||
struct Int_Pair_t_
|
||||
|
|
@ -302,6 +306,40 @@ Wlc_Ntk_t * Wlc_NtkIntroduceChoices( Wlc_Ntk_t * pNtk, Vec_Int_t * vBlacks )
|
|||
return pNew;
|
||||
}
|
||||
|
||||
static int Wlc_NtkCexIsReal( Wlc_Ntk_t * pOrig, Abc_Cex_t * pCex )
|
||||
{
|
||||
Gia_Man_t * pGiaOrig = Wlc_NtkBitBlast( pOrig, NULL, -1, 0, 0, 0, 0 );
|
||||
int f, i;
|
||||
Gia_Obj_t * pObj, * pObjRi;
|
||||
|
||||
Gia_ManConst0(pGiaOrig)->Value = 0;
|
||||
Gia_ManForEachRi( pGiaOrig, pObj, i )
|
||||
pObj->Value = 0;
|
||||
for ( f = 0; f <= pCex->iFrame; f++ )
|
||||
{
|
||||
for( i = 0; i < Gia_ManPiNum( pGiaOrig ); i++ )
|
||||
Gia_ManPi(pGiaOrig, i)->Value = Abc_InfoHasBit(pCex->pData, pCex->nRegs+pCex->nPis*f + i);
|
||||
Gia_ManForEachRiRo( pGiaOrig, pObjRi, pObj, i )
|
||||
pObj->Value = pObjRi->Value;
|
||||
Gia_ManForEachAnd( pGiaOrig, pObj, i )
|
||||
pObj->Value = Gia_ObjFanin0Copy(pObj) & Gia_ObjFanin1Copy(pObj);
|
||||
Gia_ManForEachCo( pGiaOrig, pObj, i )
|
||||
pObj->Value = Gia_ObjFanin0Copy(pObj);
|
||||
Gia_ManForEachPo( pGiaOrig, pObj, i )
|
||||
{
|
||||
if (pObj->Value==1) {
|
||||
Abc_Print( 1, "CEX is real on the original model.\n" );
|
||||
Gia_ManStop(pGiaOrig);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Abc_Print( 1, "CEX is spurious.\n" );
|
||||
Gia_ManStop(pGiaOrig);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Wlc_Ntk_t * Wlc_NtkAbs2( Wlc_Ntk_t * pNtk, Vec_Int_t * vBlacks, Vec_Int_t ** pvFlops )
|
||||
{
|
||||
Vec_Int_t * vFlops = Vec_IntAlloc( 100 );
|
||||
|
|
@ -1077,20 +1115,83 @@ int Wlc_NtkPdrAbs( Wlc_Ntk_t * p, Wlc_Par_t * pPars )
|
|||
Gia_ManPrintStats( pGia, NULL );
|
||||
}
|
||||
Wlc_NtkFree( pAbs );
|
||||
// Gia_AigerWrite( pGia, "abs.aig", 0, 0 );
|
||||
|
||||
// try to prove abstracted GIA by converting it to AIG and calling PDR
|
||||
pAig = Gia_ManToAigSimple( pGia );
|
||||
|
||||
pPdr = Pdr_ManStart( pAig, pPdrPars, NULL );
|
||||
clk2 = Abc_Clock();
|
||||
|
||||
if ( vClauses && pPars->fCheckCombUnsat )
|
||||
{
|
||||
Pdr_Man_t * pPdr2;
|
||||
|
||||
if ( Aig_ManAndNum( pAig ) <= 20000 )
|
||||
{
|
||||
Aig_Man_t * pAigScorr;
|
||||
Ssw_Pars_t ScorrPars, * pScorrPars = &ScorrPars;
|
||||
int nAnds;
|
||||
|
||||
clk2 = Abc_Clock();
|
||||
|
||||
Ssw_ManSetDefaultParams( pScorrPars );
|
||||
pScorrPars->fStopWhenGone = 1;
|
||||
pScorrPars->nFramesK = 1;
|
||||
pAigScorr = Ssw_SignalCorrespondence( pAig, pScorrPars );
|
||||
assert ( pAigScorr );
|
||||
nAnds = Aig_ManAndNum( pAigScorr);
|
||||
Aig_ManStop( pAigScorr );
|
||||
|
||||
if ( nAnds == 0 )
|
||||
{
|
||||
if ( pPars->fVerbose )
|
||||
Abc_PrintTime( 1, "SCORR proved UNSAT. Time", Abc_Clock() - clk2 );
|
||||
RetValue = 1;
|
||||
Gia_ManStop( pGia );
|
||||
Vec_IntFree( vPisNew );
|
||||
Aig_ManStop( pAig );
|
||||
break;
|
||||
}
|
||||
else if ( pPars->fVerbose )
|
||||
{
|
||||
Abc_Print( 1, "SCORR failed with %d ANDs. ", nAnds);
|
||||
Abc_PrintTime( 1, "Time", Abc_Clock() - clk2 );
|
||||
}
|
||||
}
|
||||
|
||||
clk2 = Abc_Clock();
|
||||
|
||||
pPdrPars->fVerbose = 0;
|
||||
pPdr2 = Pdr_ManStart( pAig, pPdrPars, NULL );
|
||||
RetValue = IPdr_ManCheckCombUnsat( pPdr2 );
|
||||
Pdr_ManStop( pPdr2 );
|
||||
pPdrPars->fVerbose = pPars->fPdrVerbose;
|
||||
|
||||
tPdr += Abc_Clock() - clk2;
|
||||
|
||||
if ( RetValue == 1 )
|
||||
{
|
||||
if ( pPars->fVerbose )
|
||||
Abc_PrintTime( 1, "ABS becomes combinationally UNSAT. Time", Abc_Clock() - clk2 );
|
||||
Gia_ManStop( pGia );
|
||||
Vec_IntFree( vPisNew );
|
||||
Aig_ManStop( pAig );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( pPars->fVerbose )
|
||||
Abc_PrintTime( 1, "Check comb. unsat failed. Time", Abc_Clock() - clk2 );
|
||||
}
|
||||
|
||||
clk2 = Abc_Clock();
|
||||
pPdr = Pdr_ManStart( pAig, pPdrPars, NULL );
|
||||
if ( vClauses ) {
|
||||
assert( Vec_VecSize( vClauses) >= 2 );
|
||||
IPdr_ManRestore( pPdr, vClauses, vMap );
|
||||
}
|
||||
Vec_IntFreeP( &vMap );
|
||||
|
||||
RetValue = IPdr_ManSolveInt( pPdr, pPars->fCheckClauses, pPars->fPushClauses );
|
||||
if ( !vClauses || RetValue != 1 )
|
||||
RetValue = IPdr_ManSolveInt( pPdr, pPars->fCheckClauses, pPars->fPushClauses );
|
||||
pPdr->tTotal += Abc_Clock() - clk2;
|
||||
tPdr += pPdr->tTotal;
|
||||
|
||||
|
|
@ -1107,6 +1208,16 @@ int Wlc_NtkPdrAbs( Wlc_Ntk_t * p, Wlc_Par_t * pPars )
|
|||
break;
|
||||
}
|
||||
|
||||
// verify CEX
|
||||
if ( Wlc_NtkCexIsReal( p, pCex ) )
|
||||
{
|
||||
vRefine = NULL;
|
||||
Abc_CexFree( pCex ); // return CEX in the future
|
||||
Pdr_ManStop( pPdr );
|
||||
Aig_ManStop( pAig );
|
||||
break;
|
||||
}
|
||||
|
||||
// perform refinement
|
||||
if ( pPars->fHybrid || !pPars->fProofRefine )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ int Abc_CommandPdrAbs( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
int c;
|
||||
Wlc_ManSetDefaultParams( pPars );
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "AMXFILabrcpmxvwh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "AMXFILabrcpmuxvwh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -553,6 +553,9 @@ int Abc_CommandPdrAbs( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
case 'm':
|
||||
pPars->fMFFC ^= 1;
|
||||
break;
|
||||
case 'u':
|
||||
pPars->fCheckCombUnsat ^= 1;
|
||||
break;
|
||||
case 'v':
|
||||
pPars->fVerbose ^= 1;
|
||||
break;
|
||||
|
|
@ -573,7 +576,7 @@ int Abc_CommandPdrAbs( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Wlc_NtkPdrAbs( pNtk, pPars );
|
||||
return 0;
|
||||
usage:
|
||||
Abc_Print( -2, "usage: %%pdra [-AMXFIL num] [-abrcpmxvwh]\n" );
|
||||
Abc_Print( -2, "usage: %%pdra [-AMXFIL num] [-abrcpmxuvwh]\n" );
|
||||
Abc_Print( -2, "\t abstraction for word-level networks\n" );
|
||||
Abc_Print( -2, "\t-A num : minimum bit-width of an adder/subtractor to abstract [default = %d]\n", pPars->nBitsAdd );
|
||||
Abc_Print( -2, "\t-M num : minimum bit-width of a multiplier to abstract [default = %d]\n", pPars->nBitsMul );
|
||||
|
|
@ -586,6 +589,7 @@ usage:
|
|||
Abc_Print( -2, "\t-b : toggle using proof-based refinement [default = %s]\n", pPars->fProofRefine? "yes": "no" );
|
||||
Abc_Print( -2, "\t-r : toggle using both cex-based and proof-based refinement [default = %s]\n", pPars->fHybrid? "yes": "no" );
|
||||
Abc_Print( -2, "\t-c : toggle checking clauses in the reloaded trace [default = %s]\n", pPars->fCheckClauses? "yes": "no" );
|
||||
Abc_Print( -2, "\t-u : toggle checking combinationally unsat [default = %s]\n", pPars->fCheckCombUnsat? "yes": "no" );
|
||||
Abc_Print( -2, "\t-p : toggle pushing clauses in the reloaded trace [default = %s]\n", pPars->fPushClauses? "yes": "no" );
|
||||
Abc_Print( -2, "\t-m : toggle refining the whole MFFC of a PPI [default = %s]\n", pPars->fMFFC? "yes": "no" );
|
||||
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ void Wlc_ManSetDefaultParams( Wlc_Par_t * pPars )
|
|||
pPars->fPdra = 0; // Use pdr -nct
|
||||
pPars->fProofRefine = 0; // Use proof-based refinement
|
||||
pPars->fHybrid = 1; // Use a hybrid of CBR and PBR
|
||||
pPars->fCheckCombUnsat = 0; // Check if ABS becomes comb. unsat
|
||||
pPars->fVerbose = 0; // verbose output`
|
||||
pPars->fPdrVerbose = 0; // show verbose PDR output
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ struct Scl_Con_t_
|
|||
#define SCL_OUTPUT_REQ "output_required"
|
||||
#define SCL_OUTPUT_LOAD "output_load"
|
||||
|
||||
#define SCL_DIRECTIVE(ITEM) "."ITEM
|
||||
#define SCL_DEF_DIRECTIVE(ITEM) ".default_"ITEM
|
||||
#define SCL_DIRECTIVE(ITEM) "."#ITEM
|
||||
#define SCL_DEF_DIRECTIVE(ITEM) ".default_"#ITEM
|
||||
|
||||
#define SCL_NUM 1000
|
||||
#define SCL_INFINITY (0x3FFFFFFF)
|
||||
|
|
|
|||
|
|
@ -59,8 +59,9 @@ void IPdr_ManPrintClauses( Vec_Vec_t * vClauses, int kStart, int nRegs )
|
|||
Vec_PtrSort( vArrayK, (int (*)(void))Pdr_SetCompare );
|
||||
Vec_PtrForEachEntry( Pdr_Set_t *, vArrayK, pCube, i )
|
||||
{
|
||||
Abc_Print( 1, "C=%4d. F=%4d ", Counter++, k );
|
||||
Pdr_SetPrint( stdout, pCube, nRegs, NULL );
|
||||
Abc_Print( 1, "Frame[%4d]Cube[%4d] = ", k, Counter++ );
|
||||
// Pdr_SetPrint( stdout, pCube, nRegs, NULL );
|
||||
ZPdr_SetPrint( pCube );
|
||||
Abc_Print( 1, "\n" );
|
||||
}
|
||||
}
|
||||
|
|
@ -738,6 +739,121 @@ int IPdr_ManSolve( Aig_Man_t * pAig, Pdr_Par_t * pPars )
|
|||
return RetValue;
|
||||
}
|
||||
|
||||
int IPdr_ManCheckCombUnsat( Pdr_Man_t * p )
|
||||
{
|
||||
int iFrame, RetValue = -1;
|
||||
|
||||
Pdr_ManCreateSolver( p, (iFrame = 0) );
|
||||
Pdr_ManCreateSolver( p, (iFrame = 1) );
|
||||
|
||||
p->nFrames = iFrame;
|
||||
p->iUseFrame = Abc_MaxInt(iFrame, 1);
|
||||
|
||||
RetValue = Pdr_ManCheckCube( p, iFrame, NULL, NULL, p->pPars->nConfLimit, 0, 1 );
|
||||
return RetValue;
|
||||
}
|
||||
|
||||
int IPdr_ManCheckCubeReduce( Pdr_Man_t * p, Vec_Ptr_t * vClauses, Pdr_Set_t * pCube, int nConfLimit )
|
||||
{
|
||||
sat_solver * pSat;
|
||||
Vec_Int_t * vLits, * vLitsA;
|
||||
int Lit, RetValue = l_True;
|
||||
int i;
|
||||
Pdr_Set_t * pCla;
|
||||
int iActVar = 0;
|
||||
abctime clk = Abc_Clock();
|
||||
|
||||
pSat = Pdr_ManSolver( p, 1 );
|
||||
|
||||
if ( pCube == NULL ) // solve the property
|
||||
{
|
||||
Lit = toLit( Pdr_ObjSatVar(p, 1, 2, Aig_ManCo(p->pAig, p->iOutCur)) ); // pos literal (property fails)
|
||||
RetValue = sat_solver_addclause( pSat, &Lit, &Lit+1 );
|
||||
assert( RetValue == 1 );
|
||||
|
||||
vLitsA = Vec_IntStart( Vec_PtrSize( vClauses ) );
|
||||
iActVar = Pdr_ManFreeVar( p, 1 );
|
||||
for ( i = 1; i < Vec_PtrSize( vClauses ); ++i )
|
||||
Pdr_ManFreeVar( p, 1 );
|
||||
Vec_PtrForEachEntry( Pdr_Set_t *, vClauses, pCla, i )
|
||||
{
|
||||
vLits = Pdr_ManCubeToLits( p, 1, pCla, 1, 0 );
|
||||
Lit = Abc_Var2Lit( iActVar + i, 1 );
|
||||
Vec_IntPush( vLits, Lit );
|
||||
|
||||
RetValue = sat_solver_addclause( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits) );
|
||||
assert( RetValue == 1 );
|
||||
Vec_IntWriteEntry( vLitsA, i, Abc_Var2Lit( iActVar + i, 0 ) );
|
||||
}
|
||||
sat_solver_compress( pSat );
|
||||
|
||||
// solve
|
||||
RetValue = sat_solver_solve( pSat, Vec_IntArray(vLitsA), Vec_IntArray(vLitsA) + Vec_IntSize(vLitsA), nConfLimit, 0, 0, 0 );
|
||||
Vec_IntFree( vLitsA );
|
||||
|
||||
if ( RetValue == l_Undef )
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert( RetValue != l_Undef );
|
||||
if ( RetValue == l_False ) // UNSAT
|
||||
{
|
||||
int ncorelits, *pcorelits;
|
||||
Vec_Ptr_t * vTemp = NULL;
|
||||
Vec_Bit_t * vMark = NULL;
|
||||
|
||||
ncorelits = sat_solver_final(pSat, &pcorelits);
|
||||
Abc_Print( 1, "UNSAT at the last frame. nCores = %d (out of %d).", ncorelits, Vec_PtrSize( vClauses ) );
|
||||
Abc_PrintTime( 1, " Time", Abc_Clock() - clk );
|
||||
|
||||
vTemp = Vec_PtrDup( vClauses );
|
||||
vMark = Vec_BitStart( Vec_PtrSize( vClauses) );
|
||||
Vec_PtrClear( vClauses );
|
||||
for ( i = 0; i < ncorelits; ++i )
|
||||
{
|
||||
//Abc_Print( 1, "Core[%d] = lit(%d) = var(%d) = %d-th set\n", i, pcorelits[i], Abc_Lit2Var(pcorelits[i]), Abc_Lit2Var(pcorelits[i]) - iActVar );
|
||||
Vec_BitWriteEntry( vMark, Abc_Lit2Var( pcorelits[i] ) - iActVar, 1 );
|
||||
}
|
||||
|
||||
Vec_PtrForEachEntry( Pdr_Set_t *, vTemp, pCla, i )
|
||||
{
|
||||
if ( Vec_BitEntry( vMark, i ) )
|
||||
{
|
||||
Vec_PtrPush( vClauses, pCla );
|
||||
continue;
|
||||
}
|
||||
Pdr_SetDeref( pCla );
|
||||
}
|
||||
|
||||
Vec_PtrFree( vTemp );
|
||||
Vec_BitFree( vMark );
|
||||
RetValue = 1;
|
||||
}
|
||||
else // SAT
|
||||
{
|
||||
Abc_Print( 1, "SAT at the last frame." );
|
||||
Abc_PrintTime( 1, " Time", Abc_Clock() - clk );
|
||||
RetValue = 0;
|
||||
}
|
||||
|
||||
return RetValue;
|
||||
}
|
||||
|
||||
int IPdr_ManReduceClauses( Pdr_Man_t * p, Vec_Vec_t * vClauses )
|
||||
{
|
||||
int iFrame, RetValue = -1;
|
||||
Vec_Ptr_t * vLast = NULL;
|
||||
|
||||
Pdr_ManCreateSolver( p, (iFrame = 0) );
|
||||
Pdr_ManCreateSolver( p, (iFrame = 1) );
|
||||
|
||||
p->nFrames = iFrame;
|
||||
p->iUseFrame = Abc_MaxInt(iFrame, 1);
|
||||
|
||||
vLast = Vec_VecEntry( vClauses, Vec_VecSize( vClauses ) - 1 );
|
||||
RetValue = IPdr_ManCheckCubeReduce( p, vLast, NULL, p->pPars->nConfLimit );
|
||||
return RetValue;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ SRC += src/sat/bsat/satMem.c \
|
|||
src/sat/bsat/satSolver.c \
|
||||
src/sat/bsat/satSolver2.c \
|
||||
src/sat/bsat/satSolver2i.c \
|
||||
src/sat/bsat/satSolver3.c \
|
||||
src/sat/bsat/satStore.c \
|
||||
src/sat/bsat/satTrace.c \
|
||||
src/sat/bsat/satTruth.c \
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,622 @@
|
|||
/**************************************************************************************************
|
||||
MiniSat -- Copyright (c) 2005, Niklas Sorensson
|
||||
http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
||||
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**************************************************************************************************/
|
||||
// Modified to compile with MS Visual Studio 6.0 by Alan Mishchenko
|
||||
|
||||
#ifndef ABC__sat__bsat__satSolver3_h
|
||||
#define ABC__sat__bsat__satSolver3_h
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "satVec.h"
|
||||
#include "satClause.h"
|
||||
#include "misc/util/utilDouble.h"
|
||||
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
|
||||
//=================================================================================================
|
||||
// Public interface:
|
||||
|
||||
struct sat_solver3_t;
|
||||
typedef struct sat_solver3_t sat_solver3;
|
||||
|
||||
extern sat_solver3* sat_solver3_new(void);
|
||||
extern sat_solver3* zsat_solver3_new_seed(double seed);
|
||||
extern void sat_solver3_delete(sat_solver3* s);
|
||||
|
||||
extern int sat_solver3_addclause(sat_solver3* s, lit* begin, lit* end);
|
||||
extern int sat_solver3_clause_new(sat_solver3* s, lit* begin, lit* end, int learnt);
|
||||
extern int sat_solver3_simplify(sat_solver3* s);
|
||||
extern int sat_solver3_solve(sat_solver3* s, lit* begin, lit* end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal);
|
||||
extern int sat_solver3_solve_internal(sat_solver3* s);
|
||||
extern int sat_solver3_solve_lexsat(sat_solver3* s, int * pLits, int nLits);
|
||||
extern int sat_solver3_minimize_assumptions( sat_solver3* s, int * pLits, int nLits, int nConfLimit );
|
||||
extern int sat_solver3_minimize_assumptions2( sat_solver3* s, int * pLits, int nLits, int nConfLimit );
|
||||
extern int sat_solver3_push(sat_solver3* s, int p);
|
||||
extern void sat_solver3_pop(sat_solver3* s);
|
||||
extern void sat_solver3_set_resource_limits(sat_solver3* s, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal);
|
||||
extern void sat_solver3_restart( sat_solver3* s );
|
||||
extern void zsat_solver3_restart_seed( sat_solver3* s, double seed );
|
||||
extern void sat_solver3_rollback( sat_solver3* s );
|
||||
|
||||
extern int sat_solver3_nvars(sat_solver3* s);
|
||||
extern int sat_solver3_nclauses(sat_solver3* s);
|
||||
extern int sat_solver3_nconflicts(sat_solver3* s);
|
||||
extern double sat_solver3_memory(sat_solver3* s);
|
||||
extern int sat_solver3_count_assigned(sat_solver3* s);
|
||||
|
||||
extern void sat_solver3_setnvars(sat_solver3* s,int n);
|
||||
extern int sat_solver3_get_var_value(sat_solver3* s, int v);
|
||||
extern void sat_solver3_set_var_activity(sat_solver3* s, int * pVars, int nVars);
|
||||
|
||||
extern void sat_solver3WriteDimacs( sat_solver3 * p, char * pFileName, lit* assumptionsBegin, lit* assumptionsEnd, int incrementVars );
|
||||
extern void sat_solver3PrintStats( FILE * pFile, sat_solver3 * p );
|
||||
extern int * sat_solver3GetModel( sat_solver3 * p, int * pVars, int nVars );
|
||||
extern void sat_solver3DoubleClauses( sat_solver3 * p, int iVar );
|
||||
|
||||
// trace recording
|
||||
extern void sat_solver3TraceStart( sat_solver3 * pSat, char * pName );
|
||||
extern void sat_solver3TraceStop( sat_solver3 * pSat );
|
||||
extern void sat_solver3TraceWrite( sat_solver3 * pSat, int * pBeg, int * pEnd, int fRoot );
|
||||
|
||||
// clause storage
|
||||
extern void sat_solver3_store_alloc( sat_solver3 * s );
|
||||
extern void sat_solver3_store_write( sat_solver3 * s, char * pFileName );
|
||||
extern void sat_solver3_store_free( sat_solver3 * s );
|
||||
extern void sat_solver3_store_mark_roots( sat_solver3 * s );
|
||||
extern void sat_solver3_store_mark_clauses_a( sat_solver3 * s );
|
||||
extern void * sat_solver3_store_release( sat_solver3 * s );
|
||||
|
||||
//=================================================================================================
|
||||
// Solver representation:
|
||||
|
||||
//struct clause_t;
|
||||
//typedef struct clause_t clause;
|
||||
|
||||
struct varinfo_t;
|
||||
typedef struct varinfo_t varinfo;
|
||||
|
||||
struct sat_solver3_t
|
||||
{
|
||||
int size; // nof variables
|
||||
int cap; // size of varmaps
|
||||
int qhead; // Head index of queue.
|
||||
int qtail; // Tail index of queue.
|
||||
|
||||
// clauses
|
||||
Sat_Mem_t Mem;
|
||||
int hLearnts; // the first learnt clause
|
||||
int hBinary; // the special binary clause
|
||||
clause * binary;
|
||||
veci* wlists; // watcher lists
|
||||
|
||||
// rollback
|
||||
int iVarPivot; // the pivot for variables
|
||||
int iTrailPivot; // the pivot for trail
|
||||
int hProofPivot; // the pivot for proof records
|
||||
|
||||
// activities
|
||||
int VarActType;
|
||||
int ClaActType;
|
||||
word var_inc; // Amount to bump next variable with.
|
||||
word var_inc2; // Amount to bump next variable with.
|
||||
word var_decay; // INVERSE decay factor for variable activity: stores 1/decay.
|
||||
word* activity; // A heuristic measurement of the activity of a variable.
|
||||
word* activity2; // backup variable activity
|
||||
unsigned cla_inc; // Amount to bump next clause with.
|
||||
unsigned cla_decay; // INVERSE decay factor for clause activity: stores 1/decay.
|
||||
veci act_clas; // contain clause activities
|
||||
|
||||
char * pFreqs; // how many times this variable was assigned a value
|
||||
int nVarUsed;
|
||||
|
||||
// varinfo * vi; // variable information
|
||||
int* levels; //
|
||||
char* assigns; // Current values of variables.
|
||||
char* polarity; //
|
||||
char* tags; //
|
||||
char* loads; //
|
||||
|
||||
int* orderpos; // Index in variable order.
|
||||
int* reasons; //
|
||||
lit* trail;
|
||||
veci tagged; // (contains: var)
|
||||
veci stack; // (contains: var)
|
||||
|
||||
veci order; // Variable order. (heap) (contains: var)
|
||||
veci trail_lim; // Separator indices for different decision levels in 'trail'. (contains: int)
|
||||
// veci model; // If problem is solved, this vector contains the model (contains: lbool).
|
||||
int * model; // If problem is solved, this vector contains the model (contains: lbool).
|
||||
veci conf_final; // If problem is unsatisfiable (possibly under assumptions),
|
||||
// this vector represent the final conflict clause expressed in the assumptions.
|
||||
|
||||
int root_level; // Level of first proper decision.
|
||||
int simpdb_assigns;// Number of top-level assignments at last 'simplifyDB()'.
|
||||
int simpdb_props; // Number of propagations before next 'simplifyDB()'.
|
||||
double random_seed;
|
||||
double progress_estimate;
|
||||
int verbosity; // Verbosity level. 0=silent, 1=some progress report, 2=everything
|
||||
int fVerbose;
|
||||
|
||||
stats_t stats;
|
||||
int nLearntMax; // max number of learned clauses
|
||||
int nLearntStart; // starting learned clause limit
|
||||
int nLearntDelta; // delta of learned clause limit
|
||||
int nLearntRatio; // ratio percentage of learned clauses
|
||||
int nDBreduces; // number of DB reductions
|
||||
|
||||
ABC_INT64_T nConfLimit; // external limit on the number of conflicts
|
||||
ABC_INT64_T nInsLimit; // external limit on the number of implications
|
||||
abctime nRuntimeLimit; // external limit on runtime
|
||||
|
||||
veci act_vars; // variables whose activity has changed
|
||||
double* factors; // the activity factors
|
||||
int nRestarts; // the number of local restarts
|
||||
int nCalls; // the number of local restarts
|
||||
int nCalls2; // the number of local restarts
|
||||
veci unit_lits; // variables whose activity has changed
|
||||
veci pivot_vars; // pivot variables
|
||||
|
||||
int fSkipSimplify; // set to one to skip simplification of the clause database
|
||||
int fNotUseRandom; // do not allow random decisions with a fixed probability
|
||||
int fNoRestarts; // disables periodic restarts
|
||||
|
||||
int * pGlobalVars; // for experiments with global vars during interpolation
|
||||
// clause store
|
||||
void * pStore;
|
||||
int fSolved;
|
||||
|
||||
// trace recording
|
||||
FILE * pFile;
|
||||
int nClauses;
|
||||
int nRoots;
|
||||
|
||||
veci temp_clause; // temporary storage for a CNF clause
|
||||
|
||||
// CNF loading
|
||||
void * pCnfMan; // external CNF manager
|
||||
int(*pCnfFunc)(void * p, int); // external callback
|
||||
};
|
||||
|
||||
static inline clause * clause_read( sat_solver3 * s, cla h )
|
||||
{
|
||||
return Sat_MemClauseHand( &s->Mem, h );
|
||||
}
|
||||
|
||||
static int sat_solver3_var_value( sat_solver3* s, int v )
|
||||
{
|
||||
assert( v >= 0 && v < s->size );
|
||||
return (int)(s->model[v] == l_True);
|
||||
}
|
||||
static int sat_solver3_var_literal( sat_solver3* s, int v )
|
||||
{
|
||||
assert( v >= 0 && v < s->size );
|
||||
return toLitCond( v, s->model[v] != l_True );
|
||||
}
|
||||
static void sat_solver3_act_var_clear(sat_solver3* s)
|
||||
{
|
||||
int i;
|
||||
if ( s->VarActType == 0 )
|
||||
{
|
||||
for (i = 0; i < s->size; i++)
|
||||
s->activity[i] = (1 << 10);
|
||||
s->var_inc = (1 << 5);
|
||||
}
|
||||
else if ( s->VarActType == 1 )
|
||||
{
|
||||
for (i = 0; i < s->size; i++)
|
||||
s->activity[i] = 0;
|
||||
s->var_inc = 1;
|
||||
}
|
||||
else if ( s->VarActType == 2 )
|
||||
{
|
||||
for (i = 0; i < s->size; i++)
|
||||
s->activity[i] = Xdbl_Const1();
|
||||
s->var_inc = Xdbl_Const1();
|
||||
}
|
||||
else assert(0);
|
||||
}
|
||||
static void sat_solver3_compress(sat_solver3* s)
|
||||
{
|
||||
if ( s->qtail != s->qhead )
|
||||
{
|
||||
int RetValue = sat_solver3_simplify(s);
|
||||
assert( RetValue != 0 );
|
||||
(void) RetValue;
|
||||
}
|
||||
}
|
||||
static void sat_solver3_delete_p( sat_solver3 ** ps )
|
||||
{
|
||||
if ( *ps )
|
||||
sat_solver3_delete( *ps );
|
||||
*ps = NULL;
|
||||
}
|
||||
static void sat_solver3_clean_polarity(sat_solver3* s, int * pVars, int nVars )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
s->polarity[pVars[i]] = 0;
|
||||
}
|
||||
static void sat_solver3_set_polarity(sat_solver3* s, int * pVars, int nVars )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < s->size; i++ )
|
||||
s->polarity[i] = 0;
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
s->polarity[pVars[i]] = 1;
|
||||
}
|
||||
static void sat_solver3_set_literal_polarity(sat_solver3* s, int * pLits, int nLits )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < nLits; i++ )
|
||||
s->polarity[Abc_Lit2Var(pLits[i])] = !Abc_LitIsCompl(pLits[i]);
|
||||
}
|
||||
|
||||
static int sat_solver3_final(sat_solver3* s, int ** ppArray)
|
||||
{
|
||||
*ppArray = s->conf_final.ptr;
|
||||
return s->conf_final.size;
|
||||
}
|
||||
|
||||
static abctime sat_solver3_set_runtime_limit(sat_solver3* s, abctime Limit)
|
||||
{
|
||||
abctime nRuntimeLimit = s->nRuntimeLimit;
|
||||
s->nRuntimeLimit = Limit;
|
||||
return nRuntimeLimit;
|
||||
}
|
||||
|
||||
static int sat_solver3_set_random(sat_solver3* s, int fNotUseRandom)
|
||||
{
|
||||
int fNotUseRandomOld = s->fNotUseRandom;
|
||||
s->fNotUseRandom = fNotUseRandom;
|
||||
return fNotUseRandomOld;
|
||||
}
|
||||
|
||||
static inline void sat_solver3_bookmark(sat_solver3* s)
|
||||
{
|
||||
assert( s->qhead == s->qtail );
|
||||
s->iVarPivot = s->size;
|
||||
s->iTrailPivot = s->qhead;
|
||||
Sat_MemBookMark( &s->Mem );
|
||||
if ( s->activity2 )
|
||||
{
|
||||
s->var_inc2 = s->var_inc;
|
||||
memcpy( s->activity2, s->activity, sizeof(word) * s->iVarPivot );
|
||||
}
|
||||
}
|
||||
static inline void sat_solver3_set_pivot_variables( sat_solver3* s, int * pPivots, int nPivots )
|
||||
{
|
||||
s->pivot_vars.cap = nPivots;
|
||||
s->pivot_vars.size = nPivots;
|
||||
s->pivot_vars.ptr = pPivots;
|
||||
}
|
||||
static inline int sat_solver3_count_usedvars(sat_solver3* s)
|
||||
{
|
||||
int i, nVars = 0;
|
||||
for ( i = 0; i < s->size; i++ )
|
||||
if ( s->pFreqs[i] )
|
||||
{
|
||||
s->pFreqs[i] = 0;
|
||||
nVars++;
|
||||
}
|
||||
return nVars;
|
||||
}
|
||||
|
||||
static inline int sat_solver3_add_const( sat_solver3 * pSat, int iVar, int fCompl )
|
||||
{
|
||||
lit Lits[1];
|
||||
int Cid;
|
||||
assert( iVar >= 0 );
|
||||
|
||||
Lits[0] = toLitCond( iVar, fCompl );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 1 );
|
||||
assert( Cid );
|
||||
return 1;
|
||||
}
|
||||
static inline int sat_solver3_add_buffer( sat_solver3 * pSat, int iVarA, int iVarB, int fCompl )
|
||||
{
|
||||
lit Lits[2];
|
||||
int Cid;
|
||||
assert( iVarA >= 0 && iVarB >= 0 );
|
||||
|
||||
Lits[0] = toLitCond( iVarA, 0 );
|
||||
Lits[1] = toLitCond( iVarB, !fCompl );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 2 );
|
||||
if ( Cid == 0 )
|
||||
return 0;
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarA, 1 );
|
||||
Lits[1] = toLitCond( iVarB, fCompl );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 2 );
|
||||
if ( Cid == 0 )
|
||||
return 0;
|
||||
assert( Cid );
|
||||
return 2;
|
||||
}
|
||||
static inline int sat_solver3_add_buffer_enable( sat_solver3 * pSat, int iVarA, int iVarB, int iVarEn, int fCompl )
|
||||
{
|
||||
lit Lits[3];
|
||||
int Cid;
|
||||
assert( iVarA >= 0 && iVarB >= 0 && iVarEn >= 0 );
|
||||
|
||||
Lits[0] = toLitCond( iVarA, 0 );
|
||||
Lits[1] = toLitCond( iVarB, !fCompl );
|
||||
Lits[2] = toLitCond( iVarEn, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarA, 1 );
|
||||
Lits[1] = toLitCond( iVarB, fCompl );
|
||||
Lits[2] = toLitCond( iVarEn, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
return 2;
|
||||
}
|
||||
static inline int sat_solver3_add_and( sat_solver3 * pSat, int iVar, int iVar0, int iVar1, int fCompl0, int fCompl1, int fCompl )
|
||||
{
|
||||
lit Lits[3];
|
||||
int Cid;
|
||||
|
||||
Lits[0] = toLitCond( iVar, !fCompl );
|
||||
Lits[1] = toLitCond( iVar0, fCompl0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 2 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVar, !fCompl );
|
||||
Lits[1] = toLitCond( iVar1, fCompl1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 2 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVar, fCompl );
|
||||
Lits[1] = toLitCond( iVar0, !fCompl0 );
|
||||
Lits[2] = toLitCond( iVar1, !fCompl1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
return 3;
|
||||
}
|
||||
static inline int sat_solver3_add_xor( sat_solver3 * pSat, int iVarA, int iVarB, int iVarC, int fCompl )
|
||||
{
|
||||
lit Lits[3];
|
||||
int Cid;
|
||||
assert( iVarA >= 0 && iVarB >= 0 && iVarC >= 0 );
|
||||
|
||||
Lits[0] = toLitCond( iVarA, !fCompl );
|
||||
Lits[1] = toLitCond( iVarB, 1 );
|
||||
Lits[2] = toLitCond( iVarC, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarA, !fCompl );
|
||||
Lits[1] = toLitCond( iVarB, 0 );
|
||||
Lits[2] = toLitCond( iVarC, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarA, fCompl );
|
||||
Lits[1] = toLitCond( iVarB, 1 );
|
||||
Lits[2] = toLitCond( iVarC, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarA, fCompl );
|
||||
Lits[1] = toLitCond( iVarB, 0 );
|
||||
Lits[2] = toLitCond( iVarC, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
return 4;
|
||||
}
|
||||
static inline int sat_solver3_add_mux( sat_solver3 * pSat, int iVarZ, int iVarC, int iVarT, int iVarE, int iComplC, int iComplT, int iComplE, int iComplZ )
|
||||
{
|
||||
lit Lits[3];
|
||||
int Cid;
|
||||
assert( iVarC >= 0 && iVarT >= 0 && iVarE >= 0 && iVarZ >= 0 );
|
||||
|
||||
Lits[0] = toLitCond( iVarC, 1 ^ iComplC );
|
||||
Lits[1] = toLitCond( iVarT, 1 ^ iComplT );
|
||||
Lits[2] = toLitCond( iVarZ, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarC, 1 ^ iComplC );
|
||||
Lits[1] = toLitCond( iVarT, 0 ^ iComplT );
|
||||
Lits[2] = toLitCond( iVarZ, 1 ^ iComplZ );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarC, 0 ^ iComplC );
|
||||
Lits[1] = toLitCond( iVarE, 1 ^ iComplE );
|
||||
Lits[2] = toLitCond( iVarZ, 0 ^ iComplZ );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarC, 0 ^ iComplC );
|
||||
Lits[1] = toLitCond( iVarE, 0 ^ iComplE );
|
||||
Lits[2] = toLitCond( iVarZ, 1 ^ iComplZ );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
if ( iVarT == iVarE )
|
||||
return 4;
|
||||
|
||||
Lits[0] = toLitCond( iVarT, 0 ^ iComplT );
|
||||
Lits[1] = toLitCond( iVarE, 0 ^ iComplE );
|
||||
Lits[2] = toLitCond( iVarZ, 1 ^ iComplZ );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarT, 1 ^ iComplT );
|
||||
Lits[1] = toLitCond( iVarE, 1 ^ iComplE );
|
||||
Lits[2] = toLitCond( iVarZ, 0 ^ iComplZ );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
return 6;
|
||||
}
|
||||
static inline int sat_solver3_add_mux41( sat_solver3 * pSat, int iVarZ, int iVarC0, int iVarC1, int iVarD0, int iVarD1, int iVarD2, int iVarD3 )
|
||||
{
|
||||
lit Lits[4];
|
||||
int Cid;
|
||||
assert( iVarC0 >= 0 && iVarC1 >= 0 && iVarD0 >= 0 && iVarD1 >= 0 && iVarD2 >= 0 && iVarD3 >= 0 && iVarZ >= 0 );
|
||||
|
||||
Lits[0] = toLitCond( iVarD0, 1 );
|
||||
Lits[1] = toLitCond( iVarC0, 0 );
|
||||
Lits[2] = toLitCond( iVarC1, 0 );
|
||||
Lits[3] = toLitCond( iVarZ, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarD1, 1 );
|
||||
Lits[1] = toLitCond( iVarC0, 1 );
|
||||
Lits[2] = toLitCond( iVarC1, 0 );
|
||||
Lits[3] = toLitCond( iVarZ, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarD2, 1 );
|
||||
Lits[1] = toLitCond( iVarC0, 0 );
|
||||
Lits[2] = toLitCond( iVarC1, 1 );
|
||||
Lits[3] = toLitCond( iVarZ, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarD3, 1 );
|
||||
Lits[1] = toLitCond( iVarC0, 1 );
|
||||
Lits[2] = toLitCond( iVarC1, 1 );
|
||||
Lits[3] = toLitCond( iVarZ, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
|
||||
|
||||
Lits[0] = toLitCond( iVarD0, 0 );
|
||||
Lits[1] = toLitCond( iVarC0, 0 );
|
||||
Lits[2] = toLitCond( iVarC1, 0 );
|
||||
Lits[3] = toLitCond( iVarZ, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarD1, 0 );
|
||||
Lits[1] = toLitCond( iVarC0, 1 );
|
||||
Lits[2] = toLitCond( iVarC1, 0 );
|
||||
Lits[3] = toLitCond( iVarZ, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarD2, 0 );
|
||||
Lits[1] = toLitCond( iVarC0, 0 );
|
||||
Lits[2] = toLitCond( iVarC1, 1 );
|
||||
Lits[3] = toLitCond( iVarZ, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarD3, 0 );
|
||||
Lits[1] = toLitCond( iVarC0, 1 );
|
||||
Lits[2] = toLitCond( iVarC1, 1 );
|
||||
Lits[3] = toLitCond( iVarZ, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
return 8;
|
||||
}
|
||||
static inline int sat_solver3_add_xor_and( sat_solver3 * pSat, int iVarF, int iVarA, int iVarB, int iVarC )
|
||||
{
|
||||
// F = (a (+) b) * c
|
||||
lit Lits[4];
|
||||
int Cid;
|
||||
assert( iVarF >= 0 && iVarA >= 0 && iVarB >= 0 && iVarC >= 0 );
|
||||
|
||||
Lits[0] = toLitCond( iVarF, 1 );
|
||||
Lits[1] = toLitCond( iVarA, 1 );
|
||||
Lits[2] = toLitCond( iVarB, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarF, 1 );
|
||||
Lits[1] = toLitCond( iVarA, 0 );
|
||||
Lits[2] = toLitCond( iVarB, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarF, 1 );
|
||||
Lits[1] = toLitCond( iVarC, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 2 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarF, 0 );
|
||||
Lits[1] = toLitCond( iVarA, 1 );
|
||||
Lits[2] = toLitCond( iVarB, 0 );
|
||||
Lits[3] = toLitCond( iVarC, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarF, 0 );
|
||||
Lits[1] = toLitCond( iVarA, 0 );
|
||||
Lits[2] = toLitCond( iVarB, 1 );
|
||||
Lits[3] = toLitCond( iVarC, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 4 );
|
||||
assert( Cid );
|
||||
return 5;
|
||||
}
|
||||
static inline int sat_solver3_add_constraint( sat_solver3 * pSat, int iVar, int iVar2, int fCompl )
|
||||
{
|
||||
lit Lits[2];
|
||||
int Cid;
|
||||
assert( iVar >= 0 );
|
||||
|
||||
Lits[0] = toLitCond( iVar, fCompl );
|
||||
Lits[1] = toLitCond( iVar2, 0 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 2 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVar, fCompl );
|
||||
Lits[1] = toLitCond( iVar2, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 2 );
|
||||
assert( Cid );
|
||||
return 2;
|
||||
}
|
||||
|
||||
static inline int sat_solver3_add_half_sorter( sat_solver3 * pSat, int iVarA, int iVarB, int iVar0, int iVar1 )
|
||||
{
|
||||
lit Lits[3];
|
||||
int Cid;
|
||||
|
||||
Lits[0] = toLitCond( iVarA, 0 );
|
||||
Lits[1] = toLitCond( iVar0, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 2 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarA, 0 );
|
||||
Lits[1] = toLitCond( iVar1, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 2 );
|
||||
assert( Cid );
|
||||
|
||||
Lits[0] = toLitCond( iVarB, 0 );
|
||||
Lits[1] = toLitCond( iVar0, 1 );
|
||||
Lits[2] = toLitCond( iVar1, 1 );
|
||||
Cid = sat_solver3_addclause( pSat, Lits, Lits + 3 );
|
||||
assert( Cid );
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue