ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ivyCutTrav.c File Reference
#include "ivy.h"
Include dependency graph for ivyCutTrav.c:

Go to the source code of this file.

Functions

Ivy_Store_tIvy_NodeFindCutsTravAll (Ivy_Man_t *p, Ivy_Obj_t *pObj, int nLeaves, int nNodeLimit, Vec_Ptr_t *vNodes, Vec_Ptr_t *vFront, Vec_Int_t *vStore, Vec_Vec_t *vBitCuts)
 FUNCTION DEFINITIONS ///.
 
int Ivy_CompareNodesByLevel (Ivy_Obj_t **ppObj1, Ivy_Obj_t **ppObj2)
 
void Ivy_NodeComputeVolumeTrav1_rec (Ivy_Obj_t *pObj, int Depth)
 
void Ivy_NodeComputeVolumeTrav2_rec (Ivy_Obj_t *pObj, Vec_Ptr_t *vNodes)
 
void Ivy_NodeComputeVolume2 (Ivy_Obj_t *pObj, int nNodeLimit, Vec_Ptr_t *vNodes, Vec_Ptr_t *vFront)
 
void Ivy_ManTestCutsTravAll (Ivy_Man_t *p)
 

Function Documentation

◆ Ivy_CompareNodesByLevel()

int Ivy_CompareNodesByLevel ( Ivy_Obj_t ** ppObj1,
Ivy_Obj_t ** ppObj2 )

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

Synopsis [Compares the node by level.]

Description []

SideEffects []

SeeAlso []

Definition at line 161 of file ivyCutTrav.c.

162{
163 Ivy_Obj_t * pObj1 = *ppObj1;
164 Ivy_Obj_t * pObj2 = *ppObj2;
165 if ( pObj1->Level < pObj2->Level )
166 return -1;
167 if ( pObj1->Level > pObj2->Level )
168 return 1;
169 return 0;
170}
struct Ivy_Obj_t_ Ivy_Obj_t
Definition ivy.h:47
unsigned Level
Definition ivy.h:84
Here is the caller graph for this function:

◆ Ivy_ManTestCutsTravAll()

void Ivy_ManTestCutsTravAll ( Ivy_Man_t * p)

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

Synopsis [Compute the set of all cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 434 of file ivyCutTrav.c.

435{
436 Ivy_Store_t * pStore;
437 Ivy_Obj_t * pObj;
438 Vec_Ptr_t * vNodes, * vFront;
439 Vec_Int_t * vStore;
440 Vec_Vec_t * vBitCuts;
441 int i, nCutsCut, nCutsTotal, nNodeTotal, nNodeOver;
442 abctime clk = Abc_Clock();
443
444 vNodes = Vec_PtrAlloc( 100 );
445 vFront = Vec_PtrAlloc( 100 );
446 vStore = Vec_IntAlloc( 100 );
447 vBitCuts = Vec_VecAlloc( 100 );
448
449 nNodeTotal = nNodeOver = 0;
450 nCutsTotal = -Ivy_ManNodeNum(p);
451 Ivy_ManForEachObj( p, pObj, i )
452 {
453 if ( !Ivy_ObjIsNode(pObj) )
454 continue;
455 pStore = Ivy_NodeFindCutsTravAll( p, pObj, 4, 60, vNodes, vFront, vStore, vBitCuts );
456 nCutsCut = pStore->nCuts;
457 nCutsTotal += nCutsCut;
458 nNodeOver += (nCutsCut == IVY_CUT_LIMIT);
459 nNodeTotal++;
460 }
461 printf( "Total cuts = %6d. Trivial = %6d. Nodes = %6d. Satur = %6d. ",
462 nCutsTotal, Ivy_ManPiNum(p) + Ivy_ManNodeNum(p), nNodeTotal, nNodeOver );
463 ABC_PRT( "Time", Abc_Clock() - clk );
464
465 Vec_PtrFree( vNodes );
466 Vec_PtrFree( vFront );
467 Vec_IntFree( vStore );
468 Vec_VecFree( vBitCuts );
469
470}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
Ivy_Store_t * Ivy_NodeFindCutsTravAll(Ivy_Man_t *p, Ivy_Obj_t *pObj, int nLeaves, int nNodeLimit, Vec_Ptr_t *vNodes, Vec_Ptr_t *vFront, Vec_Int_t *vStore, Vec_Vec_t *vBitCuts)
FUNCTION DEFINITIONS ///.
Definition ivyCutTrav.c:49
#define Ivy_ManForEachObj(p, pObj, i)
Definition ivy.h:393
struct Ivy_Store_t_ Ivy_Store_t
Definition ivy.h:165
#define IVY_CUT_LIMIT
Definition ivy.h:152
int nCuts
Definition ivy.h:168
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the call graph for this function:

◆ Ivy_NodeComputeVolume2()

void Ivy_NodeComputeVolume2 ( Ivy_Obj_t * pObj,
int nNodeLimit,
Vec_Ptr_t * vNodes,
Vec_Ptr_t * vFront )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 278 of file ivyCutTrav.c.

279{
280 Ivy_Obj_t * pLeaf, * pPivot, * pFanin;
281 int LevelMax, i;
282 assert( Ivy_ObjIsNode(pObj) );
283 // clear arrays
284 Vec_PtrClear( vNodes );
285 Vec_PtrClear( vFront );
286 // add the root
287 pObj->fMarkA = 1;
288 Vec_PtrPush( vNodes, pObj );
289 Vec_PtrPush( vFront, pObj );
290 // expand node with maximum level
291 LevelMax = pObj->Level;
292 do {
293 // get the node to expand
294 pPivot = NULL;
295 Vec_PtrForEachEntryReverse( Ivy_Obj_t *, vFront, pLeaf, i )
296 {
297 if ( (int)pLeaf->Level == LevelMax )
298 {
299 pPivot = pLeaf;
300 break;
301 }
302 }
303 // decrease level if we did not find the node
304 if ( pPivot == NULL )
305 {
306 if ( --LevelMax == 0 )
307 break;
308 continue;
309 }
310 // the node to expand is found
311 // remove it from frontier
312 Vec_PtrRemove( vFront, pPivot );
313 // add fanins
314 pFanin = Ivy_ObjFanin0(pPivot);
315 if ( !pFanin->fMarkA )
316 {
317 pFanin->fMarkA = 1;
318 Vec_PtrPush( vNodes, pFanin );
319 Vec_PtrPush( vFront, pFanin );
320 }
321 pFanin = Ivy_ObjFanin1(pPivot);
322 if ( pFanin && !pFanin->fMarkA )
323 {
324 pFanin->fMarkA = 1;
325 Vec_PtrPush( vNodes, pFanin );
326 Vec_PtrPush( vFront, pFanin );
327 }
328 // quit if we collected enough nodes
329 } while ( Vec_PtrSize(vNodes) < nNodeLimit );
330
331 // sort nodes by level
332 Vec_PtrSort( vNodes, (int (*)(const void *, const void *))Ivy_CompareNodesByLevel );
333 // make sure the nodes are ordered in the increasing number of levels
334 pFanin = (Ivy_Obj_t *)Vec_PtrEntry( vNodes, 0 );
335 pPivot = (Ivy_Obj_t *)Vec_PtrEntryLast( vNodes );
336 assert( pFanin->Level <= pPivot->Level );
337
338 // clean the marks and remember node numbers in the TravId
339 Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pFanin, i )
340 {
341 pFanin->fMarkA = 0;
342 pFanin->TravId = i;
343 }
344}
int Ivy_CompareNodesByLevel(Ivy_Obj_t **ppObj1, Ivy_Obj_t **ppObj2)
Definition ivyCutTrav.c:161
int TravId
Definition ivy.h:76
unsigned fMarkA
Definition ivy.h:78
#define assert(ex)
Definition util_old.h:213
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition vecPtr.h:63
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:

◆ Ivy_NodeComputeVolumeTrav1_rec()

void Ivy_NodeComputeVolumeTrav1_rec ( Ivy_Obj_t * pObj,
int Depth )

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

Synopsis [Mark all nodes up to the given depth.]

Description []

SideEffects []

SeeAlso []

Definition at line 183 of file ivyCutTrav.c.

184{
185 if ( Ivy_ObjIsCi(pObj) || Depth == 0 )
186 return;
187 Ivy_NodeComputeVolumeTrav1_rec( Ivy_ObjFanin0(pObj), Depth - 1 );
188 Ivy_NodeComputeVolumeTrav1_rec( Ivy_ObjFanin1(pObj), Depth - 1 );
189 pObj->fMarkA = 1;
190}
void Ivy_NodeComputeVolumeTrav1_rec(Ivy_Obj_t *pObj, int Depth)
Definition ivyCutTrav.c:183
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ivy_NodeComputeVolumeTrav2_rec()

void Ivy_NodeComputeVolumeTrav2_rec ( Ivy_Obj_t * pObj,
Vec_Ptr_t * vNodes )

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

