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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Nwk_ManVerifyTopoOrder (Nwk_Man_t *pNtk)
 DECLARATIONS ///. More...
 
int Nwk_ManLevelBackup (Nwk_Man_t *pNtk)
 
void Nwk_ManLevel_rec (Nwk_Obj_t *pObj)
 
int Nwk_ManLevel (Nwk_Man_t *pNtk)
 
int Nwk_ManLevelMax (Nwk_Man_t *pNtk)
 
Vec_Vec_tNwk_ManLevelize (Nwk_Man_t *pNtk)
 
void Nwk_ManDfs_rec (Nwk_Obj_t *pObj, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tNwk_ManDfs (Nwk_Man_t *pNtk)
 
void Nwk_ManDfsNodes_rec (Nwk_Obj_t *pObj, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tNwk_ManDfsNodes (Nwk_Man_t *pNtk, Nwk_Obj_t **ppNodes, int nNodes)
 
void Nwk_ManDfsReverse_rec (Nwk_Obj_t *pObj, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tNwk_ManDfsReverse (Nwk_Man_t *pNtk)
 
void Nwk_ManSupportNodes_rec (Nwk_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tNwk_ManSupportNodes (Nwk_Man_t *pNtk, Nwk_Obj_t **ppNodes, int nNodes)
 
void Nwk_ManSupportSum (Nwk_Man_t *pNtk)
 
int Nwk_ObjDeref_rec (Nwk_Obj_t *pNode)
 
int Nwk_ObjRef_rec (Nwk_Obj_t *pNode)
 
void Nwk_ObjMffcLabel_rec (Nwk_Obj_t *pNode, int fTopmost)
 
int Nwk_ObjMffcLabel (Nwk_Obj_t *pNode)
 

Function Documentation

Vec_Ptr_t* Nwk_ManDfs ( Nwk_Man_t pNtk)

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

Synopsis [Returns the DFS ordered array of all objects except latches.]

Description []

SideEffects []

SeeAlso []

Definition at line 321 of file nwkDfs.c.

322 {
323  Vec_Ptr_t * vNodes;
324  Nwk_Obj_t * pObj;
325  int i;
326  Nwk_ManIncrementTravId( pNtk );
327  vNodes = Vec_PtrAlloc( 100 );
328  Nwk_ManForEachObj( pNtk, pObj, i )
329  {
330  if ( Nwk_ObjIsCi(pObj) )
331  {
332  Nwk_ObjSetTravIdCurrent( pObj );
333  Vec_PtrPush( vNodes, pObj );
334  }
335  else if ( Nwk_ObjIsCo(pObj) )
336  Nwk_ManDfs_rec( pObj, vNodes );
337  }
338  return vNodes;
339 }
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
void Nwk_ManDfs_rec(Nwk_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: nwkDfs.c:298
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkUtil.c:47
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Nwk_ManForEachObj(p, pObj, i)
Definition: nwk.h:189
void Nwk_ManDfs_rec ( Nwk_Obj_t pObj,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 298 of file nwkDfs.c.

299 {
300  Nwk_Obj_t * pNext;
301  int i;
302  if ( Nwk_ObjIsTravIdCurrent( pObj ) )
303  return;
304  Nwk_ObjSetTravIdCurrent( pObj );
305  Nwk_ObjForEachFanin( pObj, pNext, i )
306  Nwk_ManDfs_rec( pNext, vNodes );
307  Vec_PtrPush( vNodes, pObj );
308 }
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
void Nwk_ManDfs_rec(Nwk_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: nwkDfs.c:298
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
Vec_Ptr_t* Nwk_ManDfsNodes ( Nwk_Man_t pNtk,
Nwk_Obj_t **  ppNodes,
int  nNodes 
)

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

Synopsis [Returns the set of internal nodes rooted in the given nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 378 of file nwkDfs.c.

379 {
380  Vec_Ptr_t * vNodes;
381  int i;
382  // set the traversal ID
383  Nwk_ManIncrementTravId( pNtk );
384  // start the array of nodes
385  vNodes = Vec_PtrAlloc( 100 );
386  // go through the PO nodes and call for each of them
387  for ( i = 0; i < nNodes; i++ )
388  if ( Nwk_ObjIsCo(ppNodes[i]) )
389  Nwk_ManDfsNodes_rec( Nwk_ObjFanin0(ppNodes[i]), vNodes );
390  else
391  Nwk_ManDfsNodes_rec( ppNodes[i], vNodes );
392  return vNodes;
393 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Nwk_ManDfsNodes_rec(Nwk_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: nwkDfs.c:352
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkUtil.c:47
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static Nwk_Obj_t * Nwk_ObjFanin0(Nwk_Obj_t *p)
Definition: nwk.h:140
void Nwk_ManDfsNodes_rec ( Nwk_Obj_t pObj,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 352 of file nwkDfs.c.

353 {
354  Nwk_Obj_t * pNext;
355  int i;
356  if ( Nwk_ObjIsTravIdCurrent( pObj ) )
357  return;
358  Nwk_ObjSetTravIdCurrent( pObj );
359  if ( Nwk_ObjIsCi(pObj) )
360  return;
361  assert( Nwk_ObjIsNode(pObj) );
362  Nwk_ObjForEachFanin( pObj, pNext, i )
363  Nwk_ManDfsNodes_rec( pNext, vNodes );
364  Vec_PtrPush( vNodes, pObj );
365 }
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Nwk_ManDfsNodes_rec(Nwk_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: nwkDfs.c:352
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
static int Nwk_ObjIsNode(Nwk_Obj_t *p)
Definition: nwk.h:148
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t* Nwk_ManDfsReverse ( Nwk_Man_t pNtk)

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

Synopsis [Returns the DFS ordered array of all objects except latches.]

Description []

SideEffects []

SeeAlso []

Definition at line 451 of file nwkDfs.c.

452 {
453  Vec_Ptr_t * vNodes;
454  Nwk_Obj_t * pObj;
455  int i;
456  Nwk_ManIncrementTravId( pNtk );
457  vNodes = Vec_PtrAlloc( 100 );
458  Nwk_ManForEachPi( pNtk, pObj, i )
459  Nwk_ManDfsReverse_rec( pObj, vNodes );
460  // add nodes without fanins
461  Nwk_ManForEachNode( pNtk, pObj, i )
462  if ( Nwk_ObjFaninNum(pObj) == 0 && !Nwk_ObjIsTravIdCurrent(pObj) )
463  Vec_PtrPush( vNodes, pObj );
464  return vNodes;
465 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Nwk_ManForEachPi(p, pObj, i)
Definition: nwk.h:183
static int Nwk_ObjFaninNum(Nwk_Obj_t *p)
Definition: nwk.h:137
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkUtil.c:47
void Nwk_ManDfsReverse_rec(Nwk_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: nwkDfs.c:406
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Nwk_ManForEachNode(p, pObj, i)
Definition: nwk.h:192
void Nwk_ManDfsReverse_rec ( Nwk_Obj_t pObj,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 406 of file nwkDfs.c.

407 {
408  Nwk_Obj_t * pNext;
409  int i, iBox, iTerm1, nTerms;
410  if ( Nwk_ObjIsTravIdCurrent( pObj ) )
411  return;
412  Nwk_ObjSetTravIdCurrent( pObj );
413  if ( Nwk_ObjIsCo(pObj) )
414  {
415  if ( pObj->pMan->pManTime )
416  {
417  iBox = Tim_ManBoxForCo( pObj->pMan->pManTime, pObj->PioId );
418  if ( iBox >= 0 ) // this is not a true PO
419  {
420  iTerm1 = Tim_ManBoxOutputFirst( pObj->pMan->pManTime, iBox );
421  nTerms = Tim_ManBoxOutputNum( pObj->pMan->pManTime, iBox );
422  for ( i = 0; i < nTerms; i++ )
423  {
424  pNext = Nwk_ManCi(pObj->pMan, iTerm1 + i);
425  Nwk_ManDfsReverse_rec( pNext, vNodes );
426  }
427  }
428  }
429  }
430  else if ( Nwk_ObjIsNode(pObj) || Nwk_ObjIsCi(pObj) )
431  {
432  Nwk_ObjForEachFanout( pObj, pNext, i )
433  Nwk_ManDfsReverse_rec( pNext, vNodes );
434  }
435  else
436  assert( 0 );
437  Vec_PtrPush( vNodes, pObj );
438 }
int Tim_ManBoxOutputFirst(Tim_Man_t *p, int iBox)
Definition: timBox.c:154
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
static Nwk_Obj_t * Nwk_ManCi(Nwk_Man_t *p, int i)
Definition: nwk.h:131
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
int Tim_ManBoxForCo(Tim_Man_t *p, int iCi)
Definition: timBox.c:104
#define Nwk_ObjForEachFanout(pObj, pFanout, i)
Definition: nwk.h:201
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
int Tim_ManBoxOutputNum(Tim_Man_t *p, int iBox)
Definition: timBox.c:202
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
else
Definition: sparse_int.h:55
static int Nwk_ObjIsNode(Nwk_Obj_t *p)
Definition: nwk.h:148
void Nwk_ManDfsReverse_rec(Nwk_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: nwkDfs.c:406
#define assert(ex)
Definition: util_old.h:213
int Nwk_ManLevel ( Nwk_Man_t pNtk)

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

Synopsis [Computes the number of logic levels not counting PIs/POs.]

Description [Does not assume that the objects are in a topo order.]

SideEffects []

SeeAlso []

Definition at line 215 of file nwkDfs.c.

216 {
217  Nwk_Obj_t * pObj;
218  int i, LevelMax = 0;
219  Nwk_ManForEachObj( pNtk, pObj, i )
220  Nwk_ObjSetLevel( pObj, 0 );
221  Nwk_ManIncrementTravId( pNtk );
222  Nwk_ManForEachPo( pNtk, pObj, i )
223  {
224  Nwk_ManLevel_rec( pObj );
225  if ( LevelMax < Nwk_ObjLevel(pObj) )
226  LevelMax = Nwk_ObjLevel(pObj);
227  }
228  Nwk_ManForEachCi( pNtk, pObj, i )
229  {
230  Nwk_ManLevel_rec( pObj );
231  if ( LevelMax < Nwk_ObjLevel(pObj) )
232  LevelMax = Nwk_ObjLevel(pObj);
233  }
234  return LevelMax;
235 }
void Nwk_ManLevel_rec(Nwk_Obj_t *pObj)
Definition: nwkDfs.c:160
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
#define Nwk_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: nwk.h:179
#define Nwk_ManForEachPo(p, pObj, i)
Definition: nwk.h:186
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkUtil.c:47
static void Nwk_ObjSetLevel(Nwk_Obj_t *pObj, int Level)
Definition: nwk.h:163
#define Nwk_ManForEachObj(p, pObj, i)
Definition: nwk.h:189
static int Nwk_ObjLevel(Nwk_Obj_t *pObj)
Definition: nwk.h:162
void Nwk_ManLevel_rec ( Nwk_Obj_t pObj)

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

Synopsis [Computes the number of logic levels not counting PIs/POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file nwkDfs.c.

161 {
162  Tim_Man_t * pManTime = pObj->pMan->pManTime;
163  Nwk_Obj_t * pNext;
164  int i, iBox, iTerm1, nTerms, LevelMax = 0;
165  if ( Nwk_ObjIsTravIdCurrent( pObj ) )
166  return;
167  Nwk_ObjSetTravIdCurrent( pObj );
168  if ( Nwk_ObjIsCi(pObj) )
169  {
170  if ( pManTime )
171  {
172  iBox = Tim_ManBoxForCi( pManTime, pObj->PioId );
173  if ( iBox >= 0 ) // this is not a true PI
174  {
175  iTerm1 = Tim_ManBoxInputFirst( pManTime, iBox );
176  nTerms = Tim_ManBoxInputNum( pManTime, iBox );
177  for ( i = 0; i < nTerms; i++ )
178  {
179  pNext = Nwk_ManCo(pObj->pMan, iTerm1 + i);
180  Nwk_ManLevel_rec( pNext );
181  if ( LevelMax < Nwk_ObjLevel(pNext) )
182  LevelMax = Nwk_ObjLevel(pNext);
183  }
184  LevelMax++;
185  }
186  }
187  }
188  else if ( Nwk_ObjIsNode(pObj) || Nwk_ObjIsCo(pObj) )
189  {
190  Nwk_ObjForEachFanin( pObj, pNext, i )
191  {
192  Nwk_ManLevel_rec( pNext );
193  if ( LevelMax < Nwk_ObjLevel(pNext) )
194  LevelMax = Nwk_ObjLevel(pNext);
195  }
196  if ( Nwk_ObjIsNode(pObj) && Nwk_ObjFaninNum(pObj) > 0 )
197  LevelMax++;
198  }
199  else
200  assert( 0 );
201  Nwk_ObjSetLevel( pObj, LevelMax );
202 }
int Tim_ManBoxForCi(Tim_Man_t *p, int iCo)
Definition: timBox.c:86
static Nwk_Obj_t * Nwk_ManCo(Nwk_Man_t *p, int i)
Definition: nwk.h:132
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
void Nwk_ManLevel_rec(Nwk_Obj_t *pObj)
Definition: nwkDfs.c:160
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static int Nwk_ObjFaninNum(Nwk_Obj_t *p)
Definition: nwk.h:137
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
Definition: timBox.c:186
static int Nwk_ObjIsNode(Nwk_Obj_t *p)
Definition: nwk.h:148
static void Nwk_ObjSetLevel(Nwk_Obj_t *pObj, int Level)
Definition: nwk.h:163
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
static int Nwk_ObjLevel(Nwk_Obj_t *pObj)
Definition: nwk.h:162
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
int Tim_ManBoxInputFirst(Tim_Man_t *p, int iBox)
Definition: timBox.c:122
int Nwk_ManLevelBackup ( Nwk_Man_t pNtk)

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

Synopsis [Computes the number of logic levels not counting PIs/POs.]

Description [Assumes that white boxes have unit level.]

SideEffects []

SeeAlso []

Definition at line 102 of file nwkDfs.c.

103 {
104  Tim_Man_t * pManTimeUnit;
105  Nwk_Obj_t * pObj, * pFanin;
106  int i, k, LevelMax, Level;
108  // clean the levels
109  Nwk_ManForEachObj( pNtk, pObj, i )
110  Nwk_ObjSetLevel( pObj, 0 );
111  // perform level computation
112  LevelMax = 0;
113  pManTimeUnit = pNtk->pManTime ? Tim_ManDup( pNtk->pManTime, 1 ) : NULL;
114  if ( pManTimeUnit )
115  Tim_ManIncrementTravId( pManTimeUnit );
116  Nwk_ManForEachObj( pNtk, pObj, i )
117  {
118  if ( Nwk_ObjIsCi(pObj) )
119  {
120  Level = pManTimeUnit? (int)Tim_ManGetCiArrival( pManTimeUnit, pObj->PioId ) : 0;
121  Nwk_ObjSetLevel( pObj, Level );
122  }
123  else if ( Nwk_ObjIsCo(pObj) )
124  {
125  Level = Nwk_ObjLevel( Nwk_ObjFanin0(pObj) );
126  if ( pManTimeUnit )
127  Tim_ManSetCoArrival( pManTimeUnit, pObj->PioId, (float)Level );
128  Nwk_ObjSetLevel( pObj, Level );
129  if ( LevelMax < Nwk_ObjLevel(pObj) )
130  LevelMax = Nwk_ObjLevel(pObj);
131  }
132  else if ( Nwk_ObjIsNode(pObj) )
133  {
134  Level = 0;
135  Nwk_ObjForEachFanin( pObj, pFanin, k )
136  if ( Level < Nwk_ObjLevel(pFanin) )
137  Level = Nwk_ObjLevel(pFanin);
138  Nwk_ObjSetLevel( pObj, Level + 1 );
139  }
140  else
141  assert( 0 );
142  }
143  // set the old timing manager
144  if ( pManTimeUnit )
145  Tim_ManStop( pManTimeUnit );
146  return LevelMax;
147 }
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Definition: timTrav.c:44
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
Definition: timTime.c:116
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
Tim_Man_t * Tim_ManDup(Tim_Man_t *p, int fUnitDelay)
Definition: timMan.c:86
void Tim_ManStop(Tim_Man_t *p)
Definition: timMan.c:375
ABC_NAMESPACE_IMPL_START int Nwk_ManVerifyTopoOrder(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkDfs.c:45
static int Nwk_ObjIsNode(Nwk_Obj_t *p)
Definition: nwk.h:148
static void Nwk_ObjSetLevel(Nwk_Obj_t *pObj, int Level)
Definition: nwk.h:163
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
#define Nwk_ManForEachObj(p, pObj, i)
Definition: nwk.h:189
static Nwk_Obj_t * Nwk_ObjFanin0(Nwk_Obj_t *p)
Definition: nwk.h:140
static int Nwk_ObjLevel(Nwk_Obj_t *pObj)
Definition: nwk.h:162
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
Definition: timTime.c:174
Vec_Vec_t* Nwk_ManLevelize ( Nwk_Man_t pNtk)

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

Synopsis [Returns the array of objects in the AIG manager ordered by level.]

Description []

SideEffects []

SeeAlso []

Definition at line 269 of file nwkDfs.c.

270 {
271  Nwk_Obj_t * pObj;
272  Vec_Vec_t * vLevels;
273  int nLevels, i;
274  assert( Nwk_ManVerifyLevel(pNtk) );
275  nLevels = Nwk_ManLevelMax( pNtk );
276  vLevels = Vec_VecStart( nLevels + 1 );
277  Nwk_ManForEachNode( pNtk, pObj, i )
278  {
279  assert( Nwk_ObjLevel(pObj) <= nLevels );
280  Vec_VecPush( vLevels, Nwk_ObjLevel(pObj), pObj );
281  }
282  return vLevels;
283 }
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
Definition: vecVec.h:456
ABC_DLL int Nwk_ManVerifyLevel(Nwk_Man_t *pNtk)
Definition: nwkTiming.c:832
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
int Nwk_ManLevelMax(Nwk_Man_t *pNtk)
Definition: nwkDfs.c:248
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
static int Nwk_ObjLevel(Nwk_Obj_t *pObj)
Definition: nwk.h:162
#define assert(ex)
Definition: util_old.h:213
#define Nwk_ManForEachNode(p, pObj, i)
Definition: nwk.h:192
int Nwk_ManLevelMax ( Nwk_Man_t pNtk)

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

Synopsis [Computes the number of logic levels not counting PIs/POs.]

Description [Does not assume that the objects are in a topo order.]

SideEffects []

SeeAlso []

Definition at line 248 of file nwkDfs.c.

249 {
250  Nwk_Obj_t * pObj;
251  int i, LevelMax = 0;
252  Nwk_ManForEachPo( pNtk, pObj, i )
253  if ( LevelMax < Nwk_ObjLevel(pObj) )
254  LevelMax = Nwk_ObjLevel(pObj);
255  return LevelMax;
256 }
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
if(last==0)
Definition: sparse_int.h:34
#define Nwk_ManForEachPo(p, pObj, i)
Definition: nwk.h:186
static int Nwk_ObjLevel(Nwk_Obj_t *pObj)
Definition: nwk.h:162
Vec_Ptr_t* Nwk_ManSupportNodes ( Nwk_Man_t pNtk,
Nwk_Obj_t **  ppNodes,
int  nNodes 
)

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

Synopsis [Returns the set of CI nodes in the support of the given nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 510 of file nwkDfs.c.

511 {
512  Vec_Ptr_t * vNodes;
513  int i;
514  // set the traversal ID
515  Nwk_ManIncrementTravId( pNtk );
516  // start the array of nodes
517  vNodes = Vec_PtrAlloc( 100 );
518  // go through the PO nodes and call for each of them
519  for ( i = 0; i < nNodes; i++ )
520  if ( Nwk_ObjIsCo(ppNodes[i]) )
521  Nwk_ManSupportNodes_rec( Nwk_ObjFanin0(ppNodes[i]), vNodes );
522  else
523  Nwk_ManSupportNodes_rec( ppNodes[i], vNodes );
524  return vNodes;
525 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Nwk_ManSupportNodes_rec(Nwk_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: nwkDfs.c:478
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkUtil.c:47
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static Nwk_Obj_t * Nwk_ObjFanin0(Nwk_Obj_t *p)
Definition: nwk.h:140
void Nwk_ManSupportNodes_rec ( Nwk_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 478 of file nwkDfs.c.

479 {
480  Nwk_Obj_t * pFanin;
481  int i;
482  // if this node is already visited, skip
483  if ( Nwk_ObjIsTravIdCurrent( pNode ) )
484  return;
485  // mark the node as visited
486  Nwk_ObjSetTravIdCurrent( pNode );
487  // collect the CI
488  if ( Nwk_ObjIsCi(pNode) )
489  {
490  Vec_PtrPush( vNodes, pNode );
491  return;
492  }
493  assert( Nwk_ObjIsNode( pNode ) );
494  // visit the transitive fanin of the node
495  Nwk_ObjForEachFanin( pNode, pFanin, i )
496  Nwk_ManSupportNodes_rec( pFanin, vNodes );
497 }
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
void Nwk_ManSupportNodes_rec(Nwk_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: nwkDfs.c:478
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
static int Nwk_ObjIsNode(Nwk_Obj_t *p)
Definition: nwk.h:148
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
#define assert(ex)
Definition: util_old.h:213
void Nwk_ManSupportSum ( Nwk_Man_t pNtk)

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

Synopsis [Computes the sum total of supports of all outputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 538 of file nwkDfs.c.

539 {
540  Vec_Ptr_t * vSupp;
541  Nwk_Obj_t * pObj;
542  int i, nTotalSupps = 0;
543  Nwk_ManForEachCo( pNtk, pObj, i )
544  {
545  vSupp = Nwk_ManSupportNodes( pNtk, &pObj, 1 );
546  nTotalSupps += Vec_PtrSize( vSupp );
547  Vec_PtrFree( vSupp );
548  }
549  printf( "Total supports = %d.\n", nTotalSupps );
550 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define Nwk_ManForEachCo(p, pObj, i)
Definition: nwk.h:181
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
Vec_Ptr_t * Nwk_ManSupportNodes(Nwk_Man_t *pNtk, Nwk_Obj_t **ppNodes, int nNodes)
Definition: nwkDfs.c:510
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
ABC_NAMESPACE_IMPL_START int Nwk_ManVerifyTopoOrder ( Nwk_Man_t pNtk)

DECLARATIONS ///.

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

FileName [nwkDfs.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Logic network representation.]

Synopsis [DFS traversals.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
nwkDfs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

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

Synopsis [Verifies that the objects are in a topo order.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file nwkDfs.c.

46 {
47  Nwk_Obj_t * pObj, * pNext;
48  int i, k, iBox, iTerm1, nTerms;
49  Nwk_ManIncrementTravId( pNtk );
50  Nwk_ManForEachObj( pNtk, pObj, i )
51  {
52  if ( Nwk_ObjIsNode(pObj) || Nwk_ObjIsCo(pObj) )
53  {
54  Nwk_ObjForEachFanin( pObj, pNext, k )
55  {
56  if ( !Nwk_ObjIsTravIdCurrent(pNext) )
57  {
58  printf( "Node %d has fanin %d that is not in a topological order.\n", pObj->Id, pNext->Id );
59  return 0;
60  }
61  }
62  }
63  else if ( Nwk_ObjIsCi(pObj) )
64  {
65  if ( pNtk->pManTime )
66  {
67  iBox = Tim_ManBoxForCi( pNtk->pManTime, pObj->PioId );
68  if ( iBox >= 0 ) // this is not a true PI
69  {
70  iTerm1 = Tim_ManBoxInputFirst( pNtk->pManTime, iBox );
71  nTerms = Tim_ManBoxInputNum( pNtk->pManTime, iBox );
72  for ( k = 0; k < nTerms; k++ )
73  {
74  pNext = Nwk_ManCo( pNtk, iTerm1 + k );
75  if ( !Nwk_ObjIsTravIdCurrent(pNext) )
76  {
77  printf( "Box %d has input %d that is not in a topological order.\n", iBox, pNext->Id );
78  return 0;
79  }
80  }
81  }
82  }
83  }
84  else
85  assert( 0 );
87  }
88  return 1;
89 }
int Tim_ManBoxForCi(Tim_Man_t *p, int iCo)
Definition: timBox.c:86
static Nwk_Obj_t * Nwk_ManCo(Nwk_Man_t *p, int i)
Definition: nwk.h:132
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkUtil.c:47
Tim_Man_t * pManTime
Definition: nwk.h:74
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
Definition: timBox.c:186
static int Nwk_ObjIsNode(Nwk_Obj_t *p)
Definition: nwk.h:148
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
#define Nwk_ManForEachObj(p, pObj, i)
Definition: nwk.h:189
#define assert(ex)
Definition: util_old.h:213
int Tim_ManBoxInputFirst(Tim_Man_t *p, int iBox)
Definition: timBox.c:122
int Nwk_ObjDeref_rec ( Nwk_Obj_t pNode)

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

Synopsis [Dereferences the node's MFFC.]

Description []

SideEffects []

SeeAlso []

Definition at line 564 of file nwkDfs.c.

565 {
566  Nwk_Obj_t * pFanin;
567  int i, Counter = 1;
568  if ( Nwk_ObjIsCi(pNode) )
569  return 0;
570  Nwk_ObjForEachFanin( pNode, pFanin, i )
571  {
572  assert( pFanin->nFanouts > 0 );
573  if ( --pFanin->nFanouts == 0 )
574  Counter += Nwk_ObjDeref_rec( pFanin );
575  }
576  return Counter;
577 }
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
int Nwk_ObjDeref_rec(Nwk_Obj_t *pNode)
Definition: nwkDfs.c:564
static int Counter
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
#define assert(ex)
Definition: util_old.h:213
int Nwk_ObjMffcLabel ( Nwk_Obj_t pNode)

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

Synopsis [Collects the internal nodes of the MFFC limited by cut.]

Description []

SideEffects [Increments the trav ID and marks visited nodes.]

SeeAlso []

Definition at line 644 of file nwkDfs.c.

645 {
646  int Count1, Count2;
647  // dereference the node
648  Count1 = Nwk_ObjDeref_rec( pNode );
649  // collect the nodes inside the MFFC
650  Nwk_ManIncrementTravId( pNode->pMan );
651  Nwk_ObjMffcLabel_rec( pNode, 1 );
652  // reference it back
653  Count2 = Nwk_ObjRef_rec( pNode );
654  assert( Count1 == Count2 );
655  return Count1;
656 }
void Nwk_ObjMffcLabel_rec(Nwk_Obj_t *pNode, int fTopmost)
Definition: nwkDfs.c:615
int Nwk_ObjDeref_rec(Nwk_Obj_t *pNode)
Definition: nwkDfs.c:564
int Nwk_ObjRef_rec(Nwk_Obj_t *pNode)
Definition: nwkDfs.c:590
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkUtil.c:47
#define assert(ex)
Definition: util_old.h:213
void Nwk_ObjMffcLabel_rec ( Nwk_Obj_t pNode,
int  fTopmost 
)

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

Synopsis [Collects the internal and boundary nodes in the derefed MFFC.]

Description []

SideEffects []

SeeAlso []

Definition at line 615 of file nwkDfs.c.

616 {
617  Nwk_Obj_t * pFanin;
618  int i;
619  // add to the new support nodes
620  if ( !fTopmost && (Nwk_ObjIsCi(pNode) || pNode->nFanouts > 0) )
621  return;
622  // skip visited nodes
623  if ( Nwk_ObjIsTravIdCurrent(pNode) )
624  return;
626  // recur on the children
627  Nwk_ObjForEachFanin( pNode, pFanin, i )
628  Nwk_ObjMffcLabel_rec( pFanin, 0 );
629  // collect the internal node
630 // printf( "%d ", pNode->Id );
631 }
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
void Nwk_ObjMffcLabel_rec(Nwk_Obj_t *pNode, int fTopmost)
Definition: nwkDfs.c:615
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
int Nwk_ObjRef_rec ( Nwk_Obj_t pNode)

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

Synopsis [References the node's MFFC.]

Description []

SideEffects []

SeeAlso []

Definition at line 590 of file nwkDfs.c.

591 {
592  Nwk_Obj_t * pFanin;
593  int i, Counter = 1;
594  if ( Nwk_ObjIsCi(pNode) )
595  return 0;
596  Nwk_ObjForEachFanin( pNode, pFanin, i )
597  {
598  if ( pFanin->nFanouts++ == 0 )
599  Counter += Nwk_ObjRef_rec( pFanin );
600  }
601  return Counter;
602 }
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
int Nwk_ObjRef_rec(Nwk_Obj_t *pNode)
Definition: nwkDfs.c:590
static int Counter
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199