ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bbrNtbdd.c
Go to the documentation of this file.
1
20
21#include "bbr.h"
22//#include "bar.h"
23
25
26
27typedef char ProgressBar;
28
32
33static inline void Aig_ObjSetGlobalBdd( Aig_Obj_t * pObj, DdNode * bFunc ) { pObj->pData = bFunc; }
34static inline void Aig_ObjCleanGlobalBdd( DdManager * dd, Aig_Obj_t * pObj ) { Cudd_RecursiveDeref( dd, (DdNode *)pObj->pData ); pObj->pData = NULL; }
35
39
51DdNode * Bbr_NodeGlobalBdds_rec( DdManager * dd, Aig_Obj_t * pNode, int nBddSizeMax, int fDropInternal, ProgressBar * pProgress, int * pCounter, int fVerbose )
52{
53 DdNode * bFunc, * bFunc0, * bFunc1;
54 assert( !Aig_IsComplement(pNode) );
55 if ( Cudd_ReadKeys(dd)-Cudd_ReadDead(dd) > (unsigned)nBddSizeMax )
56 {
57// Extra_ProgressBarStop( pProgress );
58 if ( fVerbose )
59 printf( "The number of live nodes reached %d.\n", nBddSizeMax );
60 fflush( stdout );
61 return NULL;
62 }
63 // if the result is available return
64 if ( Aig_ObjGlobalBdd(pNode) == NULL )
65 {
66 // compute the result for both branches
67 bFunc0 = Bbr_NodeGlobalBdds_rec( dd, Aig_ObjFanin0(pNode), nBddSizeMax, fDropInternal, pProgress, pCounter, fVerbose );
68 if ( bFunc0 == NULL )
69 return NULL;
70 Cudd_Ref( bFunc0 );
71 bFunc1 = Bbr_NodeGlobalBdds_rec( dd, Aig_ObjFanin1(pNode), nBddSizeMax, fDropInternal, pProgress, pCounter, fVerbose );
72 if ( bFunc1 == NULL )
73 return NULL;
74 Cudd_Ref( bFunc1 );
75 bFunc0 = Cudd_NotCond( bFunc0, Aig_ObjFaninC0(pNode) );
76 bFunc1 = Cudd_NotCond( bFunc1, Aig_ObjFaninC1(pNode) );
77 // get the final result
78 bFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( bFunc );
79 Cudd_RecursiveDeref( dd, bFunc0 );
80 Cudd_RecursiveDeref( dd, bFunc1 );
81 // add the number of used nodes
82 (*pCounter)++;
83 // set the result
84 assert( Aig_ObjGlobalBdd(pNode) == NULL );
85 Aig_ObjSetGlobalBdd( pNode, bFunc );
86 // increment the progress bar
87// if ( pProgress )
88// Extra_ProgressBarUpdate( pProgress, *pCounter, NULL );
89 }
90 // prepare the return value
91 bFunc = Aig_ObjGlobalBdd(pNode);
92 // dereference BDD at the node
93 if ( --pNode->nRefs == 0 && fDropInternal )
94 {
95 Cudd_Deref( bFunc );
96 Aig_ObjSetGlobalBdd( pNode, NULL );
97 }
98 return bFunc;
99}
100
112void Aig_ManFreeGlobalBdds( Aig_Man_t * p, DdManager * dd )
113{
114 Aig_Obj_t * pObj;
115 int i;
116 Aig_ManForEachObj( p, pObj, i )
117 if ( Aig_ObjGlobalBdd(pObj) )
118 Aig_ObjCleanGlobalBdd( dd, pObj );
119}
120
133{
134 Vec_Ptr_t * vFuncsGlob;
135 Aig_Obj_t * pObj;
136 int RetValue, i;
137 // complement the global functions
138 vFuncsGlob = Vec_PtrAlloc( Aig_ManCoNum(p) );
139 Aig_ManForEachCo( p, pObj, i )
140 Vec_PtrPush( vFuncsGlob, Aig_ObjGlobalBdd(pObj) );
141 RetValue = Cudd_SharingSize( (DdNode **)Vec_PtrArray(vFuncsGlob), Vec_PtrSize(vFuncsGlob) );
142 Vec_PtrFree( vFuncsGlob );
143 return RetValue;
144}
145
157DdManager * Aig_ManComputeGlobalBdds( Aig_Man_t * p, int nBddSizeMax, int fDropInternal, int fReorder, int fVerbose )
158{
159 ProgressBar * pProgress = NULL;
160 Aig_Obj_t * pObj;
161 DdManager * dd;
162 DdNode * bFunc;
163 int i, Counter;
164 // start the manager
165 dd = Cudd_Init( Aig_ManCiNum(p), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
166 // set reordering
167 if ( fReorder )
168 Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
169 // prepare to construct global BDDs
171 // assign the constant node BDD
172 Aig_ObjSetGlobalBdd( Aig_ManConst1(p), dd->one ); Cudd_Ref( dd->one );
173 // set the elementary variables
174 Aig_ManForEachCi( p, pObj, i )
175 {
176 Aig_ObjSetGlobalBdd( pObj, dd->vars[i] ); Cudd_Ref( dd->vars[i] );
177 }
178
179 // collect the global functions of the COs
180 Counter = 0;
181 // construct the BDDs
182// pProgress = Extra_ProgressBarStart( stdout, Aig_ManNodeNum(p) );
183 Aig_ManForEachCo( p, pObj, i )
184 {
185 bFunc = Bbr_NodeGlobalBdds_rec( dd, Aig_ObjFanin0(pObj), nBddSizeMax, fDropInternal, pProgress, &Counter, fVerbose );
186 if ( bFunc == NULL )
187 {
188 if ( fVerbose )
189 printf( "Constructing global BDDs is aborted.\n" );
191 Cudd_Quit( dd );
192 // reset references
194 return NULL;
195 }
196 bFunc = Cudd_NotCond( bFunc, Aig_ObjFaninC0(pObj) ); Cudd_Ref( bFunc );
197 Aig_ObjSetGlobalBdd( pObj, bFunc );
198 }
199// Extra_ProgressBarStop( pProgress );
200 // reset references
202 // reorder one more time
203 if ( fReorder )
204 {
205 Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 );
206 Cudd_AutodynDisable( dd );
207 }
208// Cudd_PrintInfo( dd, stdout );
209 return dd;
210}
211
215
216
218
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
void Aig_ManResetRefs(Aig_Man_t *p)
Definition aigUtil.c:122
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
void Aig_ManCleanData(Aig_Man_t *p)
Definition aigUtil.c:205
DdNode * Bbr_NodeGlobalBdds_rec(DdManager *dd, Aig_Obj_t *pNode, int nBddSizeMax, int fDropInternal, ProgressBar *pProgress, int *pCounter, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition bbrNtbdd.c:51
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition bbrNtbdd.c:27
DdManager * Aig_ManComputeGlobalBdds(Aig_Man_t *p, int nBddSizeMax, int fDropInternal, int fReorder, int fVerbose)
Definition bbrNtbdd.c:157
int Aig_ManSizeOfGlobalBdds(Aig_Man_t *p)
Definition bbrNtbdd.c:132
void Aig_ManFreeGlobalBdds(Aig_Man_t *p, DdManager *dd)
Definition bbrNtbdd.c:112
Cube * p
Definition exorList.c:222
unsigned int nRefs
Definition aig.h:81
void * pData
Definition aig.h:87
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42