Commit 59348e22 by Alan Mishchenko

Clone of the main SAT solver to eneable independent work.

parent 154f4b64
...@@ -1743,6 +1743,14 @@ SOURCE=.\src\sat\bsat\satSolver2i.c ...@@ -1743,6 +1743,14 @@ SOURCE=.\src\sat\bsat\satSolver2i.c
# End Source File # End Source File
# Begin 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 SOURCE=.\src\sat\bsat\satStore.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
/**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
...@@ -313,6 +313,7 @@ static int Abc_CommandDSat ( Abc_Frame_t * pAbc, int argc, cha ...@@ -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_CommandXSat ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSatoko ( 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_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_CommandPSat ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandProve ( 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 ); static int Abc_CommandIProve ( Abc_Frame_t * pAbc, int argc, char ** argv );
...@@ -965,6 +966,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) ...@@ -965,6 +966,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Verification", "xsat", Abc_CommandXSat, 0 ); Cmd_CommandAdd( pAbc, "Verification", "xsat", Abc_CommandXSat, 0 );
Cmd_CommandAdd( pAbc, "Verification", "satoko", Abc_CommandSatoko, 0 ); Cmd_CommandAdd( pAbc, "Verification", "satoko", Abc_CommandSatoko, 0 );
Cmd_CommandAdd( pAbc, "Verification", "&satoko", Abc_CommandAbc9Satoko, 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", "psat", Abc_CommandPSat, 0 );
Cmd_CommandAdd( pAbc, "Verification", "prove", Abc_CommandProve, 1 ); Cmd_CommandAdd( pAbc, "Verification", "prove", Abc_CommandProve, 1 );
Cmd_CommandAdd( pAbc, "Verification", "iprove", Abc_CommandIProve, 1 ); Cmd_CommandAdd( pAbc, "Verification", "iprove", Abc_CommandIProve, 1 );
...@@ -23565,6 +23567,74 @@ usage: ...@@ -23565,6 +23567,74 @@ usage:
SeeAlso [] 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 []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment