ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
resDivs.c File Reference
#include "base/abc/abc.h"
#include "resInt.h"
Include dependency graph for resDivs.c:

Go to the source code of this file.

Functions

void Res_WinDivisors (Res_Win_t *p, int nLevDivMax)
 FUNCTION DEFINITIONS ///.
 
void Res_WinMarkTfi_rec (Res_Win_t *p, Abc_Obj_t *pObj)
 
void Res_WinSweepLeafTfo_rec (Abc_Obj_t *pObj, int nLevelLimit)
 
int Res_NodeDeref_rec (Abc_Obj_t *pNode)
 
int Res_NodeRef_rec (Abc_Obj_t *pNode)
 
int Res_WinVisitMffc (Abc_Obj_t *pNode)
 

Function Documentation

◆ Res_NodeDeref_rec()

int Res_NodeDeref_rec ( Abc_Obj_t * pNode)

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

Synopsis [Dereferences the node's MFFC.]

Description []

SideEffects []

SeeAlso []

Definition at line 220 of file resDivs.c.

221{
222 Abc_Obj_t * pFanin;
223 int i, Counter = 1;
224 if ( Abc_ObjIsCi(pNode) )
225 return 0;
226 Abc_NodeSetTravIdCurrent( pNode );
227 Abc_ObjForEachFanin( pNode, pFanin, i )
228 {
229 assert( pFanin->vFanouts.nSize > 0 );
230 if ( --pFanin->vFanouts.nSize == 0 )
231 Counter += Res_NodeDeref_rec( pFanin );
232 }
233 return Counter;
234}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
int Res_NodeDeref_rec(Abc_Obj_t *pNode)
Definition resDivs.c:220
Vec_Int_t vFanouts
Definition abc.h:144
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Res_NodeRef_rec()

int Res_NodeRef_rec ( Abc_Obj_t * pNode)

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

Synopsis [References the node's MFFC.]

Description []

SideEffects []

SeeAlso []

Definition at line 247 of file resDivs.c.

248{
249 Abc_Obj_t * pFanin;
250 int i, Counter = 1;
251 if ( Abc_ObjIsCi(pNode) )
252 return 0;
253 Abc_ObjForEachFanin( pNode, pFanin, i )
254 {
255 if ( pFanin->vFanouts.nSize++ == 0 )
256 Counter += Res_NodeRef_rec( pFanin );
257 }
258 return Counter;
259}
int Res_NodeRef_rec(Abc_Obj_t *pNode)
Definition resDivs.c:247
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Res_WinDivisors()

void Res_WinDivisors ( Res_Win_t * p,
int nLevDivMax )

FUNCTION DEFINITIONS ///.

MACRO DEFINITIONS ///.

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

Synopsis [Adds candidate divisors of the node to its window.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file resDivs.c.

49{
50 Abc_Obj_t * pObj, * pFanout, * pFanin;
51 int k, f, m;
52
53 // set the maximum level of the divisors
54 p->nLevDivMax = nLevDivMax;
55
56 // mark the TFI with the current trav ID
57 Abc_NtkIncrementTravId( p->pNode->pNtk );
58 Res_WinMarkTfi( p );
59
60 // mark with the current trav ID those nodes that should not be divisors:
61 // (1) the node and its TFO
62 // (2) the MFFC of the node
63 // (3) the node's fanins (these are treated as a special case)
64 Abc_NtkIncrementTravId( p->pNode->pNtk );
65 Res_WinSweepLeafTfo_rec( p->pNode, p->nLevDivMax );
66 Res_WinVisitMffc( p->pNode );
67 Abc_ObjForEachFanin( p->pNode, pObj, k )
68 Abc_NodeSetTravIdCurrent( pObj );
69
70 // at this point the nodes are marked with two trav IDs:
71 // nodes to be collected as divisors are marked with previous trav ID
72 // nodes to be avoided as divisors are marked with current trav ID
73
74 // start collecting the divisors
75 Vec_PtrClear( p->vDivs );
76 Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, k )
77 {
78 assert( (int)pObj->Level >= p->nLevLeafMin );
79 if ( !Abc_NodeIsTravIdPrevious(pObj) )
80 continue;
81 if ( (int)pObj->Level > p->nLevDivMax )
82 continue;
83 Vec_PtrPush( p->vDivs, pObj );
84 }
85 // add the internal nodes to the data structure
86 Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pObj, k )
87 {
88 if ( !Abc_NodeIsTravIdPrevious(pObj) )
89 continue;
90 if ( (int)pObj->Level > p->nLevDivMax )
91 continue;
92 Vec_PtrPush( p->vDivs, pObj );
93 }
94
95 // explore the fanouts of already collected divisors
96 p->nDivsPlus = 0;
97 Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pObj, k )
98 {
99 // consider fanouts of this node
100 Abc_ObjForEachFanout( pObj, pFanout, f )
101 {
102 // stop if there are too many fanouts
103 if ( f > 20 )
104 break;
105 // skip nodes that are already added
106 if ( Abc_NodeIsTravIdPrevious(pFanout) )
107 continue;
108 // skip nodes in the TFO or in the MFFC of node
109 if ( Abc_NodeIsTravIdCurrent(pFanout) )
110 continue;
111 // skip COs
112 if ( !Abc_ObjIsNode(pFanout) )
113 continue;
114 // skip nodes with large level
115 if ( (int)pFanout->Level > p->nLevDivMax )
116 continue;
117 // skip nodes whose fanins are not divisors
118 Abc_ObjForEachFanin( pFanout, pFanin, m )
119 if ( !Abc_NodeIsTravIdPrevious(pFanin) )
120 break;
121 if ( m < Abc_ObjFaninNum(pFanout) )
122 continue;
123 // add the node to the divisors
124 Vec_PtrPush( p->vDivs, pFanout );
125 Vec_PtrPush( p->vNodes, pFanout );
126 Abc_NodeSetTravIdPrevious( pFanout );
127 p->nDivsPlus++;
128 }
129 }
130/*
131 printf( "Node level = %d. ", Abc_ObjLevel(p->pNode) );
132 Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs, pObj, k, Vec_PtrSize(p->vDivs)-p->nDivsPlus )
133 printf( "%d ", Abc_ObjLevel(pObj) );
134 printf( "\n" );
135*/
136//printf( "%d ", p->nDivsPlus );
137}
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
Cube * p
Definition exorList.c:222
void Res_WinSweepLeafTfo_rec(Abc_Obj_t *pObj, int nLevelLimit)
Definition resDivs.c:196
int Res_WinVisitMffc(Abc_Obj_t *pNode)
Definition resDivs.c:272
unsigned Level
Definition abc.h:142
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Res_WinMarkTfi_rec()

void Res_WinMarkTfi_rec ( Res_Win_t * p,
Abc_Obj_t * pObj )

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

Synopsis [Marks the TFI cone of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file resDivs.c.

151{
152 Abc_Obj_t * pFanin;
153 int i;
154 if ( Abc_NodeIsTravIdCurrent(pObj) )
155 return;
156 Abc_NodeSetTravIdCurrent( pObj );
157 assert( Abc_ObjIsNode(pObj) );
158 // visit the fanins of the node
159 Abc_ObjForEachFanin( pObj, pFanin, i )
160 Res_WinMarkTfi_rec( p, pFanin );
161}
void Res_WinMarkTfi_rec(Res_Win_t *p, Abc_Obj_t *pObj)
Definition resDivs.c:150
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Res_WinSweepLeafTfo_rec()

void Res_WinSweepLeafTfo_rec ( Abc_Obj_t * pObj,
int nLevelLimit )

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

Synopsis [Marks the TFO of the collected nodes up to the given level.]

Description []

SideEffects []

SeeAlso []

Definition at line 196 of file resDivs.c.

197{
198 Abc_Obj_t * pFanout;
199 int i;
200 if ( Abc_ObjIsCo(pObj) || (int)pObj->Level > nLevelLimit )
201 return;
202 if ( Abc_NodeIsTravIdCurrent(pObj) )
203 return;
204 Abc_NodeSetTravIdCurrent( pObj );
205 Abc_ObjForEachFanout( pObj, pFanout, i )
206 Res_WinSweepLeafTfo_rec( pFanout, nLevelLimit );
207}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Res_WinVisitMffc()

int Res_WinVisitMffc ( Abc_Obj_t * pNode)

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

Synopsis [Labels MFFC of the node with the current trav ID.]

Description []

SideEffects []

SeeAlso []

Definition at line 272 of file resDivs.c.

273{
274 int Count1, Count2;
275 assert( Abc_ObjIsNode(pNode) );
276 // dereference the node (mark with the current trav ID)
277 Count1 = Res_NodeDeref_rec( pNode );
278 // reference it back
279 Count2 = Res_NodeRef_rec( pNode );
280 assert( Count1 == Count2 );
281 return Count1;
282}
Here is the call graph for this function:
Here is the caller graph for this function: