ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bmcBmc2.c File Reference
#include "sat/cnf/cnf.h"
#include "sat/bsat/satStore.h"
#include "sat/satoko/satoko.h"
#include "proof/ssw/ssw.h"
#include "bmc.h"
Include dependency graph for bmcBmc2.c:

Go to the source code of this file.

Classes

struct  Saig_Bmc_t_
 

Macros

#define ABS_ZER   1
 FUNCTION DEFINITIONS ///.
 
#define ABS_ONE   2
 
#define ABS_UND   3
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Saig_Bmc_t_ Saig_Bmc_t
 DECLARATIONS ///.
 

Functions

int Abs_ManExtendOneEval_rec (Vec_Ptr_t *vSimInfo, Aig_Man_t *p, Aig_Obj_t *pObj, int iFrame)
 
Vec_Ptr_tAbs_ManTernarySimulate (Aig_Man_t *p, int nFramesMax, int fVerbose)
 
void Abs_ManFreeAray (Vec_Ptr_t *p)
 
Saig_Bmc_tSaig_BmcManStart (Aig_Man_t *pAig, int nFramesMax, int nNodesMax, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fUseSatoko)
 
void Saig_BmcManStop (Saig_Bmc_t *p)
 
Aig_Obj_tSaig_BmcIntervalConstruct_rec (Saig_Bmc_t *p, Aig_Obj_t *pObj, int i, Vec_Int_t *vVisited)
 
void Saig_BmcInterval (Saig_Bmc_t *p)
 
Aig_Obj_tSaig_BmcIntervalToAig_rec (Saig_Bmc_t *p, Aig_Man_t *pNew, Aig_Obj_t *pObj)
 
Aig_Man_tSaig_BmcIntervalToAig (Saig_Bmc_t *p)
 
void Saig_BmcLoadCnf (Saig_Bmc_t *p, Cnf_Dat_t *pCnf)
 
void Saig_BmcDeriveFailed (Saig_Bmc_t *p, int iTargetFail)
 
Abc_Cex_tSaig_BmcGenerateCounterExample (Saig_Bmc_t *p)
 
int Saig_BmcSolveTargets (Saig_Bmc_t *p, int nStart, int *pnOutsSolved)
 
void Saig_BmcAddTargetsAsPos (Saig_Bmc_t *p)
 
int Saig_BmcPerform (Aig_Man_t *pAig, int nStart, int nFramesMax, int nNodesMax, int nTimeOut, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fVerbOverwrite, int *piFrames, int fSilent, int fUseSatoko)
 

Macro Definition Documentation

◆ ABS_ONE

#define ABS_ONE   2

Definition at line 108 of file bmcBmc2.c.

◆ ABS_UND

#define ABS_UND   3

Definition at line 109 of file bmcBmc2.c.

◆ ABS_ZER

#define ABS_ZER   1

FUNCTION DEFINITIONS ///.

Definition at line 107 of file bmcBmc2.c.

Typedef Documentation

◆ Saig_Bmc_t

typedef typedefABC_NAMESPACE_IMPL_START struct Saig_Bmc_t_ Saig_Bmc_t

DECLARATIONS ///.

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

FileName [bmcBmc2.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based bounded model checking.]

