abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
llb2Bad.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [llb2Bad.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [BDD based reachability.]
8 
9  Synopsis [Computing bad states.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: llb2Bad.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "llbInt.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Computes bad in working manager.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
45 DdNode * Llb_BddComputeBad( Aig_Man_t * pInit, DdManager * dd, abctime TimeOut )
46 {
47  Vec_Ptr_t * vNodes;
48  DdNode * bBdd0, * bBdd1, * bTemp, * bResult;
49  Aig_Obj_t * pObj;
50  int i, k;
51  assert( Cudd_ReadSize(dd) == Aig_ManCiNum(pInit) );
52  // initialize elementary variables
53  Aig_ManConst1(pInit)->pData = Cudd_ReadOne( dd );
54  Saig_ManForEachLo( pInit, pObj, i )
55  pObj->pData = Cudd_bddIthVar( dd, i );
56  Saig_ManForEachPi( pInit, pObj, i )
57  pObj->pData = Cudd_bddIthVar( dd, Aig_ManRegNum(pInit) + i );
58  // compute internal nodes
59  vNodes = Aig_ManDfsNodes( pInit, (Aig_Obj_t **)Vec_PtrArray(pInit->vCos), Saig_ManPoNum(pInit) );
60  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
61  {
62  if ( !Aig_ObjIsNode(pObj) )
63  continue;
64  bBdd0 = Cudd_NotCond( (DdNode *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
65  bBdd1 = Cudd_NotCond( (DdNode *)Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj) );
66 // pObj->pData = Extra_bddAndTime( dd, bBdd0, bBdd1, TimeOut );
67  pObj->pData = Cudd_bddAnd( dd, bBdd0, bBdd1 );
68  if ( pObj->pData == NULL )
69  {
70  Vec_PtrForEachEntryStop( Aig_Obj_t *, vNodes, pObj, k, i )
71  if ( pObj->pData )
72  Cudd_RecursiveDeref( dd, (DdNode *)pObj->pData );
73  Vec_PtrFree( vNodes );
74  return NULL;
75  }
76  Cudd_Ref( (DdNode *)pObj->pData );
77  }
78  // quantify PIs of each PO
79  bResult = Cudd_ReadLogicZero( dd ); Cudd_Ref( bResult );
80  Saig_ManForEachPo( pInit, pObj, i )
81  {
82  bBdd0 = Cudd_NotCond( Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
83  bResult = Cudd_bddOr( dd, bTemp = bResult, bBdd0 ); Cudd_Ref( bResult );
84  Cudd_RecursiveDeref( dd, bTemp );
85  }
86  // deref
87  Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
88  {
89  if ( !Aig_ObjIsNode(pObj) )
90  continue;
91  Cudd_RecursiveDeref( dd, (DdNode *)pObj->pData );
92  }
93  Vec_PtrFree( vNodes );
94  Cudd_Deref( bResult );
95  return bResult;
96 }
97 
98 /**Function*************************************************************
99 
100  Synopsis []
101 
102  Description []
103 
104  SideEffects []
105 
106  SeeAlso []
107 
108 ***********************************************************************/
110 {
111  DdNode * bVar, * bCube, * bTemp;
112  Aig_Obj_t * pObj;
113  int i;
114  abctime TimeStop;
115  assert( Cudd_ReadSize(dd) == Aig_ManCiNum(pInit) );
116  TimeStop = dd->TimeStop; dd->TimeStop = 0;
117  // create PI cube
118  bCube = Cudd_ReadOne( dd ); Cudd_Ref( bCube );
119  Saig_ManForEachPi( pInit, pObj, i ) {
120  bVar = Cudd_bddIthVar( dd, Aig_ManRegNum(pInit) + i );
121  bCube = Cudd_bddAnd( dd, bTemp = bCube, bVar ); Cudd_Ref( bCube );
122  Cudd_RecursiveDeref( dd, bTemp );
123  }
124  // quantify PI cube
125  bFunc = Cudd_bddExistAbstract( dd, bFunc, bCube ); Cudd_Ref( bFunc );
126  Cudd_RecursiveDeref( dd, bCube );
127  Cudd_Deref( bFunc );
128  dd->TimeStop = TimeStop;
129  return bFunc;
130 }
131 
132 ////////////////////////////////////////////////////////////////////////
133 /// END OF FILE ///
134 ////////////////////////////////////////////////////////////////////////
135 
136 
138 
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
abctime TimeStop
Definition: cuddInt.h:489
Definition: cudd.h:278
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
void * pData
Definition: aig.h:87
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
DdNode * Cudd_bddExistAbstract(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:130
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
ABC_NAMESPACE_IMPL_START DdNode * Llb_BddComputeBad(Aig_Man_t *pInit, DdManager *dd, abctime TimeOut)
DECLARATIONS ///.
Definition: llb2Bad.c:45
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
int Cudd_ReadSize(DdManager *dd)
Definition: cuddAPI.c:1441
DdNode * Llb_BddQuantifyPis(Aig_Man_t *pInit, DdManager *dd, DdNode *bFunc)
Definition: llb2Bad.c:109
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
Vec_Ptr_t * Aig_ManDfsNodes(Aig_Man_t *p, Aig_Obj_t **ppNodes, int nNodes)
Definition: aigDfs.c:333
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Definition: aig.h:69
#define Saig_ManForEachLo(p, pObj, i)
Definition: saig.h:96
DdNode * Cudd_bddOr(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:381
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
Definition: vecPtr.h:59
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define Saig_ManForEachPo(p, pObj, i)
Definition: saig.h:93
#define assert(ex)
Definition: util_old.h:213
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
static void ** Vec_PtrArray(Vec_Ptr_t *p)
Definition: vecPtr.h:279
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
#define Saig_ManForEachPi(p, pObj, i)
Definition: saig.h:91