summaryrefslogtreecommitdiffstats
path: root/src/aig/ntk/ntkDfs.c
blob: ce176898eb97ddeac023c5fc209bb9b400ca69d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**CFile****************************************************************

  FileName    [ntkDfs.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Netlist representation.]

  Synopsis    [DFS traversals.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

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

  Revision    [$Id: ntkDfs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

***********************************************************************/

#include "ntk.h"

////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

  Synopsis    [Performs DFS for one node.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Ntk_ManDfs_rec( Ntk_Obj_t * pNode, Vec_Ptr_t * vNodes )
{
    Ntk_Obj_t * pNext;
    int i;
    if ( Ntk_ObjIsTravIdCurrent( pNode ) )
        return;
    Ntk_ObjSetTravIdCurrent( pNode );
    Ntk_ObjForEachFanin( pNode, pNext, i )
        Ntk_ManDfs_rec( pNext, vNodes );
    Vec_PtrPush( vNodes, pNode );
}

/**Function*************************************************************

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

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Vec_Ptr_t * Ntk_ManDfs( Ntk_Man_t * pNtk )
{
    Vec_Ptr_t * vNodes;
    Ntk_Obj_t * pObj;
    int i;
    Ntk_ManIncrementTravId( pNtk );
    vNodes = Vec_PtrAlloc( 100 );
    Ntk_ManForEachPo( pNtk, pObj, i )
        Ntk_ManDfs_rec( pObj, vNodes );
    return vNodes;
}

/**Function*************************************************************

  Synopsis    [Performs DFS for one node.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Ntk_ManDfsReverse_rec( Ntk_Obj_t * pNode, Vec_Ptr_t * vNodes )
{
    Ntk_Obj_t * pNext;
    int i;
    if ( Ntk_ObjIsTravIdCurrent( pNode ) )
        return;
    Ntk_ObjSetTravIdCurrent( pNode );
    Ntk_ObjForEachFanout( pNode, pNext, i )
        Ntk_ManDfsReverse_rec( pNext, vNodes );
    Vec_PtrPush( vNodes, pNode );
}

/**Function*************************************************************

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

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Vec_Ptr_t * Ntk_ManDfsReverse( Ntk_Man_t * pNtk )
{
    Vec_Ptr_t * vNodes;
    Ntk_Obj_t * pObj;
    int i;
    Ntk_ManIncrementTravId( pNtk );
    vNodes = Vec_PtrAlloc( 100 );
    Ntk_ManForEachPi( pNtk, pObj, i )
        Ntk_ManDfsReverse_rec( pObj, vNodes );
    return vNodes;
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////