ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cecSolveG.c File Reference
#include "cecInt.h"
#include "sat/glucose2/AbcGlucose2.h"
Include dependency graph for cecSolveG.c:

Go to the source code of this file.

Macros

#define USE_GLUCOSE2
 
#define sat_solver   bmcg2_sat_solver
 
#define sat_solver_start   bmcg2_sat_solver_start
 
#define sat_solver_stop   bmcg2_sat_solver_stop
 
#define sat_solver_addclause   bmcg2_sat_solver_addclause
 
#define sat_solver_add_and   bmcg2_sat_solver_add_and
 
#define sat_solver_add_xor   bmcg2_sat_solver_add_xor
 
#define sat_solver_addvar   bmcg2_sat_solver_addvar
 
#define sat_solver_reset   bmcg2_sat_solver_reset
 
#define sat_solver_set_conflict_budget   bmcg2_sat_solver_set_conflict_budget
 
#define sat_solver_conflictnum   bmcg2_sat_solver_conflictnum
 
#define sat_solver_solve   bmcg2_sat_solver_solve
 
#define sat_solver_read_cex_varvalue   bmcg2_sat_solver_read_cex_varvalue
 
#define sat_solver_read_cex   bmcg2_sat_solver_read_cex
 
#define sat_solver_jftr   bmcg2_sat_solver_jftr
 
#define sat_solver_set_jftr   bmcg2_sat_solver_set_jftr
 
#define sat_solver_set_var_fanin_lit   bmcg2_sat_solver_set_var_fanin_lit
 
#define sat_solver_start_new_round   bmcg2_sat_solver_start_new_round
 
#define sat_solver_mark_cone   bmcg2_sat_solver_mark_cone
 
#define sat_solver_varnum   bmcg2_sat_solver_varnum
 

Functions

int CecG_ObjSatVarValue (Cec_ManSat_t *p, Gia_Obj_t *pObj)
 FUNCTION DEFINITIONS ///.
 
void CecG_AddClausesMux (Cec_ManSat_t *p, Gia_Obj_t *pNode)
 
void CecG_AddClausesSuper (Cec_ManSat_t *p, Gia_Obj_t *pNode, Vec_Ptr_t *vSuper)
 
void CecG_CollectSuper_rec (Gia_Obj_t *pObj, Vec_Ptr_t *vSuper, int fFirst, int fUseMuxes, int fUseSuper)
 
void CecG_CollectSuper (Gia_Obj_t *pObj, int fUseMuxes, int fUseSuper, Vec_Ptr_t *vSuper)
 
void CecG_ObjAddToFrontier (Cec_ManSat_t *p, Gia_Obj_t *pObj, Vec_Ptr_t *vFrontier)
 
void CecG_CnfNodeAddToSolver (Cec_ManSat_t *p, Gia_Obj_t *pObj)
 
void CecG_ManSatSolverRecycle (Cec_ManSat_t *p)
 
int CecG_ManSatCheckNode (Cec_ManSat_t *p, Gia_Obj_t *pObj)
 
void CecG_ManSatSolve (Cec_ManPat_t *pPat, Gia_Man_t *pAig, Cec_ParSat_t *pPars, int f0Proved)
 

Macro Definition Documentation

◆ sat_solver

Definition at line 30 of file cecSolveG.c.

◆ sat_solver_add_and

#define sat_solver_add_and   bmcg2_sat_solver_add_and

Definition at line 34 of file cecSolveG.c.

◆ sat_solver_add_xor

#define sat_solver_add_xor   bmcg2_sat_solver_add_xor

Definition at line 35 of file cecSolveG.c.

◆ sat_solver_addclause

#define sat_solver_addclause   bmcg2_sat_solver_addclause

Definition at line 33 of file cecSolveG.c.

◆ sat_solver_addvar

#define sat_solver_addvar   bmcg2_sat_solver_addvar

Definition at line 36 of file cecSolveG.c.

◆ sat_solver_conflictnum

#define sat_solver_conflictnum   bmcg2_sat_solver_conflictnum

