abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bmcLoad.c File Reference
#include "bmc.h"
#include "sat/bsat/satStore.h"

Go to the source code of this file.

Data Structures

struct  Bmc_Load_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Bmc_Load_t_ 
Bmc_Load_t
 DECLARATIONS ///. More...
 

Functions

int Bmc_LoadGetSatVar (Bmc_Load_t *p, int Id)
 FUNCTION DEFINITIONS ///. More...
 
int Bmc_LoadAddCnf (void *pMan, int iLit)
 
int Bmc_LoadAddCnf_rec (Bmc_Load_t *p, int Id)
 
Bmc_Load_tBmc_LoadStart (Gia_Man_t *pGia)
 
void Bmc_LoadStop (Bmc_Load_t *p)
 
void Bmc_LoadTest (Gia_Man_t *pGia, int fLoadCnf, int fVerbose)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Bmc_Load_t_ Bmc_Load_t

DECLARATIONS ///.

CFile****************************************************************

FileName [bmcLoad.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based bounded model checking.]

Synopsis [Experiments with CNF loading.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
bmcLoad.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 31 of file bmcLoad.c.

Function Documentation

int Bmc_LoadAddCnf ( void *  pMan,
int  iLit 
)

Definition at line 71 of file bmcLoad.c.

72 {
73  Bmc_Load_t * p = (Bmc_Load_t *)pMan;
74  int Lits[3], iVar = Abc_Lit2Var(iLit);
75  Gia_Obj_t * pObj = Gia_ManObj( p->pGia, Vec_IntEntry(p->vSat2Id, iVar) );
76  p->nCallBacks1++;
77  if ( Gia_ObjIsCi(pObj) || Gia_ObjIsConst0(pObj) )
78  return 0;
79  assert( Gia_ObjIsAnd(pObj) );
80  if ( (Abc_LitIsCompl(iLit) ? pObj->fMark1 : pObj->fMark0) )
81  return 0;
82  Lits[0] = Abc_LitNot(iLit);
83  if ( Abc_LitIsCompl(iLit) )
84  {
85  Lits[1] = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId0p(p->pGia, pObj)), !Gia_ObjFaninC0(pObj) );
86  Lits[2] = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId1p(p->pGia, pObj)), !Gia_ObjFaninC1(pObj) );
87  sat_solver_clause_new( p->pSat, Lits, Lits + 3, 0 );
88  pObj->fMark1 = 1;
89  }
90  else
91  {
92  Lits[1] = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId0p(p->pGia, pObj)), Gia_ObjFaninC0(pObj) );
93  sat_solver_clause_new( p->pSat, Lits, Lits + 2, 0 );
94  Lits[1] = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId1p(p->pGia, pObj)), Gia_ObjFaninC1(pObj) );
95  sat_solver_clause_new( p->pSat, Lits, Lits + 2, 0 );
96  pObj->fMark0 = 1;
97  }
98  p->nCallBacks2++;
99  return 1;
100 }
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_clause_new(sat_solver *s, lit *begin, lit *end, int learnt)
Definition: satSolver.c:402
typedefABC_NAMESPACE_IMPL_START struct Bmc_Load_t_ Bmc_Load_t
DECLARATIONS ///.
Definition: bmcLoad.c:31
static int Gia_ObjIsConst0(Gia_Obj_t *pObj)
Definition: gia.h:430
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int Gia_ObjFaninId1p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:464
int Bmc_LoadGetSatVar(Bmc_Load_t *p, int Id)
FUNCTION DEFINITIONS ///.
Definition: bmcLoad.c:60
unsigned fMark1
Definition: gia.h:84
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
unsigned fMark0
Definition: gia.h:79
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
int Bmc_LoadAddCnf_rec ( Bmc_Load_t p,
int  Id 
)

Definition at line 101 of file bmcLoad.c.

102 {
103  int iVar = Bmc_LoadGetSatVar( p, Id );
104  Gia_Obj_t * pObj = Gia_ManObj( p->pGia, Id );
105  if ( Gia_ObjIsAnd(pObj) && !(pObj->fMark0 && pObj->fMark1) )
106  {
107  Bmc_LoadAddCnf( p, Abc_Var2Lit(iVar, 0) );
108  Bmc_LoadAddCnf( p, Abc_Var2Lit(iVar, 1) );
109  Bmc_LoadAddCnf_rec( p, Gia_ObjFaninId0(pObj, Id) );
110  Bmc_LoadAddCnf_rec( p, Gia_ObjFaninId1(pObj, Id) );
111  }
112  return iVar;
113 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
int Bmc_LoadGetSatVar(Bmc_Load_t *p, int Id)
FUNCTION DEFINITIONS ///.
Definition: bmcLoad.c:60
unsigned fMark1
Definition: gia.h:84
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
int Bmc_LoadAddCnf(void *pMan, int iLit)
Definition: bmcLoad.c:71
unsigned fMark0
Definition: gia.h:79
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
int Bmc_LoadAddCnf_rec(Bmc_Load_t *p, int Id)
Definition: bmcLoad.c:101
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
int Bmc_LoadGetSatVar ( Bmc_Load_t p,
int  Id 
)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Load CNF for the cone.]

Description []

SideEffects []

SeeAlso []

Definition at line 60 of file bmcLoad.c.

61 {
62  Gia_Obj_t * pObj = Gia_ManObj( p->pGia, Id );
63  if ( pObj->Value == 0 )
64  {
65  pObj->Value = Vec_IntSize( p->vSat2Id );
66  Vec_IntPush( p->vSat2Id, Id );
67  sat_solver_setnvars( p->pSat, Vec_IntSize(p->vSat2Id) );
68  }
69  return pObj->Value;
70 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
unsigned Value
Definition: gia.h:87
Bmc_Load_t* Bmc_LoadStart ( Gia_Man_t pGia)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file bmcLoad.c.

127 {
128  Bmc_Load_t * p;
129  int Lit;
130  Gia_ManSetPhase( pGia );
131  Gia_ManCleanValue( pGia );
132  Gia_ManCreateRefs( pGia );
133  p = ABC_CALLOC( Bmc_Load_t, 1 );
134  p->pGia = pGia;
135  p->pSat = sat_solver_new();
136  p->vSat2Id = Vec_IntAlloc( 1000 );
137  Vec_IntPush( p->vSat2Id, 0 );
138  // create constant node
139  Lit = Abc_Var2Lit( Bmc_LoadGetSatVar(p, 0), 1 );
140  sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
141  return p;
142 }
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
typedefABC_NAMESPACE_IMPL_START struct Bmc_Load_t_ Bmc_Load_t
DECLARATIONS ///.
Definition: bmcLoad.c:31
void Gia_ManCleanValue(Gia_Man_t *p)
Definition: giaUtil.c:310
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
int Bmc_LoadGetSatVar(Bmc_Load_t *p, int Id)
FUNCTION DEFINITIONS ///.
Definition: bmcLoad.c:60
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
void Gia_ManSetPhase(Gia_Man_t *p)
Definition: giaUtil.c:379
void Bmc_LoadStop ( Bmc_Load_t p)

Definition at line 143 of file bmcLoad.c.

144 {
145  Vec_IntFree( p->vSat2Id );
146  sat_solver_delete( p->pSat );
147  ABC_FREE( p );
148 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
void Bmc_LoadTest ( Gia_Man_t pGia,
int  fLoadCnf,
int  fVerbose 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 161 of file bmcLoad.c.

162 {
163  int nConfLimit = 0;
164  Bmc_Load_t * p;
165  Gia_Obj_t * pObj;
166  int i, status, Lit;
167  abctime clk = Abc_Clock();
168  // create the loading manager
169  p = Bmc_LoadStart( pGia );
170  // add callback for CNF loading
171  if ( fLoadCnf )
172  {
173  p->pSat->pCnfMan = p;
174  p->pSat->pCnfFunc = Bmc_LoadAddCnf;
175  }
176  // solve SAT problem for each PO
177  Gia_ManForEachPo( pGia, pObj, i )
178  {
179  if ( fLoadCnf )
180  Lit = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId0p(pGia, pObj)), Gia_ObjFaninC0(pObj) );
181  else
182  Lit = Abc_Var2Lit( Bmc_LoadAddCnf_rec(p, Gia_ObjFaninId0p(pGia, pObj)), Gia_ObjFaninC0(pObj) );
183  if ( fVerbose )
184  {
185  printf( "Frame%4d : ", i );
186  printf( "Vars = %6d ", Vec_IntSize(p->vSat2Id) );
187  printf( "Clas = %6d ", sat_solver_nclauses(p->pSat) );
188  }
189  status = sat_solver_solve( p->pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
190  if ( fVerbose )
191  {
192  printf( "Conf = %6d ", sat_solver_nconflicts(p->pSat) );
193  if ( status == l_False )
194  printf( "UNSAT " );
195  else if ( status == l_True )
196  printf( "SAT " );
197  else // if ( status == l_Undec )
198  printf( "UNDEC " );
199  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
200  }
201  }
202  printf( "Callbacks = %d. Loadings = %d.\n", p->nCallBacks1, p->nCallBacks2 );
203  Bmc_LoadStop( p );
204 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Bmc_LoadStop(Bmc_Load_t *p)
Definition: bmcLoad.c:143
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
typedefABC_NAMESPACE_IMPL_START struct Bmc_Load_t_ Bmc_Load_t
DECLARATIONS ///.
Definition: bmcLoad.c:31
Bmc_Load_t * Bmc_LoadStart(Gia_Man_t *pGia)
Definition: bmcLoad.c:126
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
int sat_solver_nconflicts(sat_solver *s)
Definition: satSolver.c:1908
#define l_True
Definition: SolverTypes.h:84
int Bmc_LoadGetSatVar(Bmc_Load_t *p, int Id)
FUNCTION DEFINITIONS ///.
Definition: bmcLoad.c:60
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: gia.h:75
int Bmc_LoadAddCnf(void *pMan, int iLit)
Definition: bmcLoad.c:71
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
int sat_solver_nclauses(sat_solver *s)
Definition: satSolver.c:1902
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define l_False
Definition: SolverTypes.h:85
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
int Bmc_LoadAddCnf_rec(Bmc_Load_t *p, int Id)
Definition: bmcLoad.c:101
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036