abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
aigWin.c File Reference
#include "aig.h"

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Aig_NodeGetLeafCostOne (Aig_Obj_t *pNode, int nFanoutLimit)
 DECLARATIONS ///. More...
 
int Aig_ManFindCut_int (Vec_Ptr_t *vFront, Vec_Ptr_t *vVisited, int nSizeLimit, int nFanoutLimit)
 
void Aig_ManFindCut (Aig_Obj_t *pRoot, Vec_Ptr_t *vFront, Vec_Ptr_t *vVisited, int nSizeLimit, int nFanoutLimit)
 

Function Documentation

void Aig_ManFindCut ( Aig_Obj_t pRoot,
Vec_Ptr_t vFront,
Vec_Ptr_t vVisited,
int  nSizeLimit,
int  nFanoutLimit 
)

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

Synopsis [Computes one sequential cut of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file aigWin.c.

146 {
147  Aig_Obj_t * pNode;
148  int i;
149 
150  assert( !Aig_IsComplement(pRoot) );
151  assert( Aig_ObjIsNode(pRoot) );
152  assert( Aig_ObjChild0(pRoot) );
153  assert( Aig_ObjChild1(pRoot) );
154 
155  // start the cut
156  Vec_PtrClear( vFront );
157  Vec_PtrPush( vFront, Aig_ObjFanin0(pRoot) );
158  Vec_PtrPush( vFront, Aig_ObjFanin1(pRoot) );
159 
160  // start the visited nodes
161  Vec_PtrClear( vVisited );
162  Vec_PtrPush( vVisited, pRoot );
163  Vec_PtrPush( vVisited, Aig_ObjFanin0(pRoot) );
164  Vec_PtrPush( vVisited, Aig_ObjFanin1(pRoot) );
165 
166  // mark these nodes
167  assert( !pRoot->fMarkA );
168  assert( !Aig_ObjFanin0(pRoot)->fMarkA );
169  assert( !Aig_ObjFanin1(pRoot)->fMarkA );
170  pRoot->fMarkA = 1;
171  Aig_ObjFanin0(pRoot)->fMarkA = 1;
172  Aig_ObjFanin1(pRoot)->fMarkA = 1;
173 
174  // compute the cut
175  while ( Aig_ManFindCut_int( vFront, vVisited, nSizeLimit, nFanoutLimit ) );
176  assert( Vec_PtrSize(vFront) <= nSizeLimit );
177 
178  // clean the visit markings
179  Vec_PtrForEachEntry( Aig_Obj_t *, vVisited, pNode, i )
180  pNode->fMarkA = 0;
181 }
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned int fMarkA
Definition: aig.h:79
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int Aig_ManFindCut_int(Vec_Ptr_t *vFront, Vec_Ptr_t *vVisited, int nSizeLimit, int nFanoutLimit)
Definition: aigWin.c:80
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Aig_ManFindCut_int ( Vec_Ptr_t vFront,
Vec_Ptr_t vVisited,
int  nSizeLimit,
int  nFanoutLimit 
)

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

Synopsis [Builds reconvergence-driven cut by changing one leaf at a time.]

Description [This procedure looks at the current leaves and tries to change one leaf at a time in such a way that the cut grows as little as possible. In evaluating the fanins, this procedure looks only at their immediate predecessors (this is why it is called a one-level construction procedure).]

SideEffects []

SeeAlso []

Definition at line 80 of file aigWin.c.

81 {
82  Aig_Obj_t * pNode, * pFaninBest, * pNext;
83  int CostBest, CostCur, i;
84  // find the best fanin
85  CostBest = 100;
86  pFaninBest = NULL;
87 //printf( "Evaluating fanins of the cut:\n" );
88  Vec_PtrForEachEntry( Aig_Obj_t *, vFront, pNode, i )
89  {
90  CostCur = Aig_NodeGetLeafCostOne( pNode, nFanoutLimit );
91 //printf( " Fanin %s has cost %d.\n", Aig_ObjName(pNode), CostCur );
92  if ( CostBest > CostCur ||
93  (CostBest == CostCur && pNode->Level > pFaninBest->Level) )
94  {
95  CostBest = CostCur;
96  pFaninBest = pNode;
97  }
98  if ( CostBest == 0 )
99  break;
100  }
101  if ( pFaninBest == NULL )
102  return 0;
103  assert( CostBest < 3 );
104  if ( Vec_PtrSize(vFront) - 1 + CostBest > nSizeLimit )
105  return 0;
106  assert( Aig_ObjIsNode(pFaninBest) );
107  // remove the node from the array
108  Vec_PtrRemove( vFront, pFaninBest );
109 //printf( "Removing fanin %s.\n", Aig_ObjName(pFaninBest) );
110 
111  // add the left child to the fanins
112  pNext = Aig_ObjFanin0(pFaninBest);
113  if ( !pNext->fMarkA )
114  {
115 //printf( "Adding fanin %s.\n", Aig_ObjName(pNext) );
116  pNext->fMarkA = 1;
117  Vec_PtrPush( vFront, pNext );
118  Vec_PtrPush( vVisited, pNext );
119  }
120  // add the right child to the fanins
121  pNext = Aig_ObjFanin1(pFaninBest);
122  if ( !pNext->fMarkA )
123  {
124 //printf( "Adding fanin %s.\n", Aig_ObjName(pNext) );
125  pNext->fMarkA = 1;
126  Vec_PtrPush( vFront, pNext );
127  Vec_PtrPush( vVisited, pNext );
128  }
129  assert( Vec_PtrSize(vFront) <= nSizeLimit );
130  // keep doing this
131  return 1;
132 }
unsigned Level
Definition: aig.h:82
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned int fMarkA
Definition: aig.h:79
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:714
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static ABC_NAMESPACE_IMPL_START int Aig_NodeGetLeafCostOne(Aig_Obj_t *pNode, int nFanoutLimit)
DECLARATIONS ///.
Definition: aigWin.c:46
static ABC_NAMESPACE_IMPL_START int Aig_NodeGetLeafCostOne ( Aig_Obj_t pNode,
int  nFanoutLimit 
)
inlinestatic

DECLARATIONS ///.

CFile****************************************************************

FileName [aigWin.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Window computation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id:
aigWin.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Evaluate the cost of removing the node from the set of leaves.]

Description [Returns the number of new leaves that will be brought in. Returns large number if the node cannot be removed from the set of leaves.]

SideEffects []

SeeAlso []

Definition at line 46 of file aigWin.c.

47 {
48  int Cost;
49  // make sure the node is in the construction zone
50  assert( pNode->fMarkA );
51  // cannot expand over the PI node
52  if ( Aig_ObjIsCi(pNode) )
53  return 999;
54  // get the cost of the cone
55  Cost = (!Aig_ObjFanin0(pNode)->fMarkA) + (!Aig_ObjFanin1(pNode)->fMarkA);
56  // always accept if the number of leaves does not increase
57  if ( Cost < 2 )
58  return Cost;
59  // skip nodes with many fanouts
60  if ( (int)pNode->nRefs > nFanoutLimit )
61  return 999;
62  // return the number of nodes that will be on the leaves if this node is removed
63  return Cost;
64 }
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
unsigned int fMarkA
Definition: aig.h:79
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
unsigned int nRefs
Definition: aig.h:81