Definition at line 39 of file cecSolveG.c.

◆ sat_solver_jftr

#define sat_solver_jftr   bmcg2_sat_solver_jftr

Definition at line 43 of file cecSolveG.c.

◆ sat_solver_mark_cone

#define sat_solver_mark_cone   bmcg2_sat_solver_mark_cone

Definition at line 47 of file cecSolveG.c.

◆ sat_solver_read_cex

#define sat_solver_read_cex   bmcg2_sat_solver_read_cex

Definition at line 42 of file cecSolveG.c.

◆ sat_solver_read_cex_varvalue

#define sat_solver_read_cex_varvalue   bmcg2_sat_solver_read_cex_varvalue

Definition at line 41 of file cecSolveG.c.

◆ sat_solver_reset

#define sat_solver_reset   bmcg2_sat_solver_reset

Definition at line 37 of file cecSolveG.c.

◆ sat_solver_set_conflict_budget

#define sat_solver_set_conflict_budget   bmcg2_sat_solver_set_conflict_budget

Definition at line 38 of file cecSolveG.c.

◆ sat_solver_set_jftr

#define sat_solver_set_jftr   bmcg2_sat_solver_set_jftr

Definition at line 44 of file cecSolveG.c.

◆ sat_solver_set_var_fanin_lit

#define sat_solver_set_var_fanin_lit   bmcg2_sat_solver_set_var_fanin_lit

Definition at line 45 of file cecSolveG.c.

◆ sat_solver_solve

#define sat_solver_solve   bmcg2_sat_solver_solve

Definition at line 40 of file cecSolveG.c.

◆ sat_solver_start

#define sat_solver_start   bmcg2_sat_solver_start

Definition at line 31 of file cecSolveG.c.

◆ sat_solver_start_new_round

#define sat_solver_start_new_round   bmcg2_sat_solver_start_new_round

Definition at line 46 of file cecSolveG.c.

◆ sat_solver_stop

#define sat_solver_stop   bmcg2_sat_solver_stop

Definition at line 32 of file cecSolveG.c.

◆ sat_solver_varnum

#define sat_solver_varnum   bmcg2_sat_solver_varnum

Definition at line 49 of file cecSolveG.c.

◆ USE_GLUCOSE2

#define USE_GLUCOSE2

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

FileName [cecSolve.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Combinational equivalence checking.]

Synopsis [Performs one round of SAT solving.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 24 of file cecSolveG.c.

Function Documentation

◆ CecG_AddClausesMux()

void CecG_AddClausesMux ( Cec_ManSat_t * p,
Gia_Obj_t * pNode )

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

Synopsis [Addes clauses to the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 117 of file cecSolveG.c.

118{
119 Gia_Obj_t * pNodeI, * pNodeT, * pNodeE;
120 int pLits[4], RetValue, VarF, VarI, VarT, VarE, fCompT, fCompE;
121
122 assert( !Gia_IsComplement( pNode ) );
123 assert( Gia_ObjIsMuxType( pNode ) );
124 // get nodes (I = if, T = then, E = else)
125 pNodeI = Gia_ObjRecognizeMux( pNode, &pNodeT, &pNodeE );
126 // get the variable numbers
127 VarF = CecG_ObjSatNum(p,pNode);
128 VarI = CecG_ObjSatNum(p,pNodeI);
129 VarT = CecG_ObjSatNum(p,Gia_Regular(pNodeT));
130 VarE = CecG_ObjSatNum(p,Gia_Regular(pNodeE));
131 // get the complementation flags
132 fCompT = Gia_IsComplement(pNodeT);
133 fCompE = Gia_IsComplement(pNodeE);
134
135 // f = ITE(i, t, e)
136
137 // i' + t' + f
138 // i' + t + f'
139 // i + e' + f
140 // i + e + f'
141
142 // create four clauses
143 pLits[0] = toLitCond(VarI, 1);
144 pLits[1] = toLitCond(VarT, 1^fCompT);
145 pLits[2] = toLitCond(VarF, 0);
146 if ( p->pPars->fPolarFlip )
147 {
148 if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] );
149 if ( Gia_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] );
150 if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
151 }
152 RetValue = sat_solver_addclause( p->pSat, pLits, 3 );
153 assert( RetValue );
154 pLits[0] = toLitCond(VarI, 1);
155 pLits[1] = toLitCond(VarT, 0^fCompT);
156 pLits[2] = toLitCond(VarF, 1);
157 if ( p->pPars->fPolarFlip )
158 {
159 if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] );
160 if ( Gia_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] );
161 if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
162 }
163 RetValue = sat_solver_addclause( p->pSat, pLits, 3 );
164 assert( RetValue );
165 pLits[0] = toLitCond(VarI, 0);
166 pLits[1] = toLitCond(VarE, 1^fCompE);
167 pLits[2] = toLitCond(VarF, 0);
168 if ( p->pPars->fPolarFlip )
169 {
170 if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] );
171 if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] );
172 if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
173 }
174 RetValue = sat_solver_addclause( p->pSat, pLits, 3 );
175 assert( RetValue );
176 pLits[0] = toLitCond(VarI, 0);
177 pLits[1] = toLitCond(VarE, 0^fCompE);
178 pLits[2] = toLitCond(VarF, 1);
179 if ( p->pPars->fPolarFlip )
180 {
181 if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] );
182 if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] );
183 if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
184 }
185 RetValue = sat_solver_addclause( p->pSat, pLits, 3 );
186 assert( RetValue );
187
188 // two additional clauses
189 // t' & e' -> f'
190 // t & e -> f
191
192 // t + e + f'
193 // t' + e' + f
194
195 if ( VarT == VarE )
196 {
197// assert( fCompT == !fCompE );
198 return;
199 }
200
201 pLits[0] = toLitCond(VarT, 0^fCompT);
202 pLits[1] = toLitCond(VarE, 0^fCompE);
203 pLits[2] = toLitCond(VarF, 1);
204 if ( p->pPars->fPolarFlip )
205 {
206 if ( Gia_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] );
207 if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] );
208 if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
209 }
210 RetValue = sat_solver_addclause( p->pSat, pLits, 3 );
211 assert( RetValue );
212 pLits[0] = toLitCond(VarT, 1^fCompT);
213 pLits[1] = toLitCond(VarE, 1^fCompE);
214 pLits[2] = toLitCond(VarF, 0);
215 if ( p->pPars->fPolarFlip )
216 {
217 if ( Gia_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] );
218 if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] );
219 if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] );
220 }
221 RetValue = sat_solver_addclause( p->pSat, pLits, 3 );
222 assert( RetValue );
223}
#define sat_solver_addclause
Definition cecSolveG.c:33
Cube * p
Definition exorList.c:222
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition giaUtil.c:1056
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition giaUtil.c:982
unsigned fPhase
Definition gia.h:87
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CecG_AddClausesSuper()

void CecG_AddClausesSuper ( Cec_ManSat_t * p,
Gia_Obj_t * pNode,
Vec_Ptr_t * vSuper )

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

Synopsis [Addes clauses to the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 236 of file cecSolveG.c.

237{
238 Gia_Obj_t * pFanin;
239 int * pLits, nLits, RetValue, i;
240 assert( !Gia_IsComplement(pNode) );
241 assert( Gia_ObjIsAnd( pNode ) );
242 // create storage for literals
243 nLits = Vec_PtrSize(vSuper) + 1;
244 pLits = ABC_ALLOC( int, nLits );
245 // suppose AND-gate is A & B = C
246 // add !A => !C or A + !C
247 Vec_PtrForEachEntry( Gia_Obj_t *, vSuper, pFanin, i )
248 {
249 pLits[0] = toLitCond(CecG_ObjSatNum(p,Gia_Regular(pFanin)), Gia_IsComplement(pFanin));
250 pLits[1] = toLitCond(CecG_ObjSatNum(p,pNode), 1);
251 if ( p->pPars->fPolarFlip )
252 {
253 if ( Gia_Regular(pFanin)->fPhase ) pLits[0] = lit_neg( pLits[0] );
254 if ( pNode->fPhase ) pLits[1] = lit_neg( pLits[1] );
255 }
256 RetValue = sat_solver_addclause( p->pSat, pLits, 2 );
257 assert( RetValue );
258 }
259 // add A & B => C or !A + !B + C
260 Vec_PtrForEachEntry( Gia_Obj_t *, vSuper, pFanin, i )
261 {
262 pLits[i] = toLitCond(CecG_ObjSatNum(p,Gia_Regular(pFanin)), !Gia_IsComplement(pFanin));
263 if ( p->pPars->fPolarFlip )
264 {
265 if ( Gia_Regular(pFanin)->fPhase ) pLits[i] = lit_neg( pLits[i] );
266 }
267 }
268 pLits[nLits-1] = toLitCond(CecG_ObjSatNum(p,pNode), 0);
269 if ( p->pPars->fPolarFlip )
270 {
271 if ( pNode->fPhase ) pLits[nLits-1] = lit_neg( pLits[nLits-1] );
272 }
273 RetValue = sat_solver_addclause( p->pSat, pLits, nLits );
274 assert( RetValue );
275 ABC_FREE( pLits );
276}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ CecG_CnfNodeAddToSolver()

void CecG_CnfNodeAddToSolver ( Cec_ManSat_t * p,
Gia_Obj_t * pObj )

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

Synopsis [Updates the solver clause database.]

Description []

SideEffects []

SeeAlso []

Definition at line 364 of file cecSolveG.c.

365{
366 Vec_Ptr_t * vFrontier;
367 Gia_Obj_t * pNode, * pFanin;
368 int i, k, fUseMuxes = 0 == p->pPars->SolverType;
369 // quit if CNF is ready
370 if ( CecG_ObjSatNum(p,pObj) )
371 return;
372 if ( Gia_ObjIsCi(pObj) )
373 {
374 Vec_PtrPush( p->vUsedNodes, pObj );
375 CecG_ObjSetSatNum( p, pObj, sat_solver_addvar( p->pSat ) );
376 return;
377 }
378 assert( Gia_ObjIsAnd(pObj) );
379
380 // start the frontier
381 vFrontier = Vec_PtrAlloc( 100 );
382 CecG_ObjAddToFrontier( p, pObj, vFrontier );
383 // explore nodes in the frontier
384 Vec_PtrForEachEntry( Gia_Obj_t *, vFrontier, pNode, i )
385 {
386 // create the supergate
387 assert( CecG_ObjSatNum(p,pNode) );
388 if ( fUseMuxes && Gia_ObjIsMuxType(pNode) )
389 {
390 Vec_PtrClear( p->vFanins );
391 Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin0( Gia_ObjFanin0(pNode) ) );
392 Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin0( Gia_ObjFanin1(pNode) ) );
393 Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin1( Gia_ObjFanin0(pNode) ) );
394 Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin1( Gia_ObjFanin1(pNode) ) );
395 Vec_PtrForEachEntry( Gia_Obj_t *, p->vFanins, pFanin, k )
396 CecG_ObjAddToFrontier( p, Gia_Regular(pFanin), vFrontier );
397 CecG_AddClausesMux( p, pNode );
398 }
399 else
400 {
401 CecG_CollectSuper( pNode, fUseMuxes, 0 == p->pPars->SolverType, p->vFanins );
402 Vec_PtrForEachEntry( Gia_Obj_t *, p->vFanins, pFanin, k )
403 CecG_ObjAddToFrontier( p, Gia_Regular(pFanin), vFrontier );
404
405 if( p->pPars->SolverType < 2 )
406 CecG_AddClausesSuper( p, pNode, p->vFanins );
407 }
408 assert( Vec_PtrSize(p->vFanins) > 1 );
409 }
410 if( p->pPars->SolverType )
411 Vec_PtrForEachEntry( Gia_Obj_t *, vFrontier, pNode, i ){
412 int var = CecG_ObjSatNum( p, pNode );
413 int Lit0 = Abc_Var2Lit( CecG_ObjSatNum( p, Gia_ObjFanin0(pNode) ), Gia_ObjFaninC0(pNode) );
414 int Lit1 = Abc_Var2Lit( CecG_ObjSatNum( p, Gia_ObjFanin1(pNode) ), Gia_ObjFaninC1(pNode) );
415 assert(Gia_ObjIsAnd(pNode));
416 if ( (Lit0 > Lit1) ^ Gia_ObjIsXor(pNode) )
417 Lit1 ^= Lit0, Lit0 ^= Lit1, Lit1 ^= Lit0;
418 sat_solver_set_var_fanin_lit( p->pSat, var, Lit0, Lit1 );
419 }
420 Vec_PtrFree( vFrontier );
421}
#define sat_solver_addvar
Definition cecSolveG.c:36
void CecG_AddClausesSuper(Cec_ManSat_t *p, Gia_Obj_t *pNode, Vec_Ptr_t *vSuper)
Definition cecSolveG.c:236
void CecG_AddClausesMux(Cec_ManSat_t *p, Gia_Obj_t *pNode)
Definition cecSolveG.c:117
void CecG_ObjAddToFrontier(Cec_ManSat_t *p, Gia_Obj_t *pObj, Vec_Ptr_t *vFrontier)
Definition cecSolveG.c:339
#define sat_solver_set_var_fanin_lit
Definition cecSolveG.c:45
void CecG_CollectSuper(Gia_Obj_t *pObj, int fUseMuxes, int fUseSuper, Vec_Ptr_t *vSuper)
Definition cecSolveG.c:320
unsigned short var
Definition giaNewBdd.h:35
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CecG_CollectSuper()

void CecG_CollectSuper ( Gia_Obj_t * pObj,
int fUseMuxes,
int fUseSuper,
Vec_Ptr_t * vSuper )

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

Synopsis [Collects the supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 320 of file cecSolveG.c.

321{
322 assert( !Gia_IsComplement(pObj) );
323 assert( !Gia_ObjIsCi(pObj) );
324 Vec_PtrClear( vSuper );
325 CecG_CollectSuper_rec( pObj, vSuper, 1, fUseMuxes, fUseSuper );
326}
void CecG_CollectSuper_rec(Gia_Obj_t *pObj, Vec_Ptr_t *vSuper, int fFirst, int fUseMuxes, int fUseSuper)
Definition cecSolveG.c:289
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CecG_CollectSuper_rec()

void CecG_CollectSuper_rec ( Gia_Obj_t * pObj,
Vec_Ptr_t * vSuper,
int fFirst,
int fUseMuxes,
int fUseSuper )

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

Synopsis [Collects the supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 289 of file cecSolveG.c.

290{
291 // if the new node is complemented or a PI, another gate begins
292 if ( Gia_IsComplement(pObj) || Gia_ObjIsCi(pObj) ||
293 (!fFirst && Gia_ObjValue(pObj) > 1) ||
294 (fUseMuxes && Gia_ObjIsMuxType(pObj)) )
295 {
296 Vec_PtrPushUnique( vSuper, pObj );
297 return;
298 }
299 if( !fUseSuper ){
300 Vec_PtrPushUnique( vSuper, Gia_ObjChild0(pObj) );
301 Vec_PtrPushUnique( vSuper, Gia_ObjChild1(pObj) );
302 return ;
303 }
304 // go through the branches
305 CecG_CollectSuper_rec( Gia_ObjChild0(pObj), vSuper, 0, fUseMuxes, fUseSuper );
306 CecG_CollectSuper_rec( Gia_ObjChild1(pObj), vSuper, 0, fUseMuxes, fUseSuper );
307}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CecG_ManSatCheckNode()

int CecG_ManSatCheckNode ( Cec_ManSat_t * p,
Gia_Obj_t * pObj )

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

Synopsis [Runs equivalence test for the two nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 479 of file cecSolveG.c.

480{
481 Gia_Obj_t * pObjR = Gia_Regular(pObj);
482 int nBTLimit = p->pPars->nBTLimit;
483 int Lit, RetValue, nConflicts;
484 abctime clk = Abc_Clock();
485
486 if ( pObj == Gia_ManConst0(p->pAig) )
487 return 1;
488 if ( pObj == Gia_ManConst1(p->pAig) )
489 {
490 assert( 0 );
491 return 0;
492 }
493
494 p->nCallsSince++; // experiment with this!!!
495 p->nSatTotal++;
496
497 // check if SAT solver needs recycling
498 if ( p->pSat == NULL ||
499 (p->pPars->nSatVarMax &&
500 sat_solver_varnum(p->pSat) > p->pPars->nSatVarMax &&
501 p->nCallsSince > p->pPars->nCallsRecycle) )
503
504 // if the nodes do not have SAT variables, allocate them
505 CecG_CnfNodeAddToSolver( p, pObjR );
506
507 if( p->pPars->SolverType ){
509 sat_solver_mark_cone( p->pSat, CecG_ObjSatNum(p, pObjR) );
510 }
511
512 // propage unit clauses // minisat only
513 //if ( p->pSat->qtail != p->pSat->qhead )
514 //{
515 // status = sat_solver_simplify(p->pSat);
516 // assert( status != 0 );
517 // assert( p->pSat->qtail == p->pSat->qhead );
518 //}
519
520 // solve under assumptions
521 // A = 1; B = 0 OR A = 1; B = 1
522 Lit = toLitCond( CecG_ObjSatNum(p,pObjR), Gia_IsComplement(pObj) );
523 if ( p->pPars->fPolarFlip )
524 {
525 if ( pObjR->fPhase ) Lit = lit_neg( Lit );
526 }
527 nConflicts = sat_solver_conflictnum(p->pSat);
528
529 sat_solver_set_conflict_budget( p->pSat, nBTLimit );
530 RetValue = sat_solver_solve( p->pSat, &Lit, 1 );
531 //RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1,
532 // (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
533 if ( RetValue == l_False )
534 {
535p->timeSatUnsat += Abc_Clock() - clk;
536 Lit = lit_neg( Lit );
537 RetValue = sat_solver_addclause( p->pSat, &Lit, 1 );
538 assert( RetValue );
539 p->nSatUnsat++;
540 p->nConfUnsat += sat_solver_conflictnum(p->pSat) - nConflicts;
541//Abc_Print( 1, "UNSAT after %d conflicts\n", sat_solver_conflictnum(p->pSat) - nConflicts );
542 return 1;
543 }
544 else if ( RetValue == l_True )
545 {
546p->timeSatSat += Abc_Clock() - clk;
547 p->nSatSat++;
548 p->nConfSat += sat_solver_conflictnum(p->pSat) - nConflicts;
549//Abc_Print( 1, "SAT after %d conflicts\n", sat_solver_conflictnum(p->pSat) - nConflicts );
550 return 0;
551 }
552 else // if ( RetValue == l_Undef )
553 {
554p->timeSatUndec += Abc_Clock() - clk;
555 p->nSatUndec++;
556 p->nConfUndec += sat_solver_conflictnum(p->pSat) - nConflicts;
557//Abc_Print( 1, "UNDEC after %d conflicts\n", sat_solver_conflictnum(p->pSat) - nConflicts );
558 return -1;
559 }
560}
ABC_INT64_T abctime
Definition abc_global.h:332
#define l_True
Definition bmcBmcS.c:35
#define l_False
Definition bmcBmcS.c:36
#define sat_solver_set_conflict_budget
Definition cecSolveG.c:38
#define sat_solver_mark_cone
Definition cecSolveG.c:47
#define sat_solver_start_new_round
Definition cecSolveG.c:46
void CecG_ManSatSolverRecycle(Cec_ManSat_t *p)
Definition cecSolveG.c:435
void CecG_CnfNodeAddToSolver(Cec_ManSat_t *p, Gia_Obj_t *pObj)
Definition cecSolveG.c:364
#define sat_solver_conflictnum
Definition cecSolveG.c:39
#define sat_solver_varnum
Definition cecSolveG.c:49
#define sat_solver_solve
Definition cecSolveG.c:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CecG_ManSatSolve()

void CecG_ManSatSolve ( Cec_ManPat_t * pPat,
Gia_Man_t * pAig,
Cec_ParSat_t * pPars,
int f0Proved )

Definition at line 562 of file cecSolveG.c.

563{
564 Bar_Progress_t * pProgress = NULL;
565 Cec_ManSat_t * p;
566 Gia_Obj_t * pObj;
567 int i, status;
568 abctime clk = Abc_Clock(), clk2;
569 Vec_PtrFreeP( &pAig->vSeqModelVec );
570 if( pPars->SolverType )
571 pPars->fPolarFlip = 0;
572 // reset the manager
573 if ( pPat )
574 {
575 pPat->iStart = Vec_StrSize(pPat->vStorage);
576 pPat->nPats = 0;
577 pPat->nPatLits = 0;
578 pPat->nPatLitsMin = 0;
579 }
580 Gia_ManSetPhase( pAig );
581 Gia_ManLevelNum( pAig );
583 p = Cec_ManSatCreate( pAig, pPars );
584 pProgress = Bar_ProgressStart( stdout, Gia_ManPoNum(pAig) );
585 Gia_ManForEachCo( pAig, pObj, i )
586 {
587 if ( Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) )
588 {
589 status = !Gia_ObjFaninC0(pObj);
590 pObj->fMark0 = (status == 0);
591 pObj->fMark1 = (status == 1);
592 continue;
593 }
594 Bar_ProgressUpdate( pProgress, i, "SAT..." );
595clk2 = Abc_Clock();
596 status = CecG_ManSatCheckNode( p, Gia_ObjChild0(pObj) );
597 pObj->fMark0 = (status == 0);
598 pObj->fMark1 = (status == 1);
599
600 if ( f0Proved && status == 1 )
601 Gia_ManPatchCoDriver( pAig, i, 0 );
602/*
603 if ( status == -1 )
604 {
605 Gia_Man_t * pTemp = Gia_ManDupDfsCone( pAig, pObj );
606 Gia_AigerWrite( pTemp, "gia_hard.aig", 0, 0, 0 );
607 Gia_ManStop( pTemp );
608 Abc_Print( 1, "Dumping hard cone into file \"%s\".\n", "gia_hard.aig" );
609 }
610*/
611 if ( status != 0 )
612 continue;
613 // save the pattern
614 //if ( pPat )
615 //{
616 // abctime clk3 = Abc_Clock();
617 // Cec_ManPatSavePattern( pPat, p, pObj );
618 // pPat->timeTotalSave += Abc_Clock() - clk3;
619 //}
620 // quit if one of them is solved
621 if ( pPars->fCheckMiter )
622 break;
623 }
624 p->timeTotal = Abc_Clock() - clk;
625 printf("Recycles %d\n", p->nRecycles);
626 Bar_ProgressStop( pProgress );
627 if ( pPars->fVerbose )
629 if( p->pSat )
630 sat_solver_stop( p->pSat );
631 p->pSat = NULL;
632 Cec_ManSatStop( p );
633}
void Bar_ProgressStop(Bar_Progress_t *p)
Definition bar.c:126
Bar_Progress_t * Bar_ProgressStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
Definition bar.c:66
struct Bar_Progress_t_ Bar_Progress_t
BASIC TYPES ///.
Definition bar.h:48
void Cec_ManSatPrintStats(Cec_ManSat_t *p)
Definition cecMan.c:74
void Cec_ManSatStop(Cec_ManSat_t *p)
Definition cecMan.c:105
struct Cec_ManSat_t_ Cec_ManSat_t
Definition cecInt.h:75
Cec_ManSat_t * Cec_ManSatCreate(Gia_Man_t *pAig, Cec_ParSat_t *pPars)
DECLARATIONS ///.
Definition cecMan.c:45
int CecG_ManSatCheckNode(Cec_ManSat_t *p, Gia_Obj_t *pObj)
Definition cecSolveG.c:479
#define sat_solver_stop
Definition cecSolveG.c:32
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
void Gia_ManSetPhase(Gia_Man_t *p)
Definition giaUtil.c:420
int Gia_ManLevelNum(Gia_Man_t *p)
Definition giaUtil.c:546
Vec_Ptr_t * vSeqModelVec
Definition gia.h:151
unsigned fMark1
Definition gia.h:86
unsigned fMark0
Definition gia.h:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CecG_ManSatSolverRecycle()

void CecG_ManSatSolverRecycle ( Cec_ManSat_t * p)

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

Synopsis [Recycles the SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 435 of file cecSolveG.c.

436{
437 int Lit;
438 if ( p->pSat )
439 {
440 Gia_Obj_t * pObj;
441 int i;
442 Vec_PtrForEachEntry( Gia_Obj_t *, p->vUsedNodes, pObj, i )
443 CecG_ObjSetSatNum( p, pObj, 0 );
444 Vec_PtrClear( p->vUsedNodes );
445// memset( p->pSatVars, 0, sizeof(int) * Gia_ManObjNumMax(p->pAigTotal) );
446 sat_solver_stop( p->pSat );
447 }
448 p->pSat = (struct sat_solver_t*)sat_solver_start();
449 assert( 0 <= p->pPars->SolverType && p->pPars->SolverType <= 2 );
450 sat_solver_set_jftr( p->pSat, p->pPars->SolverType );
451 //sat_solver_setnvars( p->pSat, 1000 ); // minisat only
452 //p->pSat->factors = ABC_CALLOC( double, p->pSat->cap );
453 // var 0 is not used
454 // var 1 is reserved for const0 node - add the clause
455
456// p->nSatVars = 0;
457 CecG_ObjSetSatNum( p, Gia_ManConst0(p->pAig), sat_solver_addvar( p->pSat ) );
458 Lit = toLitCond( CecG_ObjSatNum( p, Gia_ManConst0(p->pAig) ), 1 );
459 sat_solver_addclause( p->pSat, &Lit, 1 );
460// if ( p->pPars->fPolarFlip ) // no need to normalize const0 node (bug fix by SS on 9/17/2012)
461// Lit = lit_neg( Lit );
462
463 p->nRecycles++;
464 p->nCallsSince = 0;
465}
#define sat_solver_addvar
Definition cecSatG2.c:40
#define sat_solver_start
Definition cecSolveG.c:31
#define sat_solver_set_jftr
Definition cecSolveG.c:44
Here is the caller graph for this function:

◆ CecG_ObjAddToFrontier()

void CecG_ObjAddToFrontier ( Cec_ManSat_t * p,
Gia_Obj_t * pObj,
Vec_Ptr_t * vFrontier )

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

Synopsis [Updates the solver clause database.]

Description []

SideEffects []

SeeAlso []

Definition at line 339 of file cecSolveG.c.

340{
341 assert( !Gia_IsComplement(pObj) );
342 if ( CecG_ObjSatNum(p,pObj) )
343 return;
344 assert( CecG_ObjSatNum(p,pObj) == 0 );
345 if ( Gia_ObjIsConst0(pObj) )
346 return;
347 Vec_PtrPush( p->vUsedNodes, pObj );
348 CecG_ObjSetSatNum( p, pObj, sat_solver_addvar( p->pSat ) );
349 if ( Gia_ObjIsAnd(pObj) )
350 Vec_PtrPush( vFrontier, pObj );
351}
Here is the caller graph for this function:

◆ CecG_ObjSatVarValue()

int CecG_ObjSatVarValue ( Cec_ManSat_t * p,
Gia_Obj_t * pObj )

FUNCTION DEFINITIONS ///.

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

Synopsis [Returns value of the SAT variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file cecSolveG.c.

102{
103 return sat_solver_read_cex_varvalue( p->pSat, CecG_ObjSatNum(p, pObj) );
104}
#define sat_solver_read_cex_varvalue
Definition cecSolveG.c:41