Synopsis [Simple BMC package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 35 of file bmcBmc2.c.

Function Documentation

◆ Abs_ManExtendOneEval_rec()

int Abs_ManExtendOneEval_rec ( Vec_Ptr_t * vSimInfo,
Aig_Man_t * p,
Aig_Obj_t * pObj,
int iFrame )

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

Synopsis [Performs ternary simulation for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 154 of file bmcBmc2.c.

155{
156 int Value0, Value1, Value;
157 Value = Abs_ManSimInfoGet( vSimInfo, pObj, iFrame );
158 if ( Value )
159 return Value;
160 if ( Aig_ObjIsCi(pObj) )
161 {
162 assert( Saig_ObjIsLo(p, pObj) );
163 Value = Abs_ManExtendOneEval_rec( vSimInfo, p, Saig_ObjLoToLi(p, pObj), iFrame-1 );
164 Abs_ManSimInfoSet( vSimInfo, pObj, iFrame, Value );
165 return Value;
166 }
167 Value0 = Abs_ManExtendOneEval_rec( vSimInfo, p, Aig_ObjFanin0(pObj), iFrame );
168 if ( Aig_ObjFaninC0(pObj) )
169 Value0 = Abs_ManSimInfoNot( Value0 );
170 if ( Aig_ObjIsCo(pObj) )
171 {
172 Abs_ManSimInfoSet( vSimInfo, pObj, iFrame, Value0 );
173 return Value0;
174 }
175 assert( Aig_ObjIsNode(pObj) );
176 if ( Value0 == ABS_ZER )
177 Value = ABS_ZER;
178 else
179 {
180 Value1 = Abs_ManExtendOneEval_rec( vSimInfo, p, Aig_ObjFanin1(pObj), iFrame );
181 if ( Aig_ObjFaninC1(pObj) )
182 Value1 = Abs_ManSimInfoNot( Value1 );
183 Value = Abs_ManSimInfoAnd( Value0, Value1 );
184 }
185 Abs_ManSimInfoSet( vSimInfo, pObj, iFrame, Value );
186 assert( Value );
187 return Value;
188}
#define ABS_ZER
FUNCTION DEFINITIONS ///.
Definition bmcBmc2.c:107
int Abs_ManExtendOneEval_rec(Vec_Ptr_t *vSimInfo, Aig_Man_t *p, Aig_Obj_t *pObj, int iFrame)
Definition bmcBmc2.c:154
Cube * p
Definition exorList.c:222
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abs_ManFreeAray()

void Abs_ManFreeAray ( Vec_Ptr_t * p)

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

Synopsis [Free the array of simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file bmcBmc2.c.

262{
263 void * pTemp;
264 int i;
265 Vec_PtrForEachEntry( void *, p, pTemp, i )
266 ABC_FREE( pTemp );
267 Vec_PtrFree( p );
268}
#define ABC_FREE(obj)
Definition abc_global.h:267
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55

◆ Abs_ManTernarySimulate()

Vec_Ptr_t * Abs_ManTernarySimulate ( Aig_Man_t * p,
int nFramesMax,
int fVerbose )

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

Synopsis [Performs ternary simulation for one design.]

Description [The returned array contains the result of ternary simulation for all the frames where the output could be proved 0.]

SideEffects []

SeeAlso []

Definition at line 202 of file bmcBmc2.c.

203{
204 Vec_Ptr_t * vSimInfo;
205 Aig_Obj_t * pObj;
206 int i, f, nFramesLimit, nFrameWords;
207 abctime clk = Abc_Clock();
208 assert( Aig_ManRegNum(p) > 0 );
209 // the maximum number of frames will be determined to use at most 200Mb of RAM
210 nFramesLimit = 1 + (200000000 * 4)/Aig_ManObjNum(p);
211 nFramesLimit = Abc_MinInt( nFramesLimit, nFramesMax );
212 nFrameWords = Abc_BitWordNum( 2 * Aig_ManObjNum(p) );
213 // allocate simulation info
214 vSimInfo = Vec_PtrAlloc( nFramesLimit );
215 for ( f = 0; f < nFramesLimit; f++ )
216 {
217 Vec_PtrPush( vSimInfo, ABC_CALLOC(unsigned, nFrameWords) );
218 if ( f == 0 )
219 {
220 Saig_ManForEachLo( p, pObj, i )
221 Abs_ManSimInfoSet( vSimInfo, pObj, 0, ABS_ZER );
222 }
223 Abs_ManSimInfoSet( vSimInfo, Aig_ManConst1(p), f, ABS_ONE );
224 Saig_ManForEachPi( p, pObj, i )
225 Abs_ManSimInfoSet( vSimInfo, pObj, f, ABS_UND );
226 Saig_ManForEachPo( p, pObj, i )
227 Abs_ManExtendOneEval_rec( vSimInfo, p, pObj, f );
228 // check if simulation has derived at least one fail or unknown
229 Saig_ManForEachPo( p, pObj, i )
230 if ( Abs_ManSimInfoGet(vSimInfo, pObj, f) != ABS_ZER )
231 {
232 if ( fVerbose )
233 {
234 printf( "Ternary sim found non-zero output in frame %d. Used %5.2f MB. ",
235 f, 0.25 * (f+1) * Aig_ManObjNum(p) / (1<<20) );
236 ABC_PRT( "Time", Abc_Clock() - clk );
237 }
238 return vSimInfo;
239 }
240 }
241 if ( fVerbose )
242 {
243 printf( "Ternary sim proved all outputs in the first %d frames. Used %5.2f MB. ",
244 nFramesLimit, 0.25 * nFramesLimit * Aig_ManObjNum(p) / (1<<20) );
245 ABC_PRT( "Time", Abc_Clock() - clk );
246 }
247 return vSimInfo;
248}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define ABS_UND
Definition bmcBmc2.c:109
#define ABS_ONE
Definition bmcBmc2.c:108
#define Saig_ManForEachPo(p, pObj, i)
Definition saig.h:93
#define Saig_ManForEachLo(p, pObj, i)
Definition saig.h:96
#define Saig_ManForEachPi(p, pObj, i)
Definition saig.h:91
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:

◆ Saig_BmcAddTargetsAsPos()

void Saig_BmcAddTargetsAsPos ( Saig_Bmc_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 789 of file bmcBmc2.c.

790{
791 Aig_Obj_t * pObj;
792 int i;
793 Vec_PtrForEachEntry( Aig_Obj_t *, p->vTargets, pObj, i )
794 Aig_ObjCreateCo( p->pFrm, pObj );
795 Aig_ManPrintStats( p->pFrm );
796 Aig_ManCleanup( p->pFrm );
797 Aig_ManPrintStats( p->pFrm );
798}
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
void Aig_ManPrintStats(Aig_Man_t *p)
Definition aigMan.c:379
int Aig_ManCleanup(Aig_Man_t *p)
Definition aigMan.c:265
Here is the call graph for this function:

◆ Saig_BmcDeriveFailed()

void Saig_BmcDeriveFailed ( Saig_Bmc_t * p,
int iTargetFail )

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

Synopsis [Solves targets with the given resource limit.]

Description []

SideEffects []

SeeAlso []

Definition at line 645 of file bmcBmc2.c.

646{
647 int k;
648 p->iOutputFail = p->iOutputLast;
649 p->iFrameFail = p->iFrameLast;
650 for ( k = Vec_PtrSize(p->vTargets); k > iTargetFail; k-- )
651 {
652 if ( p->iOutputFail == 0 )
653 {
654 p->iOutputFail = Saig_ManPoNum(p->pAig);
655 p->iFrameFail--;
656 }
657 p->iOutputFail--;
658 }
659}
Here is the caller graph for this function:

◆ Saig_BmcGenerateCounterExample()

Abc_Cex_t * Saig_BmcGenerateCounterExample ( Saig_Bmc_t * p)

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

Synopsis [Solves targets with the given resource limit.]

Description []

SideEffects []

SeeAlso []

Definition at line 672 of file bmcBmc2.c.

673{
674 Abc_Cex_t * pCex;
675 Aig_Obj_t * pObj, * pObjFrm;
676 int i, f, iVarNum;
677 // start the counter-example
678 pCex = Abc_CexAlloc( Aig_ManRegNum(p->pAig), Saig_ManPiNum(p->pAig), p->iFrameFail+1 );
679 pCex->iFrame = p->iFrameFail;
680 pCex->iPo = p->iOutputFail;
681 // copy the bit data
682 for ( f = 0; f <= p->iFrameFail; f++ )
683 {
684 Saig_ManForEachPi( p->pAig, pObj, i )
685 {
686 pObjFrm = Saig_BmcObjFrame( p, pObj, f );
687 if ( pObjFrm == NULL )
688 continue;
689 iVarNum = Saig_BmcSatNum( p, pObjFrm );
690 if ( iVarNum == 0 )
691 continue;
692 if ( p->pSat2 ? satoko_read_cex_varvalue(p->pSat2, iVarNum) : sat_solver_var_value(p->pSat, iVarNum) )
693 Abc_InfoSetBit( pCex->pData, pCex->nRegs + Saig_ManPiNum(p->pAig) * f + i );
694 }
695 }
696 // verify the counter example
697 if ( !Saig_ManVerifyCex( p->pAig, pCex ) )
698 {
699 printf( "Saig_BmcGenerateCounterExample(): Counter-example is invalid.\n" );
700 Abc_CexFree( pCex );
701 pCex = NULL;
702 }
703 return pCex;
704}
int Saig_ManVerifyCex(Aig_Man_t *pAig, Abc_Cex_t *p)
Definition saigDup.c:281
int satoko_read_cex_varvalue(satoko_t *, int)
Definition solver_api.c:660
void Abc_CexFree(Abc_Cex_t *p)
Definition utilCex.c:382
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
Definition utilCex.c:51
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition utilCex.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_BmcInterval()

void Saig_BmcInterval ( Saig_Bmc_t * p)

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

Synopsis [Adds new AIG nodes to the frames.]

Description []

SideEffects []

SeeAlso []

Definition at line 470 of file bmcBmc2.c.

471{
472 Aig_Obj_t * pTarget;
473 int i, iObj, iFrame;
474 int nNodes = Aig_ManObjNum( p->pFrm );
475 Vec_PtrClear( p->vTargets );
476 p->iFramePrev = p->iFrameLast;
477 for ( ; p->iFrameLast < p->nFramesMax; p->iFrameLast++, p->iOutputLast = 0 )
478 {
479 if ( p->iOutputLast == 0 )
480 {
481 Saig_BmcObjSetFrame( p, Aig_ManConst1(p->pAig), p->iFrameLast, Aig_ManConst1(p->pFrm) );
482 }
483 for ( ; p->iOutputLast < Saig_ManPoNum(p->pAig); p->iOutputLast++ )
484 {
485 if ( Aig_ManObjNum(p->pFrm) >= nNodes + p->nNodesMax )
486 return;
487// Saig_BmcIntervalExplore_rec( p, Aig_ManCo(p->pAig, p->iOutputLast), p->iFrameLast );
488 Vec_IntClear( p->vVisited );
489 pTarget = Saig_BmcIntervalConstruct_rec( p, Aig_ManCo(p->pAig, p->iOutputLast), p->iFrameLast, p->vVisited );
490 Vec_PtrPush( p->vTargets, pTarget );
491 Aig_ObjCreateCo( p->pFrm, pTarget );
492 Aig_ManCleanup( p->pFrm ); // it is not efficient to cleanup the whole manager!!!
493 // check if the node is gone
494 Vec_IntForEachEntryDouble( p->vVisited, iObj, iFrame, i )
495 Saig_BmcObjFrame( p, Aig_ManObj(p->pAig, iObj), iFrame );
496 // it is not efficient to remove nodes, which may be used later!!!
497 }
498 }
499}
Aig_Obj_t * Saig_BmcIntervalConstruct_rec(Saig_Bmc_t *p, Aig_Obj_t *pObj, int i, Vec_Int_t *vVisited)
Definition bmcBmc2.c:426
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_BmcIntervalConstruct_rec()

Aig_Obj_t * Saig_BmcIntervalConstruct_rec ( Saig_Bmc_t * p,
Aig_Obj_t * pObj,
int i,
Vec_Int_t * vVisited )

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

Synopsis [Explores the possibility of constructing the output.]

Description []

SideEffects []

SeeAlso [] Function*************************************************************

Synopsis [Performs the actual construction of the output.]

Description []

SideEffects []

SeeAlso []

Definition at line 426 of file bmcBmc2.c.

427{
428 Aig_Obj_t * pRes;
429 pRes = Saig_BmcObjFrame( p, pObj, i );
430 if ( pRes != NULL )
431 return pRes;
432 if ( Saig_ObjIsPi( p->pAig, pObj ) )
433 pRes = Aig_ObjCreateCi(p->pFrm);
434 else if ( Saig_ObjIsLo( p->pAig, pObj ) )
435 pRes = Saig_BmcIntervalConstruct_rec( p, Saig_ObjLoToLi(p->pAig, pObj), i-1, vVisited );
436 else if ( Aig_ObjIsCo( pObj ) )
437 {
438 Saig_BmcIntervalConstruct_rec( p, Aig_ObjFanin0(pObj), i, vVisited );
439 pRes = Saig_BmcObjChild0( p, pObj, i );
440 }
441 else
442 {
443 Saig_BmcIntervalConstruct_rec( p, Aig_ObjFanin0(pObj), i, vVisited );
444 if ( Saig_BmcObjChild0(p, pObj, i) == Aig_ManConst0(p->pFrm) )
445 pRes = Aig_ManConst0(p->pFrm);
446 else
447 {
448 Saig_BmcIntervalConstruct_rec( p, Aig_ObjFanin1(pObj), i, vVisited );
449 pRes = Aig_And( p->pFrm, Saig_BmcObjChild0(p, pObj, i), Saig_BmcObjChild1(p, pObj, i) );
450 }
451 }
452 assert( pRes != NULL );
453 Saig_BmcObjSetFrame( p, pObj, i, pRes );
454 Vec_IntPush( vVisited, Aig_ObjId(pObj) );
455 Vec_IntPush( vVisited, i );
456 return pRes;
457}
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:104
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_BmcIntervalToAig()

Aig_Man_t * Saig_BmcIntervalToAig ( Saig_Bmc_t * p)

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

Synopsis [Creates AIG of the newly added nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 539 of file bmcBmc2.c.

540{
541 Aig_Man_t * pNew;
542 Aig_Obj_t * pObj, * pObjNew;
543 int i;
544 Aig_ManForEachObj( p->pFrm, pObj, i )
545 assert( pObj->pData == NULL );
546
547 pNew = Aig_ManStart( p->nNodesMax );
548 Aig_ManConst1(p->pFrm)->pData = Aig_ManConst1(pNew);
549 Vec_IntClear( p->vVisited );
550 Vec_IntPush( p->vVisited, Aig_ObjId(Aig_ManConst1(p->pFrm)) );
551 Vec_PtrForEachEntry( Aig_Obj_t *, p->vTargets, pObj, i )
552 {
553// assert( !Aig_ObjIsConst1(Aig_Regular(pObj)) );
554 pObjNew = Saig_BmcIntervalToAig_rec( p, pNew, Aig_Regular(pObj) );
555 assert( !Aig_IsComplement(pObjNew) );
556 Aig_ObjCreateCo( pNew, pObjNew );
557 }
558 return pNew;
559}
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
Aig_Obj_t * Saig_BmcIntervalToAig_rec(Saig_Bmc_t *p, Aig_Man_t *pNew, Aig_Obj_t *pObj)
Definition bmcBmc2.c:512
void * pData
Definition aig.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_BmcIntervalToAig_rec()

Aig_Obj_t * Saig_BmcIntervalToAig_rec ( Saig_Bmc_t * p,
Aig_Man_t * pNew,
Aig_Obj_t * pObj )

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

Synopsis [Performs the actual construction of the output.]

Description []

SideEffects []

SeeAlso []

Definition at line 512 of file bmcBmc2.c.

513{
514 if ( pObj->pData )
515 return (Aig_Obj_t *)pObj->pData;
516 Vec_IntPush( p->vVisited, Aig_ObjId(pObj) );
517 if ( Saig_BmcSatNum(p, pObj) || Aig_ObjIsCi(pObj) )
518 {
519 p->nStitchVars += !Aig_ObjIsCi(pObj);
520 return (Aig_Obj_t *)(pObj->pData = Aig_ObjCreateCi(pNew));
521 }
522 Saig_BmcIntervalToAig_rec( p, pNew, Aig_ObjFanin0(pObj) );
523 Saig_BmcIntervalToAig_rec( p, pNew, Aig_ObjFanin1(pObj) );
524 assert( pObj->pData == NULL );
525 return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ));
526}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_BmcLoadCnf()

void Saig_BmcLoadCnf ( Saig_Bmc_t * p,
Cnf_Dat_t * pCnf )

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

Synopsis [Derives CNF for the newly added nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 572 of file bmcBmc2.c.

573{
574 Aig_Obj_t * pObj, * pObjNew;
575 int i, Lits[2], VarNumOld, VarNumNew;
576 Aig_ManForEachObjVec( p->vVisited, p->pFrm, pObj, i )
577 {
578 // get the new variable of this node
579 pObjNew = (Aig_Obj_t *)pObj->pData;
580 pObj->pData = NULL;
581 VarNumNew = pCnf->pVarNums[ pObjNew->Id ];
582 if ( VarNumNew == -1 )
583 continue;
584 // get the old variable of this node
585 VarNumOld = Saig_BmcSatNum( p, pObj );
586 if ( VarNumOld == 0 )
587 {
588 Saig_BmcSetSatNum( p, pObj, VarNumNew );
589 continue;
590 }
591 // add clauses connecting existing variables
592 Lits[0] = toLitCond( VarNumOld, 0 );
593 Lits[1] = toLitCond( VarNumNew, 1 );
594 if ( p->pSat2 )
595 {
596 if ( !satoko_add_clause( p->pSat2, Lits, 2 ) )
597 assert( 0 );
598 }
599 else
600 {
601 if ( !sat_solver_addclause( p->pSat, Lits, Lits+2 ) )
602 assert( 0 );
603 }
604 Lits[0] = toLitCond( VarNumOld, 1 );
605 Lits[1] = toLitCond( VarNumNew, 0 );
606 if ( p->pSat2 )
607 {
608 if ( !satoko_add_clause( p->pSat2, Lits, 2 ) )
609 assert( 0 );
610 }
611 else
612 {
613 if ( !sat_solver_addclause( p->pSat, Lits, Lits+2 ) )
614 assert( 0 );
615 }
616 }
617 // add CNF to the SAT solver
618 if ( p->pSat2 )
619 {
620 for ( i = 0; i < pCnf->nClauses; i++ )
621 if ( !satoko_add_clause( p->pSat2, pCnf->pClauses[i], pCnf->pClauses[i+1]-pCnf->pClauses[i] ) )
622 break;
623 }
624 else
625 {
626 for ( i = 0; i < pCnf->nClauses; i++ )
627 if ( !sat_solver_addclause( p->pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
628 break;
629 }
630 if ( i < pCnf->nClauses )
631 printf( "SAT solver became UNSAT after adding clauses.\n" );
632}
#define Aig_ManForEachObjVec(vIds, p, pObj, i)
Definition aig.h:408
#define sat_solver_addclause
Definition cecSatG2.c:37
int satoko_add_clause(satoko_t *, int *, int)
Definition solver_api.c:255
int Id
Definition aig.h:85
int * pVarNums
Definition cnf.h:63
int ** pClauses
Definition cnf.h:62
int nClauses
Definition cnf.h:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_BmcManStart()

Saig_Bmc_t * Saig_BmcManStart ( Aig_Man_t * pAig,
int nFramesMax,
int nNodesMax,
int nConfMaxOne,
int nConfMaxAll,
int fVerbose,
int fUseSatoko )

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

Synopsis [Create manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file bmcBmc2.c.

283{
284 Saig_Bmc_t * p;
285 Aig_Obj_t * pObj;
286 int i, Lit;
287// assert( Aig_ManRegNum(pAig) > 0 );
288 p = (Saig_Bmc_t *)ABC_ALLOC( char, sizeof(Saig_Bmc_t) );
289 memset( p, 0, sizeof(Saig_Bmc_t) );
290 // set parameters
291 p->nFramesMax = nFramesMax;
292 p->nNodesMax = nNodesMax;
293 p->nConfMaxOne = nConfMaxOne;
294 p->nConfMaxAll = nConfMaxAll;
295 p->fVerbose = fVerbose;
296 p->pAig = pAig;
297 p->nObjs = Aig_ManObjNumMax(pAig);
298 // create node and variable mappings
299 p->vAig2Frm = Vec_PtrAlloc( 100 );
300 p->vObj2Var = Vec_IntAlloc( 0 );
301 Vec_IntFill( p->vObj2Var, p->nObjs, 0 );
302 // start the AIG manager and map primary inputs
303 p->pFrm = Aig_ManStart( p->nObjs );
304 Saig_ManForEachLo( pAig, pObj, i )
305 Saig_BmcObjSetFrame( p, pObj, 0, Aig_ManConst0(p->pFrm) );
306 // create SAT solver
307 p->nSatVars = 1;
308 Lit = toLit( p->nSatVars );
309 if ( fUseSatoko )
310 {
311 satoko_opts_t opts;
312 satoko_default_opts(&opts);
313 opts.conf_limit = nConfMaxOne;
314 p->pSat2 = satoko_create();
315 satoko_configure(p->pSat2, &opts);
316 satoko_setnvars(p->pSat2, 2000);
317 satoko_add_clause( p->pSat2, &Lit, 1 );
318 }
319 else
320 {
321 p->pSat = sat_solver_new();
322 p->pSat->nLearntStart = 10000;//p->pPars->nLearnedStart;
323 p->pSat->nLearntDelta = 5000;//p->pPars->nLearnedDelta;
324 p->pSat->nLearntRatio = 75;//p->pPars->nLearnedPerce;
325 p->pSat->nLearntMax = p->pSat->nLearntStart;
326 sat_solver_setnvars( p->pSat, 2000 );
327 sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
328 }
329 Saig_BmcSetSatNum( p, Aig_ManConst1(p->pFrm), p->nSatVars++ );
330 // other data structures
331 p->vTargets = Vec_PtrAlloc( 1000 );
332 p->vVisited = Vec_IntAlloc( 1000 );
333 p->iOutputFail = -1;
334 p->iFrameFail = -1;
335 return p;
336}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
typedefABC_NAMESPACE_IMPL_START struct Saig_Bmc_t_ Saig_Bmc_t
DECLARATIONS ///.
Definition bmcBmc2.c:35
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
void satoko_setnvars(satoko_t *, int)
Definition solver_api.c:230
struct satoko_opts satoko_opts_t
Definition satoko.h:37
void satoko_default_opts(satoko_opts_t *)
Definition solver_api.c:161
satoko_t * satoko_create(void)
Definition solver_api.c:88
void satoko_configure(satoko_t *, satoko_opts_t *)
Definition solver_api.c:196
long conf_limit
Definition satoko.h:40
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_BmcManStop()

void Saig_BmcManStop ( Saig_Bmc_t * p)

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

Synopsis [Delete manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 349 of file bmcBmc2.c.

350{
351 Aig_ManStop( p->pFrm );
352 Vec_VecFree( (Vec_Vec_t *)p->vAig2Frm );
353 Vec_IntFree( p->vObj2Var );
354 if ( p->pSat ) sat_solver_delete( p->pSat );
355 if ( p->pSat2 ) satoko_destroy( p->pSat2 );
356 Vec_PtrFree( p->vTargets );
357 Vec_IntFree( p->vVisited );
358 ABC_FREE( p );
359}
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
void satoko_destroy(satoko_t *)
Definition solver_api.c:132
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_BmcPerform()

int Saig_BmcPerform ( Aig_Man_t * pAig,
int nStart,
int nFramesMax,
int nNodesMax,
int nTimeOut,
int nConfMaxOne,
int nConfMaxAll,
int fVerbose,
int fVerbOverwrite,
int * piFrames,
int fSilent,
int fUseSatoko )

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

Synopsis [Performs BMC with the given parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 811 of file bmcBmc2.c.

812{
813 Saig_Bmc_t * p;
814 Aig_Man_t * pNew;
815 Cnf_Dat_t * pCnf;
816 int nOutsSolved = 0;
817 int Iter, RetValue = -1;
818 abctime nTimeToStop = nTimeOut ? nTimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0;
819 abctime clk = Abc_Clock(), clk2, clkTotal = Abc_Clock();
820 int Status = -1;
821/*
822 Vec_Ptr_t * vSimInfo;
823 vSimInfo = Abs_ManTernarySimulate( pAig, nFramesMax, fVerbose );
824 Abs_ManFreeAray( vSimInfo );
825*/
826 if ( fVerbose )
827 {
828 printf( "Running \"bmc2\". AIG: PI/PO/Reg = %d/%d/%d. Node = %6d. Lev = %5d.\n",
829 Saig_ManPiNum(pAig), Saig_ManPoNum(pAig), Saig_ManRegNum(pAig),
830 Aig_ManNodeNum(pAig), Aig_ManLevelNum(pAig) );
831 printf( "Params: FramesMax = %d. NodesDelta = %d. ConfMaxOne = %d. ConfMaxAll = %d.\n",
832 nFramesMax, nNodesMax, nConfMaxOne, nConfMaxAll );
833 }
834 nFramesMax = nFramesMax ? nFramesMax : ABC_INFINITY;
835 p = Saig_BmcManStart( pAig, nFramesMax, nNodesMax, nConfMaxOne, nConfMaxAll, fVerbose, fUseSatoko );
836 // set runtime limit
837 if ( nTimeOut )
838 {
839 if ( p->pSat2 )
840 satoko_set_runtime_limit( p->pSat2, nTimeToStop );
841 else
842 sat_solver_set_runtime_limit( p->pSat, nTimeToStop );
843 }
844 for ( Iter = 0; ; Iter++ )
845 {
846 clk2 = Abc_Clock();
847 // add new logic interval to frames
849// Saig_BmcAddTargetsAsPos( p );
850 if ( Vec_PtrSize(p->vTargets) == 0 )
851 break;
852 // convert logic slice into new AIG
853 pNew = Saig_BmcIntervalToAig( p );
854//printf( "StitchVars = %d.\n", p->nStitchVars );
855 // derive CNF for the new AIG
856 pCnf = Cnf_Derive( pNew, Aig_ManCoNum(pNew) );
857 Cnf_DataLift( pCnf, p->nSatVars );
858 p->nSatVars += pCnf->nVars;
859 // add this CNF to the solver
860 Saig_BmcLoadCnf( p, pCnf );
861 Cnf_DataFree( pCnf );
862 Aig_ManStop( pNew );
863 // solve the targets
864 RetValue = Saig_BmcSolveTargets( p, nStart, &nOutsSolved );
865 if ( fVerbose )
866 {
867 printf( "%4d : F =%5d. O =%4d. And =%8d. Var =%8d. Conf =%7d. ",
868 Iter, p->iFrameLast, p->iOutputLast, Aig_ManNodeNum(p->pFrm), p->nSatVars,
869 p->pSat ? (int)p->pSat->stats.conflicts : satoko_conflictnum(p->pSat2) );
870 printf( "%4.0f MB", 4.0*(p->iFrameLast+1)*p->nObjs/(1<<20) );
871 printf( "%9.2f sec", (float)(Abc_Clock() - clkTotal)/(float)(CLOCKS_PER_SEC) );
872 printf( "\n" );
873 fflush( stdout );
874 }
875 if ( RetValue != l_False )
876 break;
877 // check the timeout
878 if ( nTimeOut && Abc_Clock() > nTimeToStop )
879 {
880 if ( !fSilent )
881 printf( "Reached timeout (%d seconds).\n", nTimeOut );
882 if ( piFrames )
883 *piFrames = p->iFrameLast-1;
885 return Status;
886 }
887 }
888 if ( RetValue == l_True )
889 {
890 assert( p->iFrameFail * Saig_ManPoNum(p->pAig) + p->iOutputFail + 1 == nOutsSolved );
891 if ( !fSilent )
892 Abc_Print( 1, "Output %d of miter \"%s\" was asserted in frame %d. ",
893 p->iOutputFail, p->pAig->pName, p->iFrameFail );
894 Status = 0;
895 if ( piFrames )
896 *piFrames = p->iFrameFail - 1;
897 }
898 else // if ( RetValue == l_False || RetValue == l_Undef )
899 {
900 if ( !fSilent )
901 Abc_Print( 1, "No output failed in %d frames. ", Abc_MaxInt(p->iFramePrev-1, 0) );
902 if ( piFrames )
903 {
904 if ( p->iOutputLast > 0 )
905 *piFrames = p->iFramePrev - 2;
906 else
907 *piFrames = p->iFramePrev - 1;
908 }
909 }
910 if ( !fSilent )
911 {
912 if ( fVerbOverwrite )
913 {
914 ABC_PRTr( "Time", Abc_Clock() - clk );
915 }
916 else
917 {
918 ABC_PRT( "Time", Abc_Clock() - clk );
919 }
920 if ( RetValue != l_True )
921 {
922 if ( p->iFrameLast >= p->nFramesMax )
923 printf( "Reached limit on the number of timeframes (%d).\n", p->nFramesMax );
924 else if ( p->nConfMaxAll && (p->pSat ? (int)p->pSat->stats.conflicts : satoko_conflictnum(p->pSat2)) > p->nConfMaxAll )
925 printf( "Reached global conflict limit (%d).\n", p->nConfMaxAll );
926 else if ( nTimeOut && Abc_Clock() > nTimeToStop )
927 printf( "Reached timeout (%d seconds).\n", nTimeOut );
928 else
929 printf( "Reached local conflict limit (%d).\n", p->nConfMaxOne );
930 }
931 }
933 fflush( stdout );
934 return Status;
935}
#define ABC_PRTr(a, t)
Definition abc_global.h:256
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
int Aig_ManLevelNum(Aig_Man_t *p)
Definition aigDfs.c:500
void Saig_BmcLoadCnf(Saig_Bmc_t *p, Cnf_Dat_t *pCnf)
Definition bmcBmc2.c:572
void Saig_BmcInterval(Saig_Bmc_t *p)
Definition bmcBmc2.c:470
void Saig_BmcManStop(Saig_Bmc_t *p)
Definition bmcBmc2.c:349
int Saig_BmcSolveTargets(Saig_Bmc_t *p, int nStart, int *pnOutsSolved)
Definition bmcBmc2.c:717
Aig_Man_t * Saig_BmcIntervalToAig(Saig_Bmc_t *p)
Definition bmcBmc2.c:539
Saig_Bmc_t * Saig_BmcManStart(Aig_Man_t *pAig, int nFramesMax, int nNodesMax, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fUseSatoko)
Definition bmcBmc2.c:282
#define l_True
Definition bmcBmcS.c:35
#define l_False
Definition bmcBmcS.c:36
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
Definition cnfCore.c:165
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
void Cnf_DataLift(Cnf_Dat_t *p, int nVarsPlus)
Definition cnfMan.c:232
int satoko_conflictnum(satoko_t *)
Definition solver_api.c:640
abctime satoko_set_runtime_limit(satoko_t *, abctime)
Definition solver_api.c:665
int nVars
Definition cnf.h:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_BmcSolveTargets()

int Saig_BmcSolveTargets ( Saig_Bmc_t * p,
int nStart,
int * pnOutsSolved )

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

Synopsis [Solves targets with the given resource limit.]

Description []

SideEffects []

SeeAlso []

Definition at line 717 of file bmcBmc2.c.

718{
719 Aig_Obj_t * pObj;
720 int i, k, VarNum, Lit, status, RetValue;
721 assert( Vec_PtrSize(p->vTargets) > 0 );
722 if ( p->pSat && p->pSat->qtail != p->pSat->qhead )
723 {
724 RetValue = sat_solver_simplify(p->pSat);
725 assert( RetValue != 0 );
726 }
727 Vec_PtrForEachEntry( Aig_Obj_t *, p->vTargets, pObj, i )
728 {
729 if ( ((*pnOutsSolved)++ / Saig_ManPoNum(p->pAig)) < nStart )
730 continue;
731 if ( p->nConfMaxAll && (p->pSat ? p->pSat->stats.conflicts : satoko_conflictnum(p->pSat2)) > p->nConfMaxAll )
732 return l_Undef;
733 VarNum = Saig_BmcSatNum( p, Aig_Regular(pObj) );
734 Lit = toLitCond( VarNum, Aig_IsComplement(pObj) );
735 if ( p->pSat2 )
736 RetValue = satoko_solve_assumptions_limit( p->pSat2, &Lit, 1, p->nConfMaxOne );
737 else
738 RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, (ABC_INT64_T)p->nConfMaxOne, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
739 if ( RetValue == l_False ) // unsat
740 {
741 // add final unit clause
742 Lit = lit_neg( Lit );
743 if ( p->pSat2 )
744 status = satoko_add_clause( p->pSat2, &Lit, 1 );
745 else
746 status = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
747 assert( status );
748 if ( p->pSat )
749 {
750 // add learned units
751 for ( k = 0; k < veci_size(&p->pSat->unit_lits); k++ )
752 {
753 Lit = veci_begin(&p->pSat->unit_lits)[k];
754 status = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
755 assert( status );
756 }
757 veci_resize(&p->pSat->unit_lits, 0);
758 // propagate units
759 sat_solver_compress( p->pSat );
760 }
761 continue;
762 }
763 if ( RetValue == l_Undef ) // undecided
764 return l_Undef;
765 // generate counter-example
767 p->pAig->pSeqModel = Saig_BmcGenerateCounterExample( p );
768
769 {
770// extern Vec_Int_t * Saig_ManExtendCounterExampleTest( Aig_Man_t * p, int iFirstPi, void * pCex );
771// Saig_ManExtendCounterExampleTest( p->pAig, 0, p->pAig->pSeqModel );
772 }
773 return l_True;
774 }
775 return l_False;
776}
Abc_Cex_t * Saig_BmcGenerateCounterExample(Saig_Bmc_t *p)
Definition bmcBmc2.c:672
void Saig_BmcDeriveFailed(Saig_Bmc_t *p, int iTargetFail)
Definition bmcBmc2.c:645
#define l_Undef
Definition bmcBmcS.c:34
#define sat_solver_solve
Definition cecSatG2.c:45
int sat_solver_simplify(sat_solver *s)
Definition satSolver.c:1515
int satoko_solve_assumptions_limit(satoko_t *s, int *plits, int nlits, int nconflim)
Definition solver_api.c:364
Here is the call graph for this function:
Here is the caller graph for this function: