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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Abc_NtkDfs_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 DECLARATIONS ///. More...
 
Vec_Ptr_tAbc_NtkDfs (Abc_Ntk_t *pNtk, int fCollectAll)
 
Vec_Ptr_tAbc_NtkDfsNodes (Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
 
void Abc_NtkDfsReverse_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_NtkDfsReverse (Abc_Ntk_t *pNtk)
 
void Abc_NtkDfsReverseNodes_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_NtkDfsReverseNodes (Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
 
Vec_Ptr_tAbc_NtkDfsReverseNodesContained (Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
 
void Abc_NtkDfsSeq_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_NtkDfsSeq (Abc_Ntk_t *pNtk)
 
void Abc_NtkDfsSeqReverse_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_NtkDfsSeqReverse (Abc_Ntk_t *pNtk)
 
void Abc_NtkDfs_iter (Vec_Ptr_t *vStack, Abc_Obj_t *pRoot, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_NtkDfsIter (Abc_Ntk_t *pNtk, int fCollectAll)
 
Vec_Ptr_tAbc_NtkDfsIterNodes (Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots)
 
void Abc_NtkDfsHie_rec (Abc_Obj_t *pObj, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_NtkDfsHie (Abc_Ntk_t *pNtk, int fCollectAll)
 
int Abc_NtkIsDfsOrdered (Abc_Ntk_t *pNtk)
 
void Abc_NtkDfsNets_rec (Abc_Obj_t *pNet, Vec_Ptr_t *vNets)
 
Vec_Ptr_tAbc_NtkDfsNets (Abc_Ntk_t *pNtk)
 
void Abc_NtkDfsWithBoxes_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_NtkDfsWithBoxes (Abc_Ntk_t *pNtk)
 
void Abc_NtkNodeSupport_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_NtkSupport (Abc_Ntk_t *pNtk)
 
Vec_Ptr_tAbc_NtkNodeSupport (Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
 
int Abc_ObjSuppSize_rec (Abc_Obj_t *pObj)
 
int Abc_ObjSuppSize (Abc_Obj_t *pObj)
 
int Abc_NtkSuppSizeTest (Abc_Ntk_t *p)
 
void Abc_NtkSupportSum (Abc_Ntk_t *pNtk)
 
void Abc_AigDfs_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tAbc_AigDfs (Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
 
Vec_Ptr_tAbc_AigDfsMap (Abc_Ntk_t *pNtk)
 
void Abc_DfsLevelizedTfo_rec (Abc_Obj_t *pNode, Vec_Vec_t *vLevels)
 
Vec_Vec_tAbc_DfsLevelized (Abc_Obj_t *pNode, int fTfi)
 
int Abc_NtkLevel_rec (Abc_Obj_t *pNode)
 
int Abc_NtkLevelReverse_rec (Abc_Obj_t *pNode)
 
Vec_Vec_tAbc_NtkLevelize (Abc_Ntk_t *pNtk)
 
int Abc_NtkLevel (Abc_Ntk_t *pNtk)
 
int Abc_NtkLevelReverse (Abc_Ntk_t *pNtk)
 
int Abc_NtkIsAcyclic_rec (Abc_Obj_t *pNode)
 
int Abc_NtkIsAcyclic (Abc_Ntk_t *pNtk)
 
int Abc_NtkIsAcyclicWithBoxes_rec (Abc_Obj_t *pNode)
 
int Abc_NtkIsAcyclicWithBoxes (Abc_Ntk_t *pNtk)
 
int Abc_NodeSetChoiceLevel_rec (Abc_Obj_t *pNode, int fMaximum)
 
int Abc_AigSetChoiceLevels (Abc_Ntk_t *pNtk)
 
Vec_Ptr_tAbc_AigGetLevelizedOrder (Abc_Ntk_t *pNtk, int fCollectCis)
 
int Abc_ObjSugraphSize (Abc_Obj_t *pObj)
 
int Abc_NtkPrintSubraphSizes (Abc_Ntk_t *pNtk)
 

Function Documentation

Vec_Ptr_t* Abc_AigDfs ( Abc_Ntk_t pNtk,
int  fCollectAll,
int  fCollectCos 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving out CIs/COs. However it marks both CIs and COs with the current TravId.]

SideEffects []

SeeAlso []

Definition at line 1014 of file abcDfs.c.

1015 {
1016  Vec_Ptr_t * vNodes;
1017  Abc_Obj_t * pNode;
1018  int i;
1019  assert( Abc_NtkIsStrash(pNtk) );
1020  // set the traversal ID
1021  Abc_NtkIncrementTravId( pNtk );
1022  // start the array of nodes
1023  vNodes = Vec_PtrAlloc( 100 );
1024  // go through the PO nodes and call for each of them
1025  Abc_NtkForEachCo( pNtk, pNode, i )
1026  {
1027  Abc_AigDfs_rec( Abc_ObjFanin0(pNode), vNodes );
1028  Abc_NodeSetTravIdCurrent( pNode );
1029  if ( fCollectCos )
1030  Vec_PtrPush( vNodes, pNode );
1031  }
1032  // collect dangling nodes if asked to
1033  if ( fCollectAll )
1034  {
1035  Abc_NtkForEachNode( pNtk, pNode, i )
1036  if ( !Abc_NodeIsTravIdCurrent(pNode) )
1037  Abc_AigDfs_rec( pNode, vNodes );
1038  }
1039  return vNodes;
1040 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
void Abc_AigDfs_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:978
if(last==0)
Definition: sparse_int.h:34
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
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
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_AigDfs_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 978 of file abcDfs.c.

979 {
980  Abc_Obj_t * pFanin;
981  int i;
982  // if this node is already visited, skip
983  if ( Abc_NodeIsTravIdCurrent( pNode ) )
984  return;
985  // mark the node as visited
986  Abc_NodeSetTravIdCurrent( pNode );
987  // skip the PI
988  if ( Abc_ObjIsCi(pNode) || Abc_AigNodeIsConst(pNode) )
989  return;
990  assert( Abc_ObjIsNode( pNode ) );
991  // visit the transitive fanin of the node
992  Abc_ObjForEachFanin( pNode, pFanin, i )
993  Abc_AigDfs_rec( pFanin, vNodes );
994  // visit the equivalent nodes
995  if ( Abc_AigNodeIsChoice( pNode ) )
996  for ( pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
997  Abc_AigDfs_rec( pFanin, vNodes );
998  // add the node after the fanins have been added
999  Vec_PtrPush( vNodes, pNode );
1000 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
for(p=first;p->value< newval;p=p->next)
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
void Abc_AigDfs_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:978
if(last==0)
Definition: sparse_int.h:34
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
static int Abc_AigNodeIsChoice(Abc_Obj_t *pNode)
Definition: abc.h:398
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_AigDfsMap ( Abc_Ntk_t pNtk)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving out CIs/COs. However it marks both CIs and COs with the current TravId.]

SideEffects []

SeeAlso []

Definition at line 1054 of file abcDfs.c.

1055 {
1056  Vec_Ptr_t * vNodes;
1057  Abc_Obj_t * pNode;
1058  int i;
1059  assert( Abc_NtkIsStrash(pNtk) );
1060  // set the traversal ID
1061  Abc_NtkIncrementTravId( pNtk );
1062  // start the array of nodes
1063  vNodes = Vec_PtrAlloc( 100 );
1064  // collect cones of barbufs
1065  Abc_NtkForEachCo( pNtk, pNode, i )
1066  {
1067  if ( i < Abc_NtkCoNum(pNtk) - pNtk->nBarBufs )
1068  continue;
1069  Abc_AigDfs_rec( Abc_ObjFanin0(pNode), vNodes );
1070  Abc_NodeSetTravIdCurrent( pNode );
1071  // collect latch as a placeholder
1073  Vec_PtrPush( vNodes, Abc_ObjFanout0(pNode) );
1074  }
1075  // collect nodes of real POs
1076  Abc_NtkForEachCo( pNtk, pNode, i )
1077  {
1078  if ( i >= Abc_NtkCoNum(pNtk) - pNtk->nBarBufs )
1079  break;
1080  Abc_AigDfs_rec( Abc_ObjFanin0(pNode), vNodes );
1081  assert( Abc_ObjIsCo(pNode) );
1082  Abc_NodeSetTravIdCurrent( pNode );
1083  }
1084  return vNodes;
1085 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
void Abc_AigDfs_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:978
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int nBarBufs
Definition: abc.h:174
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_AigGetLevelizedOrder ( Abc_Ntk_t pNtk,
int  fCollectCis 
)

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

Synopsis [Returns nodes by level from the smallest to the largest.]

Description [Correctly handles the case of choice nodes, by first spreading them out across several levels and then collecting.]

SideEffects [What happens with dangling nodes???]

SeeAlso []

Definition at line 1649 of file abcDfs.c.

1650 {
1651  Vec_Ptr_t * vNodes, * vLevels;
1652  Abc_Obj_t * pNode, ** ppHead;
1653  int LevelMax, i;
1654  assert( Abc_NtkIsStrash(pNtk) );
1655  // set the correct levels
1656  Abc_NtkCleanCopy( pNtk );
1657  LevelMax = Abc_AigSetChoiceLevels( pNtk );
1658  // relink nodes by level
1659  vLevels = Vec_PtrStart( LevelMax + 1 );
1660  Abc_NtkForEachNode( pNtk, pNode, i )
1661  {
1662  ppHead = ((Abc_Obj_t **)vLevels->pArray) + (int)(ABC_PTRINT_T)pNode->pCopy;
1663  pNode->pCopy = *ppHead;
1664  *ppHead = pNode;
1665  }
1666  // recollect nodes
1667  vNodes = Vec_PtrStart( Abc_NtkNodeNum(pNtk) );
1668  Vec_PtrForEachEntryStart( Abc_Obj_t *, vLevels, pNode, i, !fCollectCis )
1669  for ( ; pNode; pNode = pNode->pCopy )
1670  Vec_PtrPush( vNodes, pNode );
1671  Vec_PtrFree( vLevels );
1672  return vNodes;
1673 }
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
for(p=first;p->value< newval;p=p->next)
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
Abc_Obj_t * pCopy
Definition: abc.h:148
int Abc_AigSetChoiceLevels(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1611
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_AigSetChoiceLevels ( Abc_Ntk_t pNtk)

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

Synopsis [Resets the levels of the nodes in the choice graph.]

Description [Makes the level of the choice nodes to be equal to the maximum of the level of the nodes in the equivalence class. This way sorting by level leads to the reverse topological order, which is needed for the required time computation.]

SideEffects []

SeeAlso []

Definition at line 1611 of file abcDfs.c.

1612 {
1613  Abc_Obj_t * pObj;
1614  int i, LevelMax, LevelCur;
1615  assert( Abc_NtkIsStrash(pNtk) );
1616  // set the new travid counter
1617  Abc_NtkIncrementTravId( pNtk );
1618  // set levels of the CI and constant
1619  Abc_NtkForEachCi( pNtk, pObj, i )
1620  {
1621  Abc_NodeSetTravIdCurrent( pObj );
1622  pObj->pCopy = NULL;
1623  }
1624  pObj = Abc_AigConst1( pNtk );
1625  Abc_NodeSetTravIdCurrent( pObj );
1626  pObj->pCopy = NULL;
1627  // set levels of all other nodes
1628  LevelMax = 0;
1629  Abc_NtkForEachCo( pNtk, pObj, i )
1630  {
1631  LevelCur = Abc_NodeSetChoiceLevel_rec( Abc_ObjFanin0(pObj), 1 );
1632  LevelMax = Abc_MaxInt( LevelMax, LevelCur );
1633  }
1634  return LevelMax;
1635 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
int Abc_NodeSetChoiceLevel_rec(Abc_Obj_t *pNode, int fMaximum)
Definition: abcDfs.c:1570
Abc_Obj_t * pCopy
Definition: abc.h:148
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Vec_t* Abc_DfsLevelized ( Abc_Obj_t pNode,
int  fTfi 
)

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

Synopsis [Collects nodes in the DFS manner by level.]

Description [The number of levels should be set!!!]

SideEffects []

SeeAlso []

Definition at line 1129 of file abcDfs.c.

1130 {
1131  Vec_Vec_t * vLevels;
1132  Abc_Obj_t * pFanout;
1133  int i;
1134  assert( fTfi == 0 );
1135  assert( !Abc_NtkIsNetlist(pNode->pNtk) );
1136  // set the traversal ID
1137  Abc_NtkIncrementTravId( pNode->pNtk );
1138  vLevels = Vec_VecAlloc( 100 );
1139  if ( Abc_ObjIsNode(pNode) )
1140  Abc_DfsLevelizedTfo_rec( pNode, vLevels );
1141  else
1142  {
1143  assert( Abc_ObjIsCi(pNode) );
1144  Abc_NodeSetTravIdCurrent( pNode );
1145  Abc_ObjForEachFanout( pNode, pFanout, i )
1146  Abc_DfsLevelizedTfo_rec( pFanout, vLevels );
1147  }
1148  return vLevels;
1149 }
static Vec_Vec_t * Vec_VecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecVec.h:145
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
void Abc_DfsLevelizedTfo_rec(Abc_Obj_t *pNode, Vec_Vec_t *vLevels)
Definition: abcDfs.c:1098
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Abc_Ntk_t * pNtk
Definition: abc.h:130
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_DfsLevelizedTfo_rec ( Abc_Obj_t pNode,
Vec_Vec_t vLevels 
)

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

Synopsis [Collects nodes in the DFS manner by level.]

Description [The number of levels should be set!!!]

SideEffects []

SeeAlso []

Definition at line 1098 of file abcDfs.c.

1099 {
1100  Abc_Obj_t * pFanout;
1101  int i;
1102  // if this node is already visited, skip
1103  if ( Abc_NodeIsTravIdCurrent( pNode ) )
1104  return;
1105  // mark the node as visited
1106  Abc_NodeSetTravIdCurrent( pNode );
1107  // skip the terminals
1108  if ( Abc_ObjIsCo(pNode) )
1109  return;
1110  assert( Abc_ObjIsNode(pNode) );
1111  // add the node to the structure
1112  Vec_VecPush( vLevels, pNode->Level, pNode );
1113  // visit the TFO
1114  Abc_ObjForEachFanout( pNode, pFanout, i )
1115  Abc_DfsLevelizedTfo_rec( pFanout, vLevels );
1116 }
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
Definition: vecVec.h:456
void Abc_DfsLevelizedTfo_rec(Abc_Obj_t *pNode, Vec_Vec_t *vLevels)
Definition: abcDfs.c:1098
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
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
int Abc_NodeSetChoiceLevel_rec ( Abc_Obj_t pNode,
int  fMaximum 
)

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

Synopsis [Analyses choice nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1570 of file abcDfs.c.

1571 {
1572  Abc_Obj_t * pTemp;
1573  int Level1, Level2, Level, LevelE;
1574  // skip the visited node
1575  if ( Abc_NodeIsTravIdCurrent( pNode ) )
1576  return (int)(ABC_PTRINT_T)pNode->pCopy;
1577  Abc_NodeSetTravIdCurrent( pNode );
1578  // compute levels of the children nodes
1579  Level1 = Abc_NodeSetChoiceLevel_rec( Abc_ObjFanin0(pNode), fMaximum );
1580  Level2 = Abc_NodeSetChoiceLevel_rec( Abc_ObjFanin1(pNode), fMaximum );
1581  Level = 1 + Abc_MaxInt( Level1, Level2 );
1582  if ( pNode->pData )
1583  {
1584  LevelE = Abc_NodeSetChoiceLevel_rec( (Abc_Obj_t *)pNode->pData, fMaximum );
1585  if ( fMaximum )
1586  Level = Abc_MaxInt( Level, LevelE );
1587  else
1588  Level = Abc_MinInt( Level, LevelE );
1589  // set the level of all equivalent nodes to be the same minimum
1590  for ( pTemp = (Abc_Obj_t *)pNode->pData; pTemp; pTemp = (Abc_Obj_t *)pTemp->pData )
1591  pTemp->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Level;
1592  }
1593  pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Level;
1594  return Level;
1595 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
int Abc_NodeSetChoiceLevel_rec(Abc_Obj_t *pNode, int fMaximum)
Definition: abcDfs.c:1570
Abc_Obj_t * pCopy
Definition: abc.h:148
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
void * pData
Definition: abc.h:145
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfs ( Abc_Ntk_t pNtk,
int  fCollectAll 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving out CIs and CO. However it marks with the current TravId both CIs and COs.]

SideEffects []

SeeAlso []

Definition at line 81 of file abcDfs.c.

82 {
83  Vec_Ptr_t * vNodes;
84  Abc_Obj_t * pObj;
85  int i;
86  // set the traversal ID
87  Abc_NtkIncrementTravId( pNtk );
88  // start the array of nodes
89  vNodes = Vec_PtrAlloc( 100 );
90  Abc_NtkForEachObj( pNtk, pObj, i )
91  {
92  if ( !Abc_ObjIsCo(pObj) && !Abc_ObjIsBarBuf(pObj) )
93  continue;
96  if ( Abc_ObjIsBarBuf(pObj) )
97  Vec_PtrPush( vNodes, pObj );
98  }
99  // collect dangling nodes if asked to
100  if ( fCollectAll )
101  {
102  Abc_NtkForEachNode( pNtk, pObj, i )
103  if ( !Abc_NodeIsTravIdCurrent(pObj) )
104  Abc_NtkDfs_rec( pObj, vNodes );
105  }
106  return vNodes;
107 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static int Abc_ObjIsBarBuf(Abc_Obj_t *pObj)
Definition: abc.h:360
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
if(last==0)
Definition: sparse_int.h:34
ABC_NAMESPACE_IMPL_START void Abc_NtkDfs_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
DECLARATIONS ///.
Definition: abcDfs.c:45
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
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
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_NtkDfs_iter ( Vec_Ptr_t vStack,
Abc_Obj_t pRoot,
Vec_Ptr_t vNodes 
)

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

Synopsis [Iterative version of the DFS procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 484 of file abcDfs.c.

485 {
486  Abc_Obj_t * pNode, * pFanin;
487  int iFanin;
488  // if this node is already visited, skip
489  if ( Abc_NodeIsTravIdCurrent( pRoot ) )
490  return;
491  // mark the node as visited
492  Abc_NodeSetTravIdCurrent( pRoot );
493  // skip the CI
494  if ( Abc_ObjIsCi(pRoot) || (Abc_NtkIsStrash(pRoot->pNtk) && Abc_AigNodeIsConst(pRoot)) )
495  return;
496  // add the CI
497  Vec_PtrClear( vStack );
498  Vec_PtrPush( vStack, pRoot );
499  Vec_PtrPush( vStack, (void *)0 );
500  while ( Vec_PtrSize(vStack) > 0 )
501  {
502  // get the node and its fanin
503  iFanin = (int)(ABC_PTRINT_T)Vec_PtrPop(vStack);
504  pNode = (Abc_Obj_t *)Vec_PtrPop(vStack);
505  assert( !Abc_ObjIsNet(pNode) );
506  // add it to the array of nodes if we finished
507  if ( iFanin == Abc_ObjFaninNum(pNode) )
508  {
509  Vec_PtrPush( vNodes, pNode );
510  continue;
511  }
512  // explore the next fanin
513  Vec_PtrPush( vStack, pNode );
514  Vec_PtrPush( vStack, (void *)(ABC_PTRINT_T)(iFanin+1) );
515  // get the fanin
516  pFanin = Abc_ObjFanin0Ntk( Abc_ObjFanin(pNode,iFanin) );
517  // if this node is already visited, skip
518  if ( Abc_NodeIsTravIdCurrent( pFanin ) )
519  continue;
520  // mark the node as visited
521  Abc_NodeSetTravIdCurrent( pFanin );
522  // skip the CI
523  if ( Abc_ObjIsCi(pFanin) || (Abc_NtkIsStrash(pFanin->pNtk) && Abc_AigNodeIsConst(pFanin)) )
524  continue;
525  Vec_PtrPush( vStack, pFanin );
526  Vec_PtrPush( vStack, (void *)0 );
527  }
528 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
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
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
Abc_Ntk_t * pNtk
Definition: abc.h:130
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
ABC_NAMESPACE_IMPL_START void Abc_NtkDfs_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

DECLARATIONS ///.

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

FileName [abcDfs.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures that use depth-first search.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file abcDfs.c.

46 {
47  Abc_Obj_t * pFanin;
48  int i;
49  assert( !Abc_ObjIsNet(pNode) );
50  // if this node is already visited, skip
51  if ( Abc_NodeIsTravIdCurrent( pNode ) )
52  return;
53  // mark the node as visited
54  Abc_NodeSetTravIdCurrent( pNode );
55  // skip the CI
56  if ( Abc_ObjIsCi(pNode) || (Abc_NtkIsStrash(pNode->pNtk) && Abc_AigNodeIsConst(pNode)) )
57  return;
58  assert( Abc_ObjIsNode( pNode ) || Abc_ObjIsBox( pNode ) );
59  // visit the transitive fanin of the node
60  Abc_ObjForEachFanin( pNode, pFanin, i )
61  {
62 // pFanin = Abc_ObjFanin( pNode, Abc_ObjFaninNum(pNode)-1-i );
63  Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(pFanin), vNodes );
64  }
65  // add the node after the fanins have been added
66  Vec_PtrPush( vNodes, pNode );
67 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_NAMESPACE_IMPL_START void Abc_NtkDfs_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
DECLARATIONS ///.
Definition: abcDfs.c:45
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
Abc_Ntk_t * pNtk
Definition: abc.h:130
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjIsBox(Abc_Obj_t *pObj)
Definition: abc.h:357
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfsHie ( Abc_Ntk_t pNtk,
int  fCollectAll 
)

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

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

Description [This procedure collects everything from POs to PIs.]

SideEffects []

SeeAlso []

Definition at line 634 of file abcDfs.c.

635 {
636  Vec_Ptr_t * vNodes;
637  Abc_Obj_t * pObj;
638  int i;
639  // set the traversal ID
640  Abc_NtkIncrementTravId( pNtk );
641  // start the array of nodes
642  vNodes = Vec_PtrAlloc( 100 );
643  Abc_NtkForEachPo( pNtk, pObj, i )
644  Abc_NtkDfsHie_rec( pObj, vNodes );
645  // collect dangling nodes if asked to
646  if ( fCollectAll )
647  {
648  Abc_NtkForEachObj( pNtk, pObj, i )
649  if ( !Abc_NodeIsTravIdCurrent(pObj) )
650  Abc_NtkDfs_rec( pObj, vNodes );
651  }
652  return vNodes;
653 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
if(last==0)
Definition: sparse_int.h:34
ABC_NAMESPACE_IMPL_START void Abc_NtkDfs_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
DECLARATIONS ///.
Definition: abcDfs.c:45
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
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
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkDfsHie_rec(Abc_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:607
void Abc_NtkDfsHie_rec ( Abc_Obj_t pObj,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 607 of file abcDfs.c.

608 {
609  Abc_Obj_t * pFanin;
610  int i;
611  // if this node is already visited, skip
612  if ( Abc_NodeIsTravIdCurrent( pObj ) )
613  return;
614  // mark the node as visited
615  Abc_NodeSetTravIdCurrent( pObj );
616  // visit the transitive fanin of the node
617  Abc_ObjForEachFanin( pObj, pFanin, i )
618  Abc_NtkDfsHie_rec( pFanin, vNodes );
619  // add the node after the fanins have been added
620  Vec_PtrPush( vNodes, pObj );
621 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
void Abc_NtkDfsHie_rec(Abc_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:607
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfsIter ( Abc_Ntk_t pNtk,
int  fCollectAll 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving CIs and CO. However it marks with the current TravId both CIs and COs.]

SideEffects []

SeeAlso []

Definition at line 542 of file abcDfs.c.

543 {
544  Vec_Ptr_t * vNodes, * vStack;
545  Abc_Obj_t * pObj;
546  int i;
547  // set the traversal ID
548  Abc_NtkIncrementTravId( pNtk );
549  // start the array of nodes
550  vNodes = Vec_PtrAlloc( 1000 );
551  vStack = Vec_PtrAlloc( 1000 );
552  Abc_NtkForEachCo( pNtk, pObj, i )
553  {
554  Abc_NodeSetTravIdCurrent( pObj );
555  Abc_NtkDfs_iter( vStack, Abc_ObjFanin0Ntk(Abc_ObjFanin0(pObj)), vNodes );
556  }
557  // collect dangling nodes if asked to
558  if ( fCollectAll )
559  {
560  Abc_NtkForEachNode( pNtk, pObj, i )
561  if ( !Abc_NodeIsTravIdCurrent(pObj) )
562  Abc_NtkDfs_iter( vStack, pObj, vNodes );
563  }
564  Vec_PtrFree( vStack );
565  return vNodes;
566 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
if(last==0)
Definition: sparse_int.h:34
void Abc_NtkDfs_iter(Vec_Ptr_t *vStack, Abc_Obj_t *pRoot, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:484
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
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
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Ptr_t* Abc_NtkDfsIterNodes ( Abc_Ntk_t pNtk,
Vec_Ptr_t vRoots 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving CIs and CO. However it marks with the current TravId both CIs and COs.]

SideEffects []

SeeAlso []

Definition at line 580 of file abcDfs.c.

581 {
582  Vec_Ptr_t * vNodes, * vStack;
583  Abc_Obj_t * pObj;
584  int i;
585  Abc_NtkIncrementTravId( pNtk );
586  vNodes = Vec_PtrAlloc( 1000 );
587  vStack = Vec_PtrAlloc( 1000 );
588  Vec_PtrForEachEntry( Abc_Obj_t *, vRoots, pObj, i )
590  Abc_NtkDfs_iter( vStack, Abc_ObjRegular(pObj), vNodes );
591  Vec_PtrFree( vStack );
592  return vNodes;
593 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
if(last==0)
Definition: sparse_int.h:34
void Abc_NtkDfs_iter(Vec_Ptr_t *vStack, Abc_Obj_t *pRoot, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:484
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
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
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Ptr_t* Abc_NtkDfsNets ( Abc_Ntk_t pNtk)

Definition at line 719 of file abcDfs.c.

720 {
721  Vec_Ptr_t * vNets;
722  Abc_Obj_t * pObj; int i;
723  vNets = Vec_PtrAlloc( 100 );
724  Abc_NtkIncrementTravId( pNtk );
725  Abc_NtkForEachCi( pNtk, pObj, i )
727  Abc_NtkForEachCi( pNtk, pObj, i )
728  Vec_PtrPush( vNets, Abc_ObjFanout0(pObj) );
729  Abc_NtkForEachCo( pNtk, pObj, i )
730  Abc_NtkDfsNets_rec( Abc_ObjFanin0(pObj), vNets );
731  return vNets;
732 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
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_NtkDfsNets_rec(Abc_Obj_t *pNet, Vec_Ptr_t *vNets)
Definition: abcDfs.c:705
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_NtkDfsNets_rec ( Abc_Obj_t pNet,
Vec_Ptr_t vNets 
)

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

Synopsis [Create DFS ordering of nets.]

Description []

SideEffects []

SeeAlso []

Definition at line 705 of file abcDfs.c.

706 {
707  Abc_Obj_t * pNext;
708  Abc_Obj_t * pNode; int i;
709  assert( Abc_ObjIsNet(pNet) );
710  if ( Abc_NodeIsTravIdCurrent( pNet ) )
711  return;
712  Abc_NodeSetTravIdCurrent( pNet );
713  pNode = Abc_ObjFanin0( pNet );
714  Abc_ObjForEachFanin( pNode, pNext, i )
715  Abc_NtkDfsNets_rec( pNext, vNets );
716  Abc_ObjForEachFanout( pNode, pNext, i )
717  Vec_PtrPush( vNets, pNext );
718 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
void Abc_NtkDfsNets_rec(Abc_Obj_t *pNet, Vec_Ptr_t *vNets)
Definition: abcDfs.c:705
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfsNodes ( Abc_Ntk_t pNtk,
Abc_Obj_t **  ppNodes,
int  nNodes 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving out PIs, POs and latches.]

SideEffects []

SeeAlso []

Definition at line 120 of file abcDfs.c.

121 {
122  Vec_Ptr_t * vNodes;
123  int i;
124  // set the traversal ID
125  Abc_NtkIncrementTravId( pNtk );
126  // start the array of nodes
127  vNodes = Vec_PtrAlloc( 100 );
128  // go through the PO nodes and call for each of them
129  for ( i = 0; i < nNodes; i++ )
130  {
131  if ( Abc_NtkIsStrash(pNtk) && Abc_AigNodeIsConst(ppNodes[i]) )
132  continue;
133  if ( Abc_ObjIsCo(ppNodes[i]) )
134  {
135  Abc_NodeSetTravIdCurrent(ppNodes[i]);
136  Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(ppNodes[i])), vNodes );
137  }
138  else if ( Abc_ObjIsNode(ppNodes[i]) || Abc_ObjIsCi(ppNodes[i]) )
139  Abc_NtkDfs_rec( ppNodes[i], vNodes );
140  }
141  return vNodes;
142 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_NAMESPACE_IMPL_START void Abc_NtkDfs_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
DECLARATIONS ///.
Definition: abcDfs.c:45
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
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfsReverse ( Abc_Ntk_t pNtk)

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

Synopsis [Returns the reverse DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving out CIs/COs. However it marks both CIs and COs with the current TravId.]

SideEffects []

SeeAlso []

Definition at line 190 of file abcDfs.c.

191 {
192  Vec_Ptr_t * vNodes;
193  Abc_Obj_t * pObj, * pFanout;
194  int i, k;
195  // set the traversal ID
196  Abc_NtkIncrementTravId( pNtk );
197  // start the array of nodes
198  vNodes = Vec_PtrAlloc( 100 );
199  Abc_NtkForEachCi( pNtk, pObj, i )
200  {
201  Abc_NodeSetTravIdCurrent( pObj );
202  pObj = Abc_ObjFanout0Ntk(pObj);
203  Abc_ObjForEachFanout( pObj, pFanout, k )
204  Abc_NtkDfsReverse_rec( pFanout, vNodes );
205  }
206  // add constant nodes in the end
207  if ( !Abc_NtkIsStrash(pNtk) ) {
208  Abc_NtkForEachNode( pNtk, pObj, i )
209  if ( Abc_NodeIsConst(pObj) )
210  Vec_PtrPush( vNodes, pObj );
211  }
212  return vNodes;
213 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
Definition: abcObj.c:843
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
if(last==0)
Definition: sparse_int.h:34
static Abc_Obj_t * Abc_ObjFanout0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:376
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
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_NtkDfsReverse_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:156
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_NtkDfsReverse_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 156 of file abcDfs.c.

157 {
158  Abc_Obj_t * pFanout;
159  int i;
160  assert( !Abc_ObjIsNet(pNode) );
161  // if this node is already visited, skip
162  if ( Abc_NodeIsTravIdCurrent( pNode ) )
163  return;
164  // mark the node as visited
165  Abc_NodeSetTravIdCurrent( pNode );
166  // skip the CI
167  if ( Abc_ObjIsCo(pNode) )
168  return;
169  assert( Abc_ObjIsNode( pNode ) );
170  // visit the transitive fanin of the node
171  pNode = Abc_ObjFanout0Ntk(pNode);
172  Abc_ObjForEachFanout( pNode, pFanout, i )
173  Abc_NtkDfsReverse_rec( pFanout, vNodes );
174  // add the node after the fanins have been added
175  Vec_PtrPush( vNodes, pNode );
176 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static Abc_Obj_t * Abc_ObjFanout0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:376
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
void Abc_NtkDfsReverse_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:156
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfsReverseNodes ( Abc_Ntk_t pNtk,
Abc_Obj_t **  ppNodes,
int  nNodes 
)

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

Synopsis [Returns the levelized array of TFO nodes.]

Description [Collects the levelized array of internal nodes, leaving out CIs/COs. However it marks both CIs and COs with the current TravId.]

SideEffects []

SeeAlso []

Definition at line 263 of file abcDfs.c.

264 {
265  Vec_Ptr_t * vNodes;
266  Abc_Obj_t * pObj, * pFanout;
267  int i, k;
268  assert( Abc_NtkIsStrash(pNtk) );
269  // set the traversal ID
270  Abc_NtkIncrementTravId( pNtk );
271  // start the array of nodes
272  vNodes = Vec_PtrStart( Abc_AigLevel(pNtk) + 1 );
273  for ( i = 0; i < nNodes; i++ )
274  {
275  pObj = ppNodes[i];
276  assert( Abc_ObjIsCi(pObj) );
277  Abc_NodeSetTravIdCurrent( pObj );
278  pObj = Abc_ObjFanout0Ntk(pObj);
279  Abc_ObjForEachFanout( pObj, pFanout, k )
280  Abc_NtkDfsReverseNodes_rec( pFanout, vNodes );
281  }
282  return vNodes;
283 }
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
void Abc_NtkDfsReverseNodes_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:226
ABC_DLL int Abc_AigLevel(Abc_Ntk_t *pNtk)
Definition: abcAig.c:292
static Abc_Obj_t * Abc_ObjFanout0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:376
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_NtkDfsReverseNodes_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 226 of file abcDfs.c.

227 {
228  Abc_Obj_t * pFanout;
229  int i;
230  assert( !Abc_ObjIsNet(pNode) );
231  // if this node is already visited, skip
232  if ( Abc_NodeIsTravIdCurrent( pNode ) )
233  return;
234  // mark the node as visited
235  Abc_NodeSetTravIdCurrent( pNode );
236  // skip the CI
237  if ( Abc_ObjIsCo(pNode) )
238  return;
239  assert( Abc_ObjIsNode( pNode ) );
240  // visit the transitive fanin of the node
241  pNode = Abc_ObjFanout0Ntk(pNode);
242  Abc_ObjForEachFanout( pNode, pFanout, i )
243  Abc_NtkDfsReverseNodes_rec( pFanout, vNodes );
244  // add the node after the fanins have been added
245 // Vec_PtrPush( vNodes, pNode );
246  Vec_PtrFillExtra( vNodes, pNode->Level + 1, NULL );
247  pNode->pCopy = (Abc_Obj_t *)Vec_PtrEntry( vNodes, pNode->Level );
248  Vec_PtrWriteEntry( vNodes, pNode->Level, pNode );
249 }
static void Vec_PtrFillExtra(Vec_Ptr_t *p, int nSize, void *Fill)
Definition: vecPtr.h:469
void Abc_NtkDfsReverseNodes_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:226
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static Abc_Obj_t * Abc_ObjFanout0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:376
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfsReverseNodesContained ( Abc_Ntk_t pNtk,
Abc_Obj_t **  ppNodes,
int  nNodes 
)

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

Synopsis [Returns the levelized array of TFO nodes.]

Description [Collects the levelized array of internal nodes, leaving out CIs/COs. However it marks both CIs and COs with the current TravId. Collects only the nodes whose support does not exceed the set of given CI nodes.]

SideEffects []

SeeAlso []

Definition at line 298 of file abcDfs.c.

299 {
300  Vec_Ptr_t * vNodes;
301  Abc_Obj_t * pObj, * pFanout, * pFanin;
302  int i, k, m, nLevels;
303  // set the levels
304  nLevels = Abc_NtkLevel( pNtk );
305  // set the traversal ID
306  Abc_NtkIncrementTravId( pNtk );
307  // start the array of nodes
308  vNodes = Vec_PtrStart( nLevels + 2 );
309  for ( i = 0; i < nNodes; i++ )
310  {
311  pObj = ppNodes[i];
312  assert( Abc_ObjIsCi(pObj) );
313  Abc_NodeSetTravIdCurrent( pObj );
314  // add to the array
315  assert( pObj->Level == 0 );
316  pObj->pCopy = (Abc_Obj_t *)Vec_PtrEntry( vNodes, pObj->Level );
317  Vec_PtrWriteEntry( vNodes, pObj->Level, pObj );
318  }
319  // iterate through the levels
320  for ( i = 0; i <= nLevels; i++ )
321  {
322  // iterate through the nodes on each level
323  for ( pObj = (Abc_Obj_t *)Vec_PtrEntry(vNodes, i); pObj; pObj = pObj->pCopy )
324  {
325  // iterate through the fanouts of each node
326  Abc_ObjForEachFanout( pObj, pFanout, k )
327  {
328  // skip visited nodes
329  if ( Abc_NodeIsTravIdCurrent(pFanout) )
330  continue;
331  // visit the fanins of this fanout
332  Abc_ObjForEachFanin( pFanout, pFanin, m )
333  {
334  if ( !Abc_NodeIsTravIdCurrent(pFanin) )
335  break;
336  }
337  if ( m < Abc_ObjFaninNum(pFanout) )
338  continue;
339  // all fanins are already collected
340 
341  // mark the node as visited
342  Abc_NodeSetTravIdCurrent( pFanout );
343  // handle the COs
344  if ( Abc_ObjIsCo(pFanout) )
345  pFanout->Level = nLevels + 1;
346  // add to the array
347  pFanout->pCopy = (Abc_Obj_t *)Vec_PtrEntry( vNodes, pFanout->Level );
348  Vec_PtrWriteEntry( vNodes, pFanout->Level, pFanout );
349  // handle the COs
350  if ( Abc_ObjIsCo(pFanout) )
351  pFanout->Level = 0;
352  }
353  }
354  }
355  return vNodes;
356 }
static Vec_Ptr_t * Vec_PtrStart(int nSize)
Definition: vecPtr.h:106
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
unsigned Level
Definition: abc.h:142
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
Abc_Obj_t * pCopy
Definition: abc.h:148
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfsSeq ( Abc_Ntk_t pNtk)

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

Synopsis [Returns the array of nodes and latches reachable from POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 397 of file abcDfs.c.

398 {
399  Vec_Ptr_t * vNodes;
400  Abc_Obj_t * pObj;
401  int i;
402  assert( !Abc_NtkIsNetlist(pNtk) );
403  // set the traversal ID
404  Abc_NtkIncrementTravId( pNtk );
405  // start the array of nodes
406  vNodes = Vec_PtrAlloc( 100 );
407  Abc_NtkForEachPo( pNtk, pObj, i )
408  Abc_NtkDfsSeq_rec( pObj, vNodes );
409  // mark the PIs
410  Abc_NtkForEachPi( pNtk, pObj, i )
411  Abc_NtkDfsSeq_rec( pObj, vNodes );
412  return vNodes;
413 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
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_NtkDfsSeq_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:370
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Abc_NtkDfsSeq_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 370 of file abcDfs.c.

371 {
372  Abc_Obj_t * pFanin;
373  int i;
374  // if this node is already visited, skip
375  if ( Abc_NodeIsTravIdCurrent( pNode ) )
376  return;
377  // mark the node as visited
378  Abc_NodeSetTravIdCurrent( pNode );
379  // visit the transitive fanin of the node
380  Abc_ObjForEachFanin( pNode, pFanin, i )
381  Abc_NtkDfsSeq_rec( pFanin, vNodes );
382  // add the node after the fanins have been added
383  Vec_PtrPush( vNodes, pNode );
384 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
void Abc_NtkDfsSeq_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:370
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfsSeqReverse ( Abc_Ntk_t pNtk)

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

Synopsis [Returns the array of nodes and latches reachable from POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 454 of file abcDfs.c.

455 {
456  Vec_Ptr_t * vNodes;
457  Abc_Obj_t * pObj;
458  int i;
459  assert( !Abc_NtkIsNetlist(pNtk) );
460  // set the traversal ID
461  Abc_NtkIncrementTravId( pNtk );
462  // start the array of nodes
463  vNodes = Vec_PtrAlloc( 100 );
464  Abc_NtkForEachPi( pNtk, pObj, i )
465  Abc_NtkDfsSeqReverse_rec( pObj, vNodes );
466  // mark the logic feeding into POs
467  Abc_NtkForEachPo( pNtk, pObj, i )
468  Abc_NtkDfsSeq_rec( pObj, vNodes );
469  return vNodes;
470 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
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_NtkDfsSeq_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:370
#define assert(ex)
Definition: util_old.h:213
void Abc_NtkDfsSeqReverse_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:427
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Abc_NtkDfsSeqReverse_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 427 of file abcDfs.c.

428 {
429  Abc_Obj_t * pFanout;
430  int i;
431  // if this node is already visited, skip
432  if ( Abc_NodeIsTravIdCurrent( pNode ) )
433  return;
434  // mark the node as visited
435  Abc_NodeSetTravIdCurrent( pNode );
436  // visit the transitive fanin of the node
437  Abc_ObjForEachFanout( pNode, pFanout, i )
438  Abc_NtkDfsSeqReverse_rec( pFanout, vNodes );
439  // add the node after the fanins have been added
440  Vec_PtrPush( vNodes, pNode );
441 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
void Abc_NtkDfsSeqReverse_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:427
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkDfsWithBoxes ( Abc_Ntk_t pNtk)

Definition at line 768 of file abcDfs.c.

769 {
770  Vec_Ptr_t * vNodes;
771  Abc_Obj_t * pObj;
772  int i;
773  Abc_NtkIncrementTravId( pNtk );
774  vNodes = Vec_PtrAlloc( 100 );
775  Abc_NtkForEachPo( pNtk, pObj, i )
776  {
779  }
780  return vNodes;
781 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
void Abc_NtkDfsWithBoxes_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:746
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
void Abc_NtkDfsWithBoxes_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Returns the DFS ordered array of logic nodes.]

Description [Collects only the internal nodes, leaving out CIs and CO. However it marks with the current TravId both CIs and COs.]

SideEffects []

SeeAlso []

Definition at line 746 of file abcDfs.c.

747 {
748  Abc_Obj_t * pFanin;
749  int i;
750  assert( !Abc_ObjIsNet(pNode) );
751  if ( Abc_ObjIsBo(pNode) )
752  pNode = Abc_ObjFanin0(pNode);
753  if ( Abc_ObjIsPi(pNode) )
754  return;
755  assert( Abc_ObjIsNode( pNode ) || Abc_ObjIsBox( pNode ) );
756  if ( Abc_NodeIsTravIdCurrent( pNode ) )
757  return;
758  Abc_NodeSetTravIdCurrent( pNode );
759  Abc_ObjForEachFanin( pNode, pFanin, i )
760  {
761  if ( Abc_ObjIsBox(pNode) )
762  pFanin = Abc_ObjFanin0(pFanin);
763  assert( Abc_ObjIsNet(pFanin) );
764  Abc_NtkDfsWithBoxes_rec( Abc_ObjFanin0Ntk(pFanin), vNodes );
765  }
766  Vec_PtrPush( vNodes, pNode );
767 }
static int Abc_ObjIsBo(Abc_Obj_t *pObj)
Definition: abc.h:350
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
Definition: abc.h:347
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
void Abc_NtkDfsWithBoxes_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:746
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjIsBox(Abc_Obj_t *pObj)
Definition: abc.h:357
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
int Abc_NtkIsAcyclic ( Abc_Ntk_t pNtk)

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

Synopsis [Detects combinational loops.]

Description [This procedure is based on the idea suggested by Donald Chai. As we traverse the network and visit the nodes, we need to distinquish three types of nodes: (1) those that are visited for the first time, (2) those that have been visited in this traversal but are currently not on the traversal path, (3) those that have been visited and are currently on the travesal path. When the node of type (3) is encountered, it means that there is a combinational loop. To mark the three types of nodes, two new values of the traversal IDs are used.]

SideEffects []

SeeAlso []

Definition at line 1422 of file abcDfs.c.

1423 {
1424  Abc_Obj_t * pNode;
1425  int fAcyclic;
1426  int i;
1427  // set the traversal ID for this DFS ordering
1428  Abc_NtkIncrementTravId( pNtk );
1429  Abc_NtkIncrementTravId( pNtk );
1430  // pNode->TravId == pNet->nTravIds means "pNode is on the path"
1431  // pNode->TravId == pNet->nTravIds - 1 means "pNode is visited but is not on the path"
1432  // pNode->TravId < pNet->nTravIds - 1 means "pNode is not visited"
1433  // traverse the network to detect cycles
1434  fAcyclic = 1;
1435  Abc_NtkForEachCo( pNtk, pNode, i )
1436  {
1437  pNode = Abc_ObjFanin0Ntk(Abc_ObjFanin0(pNode));
1438  if ( Abc_NodeIsTravIdPrevious(pNode) )
1439  continue;
1440  // traverse the output logic cone
1441  if ( (fAcyclic = Abc_NtkIsAcyclic_rec(pNode)) )
1442  continue;
1443  // stop as soon as the first loop is detected
1444  fprintf( stdout, " CO \"%s\"\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1445  break;
1446  }
1447  return fAcyclic;
1448 }
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_NodeIsTravIdPrevious(Abc_Obj_t *p)
Definition: abc.h:412
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
int Abc_NtkIsAcyclic_rec(Abc_Obj_t *pNode)
Definition: abcDfs.c:1346
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
int Abc_NtkIsAcyclic_rec ( Abc_Obj_t pNode)

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

Synopsis [Recursively detects combinational loops.]

Description []

SideEffects []

SeeAlso []

Definition at line 1346 of file abcDfs.c.

1347 {
1348  Abc_Ntk_t * pNtk = pNode->pNtk;
1349  Abc_Obj_t * pFanin;
1350  int fAcyclic, i;
1351  assert( !Abc_ObjIsNet(pNode) );
1352  if ( Abc_ObjIsCi(pNode) || Abc_ObjIsBox(pNode) || (Abc_NtkIsStrash(pNode->pNtk) && Abc_AigNodeIsConst(pNode)) )
1353  return 1;
1354  assert( Abc_ObjIsNode(pNode) );
1355  // make sure the node is not visited
1356  assert( !Abc_NodeIsTravIdPrevious(pNode) );
1357  // check if the node is part of the combinational loop
1358  if ( Abc_NodeIsTravIdCurrent(pNode) )
1359  {
1360  fprintf( stdout, "Network \"%s\" contains combinational loop!\n", Abc_NtkName(pNtk) );
1361  fprintf( stdout, "Node \"%s\" is encountered twice on the following path to the COs:\n", Abc_ObjName(pNode) );
1362  return 0;
1363  }
1364  // mark this node as a node on the current path
1365  Abc_NodeSetTravIdCurrent( pNode );
1366  // visit the transitive fanin
1367  Abc_ObjForEachFanin( pNode, pFanin, i )
1368  {
1369  pFanin = Abc_ObjFanin0Ntk(pFanin);
1370  // make sure there is no mixing of networks
1371  assert( pFanin->pNtk == pNode->pNtk );
1372  // check if the fanin is visited
1373  if ( Abc_NodeIsTravIdPrevious(pFanin) )
1374  continue;
1375  // traverse the fanin's cone searching for the loop
1376  if ( (fAcyclic = Abc_NtkIsAcyclic_rec(pFanin)) )
1377  continue;
1378  // return as soon as the loop is detected
1379  fprintf( stdout, " %s ->", Abc_ObjName(pFanin) );
1380  return 0;
1381  }
1382  // visit choices
1383  if ( Abc_NtkIsStrash(pNode->pNtk) && Abc_AigNodeIsChoice(pNode) )
1384  {
1385  for ( pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
1386  {
1387  // check if the fanin is visited
1388  if ( Abc_NodeIsTravIdPrevious(pFanin) )
1389  continue;
1390  // traverse the fanin's cone searching for the loop
1391  if ( (fAcyclic = Abc_NtkIsAcyclic_rec(pFanin)) )
1392  continue;
1393  // return as soon as the loop is detected
1394  fprintf( stdout, " %s", Abc_ObjName(pFanin) );
1395  fprintf( stdout, " (choice of %s) -> ", Abc_ObjName(pNode) );
1396  return 0;
1397  }
1398  }
1399  // mark this node as a visited node
1400  Abc_NodeSetTravIdPrevious( pNode );
1401  return 1;
1402 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static void Abc_NodeSetTravIdPrevious(Abc_Obj_t *p)
Definition: abc.h:410
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
static int Abc_NodeIsTravIdPrevious(Abc_Obj_t *p)
Definition: abc.h:412
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
static int Abc_AigNodeIsChoice(Abc_Obj_t *pNode)
Definition: abc.h:398
Abc_Ntk_t * pNtk
Definition: abc.h:130
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
Definition: abc.h:270
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
int Abc_NtkIsAcyclic_rec(Abc_Obj_t *pNode)
Definition: abcDfs.c:1346
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjIsBox(Abc_Obj_t *pObj)
Definition: abc.h:357
void * pData
Definition: abc.h:145
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
int Abc_NtkIsAcyclicWithBoxes ( Abc_Ntk_t pNtk)

Definition at line 1510 of file abcDfs.c.

1511 {
1512  Abc_Obj_t * pNode;
1513  int fAcyclic;
1514  int i;
1515  // set the traversal ID for this DFS ordering
1516  Abc_NtkIncrementTravId( pNtk );
1517  Abc_NtkIncrementTravId( pNtk );
1518  // pNode->TravId == pNet->nTravIds means "pNode is on the path"
1519  // pNode->TravId == pNet->nTravIds - 1 means "pNode is visited but is not on the path"
1520  // pNode->TravId < pNet->nTravIds - 1 means "pNode is not visited"
1521  // traverse the network to detect cycles
1522  fAcyclic = 1;
1523  Abc_NtkForEachPo( pNtk, pNode, i )
1524  {
1525  pNode = Abc_ObjFanin0Ntk(Abc_ObjFanin0(pNode));
1526  if ( Abc_ObjIsBo(pNode) )
1527  pNode = Abc_ObjFanin0(pNode);
1528  if ( Abc_NodeIsTravIdPrevious(pNode) )
1529  continue;
1530  // traverse the output logic cone
1531  if ( (fAcyclic = Abc_NtkIsAcyclicWithBoxes_rec(pNode)) )
1532  continue;
1533  // stop as soon as the first loop is detected
1534  fprintf( stdout, " PO \"%s\"\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1535  break;
1536  }
1537  if ( fAcyclic )
1538  {
1539  Abc_NtkForEachLatchInput( pNtk, pNode, i )
1540  {
1541  pNode = Abc_ObjFanin0Ntk(Abc_ObjFanin0(pNode));
1542  if ( Abc_ObjIsBo(pNode) )
1543  pNode = Abc_ObjFanin0(pNode);
1544  if ( Abc_NodeIsTravIdPrevious(pNode) )
1545  continue;
1546  // traverse the output logic cone
1547  if ( (fAcyclic = Abc_NtkIsAcyclicWithBoxes_rec(pNode)) )
1548  continue;
1549  // stop as soon as the first loop is detected
1550  fprintf( stdout, " PO \"%s\"\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1551  break;
1552  }
1553  }
1554  return fAcyclic;
1555 }
static int Abc_ObjIsBo(Abc_Obj_t *pObj)
Definition: abc.h:350
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static int Abc_NodeIsTravIdPrevious(Abc_Obj_t *p)
Definition: abc.h:412
int Abc_NtkIsAcyclicWithBoxes_rec(Abc_Obj_t *pNode)
Definition: abcDfs.c:1461
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define Abc_NtkForEachLatchInput(pNtk, pObj, i)
Definition: abc.h:500
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
int Abc_NtkIsAcyclicWithBoxes_rec ( Abc_Obj_t pNode)

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

Synopsis [Checks for the loops with boxes.]

Description []

SideEffects []

SeeAlso []

Definition at line 1461 of file abcDfs.c.

1462 {
1463  Abc_Ntk_t * pNtk = pNode->pNtk;
1464  Abc_Obj_t * pFanin;
1465  int fAcyclic, i;
1466  assert( !Abc_ObjIsNet(pNode) );
1467  if ( Abc_ObjIsPi(pNode) || Abc_ObjIsLatch(pNode) || Abc_ObjIsBlackbox(pNode) )
1468  return 1;
1469  assert( Abc_ObjIsNode(pNode) || Abc_ObjIsBox(pNode) );
1470  // make sure the node is not visited
1471  assert( !Abc_NodeIsTravIdPrevious(pNode) );
1472  // check if the node is part of the combinational loop
1473  if ( Abc_NodeIsTravIdCurrent(pNode) )
1474  {
1475  fprintf( stdout, "Network \"%s\" contains combinational loop!\n", Abc_NtkName(pNtk) );
1476  if ( Abc_ObjIsBox(pNode) )
1477  fprintf( stdout, "Box \"%s\" is encountered twice on the following path to the COs:\n", Abc_ObjName(pNode) );
1478  else
1479  fprintf( stdout, "Node \"%s\" is encountered twice on the following path to the COs:\n", Abc_ObjName(Abc_ObjFanout0(pNode)) );
1480  return 0;
1481  }
1482  // mark this node as a node on the current path
1483  Abc_NodeSetTravIdCurrent( pNode );
1484  // visit the transitive fanin
1485  Abc_ObjForEachFanin( pNode, pFanin, i )
1486  {
1487  if ( Abc_ObjIsBox(pNode) )
1488  pFanin = Abc_ObjFanin0(pFanin);
1489  pFanin = Abc_ObjFanin0Ntk(pFanin);
1490  if ( Abc_ObjIsBo(pFanin) )
1491  pFanin = Abc_ObjFanin0(pFanin);
1492  // check if the fanin is visited
1493  if ( Abc_ObjIsPi(pFanin) || Abc_ObjIsLatch(pFanin) || Abc_ObjIsBlackbox(pFanin) )
1494  continue;
1495  assert( Abc_ObjIsNode(pFanin) || Abc_ObjIsBox(pFanin) );
1496  if ( Abc_NodeIsTravIdPrevious(pFanin) )
1497  continue;
1498  // traverse the fanin's cone searching for the loop
1499  if ( (fAcyclic = Abc_NtkIsAcyclicWithBoxes_rec(pFanin)) )
1500  continue;
1501  // return as soon as the loop is detected
1502  fprintf( stdout, " %s ->", Abc_ObjName( Abc_ObjIsBox(pFanin) ? pFanin : Abc_ObjFanout0(pFanin) ) );
1503  return 0;
1504  }
1505  // mark this node as a visited node
1506  assert( Abc_ObjIsNode(pNode) || Abc_ObjIsBox(pNode) );
1507  Abc_NodeSetTravIdPrevious( pNode );
1508  return 1;
1509 }
static int Abc_ObjIsBo(Abc_Obj_t *pObj)
Definition: abc.h:350
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static void Abc_NodeSetTravIdPrevious(Abc_Obj_t *p)
Definition: abc.h:410
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
Definition: abc.h:347
static int Abc_NodeIsTravIdPrevious(Abc_Obj_t *p)
Definition: abc.h:412
int Abc_NtkIsAcyclicWithBoxes_rec(Abc_Obj_t *pNode)
Definition: abcDfs.c:1461
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
Abc_Ntk_t * pNtk
Definition: abc.h:130
static char * Abc_NtkName(Abc_Ntk_t *pNtk)
Definition: abc.h:270
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjIsBox(Abc_Obj_t *pObj)
Definition: abc.h:357
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
static int Abc_ObjIsBlackbox(Abc_Obj_t *pObj)
Definition: abc.h:359
int Abc_NtkIsDfsOrdered ( Abc_Ntk_t pNtk)

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

Synopsis [Returns 1 if the ordering of nodes is DFS.]

Description []

SideEffects []

SeeAlso []

Definition at line 667 of file abcDfs.c.

668 {
669  Abc_Obj_t * pNode, * pFanin;
670  int i, k;
671  // set the traversal ID
672  Abc_NtkIncrementTravId( pNtk );
673  // mark the CIs
674  Abc_NtkForEachCi( pNtk, pNode, i )
675  Abc_NodeSetTravIdCurrent( pNode );
676  // go through the nodes
677  Abc_NtkForEachNode( pNtk, pNode, i )
678  {
679  // check the fanins of the node
680  Abc_ObjForEachFanin( pNode, pFanin, k )
681  if ( !Abc_NodeIsTravIdCurrent(pFanin) )
682  return 0;
683  // check the choices of the node
684  if ( Abc_NtkIsStrash(pNtk) && Abc_AigNodeIsChoice(pNode) )
685  for ( pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
686  if ( !Abc_NodeIsTravIdCurrent(pFanin) )
687  return 0;
688  // mark the node as visited
689  Abc_NodeSetTravIdCurrent( pNode );
690  }
691  return 1;
692 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
for(p=first;p->value< newval;p=p->next)
if(last==0)
Definition: sparse_int.h:34
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
static int Abc_AigNodeIsChoice(Abc_Obj_t *pNode)
Definition: abc.h:398
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
int Abc_NtkLevel ( Abc_Ntk_t pNtk)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1265 of file abcDfs.c.

1266 {
1267  Abc_Obj_t * pNode;
1268  int i, LevelsMax;
1269  // set the CI levels
1270  if ( pNtk->pManTime == NULL || pNtk->AndGateDelay <= 0 )
1271  Abc_NtkForEachCi( pNtk, pNode, i )
1272  pNode->Level = 0;
1273  else
1274  Abc_NtkForEachCi( pNtk, pNode, i )
1275  pNode->Level = (int)(Abc_NodeReadArrivalWorst(pNode) / pNtk->AndGateDelay);
1276  // perform the traversal
1277  LevelsMax = 0;
1278  Abc_NtkIncrementTravId( pNtk );
1279  if ( pNtk->nBarBufs == 0 )
1280  {
1281  Abc_NtkForEachNode( pNtk, pNode, i )
1282  {
1283  Abc_NtkLevel_rec( pNode );
1284  if ( LevelsMax < (int)pNode->Level )
1285  LevelsMax = (int)pNode->Level;
1286  }
1287  }
1288  else
1289  {
1290  Abc_NtkForEachLiPo( pNtk, pNode, i )
1291  {
1292  Abc_Obj_t * pDriver = Abc_ObjFanin0(pNode);
1293  Abc_NtkLevel_rec( pDriver );
1294  if ( LevelsMax < (int)pDriver->Level )
1295  LevelsMax = (int)pDriver->Level;
1296  // transfer the delay
1297  if ( i < pNtk->nBarBufs )
1298  Abc_ObjFanout0(Abc_ObjFanout0(pNode))->Level = pDriver->Level;
1299  }
1300  }
1301  return LevelsMax;
1302 }
float AndGateDelay
Definition: abc.h:194
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
unsigned Level
Definition: abc.h:142
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
ABC_DLL float Abc_NodeReadArrivalWorst(Abc_Obj_t *pNode)
Definition: abcTiming.c:95
#define Abc_NtkForEachLiPo(pNtk, pCo, i)
Definition: abc.h:521
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
Abc_ManTime_t * pManTime
Definition: abc.h:192
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
int Abc_NtkLevel_rec(Abc_Obj_t *pNode)
Definition: abcDfs.c:1163
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
int Abc_NtkLevel_rec ( Abc_Obj_t pNode)

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

Synopsis [Recursively counts the number of logic levels of one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 1163 of file abcDfs.c.

1164 {
1165  Abc_Obj_t * pNext;
1166  int i, Level;
1167  assert( !Abc_ObjIsNet(pNode) );
1168  // skip the PI
1169  if ( Abc_ObjIsCi(pNode) )
1170  return pNode->Level;
1171  assert( Abc_ObjIsNode( pNode ) || pNode->Type == ABC_OBJ_CONST1);
1172  // if this node is already visited, return
1173  if ( Abc_NodeIsTravIdCurrent( pNode ) )
1174  return pNode->Level;
1175  // mark the node as visited
1176  Abc_NodeSetTravIdCurrent( pNode );
1177  // visit the transitive fanin
1178  pNode->Level = 0;
1179  Abc_ObjForEachFanin( pNode, pNext, i )
1180  {
1181  Level = Abc_NtkLevel_rec( Abc_ObjFanin0Ntk(pNext) );
1182  if ( pNode->Level < (unsigned)Level )
1183  pNode->Level = Level;
1184  }
1185  if ( Abc_ObjFaninNum(pNode) > 0 && !Abc_ObjIsBarBuf(pNode) )
1186  pNode->Level++;
1187  return pNode->Level;
1188 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjIsBarBuf(Abc_Obj_t *pObj)
Definition: abc.h:360
unsigned Type
Definition: abc.h:133
unsigned Level
Definition: abc.h:142
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
int Abc_NtkLevel_rec(Abc_Obj_t *pNode)
Definition: abcDfs.c:1163
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Vec_t* Abc_NtkLevelize ( Abc_Ntk_t pNtk)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1239 of file abcDfs.c.

1240 {
1241  Abc_Obj_t * pObj;
1242  Vec_Vec_t * vLevels;
1243  int nLevels, i;
1244  nLevels = Abc_NtkLevel( pNtk );
1245  vLevels = Vec_VecStart( nLevels + 1 );
1246  Abc_NtkForEachNode( pNtk, pObj, i )
1247  {
1248  assert( (int)pObj->Level <= nLevels );
1249  Vec_VecPush( vLevels, pObj->Level, pObj );
1250  }
1251  return vLevels;
1252 }
static void Vec_VecPush(Vec_Vec_t *p, int Level, void *Entry)
Definition: vecVec.h:456
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
unsigned Level
Definition: abc.h:142
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define assert(ex)
Definition: util_old.h:213
int Abc_NtkLevelReverse ( Abc_Ntk_t pNtk)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 1315 of file abcDfs.c.

1316 {
1317  Abc_Obj_t * pNode;
1318  int i, LevelsMax;
1319  // set the CO levels to zero
1320  Abc_NtkForEachCo( pNtk, pNode, i )
1321  pNode->Level = 0;
1322  // perform the traversal
1323  LevelsMax = 0;
1324  Abc_NtkIncrementTravId( pNtk );
1325  Abc_NtkForEachNode( pNtk, pNode, i )
1326  {
1327  Abc_NtkLevelReverse_rec( pNode );
1328  if ( LevelsMax < (int)pNode->Level )
1329  LevelsMax = (int)pNode->Level;
1330  }
1331  return LevelsMax;
1332 }
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Abc_NtkLevelReverse_rec(Abc_Obj_t *pNode)
Definition: abcDfs.c:1201
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
int Abc_NtkLevelReverse_rec ( Abc_Obj_t pNode)

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

Synopsis [Recursively counts the number of logic levels of one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 1201 of file abcDfs.c.

1202 {
1203  Abc_Obj_t * pNext;
1204  int i, Level;
1205  assert( !Abc_ObjIsNet(pNode) );
1206  // skip the PI
1207  if ( Abc_ObjIsCo(pNode) )
1208  return pNode->Level;
1209  assert( Abc_ObjIsNode( pNode ) || pNode->Type == ABC_OBJ_CONST1);
1210  // if this node is already visited, return
1211  if ( Abc_NodeIsTravIdCurrent( pNode ) )
1212  return pNode->Level;
1213  // mark the node as visited
1214  Abc_NodeSetTravIdCurrent( pNode );
1215  // visit the transitive fanin
1216  pNode->Level = 0;
1217  Abc_ObjForEachFanout( pNode, pNext, i )
1218  {
1219  Level = Abc_NtkLevelReverse_rec( Abc_ObjFanout0Ntk(pNext) );
1220  if ( pNode->Level < (unsigned)Level )
1221  pNode->Level = Level;
1222  }
1223  if ( Abc_ObjFaninNum(pNode) > 0 && !Abc_ObjIsBarBuf(pNode) )
1224  pNode->Level++;
1225  return pNode->Level;
1226 }
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjIsBarBuf(Abc_Obj_t *pObj)
Definition: abc.h:360
unsigned Type
Definition: abc.h:133
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
static Abc_Obj_t * Abc_ObjFanout0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:376
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
int Abc_NtkLevelReverse_rec(Abc_Obj_t *pNode)
Definition: abcDfs.c:1201
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
Vec_Ptr_t* Abc_NtkNodeSupport ( Abc_Ntk_t pNtk,
Abc_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 859 of file abcDfs.c.

860 {
861  Vec_Ptr_t * vNodes;
862  int i;
863  // set the traversal ID
864  Abc_NtkIncrementTravId( pNtk );
865  // start the array of nodes
866  vNodes = Vec_PtrAlloc( 100 );
867  // go through the PO nodes and call for each of them
868  for ( i = 0; i < nNodes; i++ )
869  if ( Abc_ObjIsCo(ppNodes[i]) )
870  Abc_NtkNodeSupport_rec( Abc_ObjFanin0(ppNodes[i]), vNodes );
871  else
872  Abc_NtkNodeSupport_rec( ppNodes[i], vNodes );
873  return vNodes;
874 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
void Abc_NtkNodeSupport_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:795
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_NtkNodeSupport_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vNodes 
)

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

Synopsis [Performs DFS for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 795 of file abcDfs.c.

796 {
797  Abc_Obj_t * pFanin;
798  int i;
799  assert( !Abc_ObjIsNet(pNode) );
800  // if this node is already visited, skip
801  if ( Abc_NodeIsTravIdCurrent( pNode ) )
802  return;
803  // mark the node as visited
804  Abc_NodeSetTravIdCurrent( pNode );
805  // collect the CI
806  if ( Abc_ObjIsCi(pNode) || (Abc_NtkIsStrash(pNode->pNtk) && Abc_ObjFaninNum(pNode) == 0) )
807  {
808  Vec_PtrPush( vNodes, pNode );
809  return;
810  }
811  assert( Abc_ObjIsNode( pNode ) );
812  // visit the transitive fanin of the node
813  Abc_ObjForEachFanin( pNode, pFanin, i )
814  Abc_NtkNodeSupport_rec( Abc_ObjFanin0Ntk(pFanin), vNodes );
815 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
void Abc_NtkNodeSupport_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:795
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
Abc_Ntk_t * pNtk
Definition: abc.h:130
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static int Abc_ObjIsNet(Abc_Obj_t *pObj)
Definition: abc.h:354
#define assert(ex)
Definition: util_old.h:213
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
int Abc_NtkPrintSubraphSizes ( Abc_Ntk_t pNtk)

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

Synopsis [Prints subgraphs.]

Description []

SideEffects []

SeeAlso []

Definition at line 1707 of file abcDfs.c.

1708 {
1709  Abc_Obj_t * pObj;
1710  int i;
1711  assert( Abc_NtkIsStrash(pNtk) );
1712  Abc_NtkForEachNode( pNtk, pObj, i )
1713  if ( Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsExorType(pObj) )
1714  printf( "%d(%d) ", 1 + Abc_ObjSugraphSize(Abc_ObjFanin0(pObj)) +
1716  printf( "\n" );
1717  return 1;
1718 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
if(last==0)
Definition: sparse_int.h:34
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Abc_ObjSugraphSize(Abc_Obj_t *pObj)
Definition: abcDfs.c:1686
#define assert(ex)
Definition: util_old.h:213
ABC_DLL int Abc_NodeIsExorType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1259
Vec_Ptr_t* Abc_NtkSupport ( Abc_Ntk_t pNtk)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 828 of file abcDfs.c.

829 {
830  Vec_Ptr_t * vNodes;
831  Abc_Obj_t * pNode;
832  int i;
833  // set the traversal ID
834  Abc_NtkIncrementTravId( pNtk );
835  // start the array of nodes
836  vNodes = Vec_PtrAlloc( 100 );
837  // go through the PO nodes and call for each of them
838  Abc_NtkForEachCo( pNtk, pNode, i )
839  Abc_NtkNodeSupport_rec( Abc_ObjFanin0(pNode), vNodes );
840  // add unused CIs
841  Abc_NtkForEachCi( pNtk, pNode, i )
842  if ( !Abc_NodeIsTravIdCurrent( pNode ) )
843  Vec_PtrPush( vNodes, pNode );
844  assert( Vec_PtrSize(vNodes) == Abc_NtkCiNum(pNtk) );
845  return vNodes;
846 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
void Abc_NtkNodeSupport_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcDfs.c:795
if(last==0)
Definition: sparse_int.h:34
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
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
#define assert(ex)
Definition: util_old.h:213
void Abc_NtkSupportSum ( Abc_Ntk_t pNtk)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 952 of file abcDfs.c.

953 {
954  Vec_Ptr_t * vSupp;
955  Abc_Obj_t * pObj;
956  int i, nTotalSupps = 0;
957  Abc_NtkForEachCo( pNtk, pObj, i )
958  {
959  vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
960  nTotalSupps += Vec_PtrSize( vSupp );
961  Vec_PtrFree( vSupp );
962  }
963  printf( "Total supports = %d.\n", nTotalSupps );
964 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:859
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_NtkSuppSizeTest ( Abc_Ntk_t p)

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

Synopsis [Computes support size of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 928 of file abcDfs.c.

929 {
930  Abc_Obj_t * pObj;
931  int i, Counter = 0;
932  abctime clk = Abc_Clock();
933  Abc_NtkForEachObj( p, pObj, i )
934  if ( Abc_ObjIsNode(pObj) )
935  Counter += (Abc_ObjSuppSize(pObj) <= 16);
936  printf( "Nodes with small support %d (out of %d)\n", Counter, Abc_NtkNodeNum(p) );
937  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
938  return Counter;
939 }
static abctime Abc_Clock()
Definition: abc_global.h:279
int Abc_ObjSuppSize(Abc_Obj_t *pObj)
Definition: abcDfs.c:912
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
if(last==0)
Definition: sparse_int.h:34
static int Counter
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
int Abc_ObjSugraphSize ( Abc_Obj_t pObj)

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

Synopsis [Count the number of nodes in the subgraph.]

Description []

SideEffects []

SeeAlso []

Definition at line 1686 of file abcDfs.c.

1687 {
1688  if ( Abc_ObjIsCi(pObj) )
1689  return 0;
1690  if ( Abc_ObjFanoutNum(pObj) > 1 )
1691  return 0;
1692  return 1 + Abc_ObjSugraphSize(Abc_ObjFanin0(pObj)) +
1694 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
int Abc_ObjSugraphSize(Abc_Obj_t *pObj)
Definition: abcDfs.c:1686
int Abc_ObjSuppSize ( Abc_Obj_t pObj)

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

Synopsis [Computes support size of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 912 of file abcDfs.c.

913 {
915  return Abc_ObjSuppSize_rec( pObj );
916 }
int Abc_ObjSuppSize_rec(Abc_Obj_t *pObj)
Definition: abcDfs.c:887
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
static Abc_Ntk_t * Abc_ObjNtk(Abc_Obj_t *pObj)
Definition: abc.h:334
int Abc_ObjSuppSize_rec ( Abc_Obj_t pObj)

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

Synopsis [Computes support size of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 887 of file abcDfs.c.

888 {
889  Abc_Obj_t * pFanin;
890  int i, Counter = 0;
891  if ( Abc_NodeIsTravIdCurrent(pObj) )
892  return 0;
894  if ( Abc_ObjIsPi(pObj) )
895  return 1;
896  assert( Abc_ObjIsNode(pObj) || Abc_ObjIsBox(pObj) );
897  Abc_ObjForEachFanin( pObj, pFanin, i )
898  Counter += Abc_ObjSuppSize_rec( pFanin );
899  return Counter;
900 }
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
Definition: abc.h:347
int Abc_ObjSuppSize_rec(Abc_Obj_t *pObj)
Definition: abcDfs.c:887
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Counter
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjIsBox(Abc_Obj_t *pObj)
Definition: abc.h:357
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409