ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcRefs.c
Go to the documentation of this file.
1
20
21#include "abc.h"
22
24
25
29
30static int Abc_NodeRefDeref( Abc_Obj_t * pNode, int fReference, int fLabel );
31static int Abc_NodeRefDerefStop( Abc_Obj_t * pNode, int fReference );
32
36
49{
50 int nConeSize1, nConeSize2;
51// assert( Abc_NtkIsStrash(pNode->pNtk) );
52// assert( !Abc_ObjIsComplement( pNode ) );
53 assert( Abc_ObjIsNode( pNode ) );
54 if ( Abc_ObjFaninNum(pNode) == 0 )
55 return 0;
56 nConeSize1 = Abc_NodeRefDeref( pNode, 0, 0 ); // dereference
57 nConeSize2 = Abc_NodeRefDeref( pNode, 1, 0 ); // reference
58 assert( nConeSize1 == nConeSize2 );
59 assert( nConeSize1 > 0 );
60 return nConeSize1;
61}
62
75{
76 int nConeSize1, nConeSize2;
77 assert( Abc_NtkIsStrash(pNode->pNtk) );
78 assert( !Abc_ObjIsComplement( pNode ) );
79 assert( Abc_ObjIsNode( pNode ) );
80 if ( Abc_ObjFaninNum(pNode) == 0 )
81 return 0;
82 nConeSize1 = Abc_NodeRefDerefStop( pNode, 0 ); // dereference
83 nConeSize2 = Abc_NodeRefDerefStop( pNode, 1 ); // reference
84 assert( nConeSize1 == nConeSize2 );
85 assert( nConeSize1 > 0 );
86 return nConeSize1;
87}
88
101{
102 int nConeSize1, nConeSize2;
103 assert( Abc_NtkIsStrash(pNode->pNtk) );
104 assert( !Abc_ObjIsComplement( pNode ) );
105 assert( Abc_ObjIsNode( pNode ) );
106 if ( Abc_ObjFaninNum(pNode) == 0 )
107 return 0;
108 nConeSize1 = Abc_NodeRefDeref( pNode, 0, 1 ); // dereference
109 nConeSize2 = Abc_NodeRefDeref( pNode, 1, 0 ); // reference
110 assert( nConeSize1 == nConeSize2 );
111 assert( nConeSize1 > 0 );
112 return nConeSize1;
113}
114
126int Abc_NodeRefDeref( Abc_Obj_t * pNode, int fReference, int fLabel )
127{
128 Abc_Obj_t * pNode0, * pNode1;
129 int Counter;
130 // label visited nodes
131 if ( fLabel )
132 Abc_NodeSetTravIdCurrent( pNode );
133 // skip the CI
134 if ( Abc_ObjIsCi(pNode) )
135 return 0;
136 // process the internal node
137 pNode0 = Abc_ObjFanin0(pNode);
138 pNode1 = Abc_ObjFanin1(pNode);
139 Counter = 1;
140 if ( fReference )
141 {
142 if ( pNode0->vFanouts.nSize++ == 0 )
143 Counter += Abc_NodeRefDeref( pNode0, fReference, fLabel );
144 if ( pNode1->vFanouts.nSize++ == 0 )
145 Counter += Abc_NodeRefDeref( pNode1, fReference, fLabel );
146 }
147 else
148 {
149 assert( pNode0->vFanouts.nSize > 0 );
150 assert( pNode1->vFanouts.nSize > 0 );
151 if ( --pNode0->vFanouts.nSize == 0 )
152 Counter += Abc_NodeRefDeref( pNode0, fReference, fLabel );
153 if ( --pNode1->vFanouts.nSize == 0 )
154 Counter += Abc_NodeRefDeref( pNode1, fReference, fLabel );
155 }
156 return Counter;
157}
158
159
171int Abc_NodeRefDerefStop( Abc_Obj_t * pNode, int fReference )
172{
173 Abc_Obj_t * pNode0, * pNode1;
174 int Counter;
175 // skip the CI
176 if ( Abc_ObjIsCi(pNode) )
177 return 0;
178 // process the internal node
179 pNode0 = Abc_ObjFanin0(pNode);
180 pNode1 = Abc_ObjFanin1(pNode);
181 Counter = 1;
182 if ( fReference )
183 {
184 if ( !Abc_ObjFaninC0(pNode) && pNode0->vFanouts.nSize++ == 0 )
185 Counter += Abc_NodeRefDerefStop( pNode0, fReference );
186 if ( !Abc_ObjFaninC1(pNode) && pNode1->vFanouts.nSize++ == 0 )
187 Counter += Abc_NodeRefDerefStop( pNode1, fReference );
188 }
189 else
190 {
191 assert( pNode0->vFanouts.nSize > 0 );
192 assert( pNode1->vFanouts.nSize > 0 );
193 if ( !Abc_ObjFaninC0(pNode) && --pNode0->vFanouts.nSize == 0 )
194 Counter += Abc_NodeRefDerefStop( pNode0, fReference );
195 if ( !Abc_ObjFaninC1(pNode) && --pNode1->vFanouts.nSize == 0 )
196 Counter += Abc_NodeRefDerefStop( pNode1, fReference );
197 }
198 return Counter;
199}
200
201
202
203
216{
217 Abc_Obj_t * pFanin;
218 int i, Counter = 1;
219 if ( Abc_ObjIsCi(pNode) )
220 return 0;
221 Abc_ObjForEachFanin( pNode, pFanin, i )
222 {
223 assert( pFanin->vFanouts.nSize > 0 );
224 if ( --pFanin->vFanouts.nSize == 0 )
225 Counter += Abc_NodeDeref_rec( pFanin );
226 }
227 return Counter;
228}
229
242{
243 Abc_Obj_t * pFanin;
244 int i, Counter = 1;
245 if ( Abc_ObjIsCi(pNode) )
246 return 0;
247 Abc_ObjForEachFanin( pNode, pFanin, i )
248 {
249 if ( pFanin->vFanouts.nSize++ == 0 )
250 Counter += Abc_NodeRef_rec( pFanin );
251 }
252 return Counter;
253}
254
266void Abc_NodeMffcConeSupp_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vCone, Vec_Ptr_t * vSupp, int fTopmost )
267{
268 Abc_Obj_t * pFanin;
269 int i;
270 // skip visited nodes
271 if ( Abc_NodeIsTravIdCurrent(pNode) )
272 return;
273 Abc_NodeSetTravIdCurrent(pNode);
274 // add to the new support nodes
275 if ( !fTopmost && (Abc_ObjIsCi(pNode) || pNode->vFanouts.nSize > 0) )
276 {
277 if ( vSupp ) Vec_PtrPush( vSupp, pNode );
278 return;
279 }
280 // recur on the children
281 Abc_ObjForEachFanin( pNode, pFanin, i )
282 Abc_NodeMffcConeSupp_rec( pFanin, vCone, vSupp, 0 );
283 // collect the internal node
284 if ( vCone ) Vec_PtrPush( vCone, pNode );
285// printf( "%d ", pNode->Id );
286}
287
299void Abc_NodeMffcConeSupp( Abc_Obj_t * pNode, Vec_Ptr_t * vCone, Vec_Ptr_t * vSupp )
300{
301 assert( Abc_ObjIsNode(pNode) );
302 assert( !Abc_ObjIsComplement(pNode) );
303 if ( vCone ) Vec_PtrClear( vCone );
304 if ( vSupp ) Vec_PtrClear( vSupp );
305 Abc_NtkIncrementTravId( pNode->pNtk );
306 Abc_NodeMffcConeSupp_rec( pNode, vCone, vSupp, 1 );
307// printf( "\n" );
308}
309
322{
323 Vec_Ptr_t * vCone, * vSupp;
324 Abc_Obj_t * pObj;
325 int i;
326 vCone = Vec_PtrAlloc( 100 );
327 vSupp = Vec_PtrAlloc( 100 );
328 Abc_NodeDeref_rec( pNode );
329 Abc_NodeMffcConeSupp( pNode, vCone, vSupp );
330 Abc_NodeRef_rec( pNode );
331 printf( "Node = %6s : Supp = %3d Cone = %3d (",
332 Abc_ObjName(pNode), Vec_PtrSize(vSupp), Vec_PtrSize(vCone) );
333 Vec_PtrForEachEntry( Abc_Obj_t *, vCone, pObj, i )
334 printf( " %s", Abc_ObjName(pObj) );
335 printf( " )\n" );
336 Vec_PtrFree( vCone );
337 Vec_PtrFree( vSupp );
338}
339
351int Abc_NodeMffcInside( Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vInside )
352{
353 Abc_Obj_t * pObj;
354 int i, Count1, Count2;
355 // increment the fanout counters for the leaves
356 Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
357 pObj->vFanouts.nSize++;
358 // dereference the node
359 Count1 = Abc_NodeDeref_rec( pNode );
360 // collect the nodes inside the MFFC
361 Abc_NodeMffcConeSupp( pNode, vInside, NULL );
362 // reference it back
363 Count2 = Abc_NodeRef_rec( pNode );
364 assert( Count1 == Count2 );
365 // remove the extra counters
366 Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
367 pObj->vFanouts.nSize--;
368 return Count1;
369}
370
383{
384 Vec_Ptr_t * vInside;
385 int Count1, Count2;
386 // dereference the node
387 Count1 = Abc_NodeDeref_rec( pNode );
388 // collect the nodes inside the MFFC
389 vInside = Vec_PtrAlloc( 10 );
390 Abc_NodeMffcConeSupp( pNode, vInside, NULL );
391 // reference it back
392 Count2 = Abc_NodeRef_rec( pNode );
393 assert( Count1 == Count2 );
394 return vInside;
395}
396
408void Abc_NodeMffcLabel_rec( Abc_Obj_t * pNode, int fTopmost, Vec_Ptr_t * vNodes )
409{
410 Abc_Obj_t * pFanin;
411 int i;
412 // add to the new support nodes
413 if ( !fTopmost && (Abc_ObjIsCi(pNode) || pNode->vFanouts.nSize > 0) )
414 return;
415 // skip visited nodes
416 if ( Abc_NodeIsTravIdCurrent(pNode) )
417 return;
418 Abc_NodeSetTravIdCurrent(pNode);
419 // recur on the children
420 Abc_ObjForEachFanin( pNode, pFanin, i )
421 Abc_NodeMffcLabel_rec( pFanin, 0, vNodes );
422 // collect the internal node
423// printf( "%d ", pNode->Id );
424 if ( vNodes )
425 Vec_PtrPush( vNodes, pNode );
426}
427
439int Abc_NodeMffcLabel( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes )
440{
441 int Count1, Count2;
442 // dereference the node
443 Count1 = Abc_NodeDeref_rec( pNode );
444 // collect the nodes inside the MFFC
445 Abc_NtkIncrementTravId( pNode->pNtk );
446 Abc_NodeMffcLabel_rec( pNode, 1, vNodes );
447 // reference it back
448 Count2 = Abc_NodeRef_rec( pNode );
449 assert( Count1 == Count2 );
450 return Count1;
451}
452
456
457
459
int Abc_NodeRef_rec(Abc_Obj_t *pNode)
Definition abcRefs.c:241
int Abc_NodeDeref_rec(Abc_Obj_t *pNode)
Definition abcRefs.c:215
void Abc_NodeMffcLabel_rec(Abc_Obj_t *pNode, int fTopmost, Vec_Ptr_t *vNodes)
Definition abcRefs.c:408
void Abc_NodeMffcConeSuppPrint(Abc_Obj_t *pNode)
Definition abcRefs.c:321
int Abc_NodeMffcInside(Abc_Obj_t *pNode, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vInside)
Definition abcRefs.c:351
void Abc_NodeMffcConeSupp(Abc_Obj_t *pNode, Vec_Ptr_t *vCone, Vec_Ptr_t *vSupp)
Definition abcRefs.c:299
int Abc_NodeMffcSizeStop(Abc_Obj_t *pNode)
Definition abcRefs.c:74
int Abc_NodeMffcSize(Abc_Obj_t *pNode)
FUNCTION DEFINITIONS ///.
Definition abcRefs.c:48
Vec_Ptr_t * Abc_NodeMffcInsideCollect(Abc_Obj_t *pNode)
Definition abcRefs.c:382
void Abc_NodeMffcConeSupp_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vCone, Vec_Ptr_t *vSupp, int fTopmost)
Definition abcRefs.c:266
int Abc_NodeMffcLabelAig(Abc_Obj_t *pNode)
Definition abcRefs.c:100
int Abc_NodeMffcLabel(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcRefs.c:439
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Abc_Ntk_t * pNtk
Definition abc.h:130
Vec_Int_t vFanouts
Definition abc.h:144
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55