abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mfsWin.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [mfsWin.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [The good old minimization with complete don't-cares.]
8 
9  Synopsis [Procedures to compute windows stretching to the PIs.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: mfsWin.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "mfsInt.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Returns 1 if the node should be a root.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
45 static inline int Abc_MfsComputeRootsCheck( Abc_Obj_t * pNode, int nLevelMax, int nFanoutLimit )
46 {
47  Abc_Obj_t * pFanout;
48  int i;
49  // the node is the root if one of the following is true:
50  // (1) the node has more than fanouts than the limit
51  if ( Abc_ObjFanoutNum(pNode) > nFanoutLimit )
52  return 1;
53  // (2) the node has CO fanouts
54  // (3) the node has fanouts above the cutoff level
55  Abc_ObjForEachFanout( pNode, pFanout, i )
56  if ( Abc_ObjIsCo(pFanout) || (int)pFanout->Level > nLevelMax )
57  return 1;
58  return 0;
59 }
60 
61 /**Function*************************************************************
62 
63  Synopsis [Recursively collects the root candidates.]
64 
65  Description []
66 
67  SideEffects []
68 
69  SeeAlso []
70 
71 ***********************************************************************/
72 void Abc_MfsComputeRoots_rec( Abc_Obj_t * pNode, int nLevelMax, int nFanoutLimit, Vec_Ptr_t * vRoots )
73 {
74  Abc_Obj_t * pFanout;
75  int i;
76  assert( Abc_ObjIsNode(pNode) );
77  if ( Abc_NodeIsTravIdCurrent(pNode) )
78  return;
79  Abc_NodeSetTravIdCurrent( pNode );
80  // check if the node should be the root
81  if ( Abc_MfsComputeRootsCheck( pNode, nLevelMax, nFanoutLimit ) )
82  Vec_PtrPush( vRoots, pNode );
83  else // if not, explore its fanouts
84  Abc_ObjForEachFanout( pNode, pFanout, i )
85  Abc_MfsComputeRoots_rec( pFanout, nLevelMax, nFanoutLimit, vRoots );
86 }
87 
88 /**Function*************************************************************
89 
90  Synopsis [Recursively collects the root candidates.]
91 
92  Description [Returns 1 if the only root is this node.]
93 
94  SideEffects []
95 
96  SeeAlso []
97 
98 ***********************************************************************/
99 Vec_Ptr_t * Abc_MfsComputeRoots( Abc_Obj_t * pNode, int nWinTfoMax, int nFanoutLimit )
100 {
101  Vec_Ptr_t * vRoots;
102  vRoots = Vec_PtrAlloc( 10 );
103  Abc_NtkIncrementTravId( pNode->pNtk );
104  Abc_MfsComputeRoots_rec( pNode, pNode->Level + nWinTfoMax, nFanoutLimit, vRoots );
105  assert( Vec_PtrSize(vRoots) > 0 );
106 // if ( Vec_PtrSize(vRoots) == 1 && Vec_PtrEntry(vRoots, 0) == pNode )
107 // return 0;
108  return vRoots;
109 }
110 
111 ////////////////////////////////////////////////////////////////////////
112 /// END OF FILE ///
113 ////////////////////////////////////////////////////////////////////////
114 
115 
117 
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Vec_Ptr_t * Abc_MfsComputeRoots(Abc_Obj_t *pNode, int nWinTfoMax, int nFanoutLimit)
Definition: mfsWin.c:99
static ABC_NAMESPACE_IMPL_START int Abc_MfsComputeRootsCheck(Abc_Obj_t *pNode, int nLevelMax, int nFanoutLimit)
DECLARATIONS ///.
Definition: mfsWin.c:45
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
unsigned Level
Definition: abc.h:142
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
Abc_Ntk_t * pNtk
Definition: abc.h:130
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
void Abc_MfsComputeRoots_rec(Abc_Obj_t *pNode, int nLevelMax, int nFanoutLimit, Vec_Ptr_t *vRoots)
Definition: mfsWin.c:72
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409