abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bbrCex.c File Reference
#include "bbr.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START DdNodeBbr_bddComputeRangeCube (DdManager *dd, int iStart, int iStop)
 DECLARATIONS ///. More...
 
Abc_Cex_tAig_ManVerifyUsingBddsCountExample (Aig_Man_t *p, DdManager *dd, DdNode **pbParts, Vec_Ptr_t *vOnionRings, DdNode *bCubeFirst, int iOutput, int fVerbose, int fSilent)
 FUNCTION DEFINITIONS ///. More...
 

Function Documentation

Abc_Cex_t* Aig_ManVerifyUsingBddsCountExample ( Aig_Man_t p,
DdManager dd,
DdNode **  pbParts,
Vec_Ptr_t vOnionRings,
DdNode bCubeFirst,
int  iOutput,
int  fVerbose,
int  fSilent 
)

FUNCTION DEFINITIONS ///.

DECLARATIONS ///.

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

Synopsis [Derives the counter-example using the set of reached states.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file bbrCex.c.

50 {
51  Abc_Cex_t * pCex;
52  Aig_Obj_t * pObj;
53  Bbr_ImageTree_t * pTree;
54  DdNode * bCubeNs, * bState, * bImage;
55  DdNode * bTemp, * bVar, * bRing;
56  int i, v, RetValue, nPiOffset;
57  char * pValues;
58  abctime clk = Abc_Clock();
59 //printf( "\nDeriving counter-example.\n" );
60 
61  // allocate room for the counter-example
62  pCex = Abc_CexAlloc( Saig_ManRegNum(p), Saig_ManPiNum(p), Vec_PtrSize(vOnionRings)+1 );
63  pCex->iFrame = Vec_PtrSize(vOnionRings);
64  pCex->iPo = iOutput;
65  nPiOffset = Saig_ManRegNum(p) + Saig_ManPiNum(p) * Vec_PtrSize(vOnionRings);
66 
67  // create the cube of NS variables
69  pTree = Bbr_bddImageStart( dd, bCubeNs, Saig_ManRegNum(p), pbParts, Saig_ManCiNum(p), dd->vars, 100000000, fVerbose );
70  Cudd_RecursiveDeref( dd, bCubeNs );
71  if ( pTree == NULL )
72  {
73  if ( !fSilent )
74  printf( "BDDs blew up during qualitification scheduling. " );
75  return NULL;
76  }
77 
78  // allocate room for the cube
79  pValues = ABC_ALLOC( char, dd->size );
80 
81  // get the last cube
82  RetValue = Cudd_bddPickOneCube( dd, bCubeFirst, pValues );
83  assert( RetValue );
84 
85  // write PIs of counter-example
86  Saig_ManForEachPi( p, pObj, i )
87  if ( pValues[i] == 1 )
88  Abc_InfoSetBit( pCex->pData, nPiOffset + i );
89  nPiOffset -= Saig_ManPiNum(p);
90 
91  // write state in terms of NS variables
92  bState = (dd)->one; Cudd_Ref( bState );
93  Saig_ManForEachLo( p, pObj, i )
94  {
95  bVar = Cudd_NotCond( dd->vars[Saig_ManCiNum(p)+i], pValues[Saig_ManPiNum(p)+i] != 1 );
96  bState = Cudd_bddAnd( dd, bTemp = bState, bVar ); Cudd_Ref( bState );
97  Cudd_RecursiveDeref( dd, bTemp );
98  }
99 
100  // perform backward analysis
101  Vec_PtrForEachEntryReverse( DdNode *, vOnionRings, bRing, v )
102  {
103  // compute the next states
104  bImage = Bbr_bddImageCompute( pTree, bState );
105  if ( bImage == NULL )
106  {
107  Cudd_RecursiveDeref( dd, bState );
108  if ( !fSilent )
109  printf( "BDDs blew up during image computation. " );
110  Bbr_bddImageTreeDelete( pTree );
111  ABC_FREE( pValues );
112  return NULL;
113  }
114  Cudd_Ref( bImage );
115  Cudd_RecursiveDeref( dd, bState );
116 
117  // intersect with the previous set
118  bImage = Cudd_bddAnd( dd, bTemp = bImage, bRing ); Cudd_Ref( bImage );
119  Cudd_RecursiveDeref( dd, bTemp );
120 
121  // find any assignment of the BDD
122  RetValue = Cudd_bddPickOneCube( dd, bImage, pValues );
123  assert( RetValue );
124  Cudd_RecursiveDeref( dd, bImage );
125 
126  // write PIs of counter-example
127  Saig_ManForEachPi( p, pObj, i )
128  if ( pValues[i] == 1 )
129  Abc_InfoSetBit( pCex->pData, nPiOffset + i );
130  nPiOffset -= Saig_ManPiNum(p);
131 
132  // check that we get the init state
133  if ( v == 0 )
134  {
135  Saig_ManForEachLo( p, pObj, i )
136  assert( pValues[Saig_ManPiNum(p)+i] == 0 );
137  break;
138  }
139 
140  // write state in terms of NS variables
141  bState = (dd)->one; Cudd_Ref( bState );
142  Saig_ManForEachLo( p, pObj, i )
143  {
144  bVar = Cudd_NotCond( dd->vars[Saig_ManCiNum(p)+i], pValues[Saig_ManPiNum(p)+i] != 1 );
145  bState = Cudd_bddAnd( dd, bTemp = bState, bVar ); Cudd_Ref( bState );
146  Cudd_RecursiveDeref( dd, bTemp );
147  }
148  }
149  // cleanup
150  Bbr_bddImageTreeDelete( pTree );
151  ABC_FREE( pValues );
152  // verify the counter example
153  if ( Vec_PtrSize(vOnionRings) < 1000 )
154  {
155  RetValue = Saig_ManVerifyCex( p, pCex );
156  if ( RetValue == 0 && !fSilent )
157  printf( "Aig_ManVerifyUsingBdds(): Counter-example verification has FAILED.\n" );
158  }
159  if ( fVerbose && !fSilent )
160  {
161  ABC_PRT( "Counter-example generation time", Abc_Clock() - clk );
162  }
163  return pCex;
164 }
ABC_NAMESPACE_IMPL_START DdNode * Bbr_bddComputeRangeCube(DdManager *dd, int iStart, int iStop)
DECLARATIONS ///.
Definition: bbrReach.c:74
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Cudd_bddPickOneCube(DdManager *ddm, DdNode *node, char *string)
Definition: cuddUtil.c:1221
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition: vecPtr.h:63
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
Definition: utilCex.c:51
int size
Definition: cuddInt.h:361
int Saig_ManVerifyCex(Aig_Man_t *pAig, Abc_Cex_t *p)
Definition: saigDup.c:279
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Bbr_ImageTree_t * Bbr_bddImageStart(DdManager *dd, DdNode *bCare, int nParts, DdNode **pbParts, int nVars, DdNode **pbVars, int nBddMax, int fVerbose)
Definition: bbrImage.c:168
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
void Bbr_bddImageTreeDelete(Bbr_ImageTree_t *pTree)
Definition: bbrImage.c:307
static DdNode * one
Definition: cuddDecomp.c:112
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
#define Saig_ManForEachLo(p, pObj, i)
Definition: saig.h:96
static int Saig_ManCiNum(Aig_Man_t *p)
Definition: saig.h:75
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
Definition: saig.h:73
DdNode * Bbr_bddImageCompute(Bbr_ImageTree_t *pTree, DdNode *bCare)
Definition: bbrImage.c:253
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode ** vars
Definition: cuddInt.h:390
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition: utilCex.h:39
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Saig_ManForEachPi(p, pObj, i)
Definition: saig.h:91
ABC_NAMESPACE_IMPL_START DdNode* Bbr_bddComputeRangeCube ( DdManager dd,
int  iStart,
int  iStop 
)

DECLARATIONS ///.

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

FileName [bbrCex.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [BDD-based reachability analysis.]

Synopsis [Procedures to derive a satisfiable counter-example.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Performs the reordering-sensitive step of Extra_bddMove().]

Description []

SideEffects []

SeeAlso []

Definition at line 74 of file bbrReach.c.

75 {
76  DdNode * bTemp, * bProd;
77  int i;
78  assert( iStart <= iStop );
79  assert( iStart >= 0 && iStart <= dd->size );
80  assert( iStop >= 0 && iStop <= dd->size );
81  bProd = (dd)->one; Cudd_Ref( bProd );
82  for ( i = iStart; i < iStop; i++ )
83  {
84  bProd = Cudd_bddAnd( dd, bTemp = bProd, dd->vars[i] ); Cudd_Ref( bProd );
85  Cudd_RecursiveDeref( dd, bTemp );
86  }
87  Cudd_Deref( bProd );
88  return bProd;
89 }
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
static DdNode * one
Definition: cuddDecomp.c:112
static int size
Definition: cuddSign.c:86
DdNode ** vars
Definition: cuddInt.h:390
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define assert(ex)
Definition: util_old.h:213
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129