Synopsis [Collect the marked nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 203 of file ivyCutTrav.c.

204{
205 if ( !pObj->fMarkA )
206 return;
207 Ivy_NodeComputeVolumeTrav2_rec( Ivy_ObjFanin0(pObj), vNodes );
208 Ivy_NodeComputeVolumeTrav2_rec( Ivy_ObjFanin1(pObj), vNodes );
209 Vec_PtrPush( vNodes, pObj );
210}
void Ivy_NodeComputeVolumeTrav2_rec(Ivy_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition ivyCutTrav.c:203
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ivy_NodeFindCutsTravAll()

Ivy_Store_t * Ivy_NodeFindCutsTravAll ( Ivy_Man_t * p,
Ivy_Obj_t * pObj,
int nLeaves,
int nNodeLimit,
Vec_Ptr_t * vNodes,
Vec_Ptr_t * vFront,
Vec_Int_t * vStore,
Vec_Vec_t * vBitCuts )

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes cuts for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file ivyCutTrav.c.

51{
52 static Ivy_Store_t CutStore, * pCutStore = &CutStore;
53 Vec_Ptr_t * vCuts, * vCuts0, * vCuts1;
54 unsigned * pBitCut;
55 Ivy_Obj_t * pLeaf;
56 Ivy_Cut_t * pCut;
57 int i, k, nWords, nNodes;
58
59 assert( nLeaves <= IVY_CUT_INPUT );
60
61 // find the given number of nodes in the TFI
62 Ivy_NodeComputeVolume( pObj, nNodeLimit - 1, vNodes, vFront );
63 nNodes = Vec_PtrSize(vNodes);
64// assert( nNodes <= nNodeLimit );
65
66 // make sure vBitCuts has enough room
67 Vec_VecExpand( vBitCuts, nNodes-1 );
68 Vec_VecClear( vBitCuts );
69
70 // prepare the memory manager
71 Vec_IntClear( vStore );
72 Vec_IntGrow( vStore, 64000 );
73
74 // set elementary cuts for the leaves
75 nWords = Extra_BitWordNum( nNodes );
76 Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pLeaf, i )
77 {
78 assert( Ivy_ObjTravId(pLeaf) < nNodes );
79 // get the new bitcut
80 pBitCut = Ivy_NodeCutElementary( vStore, nWords, Ivy_ObjTravId(pLeaf) );
81 // set it as the cut of this leaf
82 Vec_VecPush( vBitCuts, Ivy_ObjTravId(pLeaf), pBitCut );
83 }
84
85 // compute the cuts for each node
86 Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pLeaf, i )
87 {
88 // skip the leaves
89 vCuts = Vec_VecEntry( vBitCuts, Ivy_ObjTravId(pLeaf) );
90 if ( Vec_PtrSize(vCuts) > 0 )
91 continue;
92 // add elementary cut
93 pBitCut = Ivy_NodeCutElementary( vStore, nWords, Ivy_ObjTravId(pLeaf) );
94 // set it as the cut of this leaf
95 Vec_VecPush( vBitCuts, Ivy_ObjTravId(pLeaf), pBitCut );
96 // get the fanin cuts
97 vCuts0 = Vec_VecEntry( vBitCuts, Ivy_ObjTravId( Ivy_ObjFanin0(pLeaf) ) );
98 vCuts1 = Vec_VecEntry( vBitCuts, Ivy_ObjTravId( Ivy_ObjFanin1(pLeaf) ) );
99 assert( Vec_PtrSize(vCuts0) > 0 );
100 assert( Vec_PtrSize(vCuts1) > 0 );
101 // merge the cuts
102 Ivy_NodeFindCutsMerge( vCuts0, vCuts1, vCuts, nLeaves, nWords, vStore );
103 }
104
105 // start the structure
106 pCutStore->nCuts = 0;
107 pCutStore->nCutsMax = IVY_CUT_LIMIT;
108 // collect the cuts of the root node
109 vCuts = Vec_VecEntry( vBitCuts, Ivy_ObjTravId(pObj) );
110 Vec_PtrForEachEntry( unsigned *, vCuts, pBitCut, i )
111 {
112 pCut = pCutStore->pCuts + pCutStore->nCuts++;
113 pCut->nSize = 0;
114 pCut->nSizeMax = nLeaves;
115 pCut->uHash = 0;
116 for ( k = 0; k < nNodes; k++ )
117 if ( Extra_TruthHasBit(pBitCut, k) )
118 pCut->pArray[ pCut->nSize++ ] = Ivy_ObjId( (Ivy_Obj_t *)Vec_PtrEntry(vNodes, k) );
119 assert( pCut->nSize <= nLeaves );
120 if ( pCutStore->nCuts == pCutStore->nCutsMax )
121 break;
122 }
123
124 // clean the travIds
125 Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pLeaf, i )
126 pLeaf->TravId = 0;
127 return pCutStore;
128}
int nWords
Definition abcNpn.c:127
struct Ivy_Cut_t_ Ivy_Cut_t
Definition ivy.h:155
#define IVY_CUT_INPUT
Definition ivy.h:153
unsigned uHash
Definition ivy.h:162
short nSize
Definition ivy.h:159
short nSizeMax
Definition ivy.h:160
int pArray[IVY_CUT_INPUT]
Definition ivy.h:161
Ivy_Cut_t pCuts[IVY_CUT_LIMIT]
Definition ivy.h:172
int nCutsMax
Definition ivy.h:170
Here is the caller graph for this function: