72static inline int Aig_Gla2AddConst(
sat_solver * pSat,
int iVar,
int fCompl )
74 lit Lit = toLitCond( iVar, fCompl );
91static inline int Aig_Gla2AddBuffer(
sat_solver * pSat,
int iVar0,
int iVar1,
int fCompl )
95 Lits[0] = toLitCond( iVar0, 0 );
96 Lits[1] = toLitCond( iVar1, !fCompl );
100 Lits[0] = toLitCond( iVar0, 1 );
101 Lits[1] = toLitCond( iVar1, fCompl );
119static inline int Aig_Gla2AddNode(
sat_solver * pSat,
int iVar,
int iVar0,
int iVar1,
int fCompl0,
int fCompl1 )
123 Lits[0] = toLitCond( iVar, 1 );
124 Lits[1] = toLitCond( iVar0, fCompl0 );
128 Lits[0] = toLitCond( iVar, 1 );
129 Lits[1] = toLitCond( iVar1, fCompl1 );
133 Lits[0] = toLitCond( iVar, 0 );
134 Lits[1] = toLitCond( iVar0, !fCompl0 );
135 Lits[2] = toLitCond( iVar1, !fCompl1 );
156 int i, iVecId, iSatVar;
157 assert( k < p->nFramesMax );
158 iVecId = Vec_IntEntry(
p->vObj2Vec, Aig_ObjId(pObj) );
161 iVecId = Vec_IntSize(
p->vVec2Var ) /
p->nFramesMax;
162 for ( i = 0; i <
p->nFramesMax; i++ )
163 Vec_IntPush(
p->vVec2Var, 0 );
164 Vec_IntWriteEntry(
p->vObj2Vec, Aig_ObjId(pObj), iVecId );
166 iSatVar = Vec_IntEntry(
p->vVec2Var, iVecId *
p->nFramesMax + k );
169 iSatVar = Vec_IntSize(
p->vVar2Inf ) / 2;
170 Vec_IntPush(
p->vVar2Inf, Aig_ObjId(pObj) );
171 Vec_IntPush(
p->vVar2Inf, k );
172 Vec_IntWriteEntry(
p->vVec2Var, iVecId *
p->nFramesMax + k, iSatVar );
190 int nVars = Vec_IntSize(
p->vVar2Inf);
192 if ( nVars == Vec_IntSize(
p->vVar2Inf) )
194 if ( Aig_ObjIsConst1(pObj) )
196 if ( Saig_ObjIsPo(
p->pAig, pObj ) )
201 if ( Aig_ObjIsCi( pObj ) )
203 if ( Saig_ObjIsLo(
p->pAig, pObj) && f > 0 )
207 assert( Aig_ObjIsNode(pObj) );
227 int i, f, ObjId, nVars, RetValue = 1;
230 for ( f =
p->nFramesMax - 1; f >= 0; f-- )
240 nVars = Vec_IntSize(
p->vVar2Inf );
245 pObj = Aig_ManObj(
p->pAig, ObjId );
246 if ( Aig_ObjIsNode(pObj) )
251 Aig_ObjFaninC0(pObj), Aig_ObjFaninC1(pObj) );
252 Vec_IntPush(
p->vCla2Obj, ObjId );
253 Vec_IntPush(
p->vCla2Obj, ObjId );
254 Vec_IntPush(
p->vCla2Obj, ObjId );
256 Vec_IntPush(
p->vCla2Fra, f );
257 Vec_IntPush(
p->vCla2Fra, f );
258 Vec_IntPush(
p->vCla2Fra, f );
260 else if ( Saig_ObjIsLo(
p->pAig, pObj) )
265 Vec_IntPush(
p->vCla2Obj, ObjId );
267 Vec_IntPush(
p->vCla2Fra, f );
271 Aig_Obj_t * pObjLi = Saig_ObjLoToLi(
p->pAig, pObj);
274 Aig_ObjFaninC0(pObjLi) );
275 Vec_IntPush(
p->vCla2Obj, ObjId );
276 Vec_IntPush(
p->vCla2Obj, ObjId );
278 Vec_IntPush(
p->vCla2Fra, f );
279 Vec_IntPush(
p->vCla2Fra, f );
282 else if ( Saig_ObjIsPo(
p->pAig, pObj) )
286 Aig_ObjFaninC0(pObj) );
287 Vec_IntPush(
p->vCla2Obj, ObjId );
288 Vec_IntPush(
p->vCla2Obj, ObjId );
290 Vec_IntPush(
p->vCla2Fra, f );
291 Vec_IntPush(
p->vCla2Fra, f );
293 else if ( Aig_ObjIsConst1(pObj) )
296 Vec_IntPush(
p->vCla2Obj, ObjId );
298 Vec_IntPush(
p->vCla2Fra, f );
300 else assert( Saig_ObjIsPi(
p->pAig, pObj) );
304 vPoLits = Vec_IntAlloc(
p->nFramesMax );
305 for ( f =
p->nStart; f < p->nFramesMax; f++ )
307 RetValue &=
sat_solver_addclause(
p->pSat, Vec_IntArray(vPoLits), Vec_IntArray(vPoLits) + Vec_IntSize(vPoLits) );
308 Vec_IntFree( vPoLits );
309 Vec_IntPush(
p->vCla2Obj, 0 );
310 Vec_IntPush(
p->vCla2Fra, 0 );
311 assert( Vec_IntSize(
p->vCla2Fra) == Vec_IntSize(
p->vCla2Obj) );
313 assert( nVars == Vec_IntSize(
p->vVar2Inf) );
319 printf(
"The resulting SAT problem contains %d variables and %d clauses.\n",
320 p->pSat->size,
p->pSat->stats.clauses );
343 p->vObj2Vec = Vec_IntStart( Aig_ManObjNumMax(pAig) );
344 p->vVec2Var = Vec_IntAlloc( 1 << 20 );
345 p->vVar2Inf = Vec_IntAlloc( 1 << 20 );
346 p->vCla2Obj = Vec_IntAlloc( 1 << 20 );
347 p->vCla2Fra = Vec_IntAlloc( 1 << 20 );
351 p->nFramesMax = nFramesMax;
352 p->fVerbose = fVerbose;
353 for ( i = 0; i <
p->nFramesMax; i++ )
354 Vec_IntPush(
p->vVec2Var, -1 );
357 Vec_IntPush(
p->vVar2Inf, -1 );
358 Vec_IntPush(
p->vVar2Inf, -1 );
375 Vec_IntFreeP( &
p->vObj2Vec );
376 Vec_IntFreeP( &
p->vVec2Var );
377 Vec_IntFreeP( &
p->vVar2Inf );
378 Vec_IntFreeP( &
p->vCla2Obj );
379 Vec_IntFreeP( &
p->vCla2Fra );
380 Vec_IntFreeP( &
p->vVec2Use );
405 clock_t clk = clock();
409 RetValue =
sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
412 printf(
"Conflict limit is reached.\n" );
417 printf(
"The BMC problem is SAT.\n" );
424 printf(
"SAT solver returned UNSAT after %7d conflicts. ", (
int)pSat->
stats.
conflicts );
425 Abc_PrintTime( 1,
"Time", clock() - clk );
436 printf(
"SAT core contains %8d clauses (out of %8d). ", Vec_IntSize(vCore),
sat_solver_nclauses(pSat) );
437 Abc_PrintTime( 1,
"Time", clock() - clk );
458 int i, ClaId, iVecId;
461 vResult = Vec_IntStart( Aig_ManObjNumMax(
p->pAig) );
462 Vec_IntWriteEntry( vResult, 0, 1 );
465 pObj = Aig_ManObj(
p->pAig, Vec_IntEntry(
p->vCla2Obj, ClaId) );
466 if ( Saig_ObjIsPi(
p->pAig, pObj) || Saig_ObjIsPo(
p->pAig, pObj) || Aig_ObjIsConst1(pObj) )
468 assert( Saig_ObjIsLo(
p->pAig, pObj) || Aig_ObjIsNode(pObj) );
469 Vec_IntWriteEntry( vResult, Aig_ObjId(pObj), 1 );
489 iVecId = Vec_IntEntry(
p->vObj2Vec, Aig_ObjId(pObj) );
490 Vec_IntWriteEntry(
p->vVec2Use, iVecId *
p->nFramesMax + Vec_IntEntry(
p->vCla2Fra, ClaId), 1 );
498 Vec_Int_t * vCounts = Vec_IntStart(
p->nFramesMax );
499 int v, f, Entry, nVecIds = Vec_IntSize(
p->vVec2Use) /
p->nFramesMax;
500 for ( f = 0; f <
p->nFramesMax; f++ )
501 for ( v = 0; v < nVecIds; v++ )
502 if ( Vec_IntEntry(
p->vVec2Use, v *
p->nFramesMax + f ) )
503 Vec_IntAddToEntry( vCounts, f, 1 );
505 printf(
"%d ", Entry );
507 Vec_IntFree( vCounts );
529 clock_t nTimeToStop = TimeLimit ? TimeLimit * CLOCKS_PER_SEC + clock(): 0;
530 clock_t clk, clk2 = clock();
531 assert( Saig_ManPoNum(pAig) == 1 );
536 printf(
"Abstracting from frame %d to frame %d with timeout %d sec.\n", nStart, nFramesMax, TimeLimit );
538 printf(
"Abstracting from frame %d to frame %d with no timeout.\n", nStart, nFramesMax );
546 printf(
"Error! SAT solver became UNSAT.\n" );
550 sat_solver_set_random(
p->pSat, fSkipRand );
551 p->timePre += clock() - clk;
555 sat_solver_set_runtime_limit(
p->pSat, nTimeToStop );
565 p->timeSat += clock() - clk;
566 p->timeTotal += clock() - clk2;
573 ABC_PRTP(
"Total ",
p->timeTotal,
p->timeTotal );
578 Vec_IntFree( vCore );
#define ABC_PRTP(a, t, T)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
struct Aig_Obj_t_ Aig_Obj_t
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define sat_solver_addclause
Vec_Int_t * Aig_Gla2ManPerform(Aig_Man_t *pAig, int nStart, int nFramesMax, int nConfLimit, int TimeLimit, int fSkipRand, int fVerbose)
Aig_Gla2Man_t * Aig_Gla2ManStart(Aig_Man_t *pAig, int nStart, int nFramesMax, int fVerbose)
Vec_Int_t * Saig_AbsSolverUnsatCore(sat_solver *pSat, int nConfMax, int fVerbose, int *piRetValue)
void Aig_Gla2ManStop(Aig_Gla2Man_t *p)
Vec_Int_t * Aig_Gla2ManCollect(Aig_Gla2Man_t *p, Vec_Int_t *vCore)
int Aig_Gla2FetchVar(Aig_Gla2Man_t *p, Aig_Obj_t *pObj, int k)
void Aig_Gla2AssignVars_rec(Aig_Gla2Man_t *p, Aig_Obj_t *pObj, int f)
typedefABC_NAMESPACE_IMPL_START struct Aig_Gla2Man_t_ Aig_Gla2Man_t
DECLARATIONS ///.
int Aig_Gla2CreateSatSolver(Aig_Gla2Man_t *p)
void * Intp_ManUnsatCore(Intp_Man_t *p, Sto_Man_t *pCnf, int fLearned, int fVerbose)
void Intp_ManFree(Intp_Man_t *p)
Intp_Man_t * Intp_ManAlloc()
FUNCTION DEFINITIONS ///.
sat_solver * sat_solver_new(void)
int sat_solver_nclauses(sat_solver *s)
void sat_solver_setnvars(sat_solver *s, int n)
void sat_solver_store_alloc(sat_solver *s)
void sat_solver_store_mark_roots(sat_solver *s)
void * sat_solver_store_release(sat_solver *s)
void sat_solver_delete(sat_solver *s)
void Sto_ManFree(Sto_Man_t *p)
struct Intp_Man_t_ Intp_Man_t
struct Sto_Man_t_ Sto_Man_t
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.