ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bmc.h File Reference
#include "aig/saig/saig.h"
#include "aig/gia/gia.h"
Include dependency graph for bmc.h:

Go to the source code of this file.

Classes

struct  Bmc_EsPar_t_
 
struct  Saig_ParBmc_t_
 
struct  Bmc_AndPar_t_
 
struct  Bmc_BCorePar_t_
 
struct  Bmc_MulPar_t_
 
struct  Bmc_ParFf_t_
 

Typedefs

typedef typedefABC_NAMESPACE_HEADER_START struct Bmc_EsPar_t_ Bmc_EsPar_t
 INCLUDES ///.
 
typedef struct Unr_Man_t_ Unr_Man_t
 
typedef struct Saig_ParBmc_t_ Saig_ParBmc_t
 
typedef struct Bmc_AndPar_t_ Bmc_AndPar_t
 
typedef struct Bmc_BCorePar_t_ Bmc_BCorePar_t
 
typedef struct Bmc_MulPar_t_ Bmc_MulPar_t
 
typedef struct Bmc_ParFf_t_ Bmc_ParFf_t
 

Functions

void Bmc_ManBCorePerform (Gia_Man_t *pGia, Bmc_BCorePar_t *pPars)
 MACRO DEFINITIONS ///.
 
int Saig_ManBmcSimple (Aig_Man_t *pAig, int nFrames, int nSizeMax, int nBTLimit, int fRewrite, int fVerbose, int *piFrame, int nCofFanLit, int fUseSatoko)
 
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)
 
void Saig_ParBmcSetDefaultParams (Saig_ParBmc_t *p)
 
int Saig_ManBmcScalable (Aig_Man_t *pAig, Saig_ParBmc_t *pPars)
 
int Gia_ManBmcPerform (Gia_Man_t *p, Bmc_AndPar_t *pPars)
 
Abc_Cex_tBmc_CexCareExtendToObjects (Gia_Man_t *p, Abc_Cex_t *pCex, Abc_Cex_t *pCexCare)
 DECLARATIONS ///.
 
Abc_Cex_tBmc_CexCareMinimize (Aig_Man_t *p, int nRealPis, Abc_Cex_t *pCex, int nTryCexes, int fCheck, int fVerbose)
 
Abc_Cex_tBmc_CexCareMinimizeAig (Gia_Man_t *p, int nRealPis, Abc_Cex_t *pCex, int nTryCexes, int fCheck, int fVerbose)
 
int Bmc_CexCareVerify (Aig_Man_t *p, Abc_Cex_t *pCex, Abc_Cex_t *pCexMin, int fVerbose)
 
int Bmc_CexCareVerifyAnyPo (Aig_Man_t *p, Abc_Cex_t *pCex, Abc_Cex_t *pCexMin, int fVerbose)
 
Abc_Cex_tBmc_CexCareSatBasedMinimize (Aig_Man_t *p, int nRealPis, Abc_Cex_t *pCex, int fHighEffort, int fCheck, int fVerbose)
 
Abc_Cex_tBmc_CexCareSatBasedMinimizeAig (Gia_Man_t *p, Abc_Cex_t *pCex, int fHighEffort, int fVerbose)
 
Gia_Man_tBmc_GiaTargetStates (Gia_Man_t *p, Abc_Cex_t *pCex, int iFrBeg, int iFrEnd, int fCombOnly, int fGenAll, int fAllFrames, int fVerbose)
 
Aig_Man_tBmc_AigTargetStates (Aig_Man_t *p, Abc_Cex_t *pCex, int iFrBeg, int iFrEnd, int fCombOnly, int fGenAll, int fAllFrames, int fVerbose)
 
Abc_Cex_tSaig_ManCexMinPerform (Aig_Man_t *pAig, Abc_Cex_t *pCex)
 
void Bmc_CexPrint (Abc_Cex_t *pCex, int nRealPis, int fVerbose)
 
int Bmc_CexVerify (Gia_Man_t *p, Abc_Cex_t *pCex, Abc_Cex_t *pCexCare)
 
int Bmc_CexVerifyAnyPo (Gia_Man_t *p, Abc_Cex_t *pCex, Abc_Cex_t *pCexCare)
 
void Bmc_PerformICheck (Gia_Man_t *p, int nFramesMax, int nTimeOut, int fEmpty, int fVerbose)
 
Vec_Int_tBmc_PerformISearch (Gia_Man_t *p, int nFramesMax, int nTimeOut, int fReverse, int fBackTopo, int fDump, int fVerbose)
 
Unr_Man_tUnr_ManUnrollStart (Gia_Man_t *pGia, int fVerbose)
 
Gia_Man_tUnr_ManUnrollFrame (Unr_Man_t *p, int f)
 
void Unr_ManFree (Unr_Man_t *p)
 

Typedef Documentation

◆ Bmc_AndPar_t

typedef struct Bmc_AndPar_t_ Bmc_AndPar_t

Definition at line 143 of file bmc.h.

◆ Bmc_BCorePar_t

Definition at line 169 of file bmc.h.

◆ Bmc_EsPar_t

typedef typedefABC_NAMESPACE_HEADER_START struct Bmc_EsPar_t_ Bmc_EsPar_t

INCLUDES ///.

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

FileName [bmc.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based bounded model checking.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
bmc.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] PARAMETERS /// BASIC TYPES ///

Definition at line 47 of file bmc.h.

◆ Bmc_MulPar_t

typedef struct Bmc_MulPar_t_ Bmc_MulPar_t

Definition at line 180 of file bmc.h.

◆ Bmc_ParFf_t

typedef struct Bmc_ParFf_t_ Bmc_ParFf_t

Definition at line 194 of file bmc.h.

◆ Saig_ParBmc_t

typedef struct Saig_ParBmc_t_ Saig_ParBmc_t

Definition at line 105 of file bmc.h.

◆ Unr_Man_t

typedef struct Unr_Man_t_ Unr_Man_t

Definition at line 103 of file bmc.h.

Function Documentation

◆ Bmc_AigTargetStates()

Aig_Man_t * Bmc_AigTargetStates ( Aig_Man_t * p,
Abc_Cex_t * pCex,
int iFrBeg,
int iFrEnd,
int fCombOnly,
int fUseOne,
int fAllFrames,
int fVerbose )
extern

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

Synopsis [Generate AIG for target bad states.]

Description []

SideEffects []

SeeAlso []

Definition at line 513 of file bmcCexCut.c.

514{
515 Aig_Man_t * pAig;
516 Gia_Man_t * pGia, * pRes;
517 pGia = Gia_ManFromAigSimple( p );
518 if ( !Gia_ManVerifyCex( pGia, pCex, 0 ) )
519 {
520 Abc_Print( 1, "Current CEX does not fail AIG \"%s\".\n", p->pName );
521 Gia_ManStop( pGia );
522 return NULL;
523 }
524 pRes = Bmc_GiaTargetStates( pGia, pCex, iFrBeg, iFrEnd, fCombOnly, fUseOne, fAllFrames, fVerbose );
525 Gia_ManStop( pGia );
526 pAig = Gia_ManToAigSimple( pRes );
527 Gia_ManStop( pRes );
528 return pAig;
529}
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
Gia_Man_t * Bmc_GiaTargetStates(Gia_Man_t *p, Abc_Cex_t *pCex, int iFrBeg, int iFrEnd, int fCombOnly, int fUseOne, int fAllFrames, int fVerbose)
Definition bmcCexCut.c:461
Cube * p
Definition exorList.c:222
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Definition giaAig.c:408
Gia_Man_t * Gia_ManFromAigSimple(Aig_Man_t *p)
Definition giaAig.c:212
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
int Gia_ManVerifyCex(Gia_Man_t *pAig, Abc_Cex_t *p, int fDualOut)
DECLARATIONS ///.
Definition giaCex.c:48
Here is the call graph for this function:

◆ Bmc_CexCareExtendToObjects()

Abc_Cex_t * Bmc_CexCareExtendToObjects ( Gia_Man_t * p,
Abc_Cex_t * pCex,
Abc_Cex_t * pCexCare )
extern

DECLARATIONS ///.

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

FileName [bmcCexCare.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based bounded model checking.]

Synopsis [Computing care set of the counter-example.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Takes CEX and its care-set. Returns care-set of all objects.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file bmcCexCare.c.

47{
48 Abc_Cex_t * pNew;
49 Gia_Obj_t * pObj;
50 int i, k;
51 assert( pCex->nPis == pCexCare->nPis );
52 assert( pCex->nRegs == pCexCare->nRegs );
53 assert( pCex->nBits == pCexCare->nBits );
54 // start the counter-example
55 pNew = Abc_CexAlloc( pCex->nRegs, Gia_ManObjNum(p), pCex->iFrame + 1 );
56 pNew->iFrame = pCex->iFrame;
57 pNew->iPo = pCex->iPo;
58 // initialize terminary simulation
59 Gia_ObjTerSimSet0( Gia_ManConst0(p) );
60 Gia_ManForEachRi( p, pObj, k )
61 Gia_ObjTerSimSet0( pObj );
62 for ( i = 0; i <= pCex->iFrame; i++ )
63 {
64 Gia_ManForEachPi( p, pObj, k )
65 {
66 if ( !Abc_InfoHasBit( pCexCare->pData, pCexCare->nRegs + i * pCexCare->nPis + k ) )
67 Gia_ObjTerSimSetX( pObj );
68 else if ( Abc_InfoHasBit( pCex->pData, pCex->nRegs + i * pCex->nPis + k ) )
69 Gia_ObjTerSimSet1( pObj );
70 else
71 Gia_ObjTerSimSet0( pObj );
72 }
73 Gia_ManForEachRo( p, pObj, k )
74 Gia_ObjTerSimRo( p, pObj );
75 Gia_ManForEachAnd( p, pObj, k )
76 Gia_ObjTerSimAnd( pObj );
77 Gia_ManForEachCo( p, pObj, k )
78 Gia_ObjTerSimCo( pObj );
79 // add cares to the exdended counter-example
80 Gia_ManForEachObj( p, pObj, k )
81 if ( !Gia_ObjTerSimGetX(pObj) )
82 Abc_InfoSetBit( pNew->pData, pNew->nRegs + pNew->nPis * i + k );
83 }
84 pObj = Gia_ManPo( p, pCex->iPo );
85 assert( Gia_ObjTerSimGet1(pObj) );
86 return pNew;
87}
#define Gia_ManForEachRo(p, pObj, i)
Definition gia.h:1252
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachPi(p, pObj, i)
Definition gia.h:1248
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachRi(p, pObj, i)
Definition gia.h:1254
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
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Bmc_CexCareMinimize()

Abc_Cex_t * Bmc_CexCareMinimize ( Aig_Man_t * p,
int nRealPis,
Abc_Cex_t * pCex,
int nTryCexes,
int fCheck,
int fVerbose )
extern

Definition at line 426 of file bmcCexCare.c.

427{
428 Gia_Man_t * pGia = Gia_ManFromAigSimple( p );
429 Abc_Cex_t * pCexMin = Bmc_CexCareMinimizeAig( pGia, nRealPis, pCex, nTryCexes, fCheck, fVerbose );
430 Gia_ManStop( pGia );
431 return pCexMin;
432}
Abc_Cex_t * Bmc_CexCareMinimizeAig(Gia_Man_t *p, int nRealPis, Abc_Cex_t *pCex, int nTryCexes, int fCheck, int fVerbose)
Definition bmcCexCare.c:254
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmc_CexCareMinimizeAig()

Abc_Cex_t * Bmc_CexCareMinimizeAig ( Gia_Man_t * p,
int nRealPis,
Abc_Cex_t * pCex,
int nTryCexes,
int fCheck,
int fVerbose )
extern

Definition at line 254 of file bmcCexCare.c.

255{
256 //int nTryCexes = 4; // belongs to range [1;4]
257 Abc_Cex_t * pCexBest, * pCexMin[4] = {NULL};
258 int k, f, i, nOnesBest, nOnesCur, Counter = 0;
259 Vec_Int_t * vPriosIn, * vPriosFf;
260 if ( pCex->nPis != Gia_ManPiNum(p) )
261 {
262 printf( "Given CEX does to have same number of inputs as the AIG.\n" );
263 return NULL;
264 }
265 if ( pCex->nRegs != Gia_ManRegNum(p) )
266 {
267 printf( "Given CEX does to have same number of flops as the AIG.\n" );
268 return NULL;
269 }
270 if ( !(pCex->iPo >= 0 && pCex->iPo < Gia_ManPoNum(p)) )
271 {
272 printf( "Given CEX has PO whose index is out of range for the AIG.\n" );
273 return NULL;
274 }
275 assert( pCex->nPis == Gia_ManPiNum(p) );
276 assert( pCex->nRegs == Gia_ManRegNum(p) );
277 assert( pCex->iPo >= 0 && pCex->iPo < Gia_ManPoNum(p) );
278 if ( fVerbose )
279 {
280 printf( "Original : " );
281 Bmc_CexPrint( pCex, nRealPis, 0 );
282 }
283 vPriosIn = Vec_IntAlloc( pCex->nPis * (pCex->iFrame + 1) );
284 vPriosFf = Vec_IntAlloc( pCex->nRegs * (pCex->iFrame + 1) );
285 for ( k = 0; k < nTryCexes; k++ )
286 {
287 Counter = 0;
288 Vec_IntFill( vPriosIn, pCex->nPis * (pCex->iFrame + 1), 0 );
289/*
290 if ( k == 0 )
291 {
292 for ( f = 0; f <= pCex->iFrame; f++ )
293 for ( i = nRealPis; i < Gia_ManPiNum(p); i++ )
294 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
295 for ( f = 0; f <= pCex->iFrame; f++ )
296 for ( i = 0; i < nRealPis; i++ )
297 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
298 }
299 else if ( k == 1 )
300 {
301 for ( f = pCex->iFrame; f >= 0; f-- )
302 for ( i = nRealPis; i < Gia_ManPiNum(p); i++ )
303 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
304 for ( f = pCex->iFrame; f >= 0; f-- )
305 for ( i = 0; i < nRealPis; i++ )
306 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
307 }
308 else if ( k == 2 )
309 {
310 for ( f = 0; f <= pCex->iFrame; f++ )
311 for ( i = Gia_ManPiNum(p) - 1; i >= nRealPis; i-- )
312 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
313 for ( f = 0; f <= pCex->iFrame; f++ )
314 for ( i = nRealPis - 1; i >= 0; i-- )
315 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
316 }
317 else if ( k == 3 )
318 {
319 for ( f = pCex->iFrame; f >= 0; f-- )
320 for ( i = Gia_ManPiNum(p) - 1; i >= nRealPis; i-- )
321 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
322 for ( f = pCex->iFrame; f >= 0; f-- )
323 for ( i = nRealPis - 1; i >= 0; i-- )
324 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
325 }
326 else assert( 0 );
327*/
328 if ( k == 0 )
329 {
330 for ( f = pCex->iFrame; f >= 0; f-- )
331 for ( i = Gia_ManPiNum(p) - 1; i >= nRealPis; i-- )
332 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
333 for ( f = pCex->iFrame; f >= 0; f-- )
334 for ( i = nRealPis - 1; i >= 0; i-- )
335 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
336 }
337 else if ( k == 1 )
338 {
339 for ( f = pCex->iFrame; f >= 0; f-- )
340 for ( i = Gia_ManPiNum(p) - 1; i >= nRealPis; i-- )
341 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
342 for ( f = pCex->iFrame; f >= 0; f-- )
343 for ( i = 0; i < nRealPis; i++ )
344 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
345 }
346 else if ( k == 2 )
347 {
348 for ( f = pCex->iFrame; f >= 0; f-- )
349 for ( i = nRealPis; i < Gia_ManPiNum(p); i++ )
350 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
351 for ( f = pCex->iFrame; f >= 0; f-- )
352 for ( i = nRealPis - 1; i >= 0; i-- )
353 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
354 }
355 else if ( k == 3 )
356 {
357 for ( f = pCex->iFrame; f >= 0; f-- )
358 for ( i = nRealPis; i < Gia_ManPiNum(p); i++ )
359 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
360 for ( f = pCex->iFrame; f >= 0; f-- )
361 for ( i = 0; i < nRealPis; i++ )
362 Vec_IntWriteEntry( vPriosIn, f * pCex->nPis + i, Abc_Var2Lit(Counter++, Abc_InfoHasBit(pCex->pData, pCex->nRegs + pCex->nPis * f + i)) );
363 }
364 else assert( 0 );
365
366 assert( Counter == pCex->nPis * (pCex->iFrame + 1) );
367 Bmc_CexCarePropagateFwd( p, pCex, vPriosIn, vPriosFf );
368 assert( Vec_IntSize(vPriosFf) == pCex->nRegs * (pCex->iFrame + 1) );
369 if ( !Abc_LitIsCompl(Gia_ManPo(p, pCex->iPo)->Value) )
370 {
371 printf( "Counter-example is invalid.\n" );
372 Vec_IntFree( vPriosIn );
373 Vec_IntFree( vPriosFf );
374 return NULL;
375 }
376 pCexMin[k] = Bmc_CexCarePropagateBwd( p, pCex, vPriosIn, vPriosFf );
377 if ( fVerbose )
378 {
379 if ( k == 0 )
380 printf( "PI- PPI-: " );
381 else if ( k == 1 )
382 printf( "PI+ PPI-: " );
383 else if ( k == 2 )
384 printf( "PI- PPI+: " );
385 else if ( k == 3 )
386 printf( "PI+ PPI+: " );
387 else assert( 0 );
388 Bmc_CexPrint( pCexMin[k], nRealPis, 0 );
389 }
390 }
391 Vec_IntFree( vPriosIn );
392 Vec_IntFree( vPriosFf );
393 // select the best one
394 pCexBest = pCexMin[0];
395 nOnesBest = Abc_CexCountOnes(pCexMin[0]);
396 for ( k = 1; k < nTryCexes; k++ )
397 {
398 if ( pCexMin[k] == NULL )
399 continue;
400 nOnesCur = Abc_CexCountOnes(pCexMin[k]);
401 if ( nOnesBest > nOnesCur )
402 {
403 nOnesBest = nOnesCur;
404 pCexBest = pCexMin[k];
405 }
406 }
407 if ( fVerbose )
408 {
409 //Abc_Cex_t * pTotal = Bmc_CexCareTotal( pCexMin, nTryCexes );
410 printf( "Final : " );
411 Bmc_CexPrint( pCexBest, nRealPis, 0 );
412 //printf( "Total : " );
413 //Bmc_CexPrint( pTotal, nRealPis, 0 );
414 //Abc_CexFreeP( &pTotal );
415 }
416 for ( k = 0; k < nTryCexes; k++ )
417 if ( pCexMin[k] && pCexBest != pCexMin[k] )
418 Abc_CexFreeP( &pCexMin[k] );
419 // verify and return
420 if ( !Bmc_CexVerify( p, pCex, pCexBest ) )
421 printf( "Counter-example verification has failed.\n" );
422 else if ( fCheck )
423 printf( "Counter-example verification succeeded.\n" );
424 return pCexBest;
425}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Bmc_CexCarePropagateFwd(Gia_Man_t *p, Abc_Cex_t *pCex, Vec_Int_t *vPriosIn, Vec_Int_t *vPriosFf)
Definition bmcCexCare.c:128
Abc_Cex_t * Bmc_CexCarePropagateBwd(Gia_Man_t *p, Abc_Cex_t *pCex, Vec_Int_t *vPriosIn, Vec_Int_t *vPriosFf)
Definition bmcCexCare.c:206
void Bmc_CexPrint(Abc_Cex_t *pCex, int nRealPis, int fVerbose)
int Bmc_CexVerify(Gia_Man_t *p, Abc_Cex_t *pCex, Abc_Cex_t *pCexCare)
void Abc_CexFreeP(Abc_Cex_t **p)
Definition utilCex.c:361
int Abc_CexCountOnes(Abc_Cex_t *p)
Definition utilCex.c:559
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmc_CexCareSatBasedMinimize()

Abc_Cex_t * Bmc_CexCareSatBasedMinimize ( Aig_Man_t * p,
int nRealPis,
Abc_Cex_t * pCex,
int fHighEffort,
int fCheck,
int fVerbose )
extern

Definition at line 433 of file bmcCexCare.c.

434{
435 Gia_Man_t * pGia = Gia_ManFromAigSimple( p );
436 Abc_Cex_t * pCexMin = Bmc_CexCareSatBasedMinimizeAig( pGia, pCex, fHighEffort, fVerbose );
437 if ( pCexMin == NULL )
438 {
439 Gia_ManStop( pGia );
440 return NULL;
441 }
442 // unfortunately, cannot verify - ternary simulation does not work
443 Gia_ManStop( pGia );
444 return pCexMin;
445}
Abc_Cex_t * Bmc_CexCareSatBasedMinimizeAig(Gia_Man_t *p, Abc_Cex_t *pCex, int fHighEffort, int fVerbose)
Definition giaCex.c:517
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmc_CexCareSatBasedMinimizeAig()

Abc_Cex_t * Bmc_CexCareSatBasedMinimizeAig ( Gia_Man_t * p,
Abc_Cex_t * pCex,
int fHighEffort,
int fVerbose )
extern

Definition at line 517 of file giaCex.c.

518{
519 abctime clk = Abc_Clock();
520 int n, i, iFirstVar, iLit, status;
521 Vec_Int_t * vLits = NULL, * vTemp;
522 sat_solver * pSat;
523 Cnf_Dat_t * pCnf;
524 int nFinal, * pFinal;
525 Abc_Cex_t * pCexBest = NULL;
526 int CountBest = 0;
527 Gia_Man_t * pFrames;
528
529 // CEX minimization
530 clk = Abc_Clock();
531 pCexBest = Bmc_CexCareMinimizeAig( p, Gia_ManPiNum(p), pCex, 1, 1, fVerbose );
532 for ( i = pCexBest->nRegs; i < pCexBest->nBits; i++ )
533 CountBest += Abc_InfoHasBit(pCexBest->pData, i);
534 if ( fVerbose )
535 {
536 printf( "Care bits = %d. ", CountBest );
537 Abc_PrintTime( 1, "Non-SAT-based CEX minimization", Abc_Clock() - clk );
538 }
539
540 // SAT instance
541 clk = Abc_Clock();
542 pFrames = Gia_ManFramesForCexMin( p, pCex->iFrame + 1 );
543 pCnf = (Cnf_Dat_t*)Mf_ManGenerateCnf( pFrames, 8, 0, 0, 0, 0 );
544 iFirstVar = pCnf->nVars - (pCex->iFrame+1) * pCex->nPis;
545 pSat = (sat_solver*)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
546 iLit = Abc_Var2Lit( 1, 1 );
547 status = sat_solver_addclause( pSat, &iLit, &iLit + 1 );
548 assert( status );
549 // create literals
550 vTemp = Vec_IntAlloc( 100 );
551 for ( i = pCex->nRegs; i < pCex->nBits; i++ )
552 Vec_IntPush( vTemp, Abc_Var2Lit(iFirstVar + i - pCex->nRegs, !Abc_InfoHasBit(pCex->pData, i)) );
553 if ( fVerbose )
554 Abc_PrintTime( 1, "Constructing SAT solver", Abc_Clock() - clk );
555
556 for ( n = 0; n < 2; n++ )
557 {
558 Vec_IntFreeP( &vLits );
559
560 vLits = Vec_IntDup( vTemp );
561 if ( n ) Vec_IntReverseOrder( vLits );
562
563 // SAT-based minimization
564 clk = Abc_Clock();
565 status = sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntLimit(vLits), 0, 0, 0, 0 );
566 nFinal = sat_solver_final( pSat, &pFinal );
567 if ( fVerbose )
568 {
569 printf( "Status %s Selected %5d assumptions out of %5d. ", status == l_False ? "OK ":"BUG", nFinal, Vec_IntSize(vLits) );
570 Abc_PrintTime( 1, "Analyze_final", Abc_Clock() - clk );
571 }
572 if ( CountBest > nFinal )
573 {
574 CountBest = nFinal;
575 ABC_FREE( pCexBest );
576 pCexBest = Bmc_CexCareDeriveCex( pCex, iFirstVar, pFinal, nFinal );
577 }
578 if ( !fHighEffort )
579 continue;
580
581 // SAT-based minimization
582 clk = Abc_Clock();
583 nFinal = sat_solver_minimize_assumptions( pSat, Vec_IntArray(vLits), Vec_IntSize(vLits), 0 );
584 if ( fVerbose )
585 {
586 printf( "Status %s Selected %5d assumptions out of %5d. ", status == l_False ? "OK ":"BUG", nFinal, Vec_IntSize(vLits) );
587 Abc_PrintTime( 1, "LEXUNSAT ", Abc_Clock() - clk );
588 }
589 if ( CountBest > nFinal )
590 {
591 CountBest = nFinal;
592 ABC_FREE( pCexBest );
593 pCexBest = Bmc_CexCareDeriveCex( pCex, iFirstVar, Vec_IntArray(vLits), nFinal );
594 }
595 }
596 if ( fVerbose )
597 {
598 printf( "Final : " );
599 Bmc_CexPrint( pCexBest, pCexBest->nPis, 0 );
600 }
601 // cleanup
602 Vec_IntFreeP( &vLits );
603 Vec_IntFreeP( &vTemp );
604 sat_solver_delete( pSat );
605 Cnf_DataFree( pCnf );
606 Gia_ManStop( pFrames );
607 return pCexBest;
608}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_FREE(obj)
Definition abc_global.h:267
#define l_False
Definition bmcBmcS.c:36
Abc_Cex_t * Bmc_CexCareMinimizeAig(Gia_Man_t *p, int nRealPis, Abc_Cex_t *pCex, int nTryCexes, int fCheck, int fVerbose)
Definition bmcCexCare.c:254
#define sat_solver_addclause
Definition cecSatG2.c:37
#define sat_solver
Definition cecSatG2.c:34
#define sat_solver_solve
Definition cecSatG2.c:45
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
Gia_Man_t * Gia_ManFramesForCexMin(Gia_Man_t *p, int nFrames)
Definition giaCex.c:401
Abc_Cex_t * Bmc_CexCareDeriveCex(Abc_Cex_t *pCex, int iFirstVar, int *pLits, int nLits)
Definition giaCex.c:503
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
Definition giaMf.c:1877
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
Definition cnfMan.c:579
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
int sat_solver_minimize_assumptions(sat_solver *s, int *pLits, int nLits, int nConfLimit)
Definition satSolver.c:2209
int nVars
Definition cnf.h:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmc_CexCareVerify()

int Bmc_CexCareVerify ( Aig_Man_t * p,
Abc_Cex_t * pCex,
Abc_Cex_t * pCexMin,
int fVerbose )
extern

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

Synopsis [Verifies the care set of the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 458 of file bmcCexCare.c.

459{
460 int result;
461 Gia_Man_t * pGia = Gia_ManFromAigSimple( p );
462 if ( fVerbose )
463 {
464 printf( "Original : " );
465 Bmc_CexPrint( pCex, Gia_ManPiNum(pGia), 0 );
466 printf( "Minimized: " );
467 Bmc_CexPrint( pCexMin, Gia_ManPiNum(pGia), 0 );
468 }
469 result = Bmc_CexVerify( pGia, pCex, pCexMin );
470 if ( !result )
471 printf( "Counter-example verification has failed.\n" );
472 else
473 printf( "Counter-example verification succeeded.\n" );
474 Gia_ManStop( pGia );
475 return result;
476}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmc_CexCareVerifyAnyPo()

int Bmc_CexCareVerifyAnyPo ( Aig_Man_t * p,
Abc_Cex_t * pCex,
Abc_Cex_t * pCexMin,
int fVerbose )
extern

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

Synopsis [Verifies the care set of the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 497 of file bmcCexCare.c.

498{
499 int iPo;
500 Gia_Man_t * pGia = Gia_ManFromAigSimple( p );
501 if ( fVerbose )
502 {
503 printf( "Original : " );
504 Bmc_CexPrint( pCex, Gia_ManPiNum(pGia), 0 );
505 printf( "Minimized: " );
506 Bmc_CexPrint( pCexMin, Gia_ManPiNum(pGia), 0 );
507 }
508 iPo = Bmc_CexVerifyAnyPo( pGia, pCex, pCexMin );
509 if ( iPo < 0 )
510 printf( "Counter-example verification has failed.\n" );
511 else
512 printf( "Counter-example verification succeeded.\n" );
513 Gia_ManStop( pGia );
514 return iPo;
515}
int Bmc_CexVerifyAnyPo(Gia_Man_t *p, Abc_Cex_t *pCex, Abc_Cex_t *pCexCare)
Here is the call graph for this function:

◆ Bmc_CexPrint()

void Bmc_CexPrint ( Abc_Cex_t * pCex,
int nRealPis,
int fVerbose )
extern

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

Synopsis [Prints one counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file bmcCexTools.c.

308{
309 int i, k, Count, iBit = pCex->nRegs;
310 Abc_CexPrintStatsInputs( pCex, nRealPis );
311 if ( !fVerbose )
312 return;
313
314 for ( i = 0; i <= pCex->iFrame; i++ )
315 {
316 Count = 0;
317 printf( "%3d : ", i );
318 for ( k = 0; k < nRealPis; k++ )
319 {
320 Count += Abc_InfoHasBit(pCex->pData, iBit);
321 printf( "%d", Abc_InfoHasBit(pCex->pData, iBit++) );
322 }
323 printf( " %3d ", Count );
324 Count = 0;
325 for ( ; k < pCex->nPis; k++ )
326 {
327 Count += Abc_InfoHasBit(pCex->pData, iBit);
328 printf( "%d", Abc_InfoHasBit(pCex->pData, iBit++) );
329 }
330 printf( " %3d\n", Count );
331 }
332 assert( iBit == pCex->nBits );
333}
void Abc_CexPrintStatsInputs(Abc_Cex_t *p, int nRealPis)
Definition utilCex.c:275
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmc_CexVerify()

int Bmc_CexVerify ( Gia_Man_t * p,
Abc_Cex_t * pCex,
Abc_Cex_t * pCexCare )
extern

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

Synopsis [Verifies the care set of the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 346 of file bmcCexTools.c.

347{
348 Gia_Obj_t * pObj;
349 int i, k;
350// assert( pCex->nRegs > 0 );
351// assert( pCexCare->nRegs == 0 );
352 Gia_ObjTerSimSet0( Gia_ManConst0(p) );
353 Gia_ManForEachRi( p, pObj, k )
354 Gia_ObjTerSimSet0( pObj );
355 for ( i = 0; i <= pCex->iFrame; i++ )
356 {
357 Gia_ManForEachPi( p, pObj, k )
358 {
359 if ( !Abc_InfoHasBit( pCexCare->pData, pCexCare->nRegs + i * pCexCare->nPis + k ) )
360 Gia_ObjTerSimSetX( pObj );
361 else if ( Abc_InfoHasBit( pCex->pData, pCex->nRegs + i * pCex->nPis + k ) )
362 Gia_ObjTerSimSet1( pObj );
363 else
364 Gia_ObjTerSimSet0( pObj );
365 }
366 Gia_ManForEachRo( p, pObj, k )
367 Gia_ObjTerSimRo( p, pObj );
368 Gia_ManForEachAnd( p, pObj, k )
369 Gia_ObjTerSimAnd( pObj );
370 Gia_ManForEachCo( p, pObj, k )
371 Gia_ObjTerSimCo( pObj );
372 }
373 pObj = Gia_ManPo( p, pCex->iPo );
374 return Gia_ObjTerSimGet1(pObj);
375}
Here is the caller graph for this function:

◆ Bmc_CexVerifyAnyPo()

int Bmc_CexVerifyAnyPo ( Gia_Man_t * p,
Abc_Cex_t * pCex,
Abc_Cex_t * pCexCare )
extern

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

Synopsis [Verifies the care set of the counter-example for an arbitrary PO.]

Description []

SideEffects []

SeeAlso []

Definition at line 388 of file bmcCexTools.c.

389{
390 Gia_Obj_t * pObj;
391 int i, k;
392// assert( pCex->nRegs > 0 );
393// assert( pCexCare->nRegs == 0 );
394 Gia_ObjTerSimSet0( Gia_ManConst0(p) );
395 Gia_ManForEachRi( p, pObj, k )
396 Gia_ObjTerSimSet0( pObj );
397 for ( i = 0; i <= pCex->iFrame; i++ )
398 {
399 Gia_ManForEachPi( p, pObj, k )
400 {
401 if ( !Abc_InfoHasBit( pCexCare->pData, pCexCare->nRegs + i * pCexCare->nPis + k ) )
402 Gia_ObjTerSimSetX( pObj );
403 else if ( Abc_InfoHasBit( pCex->pData, pCex->nRegs + i * pCex->nPis + k ) )
404 Gia_ObjTerSimSet1( pObj );
405 else
406 Gia_ObjTerSimSet0( pObj );
407 }
408 Gia_ManForEachRo( p, pObj, k )
409 Gia_ObjTerSimRo( p, pObj );
410 Gia_ManForEachAnd( p, pObj, k )
411 Gia_ObjTerSimAnd( pObj );
412 Gia_ManForEachCo( p, pObj, k )
413 Gia_ObjTerSimCo( pObj );
414 }
415 for (i = 0; i < Gia_ManPoNum(p) - Gia_ManConstrNum(p); i++)
416 {
417 pObj = Gia_ManPo( p, i );
418 if (Gia_ObjTerSimGet1(pObj))
419 return i;
420 }
421 return -1;
422}
Here is the caller graph for this function:

◆ Bmc_GiaTargetStates()

Gia_Man_t * Bmc_GiaTargetStates ( Gia_Man_t * p,
Abc_Cex_t * pCex,
int iFrBeg,
int iFrEnd,
int fCombOnly,
int fUseOne,
int fAllFrames,
int fVerbose )
extern

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

Synopsis [Generate GIA for target bad states.]

Description []

SideEffects []

SeeAlso []

Definition at line 461 of file bmcCexCut.c.

462{
463 Gia_Man_t * pNew, * pTemp;
464 Vec_Bit_t * vInitNew;
465
466 if ( iFrBeg < 0 )
467 { printf( "Starting frame is less than 0.\n" ); return NULL; }
468 if ( iFrEnd < 0 )
469 { printf( "Stopping frame is less than 0.\n" ); return NULL; }
470 if ( iFrBeg > pCex->iFrame )
471 { printf( "Starting frame is more than the last frame of CEX (%d).\n", pCex->iFrame ); return NULL; }
472 if ( iFrEnd > pCex->iFrame )
473 { printf( "Stopping frame is more than the last frame of CEX (%d).\n", pCex->iFrame ); return NULL; }
474 if ( iFrBeg > iFrEnd )
475 { printf( "Starting frame (%d) should be less than stopping frame (%d).\n", iFrBeg, iFrEnd ); return NULL; }
476 assert( iFrBeg >= 0 && iFrBeg <= pCex->iFrame );
477 assert( iFrEnd >= 0 && iFrEnd <= pCex->iFrame );
478 assert( iFrBeg < iFrEnd );
479
480 if ( fUseOne )
481 pNew = Bmc_GiaGenerateGiaOne( p, pCex, &vInitNew, iFrBeg, iFrEnd );
482 else if ( fAllFrames )
483 pNew = Bmc_GiaGenerateGiaAllFrames( p, pCex, &vInitNew, iFrBeg, iFrEnd );
484 else
485 pNew = Bmc_GiaGenerateGiaAllOne( p, pCex, &vInitNew, iFrBeg, iFrEnd );
486
487 if ( !fCombOnly )
488 {
489 // create new GIA
490 pNew = Gia_ManDupWithNewPo( p, pTemp = pNew );
491 Gia_ManStop( pTemp );
492
493 // create new initial state
494 pNew = Gia_ManDupFlip( pTemp = pNew, Vec_BitArray(vInitNew) );
495 Gia_ManStop( pTemp );
496 }
497
498 Vec_BitFree( vInitNew );
499 return pNew;
500}
Gia_Man_t * Bmc_GiaGenerateGiaAllOne(Gia_Man_t *p, Abc_Cex_t *pCex, Vec_Bit_t **pvInits, int iFrBeg, int iFrEnd)
Definition bmcCexCut.c:365
Gia_Man_t * Bmc_GiaGenerateGiaOne(Gia_Man_t *p, Abc_Cex_t *pCex, Vec_Bit_t **pvInits, int iFrBeg, int iFrEnd)
Definition bmcCexCut.c:192
Gia_Man_t * Bmc_GiaGenerateGiaAllFrames(Gia_Man_t *p, Abc_Cex_t *pCex, Vec_Bit_t **pvInits, int iFrBeg, int iFrEnd)
Definition bmcCexCut.c:237
Gia_Man_t * Gia_ManDupFlip(Gia_Man_t *p, int *pInitState)
Definition giaDup.c:628
Gia_Man_t * Gia_ManDupWithNewPo(Gia_Man_t *p1, Gia_Man_t *p2)
Definition giaDup.c:2634
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Definition vecBit.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmc_ManBCorePerform()

void Bmc_ManBCorePerform ( Gia_Man_t * p,
Bmc_BCorePar_t * pPars )
extern

MACRO DEFINITIONS ///.

FUNCTION DECLARATIONS ///

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 196 of file bmcBCore.c.

197{
198 clock_t clk = clock();
199 Intp_Man_t * pManProof;
200 Vec_Int_t * vVarMap, * vCore;
201 sat_solver * pSat;
202 FILE * pFile;
203 void * pSatCnf;
204 int RetValue;
205 // create SAT solver
206 pSat = sat_solver_new();
207 sat_solver_store_alloc( pSat );
208 sat_solver_setnvars( pSat, 1000 );
209 sat_solver_set_runtime_limit( pSat, pPars->nTimeOut ? pPars->nTimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0 );
210 vVarMap = Bmc_ManBCoreCollect( p, pPars->iFrame, pPars->iOutput, pSat );
212 // create pivot variables
213 if ( pPars->pFilePivots )
214 {
215 Vec_Int_t * vPivots = Bmc_ManBCoreCollectPivots(p, pPars->pFilePivots, vVarMap);
216 sat_solver_set_pivot_variables( pSat, Vec_IntArray(vPivots), Vec_IntSize(vPivots) );
217 Vec_IntReleaseArray( vPivots );
218 Vec_IntFree( vPivots );
219 }
220 // solve the problem
221 RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
222 if ( RetValue == l_Undef )
223 {
224 Vec_IntFree( vVarMap );
225 sat_solver_delete( pSat );
226 printf( "Timeout of conflict limit is reached.\n" );
227 return;
228 }
229 if ( RetValue == l_True )
230 {
231 Vec_IntFree( vVarMap );
232 sat_solver_delete( pSat );
233 printf( "The BMC problem is SAT.\n" );
234 return;
235 }
236 if ( pPars->fVerbose )
237 {
238 printf( "SAT solver returned UNSAT after %7d conflicts. ", (int)pSat->stats.conflicts );
239 Abc_PrintTime( 1, "Time", clock() - clk );
240 }
241 assert( RetValue == l_False );
242 pSatCnf = sat_solver_store_release( pSat );
243// Sto_ManDumpClauses( (Sto_Man_t *)pSatCnf, "cnf_store.txt" );
244 // derive the UNSAT core
245 clk = clock();
246 pManProof = Intp_ManAlloc();
247 vCore = (Vec_Int_t *)Intp_ManUnsatCore( pManProof, (Sto_Man_t *)pSatCnf, 1, pPars->fVerbose );
248 Intp_ManFree( pManProof );
249 if ( pPars->fVerbose )
250 {
251 printf( "UNSAT core contains %d (out of %d) learned clauses. ", Vec_IntSize(vCore), sat_solver_nconflicts(pSat) );
252 Abc_PrintTime( 1, "Time", clock() - clk );
253 }
254 // write the problem
255 Vec_IntSort( vCore, 0 );
256 pFile = pPars->pFileProof ? fopen( pPars->pFileProof, "wb" ) : stdout;
257 Intp_ManUnsatCorePrintForBmc( pFile, (Sto_Man_t *)pSatCnf, vCore, vVarMap );
258 if ( pFile != stdout )
259 fclose( pFile );
260 // cleanup
261 Sto_ManFree( (Sto_Man_t *)pSatCnf );
262 Vec_IntFree( vVarMap );
263 Vec_IntFree( vCore );
264 sat_solver_delete( pSat );
265}
Vec_Int_t * Bmc_ManBCoreCollectPivots(Gia_Man_t *p, char *pName, Vec_Int_t *vVarMap)
Definition bmcBCore.c:57
Vec_Int_t * Bmc_ManBCoreCollect(Gia_Man_t *p, int iFrame, int iOut, sat_solver *pSat)
Definition bmcBCore.c:117
#define l_True
Definition bmcBmcS.c:35
#define l_Undef
Definition bmcBmcS.c:34
void * Intp_ManUnsatCore(Intp_Man_t *p, Sto_Man_t *pCnf, int fLearned, int fVerbose)
Definition satInterP.c:963
void Intp_ManFree(Intp_Man_t *p)
Definition satInterP.c:178
void Intp_ManUnsatCorePrintForBmc(FILE *pFile, Sto_Man_t *pCnf, void *vCore0, void *vVarMap0)
Definition satInterP.c:1059
Intp_Man_t * Intp_ManAlloc()
FUNCTION DEFINITIONS ///.
Definition satInterP.c:96
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
int sat_solver_nconflicts(sat_solver *s)
Definition satSolver.c:2381
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
void sat_solver_store_alloc(sat_solver *s)
Definition satSolver.c:2389
void sat_solver_store_mark_roots(sat_solver *s)
Definition satSolver.c:2412
void * sat_solver_store_release(sat_solver *s)
Definition satSolver.c:2422
void Sto_ManFree(Sto_Man_t *p)
Definition satStore.c:143
struct Intp_Man_t_ Intp_Man_t
Definition satStore.h:142
struct Sto_Man_t_ Sto_Man_t
Definition satStore.h:81
char * pFileProof
Definition bmc.h:176
int nTimeOut
Definition bmc.h:174
char * pFilePivots
Definition bmc.h:175
int fVerbose
Definition bmc.h:177
int iOutput
Definition bmc.h:173
stats_t stats
Definition satSolver.h:163
ABC_INT64_T conflicts
Definition satVec.h:156
Here is the call graph for this function:

◆ Bmc_PerformICheck()

void Bmc_PerformICheck ( Gia_Man_t * p,
int nFramesMax,
int nTimeOut,
int fEmpty,
int fVerbose )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 196 of file bmcICheck.c.

197{
198 int fUseOldCnf = 0;
199 Gia_Man_t * pMiter, * pTemp;
200 Cnf_Dat_t * pCnf;
201 sat_solver * pSat;
202 Vec_Int_t * vLits, * vUsed;
203 int i, status, Lit;
204 int nLitsUsed, nLits, * pLits;
205 abctime clkStart = Abc_Clock();
206 assert( nFramesMax > 0 );
207 assert( Gia_ManRegNum(p) > 0 );
208
209 if ( fVerbose )
210 printf( "Solving M-inductiveness for design %s with %d AND nodes and %d flip-flops:\n",
211 Gia_ManName(p), Gia_ManAndNum(p), Gia_ManRegNum(p) );
212
213 // create miter
214 pTemp = Gia_ManDup( p );
215 pMiter = Gia_ManMiter( p, pTemp, 0, 1, 1, 0, 0 );
216 Gia_ManStop( pTemp );
217 assert( Gia_ManPoNum(pMiter) == 2 * Gia_ManPoNum(p) );
218 assert( Gia_ManRegNum(pMiter) == 2 * Gia_ManRegNum(p) );
219 // derive CNF
220 if ( fUseOldCnf )
221 pCnf = Cnf_DeriveGiaRemapped( pMiter );
222 else
223 {
224 pMiter = Jf_ManDeriveCnf( pTemp = pMiter, 0 );
225 Gia_ManStop( pTemp );
226 pCnf = (Cnf_Dat_t *)pMiter->pData; pMiter->pData = NULL;
227 }
228
229 // collect positive literals
230 vLits = Vec_IntAlloc( Gia_ManCoNum(p) );
231 for ( i = 0; i < Gia_ManRegNum(p); i++ )
232 Vec_IntPush( vLits, Abc_Var2Lit(i, fEmpty) );
233
234 // iteratively compute a minimal M-inductive set of next-state functions
235 nLitsUsed = fEmpty ? 0 : Vec_IntSize(vLits);
236 vUsed = Vec_IntAlloc( Vec_IntSize(vLits) );
237 while ( 1 )
238 {
239 int fChanges = 0;
240 // derive SAT solver
241 pSat = Bmc_DeriveSolver( p, pMiter, pCnf, nFramesMax, nTimeOut, fVerbose );
242// sat_solver_bookmark( pSat );
243 status = sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
244 if ( status == l_Undef )
245 {
246 printf( "Timeout reached after %d seconds.\n", nTimeOut );
247 break;
248 }
249 if ( status == l_True )
250 {
251 printf( "The problem is satisfiable (the current set is not M-inductive).\n" );
252 break;
253 }
254 assert( status == l_False );
255 // call analize_final
256 nLits = sat_solver_final( pSat, &pLits );
257 // mark used literals
258 Vec_IntFill( vUsed, Vec_IntSize(vLits), 0 );
259 for ( i = 0; i < nLits; i++ )
260 Vec_IntWriteEntry( vUsed, Abc_Lit2Var(pLits[i]), 1 );
261
262 // check if there are any positive unused
263 Vec_IntForEachEntry( vLits, Lit, i )
264 {
265 assert( i == Abc_Lit2Var(Lit) );
266 if ( Abc_LitIsCompl(Lit) )
267 continue;
268 if ( Vec_IntEntry(vUsed, i) )
269 continue;
270 // positive literal became unused
271 Vec_IntWriteEntry( vLits, i, Abc_LitNot(Lit) );
272 nLitsUsed--;
273 fChanges = 1;
274 }
275 // report the results
276 if ( fVerbose )
277 printf( "M =%4d : AIG =%8d. SAT vars =%8d. SAT conf =%8d. S =%6d. (%6.2f %%) ",
278 nFramesMax, (nFramesMax+1) * Gia_ManAndNum(pMiter),
279 Gia_ManRegNum(p) + Gia_ManCoNum(p) + sat_solver_nvars(pSat),
280 sat_solver_nconflicts(pSat), nLitsUsed, 100.0 * nLitsUsed / Gia_ManRegNum(p) );
281 if ( fVerbose )
282 Abc_PrintTime( 1, "Time", Abc_Clock() - clkStart );
283 // count the number of negative literals
284 sat_solver_delete( pSat );
285 if ( !fChanges || fEmpty )
286 break;
287// break;
288// sat_solver_rollback( pSat );
289 }
290 Cnf_DataFree( pCnf );
291 Gia_ManStop( pMiter );
292 Vec_IntFree( vLits );
293 Vec_IntFree( vUsed );
294}
sat_solver * Bmc_DeriveSolver(Gia_Man_t *p, Gia_Man_t *pMiter, Cnf_Dat_t *pCnf, int nFramesMax, int nTimeOut, int fVerbose)
Definition bmcICheck.c:91
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition giaDup.c:720
Gia_Man_t * Gia_ManMiter(Gia_Man_t *pAig0, Gia_Man_t *pAig1, int nInsDup, int fDualOut, int fSeq, int fImplic, int fVerbose)
Definition giaDup.c:2983
Gia_Man_t * Jf_ManDeriveCnf(Gia_Man_t *p, int fCnfObjIds)
Definition giaJf.c:1749
int sat_solver_nvars(sat_solver *s)
Definition satSolver.c:2369
void * pData
Definition gia.h:198
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:

◆ Bmc_PerformISearch()

Vec_Int_t * Bmc_PerformISearch ( Gia_Man_t * p,
int nFramesMax,
int nTimeOut,
int fReverse,
int fBackTopo,
int fDump,
int fVerbose )
extern

Definition at line 489 of file bmcICheck.c.

490{
491 Vec_Int_t * vLits, * vFlops;
492 int i, f;
493 if ( fVerbose )
494 printf( "Solving M-inductiveness for design %s with %d AND nodes and %d flip-flops with %s %s flop order:\n",
495 Gia_ManName(p), Gia_ManAndNum(p), Gia_ManRegNum(p), fReverse ? "reverse":"direct", fBackTopo ? "backward":"natural" );
496 fflush( stdout );
497
498 // collect positive literals
499 vLits = Vec_IntAlloc( Gia_ManCoNum(p) );
500 for ( i = 0; i < Gia_ManRegNum(p); i++ )
501 Vec_IntPush( vLits, Abc_Var2Lit(i, 0) );
502
503 for ( f = 1; f <= nFramesMax; f++ )
504 if ( Bmc_PerformISearchOne( p, f, nTimeOut, fReverse, fBackTopo, fVerbose, vLits ) )
505 {
506 Vec_IntFree( vLits );
507 return NULL;
508 }
509
510 // dump the numbers of the flops
511 if ( fDump )
512 {
513 int nLitsUsed = 0;
514 for ( i = 0; i < Gia_ManRegNum(p); i++ )
515 if ( !Abc_LitIsCompl(Vec_IntEntry(vLits, i)) )
516 nLitsUsed++;
517 printf( "The set contains %d (out of %d) next-state functions with 0-based numbers:\n", nLitsUsed, Gia_ManRegNum(p) );
518 for ( i = 0; i < Gia_ManRegNum(p); i++ )
519 if ( !Abc_LitIsCompl(Vec_IntEntry(vLits, i)) )
520 printf( "%d ", i );
521 printf( "\n" );
522 }
523 // save flop indexes
524 vFlops = Vec_IntAlloc( Gia_ManRegNum(p) );
525 for ( i = 0; i < Gia_ManRegNum(p); i++ )
526 if ( !Abc_LitIsCompl(Vec_IntEntry(vLits, i)) )
527 Vec_IntPush( vFlops, 1 );
528 else
529 Vec_IntPush( vFlops, 0 );
530 Vec_IntFree( vLits );
531 return vFlops;
532}
int Bmc_PerformISearchOne(Gia_Man_t *p, int nFramesMax, int nTimeOut, int fReverse, int fBackTopo, int fVerbose, Vec_Int_t *vLits)
Definition bmcICheck.c:370
Here is the call graph for this function:

◆ Gia_ManBmcPerform()

int Gia_ManBmcPerform ( Gia_Man_t * pGia,
Bmc_AndPar_t * pPars )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1066 of file bmcBmcAnd.c.

1067{
1068 abctime TimeToStop = pPars->nTimeOut ? pPars->nTimeOut * CLOCKS_PER_SEC + Abc_Clock() : 0;
1069 if ( pPars->nFramesAdd == 0 )
1070 return Gia_ManBmcPerformInt( pGia, pPars );
1071 // iterate over the engine until we read the global timeout
1072 assert( pPars->nTimeOut >= 0 );
1073 while ( 1 )
1074 {
1075 if ( TimeToStop && TimeToStop < Abc_Clock() )
1076 return -1;
1077 if ( Gia_ManBmcPerformInt( pGia, pPars ) == 0 )
1078 return 0;
1079 // set the new runtime limit
1080 if ( pPars->nTimeOut )
1081 {
1082 pPars->nTimeOut = Abc_MinInt( pPars->nTimeOut-1, (int)((TimeToStop - Abc_Clock()) / CLOCKS_PER_SEC) );
1083 if ( pPars->nTimeOut <= 0 )
1084 return -1;
1085 }
1086 else
1087 return -1;
1088 // set the new frames limit
1089 pPars->nFramesAdd *= 2;
1090 }
1091 return -1;
1092}
int Gia_ManBmcPerformInt(Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
Definition bmcBmcAnd.c:957
int nFramesAdd
Definition bmc.h:148
int nTimeOut
Definition bmc.h:150
Here is the call 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 )
extern

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_PRT(a, t)
Definition abc_global.h:255
#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 Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
typedefABC_NAMESPACE_IMPL_START struct Saig_Bmc_t_ Saig_Bmc_t
DECLARATIONS ///.
Definition bmcBmc2.c:35
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
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
Definition cnfCore.c:165
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_ManBmcScalable()

int Saig_ManBmcScalable ( Aig_Man_t * pAig,
Saig_ParBmc_t * pPars )
extern

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

Synopsis [Bounded model checking engine.]

Description []

SideEffects []

SeeAlso []

Definition at line 1461 of file bmcBmc3.c.

1462{
1463 Gia_ManBmc_t * p;
1464 Aig_Obj_t * pObj;
1465 Abc_Cex_t * pCexNew, * pCexNew0;
1466 FILE * pLogFile = NULL;
1467 unsigned * pInfo;
1468 int RetValue = -1, fFirst = 1, nJumpFrame = 0, fUnfinished = 0;
1469 int nOutDigits = Abc_Base10Log( Saig_ManPoNum(pAig) );
1470 int i, f, k, Lit, status;
1471 abctime clk, clk2, clkSatRun, clkOther = 0, clkTotal = Abc_Clock();
1472 abctime nTimeUnsat = 0, nTimeSat = 0, nTimeUndec = 0, clkOne = 0;
1473 abctime nTimeToStopNG, nTimeToStop;
1474 if ( pPars->pLogFileName )
1475 pLogFile = fopen( pPars->pLogFileName, "wb" );
1476 if ( pPars->nTimeOutOne && pPars->nTimeOut == 0 )
1477 pPars->nTimeOut = pPars->nTimeOutOne * Saig_ManPoNum(pAig) / 1000 + 1;
1478 if ( pPars->nTimeOutOne && !pPars->fSolveAll )
1479 pPars->nTimeOutOne = 0;
1480 nTimeToStopNG = pPars->nTimeOut ? pPars->nTimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0;
1481 nTimeToStop = Saig_ManBmcTimeToStop( pPars, nTimeToStopNG );
1482 // create BMC manager
1483 p = Saig_Bmc3ManStart( pAig, pPars->nTimeOutOne, pPars->nConfLimit, pPars->fUseSatoko, pPars->fUseGlucose );
1484 p->pPars = pPars;
1485 if ( p->pSat )
1486 {
1487 p->pSat->nLearntStart = p->pPars->nLearnedStart;
1488 p->pSat->nLearntDelta = p->pPars->nLearnedDelta;
1489 p->pSat->nLearntRatio = p->pPars->nLearnedPerce;
1490 p->pSat->nLearntMax = p->pSat->nLearntStart;
1491 p->pSat->fNoRestarts = p->pPars->fNoRestarts;
1492 p->pSat->RunId = p->pPars->RunId;
1493 p->pSat->pFuncStop = p->pPars->pFuncStop;
1494 }
1495 else if ( p->pSat3 )
1496 {
1497// satoko_set_runid(p->pSat3, p->pPars->RunId);
1498// satoko_set_stop_func(p->pSat3, p->pPars->pFuncStop);
1499 }
1500 else
1501 {
1502 satoko_set_runid(p->pSat2, p->pPars->RunId);
1503 satoko_set_stop_func(p->pSat2, p->pPars->pFuncStop);
1504 }
1505 if ( pPars->fSolveAll && p->vCexes == NULL )
1506 p->vCexes = Vec_PtrStart( Saig_ManPoNum(pAig) );
1507 if ( pPars->fVerbose )
1508 {
1509 Abc_Print( 1, "Running \"bmc3\". PI/PO/Reg = %d/%d/%d. And =%7d. Lev =%6d. ObjNums =%6d.\n",// Sect =%3d.\n",
1510 Saig_ManPiNum(pAig), Saig_ManPoNum(pAig), Saig_ManRegNum(pAig),
1511 Aig_ManNodeNum(pAig), Aig_ManLevelNum(pAig), p->nObjNums );//, Vec_VecSize(p->vSects) );
1512 Abc_Print( 1, "Params: FramesMax = %d. Start = %d. ConfLimit = %d. TimeOut = %d. SolveAll = %d.\n",
1513 pPars->nFramesMax, pPars->nStart, pPars->nConfLimit, pPars->nTimeOut, pPars->fSolveAll );
1514 }
1515 pPars->nFramesMax = pPars->nFramesMax ? pPars->nFramesMax : ABC_INFINITY;
1516 // set runtime limit
1517 if ( nTimeToStop )
1518 {
1519 if ( p->pSat2 )
1520 satoko_set_runtime_limit( p->pSat2, nTimeToStop );
1521 else if ( p->pSat3 )
1522 bmcg_sat_solver_set_runtime_limit( p->pSat3, nTimeToStop );
1523 else
1524 sat_solver_set_runtime_limit( p->pSat, nTimeToStop );
1525 }
1526 // perform frames
1527 Aig_ManRandom( 1 );
1528 pPars->timeLastSolved = Abc_Clock();
1529 for ( f = 0; f < pPars->nFramesMax; f++ )
1530 {
1531 // stop BMC after exploring all reachable states
1532 if ( !pPars->nFramesJump && Aig_ManRegNum(pAig) < 30 && f == (1 << Aig_ManRegNum(pAig)) )
1533 {
1534 Abc_Print( 1, "Stopping BMC because all 2^%d reachable states are visited.\n", Aig_ManRegNum(pAig) );
1535 if ( p->pPars->fUseBridge )
1536 Saig_ManForEachPo( pAig, pObj, i )
1537 if ( !(p->vCexes && Vec_PtrEntry(p->vCexes, i)) && !(p->pTime4Outs && p->pTime4Outs[i] == 0) ) // not SAT and not timed out
1538 Gia_ManToBridgeResult( stdout, 1, NULL, i );
1539 RetValue = pPars->nFailOuts ? 0 : 1;
1540 goto finish;
1541 }
1542 // stop BMC if all targets are solved
1543 if ( pPars->fSolveAll && pPars->nFailOuts + pPars->nDropOuts >= Saig_ManPoNum(pAig) )
1544 {
1545 Abc_Print( 1, "Stopping BMC because all targets are disproved or timed out.\n" );
1546 RetValue = pPars->nFailOuts ? 0 : 1;
1547 goto finish;
1548 }
1549 // consider the next timeframe
1550 if ( (RetValue == -1 || pPars->fSolveAll) && pPars->nStart == 0 && !nJumpFrame )
1551 pPars->iFrame = f-1;
1552 // map nodes of this section
1553 Vec_PtrPush( p->vId2Var, Vec_IntStartFull(p->nObjNums) );
1554 Vec_PtrPush( p->vTerInfo, (pInfo = ABC_CALLOC(unsigned, p->nWordNum)) );
1555/*
1556 // cannot remove mapping of frame values for any timeframes
1557 // because with constant propagation they may be needed arbitrarily far
1558 if ( f > 2*Vec_VecSize(p->vSects) )
1559 {
1560 int iFrameOld = f - 2*Vec_VecSize( p->vSects );
1561 void * pMemory = Vec_IntReleaseArray( Vec_PtrEntry(p->vId2Var, iFrameOld) );
1562 ABC_FREE( pMemory );
1563 }
1564*/
1565 // prepare some nodes
1566 Saig_ManBmcSetLiteral( p, Aig_ManConst1(pAig), f, 1 );
1567 Saig_ManBmcSimInfoSet( pInfo, Aig_ManConst1(pAig), SAIG_TER_ONE );
1568 Saig_ManForEachPi( pAig, pObj, i )
1569 Saig_ManBmcSimInfoSet( pInfo, pObj, SAIG_TER_UND );
1570 if ( f == 0 )
1571 {
1572 Saig_ManForEachLo( p->pAig, pObj, i )
1573 {
1574 Saig_ManBmcSetLiteral( p, pObj, 0, 0 );
1575 Saig_ManBmcSimInfoSet( pInfo, pObj, SAIG_TER_ZER );
1576 }
1577 }
1578 if ( (pPars->nStart && f < pPars->nStart) || (nJumpFrame && f < nJumpFrame) )
1579 continue;
1580 // create CNF upfront
1581 if ( pPars->fSolveAll )
1582 {
1583 Saig_ManForEachPo( pAig, pObj, i )
1584 {
1585 if ( i >= Saig_ManPoNum(pAig) )
1586 break;
1587 // check for timeout
1588 if ( pPars->nTimeOutGap && pPars->timeLastSolved && Abc_Clock() > pPars->timeLastSolved + pPars->nTimeOutGap * CLOCKS_PER_SEC )
1589 {
1590 Abc_Print( 1, "Reached gap timeout (%d seconds).\n", pPars->nTimeOutGap );
1591 goto finish;
1592 }
1593 if ( nTimeToStop && Abc_Clock() > nTimeToStop )
1594 {
1595 if ( !pPars->fSilent )
1596 Abc_Print( 1, "Reached timeout (%d seconds).\n", pPars->nTimeOut );
1597 goto finish;
1598 }
1599 // skip solved outputs
1600 if ( p->vCexes && Vec_PtrEntry(p->vCexes, i) )
1601 continue;
1602 // skip output whose time has run out
1603 if ( p->pTime4Outs && p->pTime4Outs[i] == 0 )
1604 continue;
1605 // add constraints for this output
1606clk2 = Abc_Clock();
1607 Saig_ManBmcCreateCnf( p, pObj, f );
1608clkOther += Abc_Clock() - clk2;
1609 }
1610 }
1611 // solve SAT
1612 clk = Abc_Clock();
1613 Saig_ManForEachPo( pAig, pObj, i )
1614 {
1615 if ( i >= Saig_ManPoNum(pAig) )
1616 break;
1617 // check for timeout
1618 if ( pPars->nTimeOutGap && pPars->timeLastSolved && Abc_Clock() > pPars->timeLastSolved + pPars->nTimeOutGap * CLOCKS_PER_SEC )
1619 {
1620 Abc_Print( 1, "Reached gap timeout (%d seconds).\n", pPars->nTimeOutGap );
1621 goto finish;
1622 }
1623 if ( nTimeToStop && Abc_Clock() > nTimeToStop )
1624 {
1625 if ( !pPars->fSilent )
1626 Abc_Print( 1, "Reached timeout (%d seconds).\n", pPars->nTimeOut );
1627 goto finish;
1628 }
1629 if ( p->pPars->pFuncStop && p->pPars->pFuncStop(p->pPars->RunId) )
1630 {
1631 if ( !pPars->fSilent )
1632 Abc_Print( 1, "Bmc3 got callbacks.\n" );
1633 goto finish;
1634 }
1635 // skip solved outputs
1636 if ( p->vCexes && Vec_PtrEntry(p->vCexes, i) )
1637 continue;
1638 // skip output whose time has run out
1639 if ( p->pTime4Outs && p->pTime4Outs[i] == 0 )
1640 continue;
1641 // add constraints for this output
1642clk2 = Abc_Clock();
1643 Lit = Saig_ManBmcCreateCnf( p, pObj, f );
1644clkOther += Abc_Clock() - clk2;
1645 // solve this output
1646 fUnfinished = 0;
1647 if ( p->pSat ) sat_solver_compress( p->pSat );
1648 if ( p->pTime4Outs )
1649 {
1650 assert( p->pTime4Outs[i] > 0 );
1651 clkOne = Abc_Clock();
1652 if ( p->pSat2 )
1653 satoko_set_runtime_limit( p->pSat2, p->pTime4Outs[i] + Abc_Clock() );
1654 else if ( p->pSat3 )
1655 bmcg_sat_solver_set_runtime_limit( p->pSat3, p->pTime4Outs[i] + Abc_Clock() );
1656 else
1657 sat_solver_set_runtime_limit( p->pSat, p->pTime4Outs[i] + Abc_Clock() );
1658 }
1659clk2 = Abc_Clock();
1660 status = Saig_ManCallSolver( p, Lit );
1661clkSatRun = Abc_Clock() - clk2;
1662 if ( pLogFile )
1663 fprintf( pLogFile, "Frame %5d Output %5d Time(ms) %8d %8d\n", f, i,
1664 Lit < 2 ? 0 : (int)(clkSatRun * 1000 / CLOCKS_PER_SEC),
1665 Lit < 2 ? 0 : Abc_MaxInt(0, Abc_MinInt(pPars->nTimeOutOne, pPars->nTimeOutOne - (int)((p->pTime4Outs[i] - clkSatRun) * 1000 / CLOCKS_PER_SEC))) );
1666 if ( p->pTime4Outs )
1667 {
1668 abctime timeSince = Abc_Clock() - clkOne;
1669 assert( p->pTime4Outs[i] > 0 );
1670 p->pTime4Outs[i] = (p->pTime4Outs[i] > timeSince) ? p->pTime4Outs[i] - timeSince : 0;
1671 if ( p->pTime4Outs[i] == 0 && status != l_True )
1672 pPars->nDropOuts++;
1673 }
1674 if ( status == l_False )
1675 {
1676nTimeUnsat += clkSatRun;
1677 if ( Lit != 0 )
1678 {
1679 // add final unit clause
1680 Lit = lit_neg( Lit );
1681 if ( p->pSat2 )
1682 status = satoko_add_clause( p->pSat2, &Lit, 1 );
1683 else if ( p->pSat3 )
1684 status = bmcg_sat_solver_addclause( p->pSat3, &Lit, 1 );
1685 else
1686 status = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
1687 assert( status );
1688 // add learned units
1689 if ( p->pSat )
1690 {
1691 for ( k = 0; k < veci_size(&p->pSat->unit_lits); k++ )
1692 {
1693 Lit = veci_begin(&p->pSat->unit_lits)[k];
1694 status = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
1695 assert( status );
1696 }
1697 veci_resize(&p->pSat->unit_lits, 0);
1698 // propagate units
1699 sat_solver_compress( p->pSat );
1700 }
1701 }
1702 if ( p->pPars->fUseBridge )
1703 Gia_ManReportProgress( stdout, i, f );
1704 }
1705 else if ( status == l_True )
1706 {
1707nTimeSat += clkSatRun;
1708 RetValue = 0;
1709 fFirst = 0;
1710 if ( !pPars->fSolveAll )
1711 {
1712 if ( pPars->fVerbose )
1713 {
1714 Abc_Print( 1, "%4d %s : ", f, fUnfinished ? "-" : "+" );
1715 Abc_Print( 1, "Var =%8.0f. ", (double)p->nSatVars );
1716 Abc_Print( 1, "Cla =%9.0f. ", (double)(p->pSat ? p->pSat->stats.clauses : p->pSat3 ? bmcg_sat_solver_clausenum(p->pSat3) : satoko_clausenum(p->pSat2)) );
1717 Abc_Print( 1, "Conf =%7.0f. ", (double)(p->pSat ? p->pSat->stats.conflicts : p->pSat3 ? bmcg_sat_solver_conflictnum(p->pSat3) : satoko_conflictnum(p->pSat2)) );
1718// Abc_Print( 1, "Imp =%10.0f. ", (double)p->pSat->stats.propagations );
1719// Abc_Print( 1, "Uni =%7.0f. ",(double)(p->pSat ? sat_solver_count_assigned(p->pSat) : 0) );
1720// ABC_PRT( "Time", Abc_Clock() - clk );
1721 Abc_Print( 1, "Learn =%7.0f. ", (double)(p->pSat ? p->pSat->stats.learnts : p->pSat3 ? bmcg_sat_solver_learntnum(p->pSat3) : satoko_learntnum(p->pSat2)) );
1722 Abc_Print( 1, "%4.0f MB", 4.25*(f+1)*p->nObjNums /(1<<20) );
1723 Abc_Print( 1, "%4.0f MB", 1.0*(p->pSat ? sat_solver_memory(p->pSat) : 0)/(1<<20) );
1724 Abc_Print( 1, "%9.2f sec ", (float)(Abc_Clock() - clkTotal)/(float)(CLOCKS_PER_SEC) );
1725// Abc_Print( 1, "\n" );
1726// ABC_PRMn( "Id2Var", (f+1)*p->nObjNums*4 );
1727// ABC_PRMn( "SAT", 42 * p->pSat->size + 16 * (int)p->pSat->stats.clauses + 4 * (int)p->pSat->stats.clauses_literals );
1728// Abc_Print( 1, "S =%6d. ", p->nBufNum );
1729// Abc_Print( 1, "D =%6d. ", p->nDupNum );
1730 Abc_Print( 1, "\n" );
1731 fflush( stdout );
1732 }
1733 ABC_FREE( pAig->pSeqModel );
1734 pAig->pSeqModel = Saig_ManGenerateCex( p, f, i );
1735 goto finish;
1736 }
1737 pPars->nFailOuts++;
1738 if ( !pPars->fNotVerbose )
1739 Abc_Print( 1, "Output %*d was asserted in frame %2d (solved %*d out of %*d outputs).\n",
1740 nOutDigits, i, f, nOutDigits, pPars->nFailOuts, nOutDigits, Saig_ManPoNum(pAig) );
1741 if ( p->vCexes == NULL )
1742 p->vCexes = Vec_PtrStart( Saig_ManPoNum(pAig) );
1743 pCexNew = (p->pPars->fUseBridge || pPars->fStoreCex) ? Saig_ManGenerateCex( p, f, i ) : (Abc_Cex_t *)(ABC_PTRINT_T)1;
1744 pCexNew0 = NULL;
1745 if ( p->pPars->fUseBridge )
1746 {
1747 Gia_ManToBridgeResult( stdout, 0, pCexNew, pCexNew->iPo );
1748 //Abc_CexFree( pCexNew );
1749 pCexNew0 = pCexNew;
1750 pCexNew = (Abc_Cex_t *)(ABC_PTRINT_T)1;
1751 }
1752 Vec_PtrWriteEntry( p->vCexes, i, Abc_CexDup(pCexNew, Saig_ManRegNum(pAig)) );
1753 if ( pPars->pFuncOnFail && pPars->pFuncOnFail(i, pPars->fStoreCex ? (Abc_Cex_t *)Vec_PtrEntry(p->vCexes, i) : NULL) )
1754 {
1755 Abc_CexFreeP( &pCexNew0 );
1756 Abc_Print( 1, "Quitting due to callback on fail.\n" );
1757 goto finish;
1758 }
1759 // reset the timeout
1760 pPars->timeLastSolved = Abc_Clock();
1761 nTimeToStop = Saig_ManBmcTimeToStop( pPars, nTimeToStopNG );
1762 if ( nTimeToStop )
1763 {
1764 if ( p->pSat2 )
1765 satoko_set_runtime_limit( p->pSat2, nTimeToStop );
1766 else if ( p->pSat3 )
1767 bmcg_sat_solver_set_runtime_limit( p->pSat3, nTimeToStop );
1768 else
1769 sat_solver_set_runtime_limit( p->pSat, nTimeToStop );
1770 }
1771
1772 // check if other outputs failed under the same counter-example
1773 Saig_ManForEachPo( pAig, pObj, k )
1774 {
1775 Abc_Cex_t * pCexDup;
1776 if ( k >= Saig_ManPoNum(pAig) )
1777 break;
1778 // skip solved outputs
1779 if ( p->vCexes && Vec_PtrEntry(p->vCexes, k) )
1780 continue;
1781 // check if this output is solved
1782 Lit = Saig_ManBmcCreateCnf( p, pObj, f );
1783 if ( p->pSat2 )
1784 {
1785 if ( satoko_read_cex_varvalue(p->pSat2, lit_var(Lit)) == Abc_LitIsCompl(Lit) )
1786 continue;
1787 }
1788 else if ( p->pSat3 )
1789 {
1790 if ( bmcg_sat_solver_read_cex_varvalue(p->pSat3, lit_var(Lit)) == Abc_LitIsCompl(Lit) )
1791 continue;
1792 }
1793 else
1794 {
1795 if ( sat_solver_var_value(p->pSat, lit_var(Lit)) == Abc_LitIsCompl(Lit) )
1796 continue;
1797 }
1798 // write entry
1799 pPars->nFailOuts++;
1800 if ( !pPars->fNotVerbose )
1801 Abc_Print( 1, "Output %*d was asserted in frame %2d (solved %*d out of %*d outputs).\n",
1802 nOutDigits, k, f, nOutDigits, pPars->nFailOuts, nOutDigits, Saig_ManPoNum(pAig) );
1803 // report to the bridge
1804 if ( p->pPars->fUseBridge )
1805 {
1806 // set the output number
1807 pCexNew0->iPo = k;
1808 Gia_ManToBridgeResult( stdout, 0, pCexNew0, pCexNew0->iPo );
1809 }
1810 // remember solved output
1811 //Vec_PtrWriteEntry( p->vCexes, k, Abc_CexDup(pCexNew, Saig_ManRegNum(pAig)) );
1812 pCexDup = Abc_CexDup(pCexNew, Saig_ManRegNum(pAig));
1813 pCexDup->iPo = k;
1814 Vec_PtrWriteEntry( p->vCexes, k, pCexDup );
1815 }
1816 Abc_CexFreeP( &pCexNew0 );
1817 Abc_CexFree( pCexNew );
1818 }
1819 else
1820 {
1821nTimeUndec += clkSatRun;
1822 assert( status == l_Undef );
1823 if ( pPars->nFramesJump )
1824 {
1825 pPars->nConfLimit = pPars->nConfLimitJump;
1826 nJumpFrame = f + pPars->nFramesJump;
1827 fUnfinished = 1;
1828 break;
1829 }
1830 if ( p->pTime4Outs == NULL )
1831 goto finish;
1832 }
1833 }
1834 if ( pPars->fVerbose )
1835 {
1836 if ( fFirst == 1 && f > 0 && (p->pSat ? p->pSat->stats.conflicts : p->pSat3 ? bmcg_sat_solver_conflictnum(p->pSat3) : satoko_conflictnum(p->pSat2)) > 1 )
1837 {
1838 fFirst = 0;
1839// Abc_Print( 1, "Outputs of frames up to %d are trivially UNSAT.\n", f );
1840 }
1841 Abc_Print( 1, "%4d %s : ", f, fUnfinished ? "-" : "+" );
1842 Abc_Print( 1, "Var =%8.0f. ", (double)p->nSatVars );
1843// Abc_Print( 1, "Used =%8.0f. ", (double)sat_solver_count_usedvars(p->pSat) );
1844 Abc_Print( 1, "Cla =%9.0f. ", (double)(p->pSat ? p->pSat->stats.clauses : p->pSat3 ? bmcg_sat_solver_clausenum(p->pSat3) : satoko_clausenum(p->pSat2)) );
1845 Abc_Print( 1, "Conf =%7.0f. ",(double)(p->pSat ? p->pSat->stats.conflicts : p->pSat3 ? bmcg_sat_solver_conflictnum(p->pSat3) : satoko_conflictnum(p->pSat2)) );
1846// Abc_Print( 1, "Imp =%10.0f. ", (double)p->pSat->stats.propagations );
1847// Abc_Print( 1, "Uni =%7.0f. ", (double)(p->pSat ? sat_solver_count_assigned(p->pSat) : 0) );
1848 Abc_Print( 1, "Learn =%7.0f. ", (double)(p->pSat ? p->pSat->stats.learnts : p->pSat3 ? bmcg_sat_solver_learntnum(p->pSat3) : satoko_learntnum(p->pSat2)) );
1849 if ( pPars->fSolveAll )
1850 Abc_Print( 1, "CEX =%5d. ", pPars->nFailOuts );
1851 if ( pPars->nTimeOutOne )
1852 Abc_Print( 1, "T/O =%4d. ", pPars->nDropOuts );
1853// ABC_PRT( "Time", Abc_Clock() - clk );
1854// Abc_Print( 1, "%4.0f MB", 4.0*Vec_IntSize(p->vVisited) /(1<<20) );
1855 Abc_Print( 1, "%4.0f MB", 4.0*(f+1)*p->nObjNums /(1<<20) );
1856 Abc_Print( 1, "%4.0f MB", 1.0*(p->pSat ? sat_solver_memory(p->pSat) : 0)/(1<<20) );
1857// Abc_Print( 1, " %6d %6d ", p->nLitUsed, p->nLitUseless );
1858 Abc_Print( 1, "%9.2f sec ", 1.0*(Abc_Clock() - clkTotal)/CLOCKS_PER_SEC );
1859// Abc_Print( 1, "\n" );
1860// ABC_PRMn( "Id2Var", (f+1)*p->nObjNums*4 );
1861// ABC_PRMn( "SAT", 42 * p->pSat->size + 16 * (int)p->pSat->stats.clauses + 4 * (int)p->pSat->stats.clauses_literals );
1862// Abc_Print( 1, "Simples = %6d. ", p->nBufNum );
1863// Abc_Print( 1, "Dups = %6d. ", p->nDupNum );
1864 Abc_Print( 1, "\n" );
1865 fflush( stdout );
1866 }
1867 }
1868 // consider the next timeframe
1869 if ( nJumpFrame && pPars->nStart == 0 )
1870 pPars->iFrame = nJumpFrame - pPars->nFramesJump;
1871 else if ( RetValue == -1 && pPars->nStart == 0 )
1872 pPars->iFrame = f-1;
1873//ABC_PRT( "CNF generation runtime", clkOther );
1874finish:
1875 if ( pPars->fVerbose )
1876 {
1877 Abc_Print( 1, "Runtime: " );
1878 Abc_Print( 1, "CNF = %.1f sec (%.1f %%) ", 1.0*clkOther/CLOCKS_PER_SEC, 100.0*clkOther/(Abc_Clock() - clkTotal) );
1879 Abc_Print( 1, "UNSAT = %.1f sec (%.1f %%) ", 1.0*nTimeUnsat/CLOCKS_PER_SEC, 100.0*nTimeUnsat/(Abc_Clock() - clkTotal) );
1880 Abc_Print( 1, "SAT = %.1f sec (%.1f %%) ", 1.0*nTimeSat/CLOCKS_PER_SEC, 100.0*nTimeSat/(Abc_Clock() - clkTotal) );
1881 Abc_Print( 1, "UNDEC = %.1f sec (%.1f %%)", 1.0*nTimeUndec/CLOCKS_PER_SEC, 100.0*nTimeUndec/(Abc_Clock() - clkTotal) );
1882 Abc_Print( 1, "\n" );
1883 }
1885 fflush( stdout );
1886 if ( pLogFile )
1887 fclose( pLogFile );
1888 return RetValue;
1889}
int bmcg_sat_solver_conflictnum(bmcg_sat_solver *s)
abctime bmcg_sat_solver_set_runtime_limit(bmcg_sat_solver *s, abctime Limit)
int bmcg_sat_solver_learntnum(bmcg_sat_solver *s)
int bmcg_sat_solver_addclause(bmcg_sat_solver *s, int *plits, int nlits)
int bmcg_sat_solver_read_cex_varvalue(bmcg_sat_solver *s, int ivar)
int bmcg_sat_solver_clausenum(bmcg_sat_solver *s)
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
unsigned Aig_ManRandom(int fReset)
Definition aigUtil.c:1170
Gia_ManBmc_t * Saig_Bmc3ManStart(Aig_Man_t *pAig, int nTimeOutOne, int nConfLimit, int fUseSatoko, int fUseGlucose)
Definition bmcBmc3.c:721
int Saig_ManBmcCreateCnf(Gia_ManBmc_t *p, Aig_Obj_t *pObj, int iFrame)
Definition bmcBmc3.c:1254
Abc_Cex_t * Saig_ManGenerateCex(Gia_ManBmc_t *p, int f, int i)
Definition bmcBmc3.c:1393
#define SAIG_TER_UND
Definition bmcBmc3.c:90
abctime Saig_ManBmcTimeToStop(Saig_ParBmc_t *pPars, abctime nTimeToStopNG)
Definition bmcBmc3.c:1369
int Gia_ManToBridgeResult(FILE *pFile, int Result, Abc_Cex_t *pCex, int iPoProved)
DECLARATIONS ///.
Definition utilBridge.c:287
void Gia_ManReportProgress(FILE *pFile, int prop_no, int depth)
Definition bmcBmc3.c:75
#define SAIG_TER_ZER
Definition bmcBmc3.c:88
typedefABC_NAMESPACE_IMPL_START struct Gia_ManBmc_t_ Gia_ManBmc_t
DECLARATIONS ///.
Definition bmcBmc3.c:36
#define SAIG_TER_ONE
Definition bmcBmc3.c:89
int Saig_ManCallSolver(Gia_ManBmc_t *p, int Lit)
Definition bmcBmc3.c:1433
void Saig_Bmc3ManStop(Gia_ManBmc_t *p)
Definition bmcBmc3.c:799
#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
double sat_solver_memory(sat_solver *s)
Definition satSolver.c:1479
void satoko_set_stop_func(satoko_t *s, int(*fnct)(int))
Definition solver_api.c:650
void satoko_set_runid(satoko_t *, int)
Definition solver_api.c:655
int satoko_add_clause(satoko_t *, int *, int)
Definition solver_api.c:255
int satoko_clausenum(satoko_t *)
Definition solver_api.c:630
int satoko_learntnum(satoko_t *)
Definition solver_api.c:635
int satoko_read_cex_varvalue(satoko_t *, int)
Definition solver_api.c:660
int nTimeOut
Definition bmc.h:113
int nTimeOutOne
Definition bmc.h:115
int fVerbose
Definition bmc.h:129
int nConfLimit
Definition bmc.h:110
int(* pFuncOnFail)(int, Abc_Cex_t *)
Definition bmc.h:137
int fUseSatoko
Definition bmc.h:124
abctime timeLastSolved
Definition bmc.h:136
int fSolveAll
Definition bmc.h:117
int fStoreCex
Definition bmc.h:118
int nTimeOutGap
Definition bmc.h:114
int fNotVerbose
Definition bmc.h:130
int fUseGlucose
Definition bmc.h:125
int nFramesMax
Definition bmc.h:109
char * pLogFileName
Definition bmc.h:131
int nDropOuts
Definition bmc.h:135
int nFailOuts
Definition bmc.h:134
int fSilent
Definition bmc.h:132
int iFrame
Definition bmc.h:133
int nFramesJump
Definition bmc.h:112
int nConfLimitJump
Definition bmc.h:111
int nStart
Definition bmc.h:108
Abc_Cex_t * Abc_CexDup(Abc_Cex_t *p, int nRegsNew)
Definition utilCex.c:145
void Abc_CexFree(Abc_Cex_t *p)
Definition utilCex.c:382
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_ManBmcSimple()

int Saig_ManBmcSimple ( Aig_Man_t * pAig,
int nFrames,
int nSizeMax,
int nConfLimit,
int fRewrite,
int fVerbose,
int * piFrame,
int nCofFanLit,
int fUseSatoko )
extern

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

Synopsis [Performs BMC for the given AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 207 of file bmcBmc.c.

208{
209 extern Aig_Man_t * Gia_ManCofactorAig( Aig_Man_t * p, int nFrames, int nCofFanLit );
210 sat_solver * pSat = NULL;
211 satoko_t * pSat2 = NULL;
212 Cnf_Dat_t * pCnf;
213 Aig_Man_t * pFrames, * pAigTemp;
214 Aig_Obj_t * pObj;
215 int status, Lit, i, RetValue = -1;
216 abctime clk;
217
218 // derive the timeframes
219 clk = Abc_Clock();
220 if ( nCofFanLit )
221 {
222 pFrames = Gia_ManCofactorAig( pAig, nFrames, nCofFanLit );
223 if ( pFrames == NULL )
224 return -1;
225 }
226 else if ( nSizeMax > 0 )
227 {
228 pFrames = Saig_ManFramesBmcLimit( pAig, nFrames, nSizeMax );
229 nFrames = Aig_ManCoNum(pFrames) / Saig_ManPoNum(pAig) + ((Aig_ManCoNum(pFrames) % Saig_ManPoNum(pAig)) > 0);
230 }
231 else
232 pFrames = Saig_ManFramesBmc( pAig, nFrames );
233 if ( piFrame )
234 *piFrame = nFrames;
235 if ( fVerbose )
236 {
237 printf( "Running \"bmc\". AIG: PI/PO/Reg = %d/%d/%d. Node = %6d. Lev = %5d.\n",
238 Saig_ManPiNum(pAig), Saig_ManPoNum(pAig), Saig_ManRegNum(pAig),
239 Aig_ManNodeNum(pAig), Aig_ManLevelNum(pAig) );
240 printf( "Time-frames (%d): PI/PO = %d/%d. Node = %6d. Lev = %5d. ",
241 nFrames, Aig_ManCiNum(pFrames), Aig_ManCoNum(pFrames),
242 Aig_ManNodeNum(pFrames), Aig_ManLevelNum(pFrames) );
243 ABC_PRT( "Time", Abc_Clock() - clk );
244 fflush( stdout );
245 }
246 // rewrite the timeframes
247 if ( fRewrite )
248 {
249 clk = Abc_Clock();
250// pFrames = Dar_ManBalance( pAigTemp = pFrames, 0 );
251 pFrames = Dar_ManRwsat( pAigTemp = pFrames, 1, 0 );
252 Aig_ManStop( pAigTemp );
253 if ( fVerbose )
254 {
255 printf( "Time-frames after rewriting: Node = %6d. Lev = %5d. ",
256 Aig_ManNodeNum(pFrames), Aig_ManLevelNum(pFrames) );
257 ABC_PRT( "Time", Abc_Clock() - clk );
258 fflush( stdout );
259 }
260 }
261 // create the SAT solver
262 clk = Abc_Clock();
263 pCnf = Cnf_Derive( pFrames, Aig_ManCoNum(pFrames) );
264//if ( s_fInterrupt )
265//return -1;
266 if ( fUseSatoko )
267 {
268 satoko_opts_t opts;
269 satoko_default_opts(&opts);
270 opts.conf_limit = nConfLimit;
271 pSat2 = satoko_create();
272 satoko_configure(pSat2, &opts);
273 satoko_setnvars(pSat2, pCnf->nVars);
274 for ( i = 0; i < pCnf->nClauses; i++ )
275 if ( !satoko_add_clause( pSat2, pCnf->pClauses[i], pCnf->pClauses[i+1]-pCnf->pClauses[i] ) )
276 assert( 0 );
277 }
278 else
279 {
280 pSat = sat_solver_new();
281 sat_solver_setnvars( pSat, pCnf->nVars );
282 for ( i = 0; i < pCnf->nClauses; i++ )
283 if ( !sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
284 assert( 0 );
285 }
286 if ( fVerbose )
287 {
288 printf( "CNF: Variables = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
289 ABC_PRT( "Time", Abc_Clock() - clk );
290 fflush( stdout );
291 }
292 status = pSat ? sat_solver_simplify(pSat) : 1;
293 if ( status == 0 )
294 {
295 if ( fVerbose )
296 {
297 printf( "The BMC problem is trivially UNSAT\n" );
298 fflush( stdout );
299 }
300 }
301 else
302 {
303 abctime clkPart = Abc_Clock();
304 Aig_ManForEachCo( pFrames, pObj, i )
305 {
306 Lit = toLitCond( pCnf->pVarNums[pObj->Id], 0 );
307 if ( fVerbose )
308 {
309 printf( "Solving output %2d of frame %3d ... \r",
310 i % Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) );
311 }
312 clk = Abc_Clock();
313 if ( pSat2 )
314 status = satoko_solve_assumptions_limit( pSat2, &Lit, 1, nConfLimit );
315 else
316 status = sat_solver_solve( pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
317 if ( fVerbose && (i % Saig_ManPoNum(pAig) == Saig_ManPoNum(pAig) - 1) )
318 {
319 printf( "Solved %2d outputs of frame %3d. ",
320 Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) );
321 printf( "Conf =%8.0f. Imp =%11.0f. ",
322 (double)(pSat ? pSat->stats.conflicts : satoko_conflictnum(pSat2)),
323 (double)(pSat ? pSat->stats.propagations : satoko_stats(pSat2)->n_propagations) );
324 ABC_PRT( "T", Abc_Clock() - clkPart );
325 clkPart = Abc_Clock();
326 fflush( stdout );
327 }
328 if ( status == l_False )
329 {
330/*
331 Lit = lit_neg( Lit );
332 RetValue = sat_solver_addclause( pSat, &Lit, &Lit + 1 );
333 assert( RetValue );
334 if ( pSat->qtail != pSat->qhead )
335 {
336 RetValue = sat_solver_simplify(pSat);
337 assert( RetValue );
338 }
339*/
340 }
341 else if ( status == l_True )
342 {
343 Vec_Int_t * vCiIds = Cnf_DataCollectPiSatNums( pCnf, pFrames );
344 int * pModel = pSat2 ? Sat2_SolverGetModel(pSat2, vCiIds->pArray, vCiIds->nSize) : Sat_SolverGetModel(pSat, vCiIds->pArray, vCiIds->nSize);
345 pModel[Aig_ManCiNum(pFrames)] = pObj->Id;
346 pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pFrames, pModel );
347 ABC_FREE( pModel );
348 Vec_IntFree( vCiIds );
349
350 if ( piFrame )
351 *piFrame = i / Saig_ManPoNum(pAig);
352 RetValue = 0;
353 break;
354 }
355 else
356 {
357 if ( piFrame )
358 *piFrame = i / Saig_ManPoNum(pAig);
359 RetValue = -1;
360 break;
361 }
362 }
363 }
364 if ( pSat ) sat_solver_delete( pSat );
365 if ( pSat2 ) satoko_destroy( pSat2 );
366 Cnf_DataFree( pCnf );
367 Aig_ManStop( pFrames );
368 return RetValue;
369}
ABC_NAMESPACE_IMPL_START Aig_Man_t * Dar_ManRwsat(Aig_Man_t *pAig, int fBalance, int fVerbose)
DECLARATIONS ///.
Definition darScript.c:71
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
ABC_NAMESPACE_IMPL_START Aig_Man_t * Saig_ManFramesBmc(Aig_Man_t *pAig, int nFrames)
DECLARATIONS ///.
Definition bmcBmc.c:49
Aig_Man_t * Saig_ManFramesBmcLimit(Aig_Man_t *pAig, int nFrames, int nSizeMax)
Definition bmcBmc.c:122
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START int * Sat2_SolverGetModel(satoko_t *p, int *pVars, int nVars)
Definition bmcBmc.c:186
Vec_Int_t * Cnf_DataCollectPiSatNums(Cnf_Dat_t *pCnf, Aig_Man_t *p)
Definition cnfMan.c:104
Abc_Cex_t * Fra_SmlCopyCounterExample(Aig_Man_t *pAig, Aig_Man_t *pFrames, int *pModel)
Definition fraSim.c:1123
Aig_Man_t * Gia_ManCofactorAig(Aig_Man_t *p, int nFrames, int nCofFanLit)
Definition giaAig.c:452
int sat_solver_simplify(sat_solver *s)
Definition satSolver.c:1515
int * Sat_SolverGetModel(sat_solver *p, int *pVars, int nVars)
Definition satUtil.c:270
void satoko_setnvars(satoko_t *, int)
Definition solver_api.c:230
struct satoko_opts satoko_opts_t
Definition satoko.h:37
int satoko_solve_assumptions_limit(satoko_t *s, int *plits, int nlits, int nconflim)
Definition solver_api.c:364
void satoko_default_opts(satoko_opts_t *)
Definition solver_api.c:161
struct solver_t_ satoko_t
Definition satoko.h:35
void satoko_destroy(satoko_t *)
Definition solver_api.c:132
satoko_t * satoko_create(void)
Definition solver_api.c:88
void satoko_configure(satoko_t *, satoko_opts_t *)
Definition solver_api.c:196
int Id
Definition aig.h:85
int nLiterals
Definition cnf.h:60
int * pVarNums
Definition cnf.h:63
int ** pClauses
Definition cnf.h:62
int nClauses
Definition cnf.h:61
long conf_limit
Definition satoko.h:40
ABC_INT64_T propagations
Definition satVec.h:156
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_ManCexMinPerform()

Abc_Cex_t * Saig_ManCexMinPerform ( Aig_Man_t * pAig,
Abc_Cex_t * pCex )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 547 of file bmcCexMin1.c.

548{
549 int fReasonPi = 0;
550
551 Abc_Cex_t * pCexMin = NULL;
552 Aig_Man_t * pManNew = NULL;
553 Vec_Vec_t * vFrameReas;
554 vFrameReas = Saig_ManCexMinComputeReason( pAig, pCex, fReasonPi );
555 printf( "Reason size = %d. Ave = %d.\n", Vec_VecSizeSize(vFrameReas), Vec_VecSizeSize(vFrameReas)/(pCex->iFrame + 1) );
556
557 // try reducing the frames
558 if ( !fReasonPi )
559 {
560 char * pFileName = "aigcube.aig";
561 pManNew = Saig_ManCexMinDupWithCubes( pAig, vFrameReas );
562 Ioa_WriteAiger( pManNew, pFileName, 0, 0 );
563 Aig_ManStop( pManNew );
564 printf( "Intermediate AIG is written into file \"%s\".\n", pFileName );
565 }
566
567 // find reduced counter-example
568 Vec_VecFree( vFrameReas );
569 return pCexMin;
570}
Aig_Man_t * Saig_ManCexMinDupWithCubes(Aig_Man_t *pAig, Vec_Vec_t *vReg2Value)
Definition bmcCexMin1.c:494
Vec_Vec_t * Saig_ManCexMinComputeReason(Aig_Man_t *pAig, Abc_Cex_t *pCex, int fPiReason)
Definition bmcCexMin1.c:464
void Ioa_WriteAiger(Aig_Man_t *pMan, char *pFileName, int fWriteSymbols, int fCompact)
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_ParBmcSetDefaultParams()

void Saig_ParBmcSetDefaultParams ( Saig_ParBmc_t * p)
extern

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

Synopsis [This procedure sets default parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 1334 of file bmcBmc3.c.

1335{
1336 memset( p, 0, sizeof(Saig_ParBmc_t) );
1337 p->nStart = 0; // maximum number of timeframes
1338 p->nFramesMax = 0; // maximum number of timeframes
1339 p->nConfLimit = 0; // maximum number of conflicts at a node
1340 p->nConfLimitJump = 0; // maximum number of conflicts after jumping
1341 p->nFramesJump = 0; // the number of tiemframes to jump
1342 p->nTimeOut = 0; // approximate timeout in seconds
1343 p->nTimeOutGap = 0; // time since the last CEX found
1344 p->nPisAbstract = 0; // the number of PIs to abstract
1345 p->fSolveAll = 0; // stops on the first SAT instance
1346 p->fDropSatOuts = 0; // replace sat outputs by constant 0
1347 p->nLearnedStart = 10000; // starting learned clause limit
1348 p->nLearnedDelta = 2000; // delta of learned clause limit
1349 p->nLearnedPerce = 80; // ratio of learned clause limit
1350 p->fVerbose = 0; // verbose
1351 p->fNotVerbose = 0; // skip line-by-line print-out
1352 p->iFrame = -1; // explored up to this frame
1353 p->nFailOuts = 0; // the number of failed outputs
1354 p->nDropOuts = 0; // the number of timed out outputs
1355 p->timeLastSolved = 0; // time when the last one was solved
1356}
struct Saig_ParBmc_t_ Saig_ParBmc_t
Definition bmc.h:105
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Unr_ManFree()

void Unr_ManFree ( Unr_Man_t * p)
extern

Definition at line 340 of file bmcUnroll.c.

341{
342 Gia_ManStop( p->pFrames );
343 // intermediate data
344 Vec_IntFreeP( &p->vOrder );
345 Vec_IntFreeP( &p->vOrderLim );
346 Vec_IntFreeP( &p->vTents );
347 Vec_IntFreeP( &p->vRanks );
348 // unrolling data
349 Vec_IntFreeP( &p->vObjLim );
350 Vec_IntFreeP( &p->vCiMap );
351 Vec_IntFreeP( &p->vCoMap );
352 Vec_IntFreeP( &p->vPiLits );
353 ABC_FREE( p->pObjs );
354 ABC_FREE( p );
355}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Unr_ManUnrollFrame()

Gia_Man_t * Unr_ManUnrollFrame ( Unr_Man_t * p,
int f )
extern

Definition at line 379 of file bmcUnroll.c.

380{
381 int i, iLit, iLit0, iLit1, hStart;
382 for ( i = 0; i < Gia_ManPiNum(p->pGia); i++ )
383 Vec_IntPush( p->vPiLits, Gia_ManAppendCi(p->pFrames) );
384 hStart = Vec_IntEntry( p->vObjLim, Abc_MaxInt(0, Vec_IntSize(p->vObjLim)-1-f) );
385 while ( p->pObjs + hStart < p->pEnd )
386 {
387 Unr_Obj_t * pUnrObj = Unr_ManObj( p, hStart );
388 if ( pUnrObj->uRDiff0 != UNR_DIFF_NULL && pUnrObj->uRDiff1 != UNR_DIFF_NULL ) // AND node
389 {
390 iLit0 = Unr_ManFanin0Value( p, pUnrObj );
391 iLit1 = Unr_ManFanin1Value( p, pUnrObj );
392 iLit = Gia_ManHashAnd( p->pFrames, iLit0, iLit1 );
393 Unr_ManObjSetValue( pUnrObj, iLit );
394 }
395 else if ( pUnrObj->uRDiff0 != UNR_DIFF_NULL && pUnrObj->uRDiff1 == UNR_DIFF_NULL ) // PO/RI/RO
396 {
397 iLit = Unr_ManFanin0Value( p, pUnrObj );
398 Unr_ManObjSetValue( pUnrObj, iLit );
399 if ( pUnrObj->fItIsPo )
400 Gia_ManAppendCo( p->pFrames, iLit );
401 }
402 else // PI (pUnrObj->hFan0 is CioId; pUnrObj->hFan1 is tent)
403 {
404 assert( pUnrObj->fItIsPi && f >= (int)pUnrObj->hFan1 );
405 iLit = Vec_IntEntry( p->vPiLits, Gia_ManPiNum(p->pGia) * (f - pUnrObj->hFan1) + pUnrObj->hFan0 );
406 Unr_ManObjSetValue( pUnrObj, iLit );
407 }
408 hStart += Unr_ObjSize( pUnrObj );
409 }
410 assert( p->pObjs + hStart == p->pEnd );
411 assert( Gia_ManPoNum(p->pFrames) == (f + 1) * Gia_ManPoNum(p->pGia) );
412 return p->pFrames;
413}
#define UNR_DIFF_NULL
DECLARATIONS ///.
Definition bmcUnroll.c:29
struct Unr_Obj_t_ Unr_Obj_t
Definition bmcUnroll.c:31
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
unsigned hFan1
Definition bmcUnroll.c:35
unsigned fItIsPi
Definition bmcUnroll.c:40
unsigned fItIsPo
Definition bmcUnroll.c:41
unsigned uRDiff1
Definition bmcUnroll.c:39
unsigned hFan0
Definition bmcUnroll.c:34
unsigned uRDiff0
Definition bmcUnroll.c:38
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Unr_ManUnrollStart()

Unr_Man_t * Unr_ManUnrollStart ( Gia_Man_t * pGia,
int fVerbose )
extern

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

Synopsis [Perform smart unrolling.]

Description []

SideEffects []

SeeAlso []

Definition at line 368 of file bmcUnroll.c.

369{
370 int i, iHandle;
371 Unr_Man_t * p;
372 p = Unr_ManAlloc( pGia );
373 Unr_ManSetup( p, fVerbose );
374 for ( i = 0; i < Gia_ManRegNum(p->pGia); i++ )
375 if ( (iHandle = Vec_IntEntry(p->vCoMap, Gia_ManPoNum(p->pGia) + i)) != -1 )
376 Unr_ManObjSetValue( Unr_ManObj(p, iHandle), 0 );
377 return p;
378}
Unr_Man_t * Unr_ManAlloc(Gia_Man_t *pGia)
Definition bmcUnroll.c:321
void Unr_ManSetup(Unr_Man_t *p, int fVerbose)
Definition bmcUnroll.c:186
struct Unr_Man_t_ Unr_Man_t
Definition bmc.h:103
Here is the call graph for this function:
Here is the caller graph for this function: