1 /**CFile****************************************************************
2
3 FileName [fpgaFanout.c]
4
5 PackageName [FRAIG: Functionally reduced AND-INV graphs.]
6
7 Synopsis [Procedures to manipulate fanouts of the FRAIG nodes.]
8
9 Author [Alan Mishchenko <alanmi@eecs.berkeley.edu>]
10
11 Affiliation [UC Berkeley]
12
13 Date [Ver. 2.0. Started - August 18, 2004.]
14
15 Revision [$Id: fpgaFanout.c,v 1.1 2005/01/23 06:59:41 alanmi Exp $]
16
17 ***********************************************************************/
18
19 #include "fpgaInt.h"
20
21 ABC_NAMESPACE_IMPL_START
22
23
24 #ifdef MAP_ALLOCATE_FANOUT
25
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33
34 /**Function*************************************************************
35
36 Synopsis [Add the fanout to the node.]
37
38 Description []
39
40 SideEffects []
41
42 SeeAlso []
43
44 ***********************************************************************/
Fpga_NodeAddFaninFanout(Fpga_Node_t * pFanin,Fpga_Node_t * pFanout)45 void Fpga_NodeAddFaninFanout( Fpga_Node_t * pFanin, Fpga_Node_t * pFanout )
46 {
47 Fpga_Node_t * pPivot;
48
49 // pFanins is a fanin of pFanout
50 assert( !Fpga_IsComplement(pFanin) );
51 assert( !Fpga_IsComplement(pFanout) );
52 assert( Fpga_Regular(pFanout->p1) == pFanin || Fpga_Regular(pFanout->p2) == pFanin );
53
54 pPivot = pFanin->pFanPivot;
55 if ( pPivot == NULL )
56 {
57 pFanin->pFanPivot = pFanout;
58 return;
59 }
60
61 if ( Fpga_Regular(pPivot->p1) == pFanin )
62 {
63 if ( Fpga_Regular(pFanout->p1) == pFanin )
64 {
65 pFanout->pFanFanin1 = pPivot->pFanFanin1;
66 pPivot->pFanFanin1 = pFanout;
67 }
68 else // if ( Fpga_Regular(pFanout->p2) == pFanin )
69 {
70 pFanout->pFanFanin2 = pPivot->pFanFanin1;
71 pPivot->pFanFanin1 = pFanout;
72 }
73 }
74 else // if ( Fpga_Regular(pPivot->p2) == pFanin )
75 {
76 assert( Fpga_Regular(pPivot->p2) == pFanin );
77 if ( Fpga_Regular(pFanout->p1) == pFanin )
78 {
79 pFanout->pFanFanin1 = pPivot->pFanFanin2;
80 pPivot->pFanFanin2 = pFanout;
81 }
82 else // if ( Fpga_Regular(pFanout->p2) == pFanin )
83 {
84 pFanout->pFanFanin2 = pPivot->pFanFanin2;
85 pPivot->pFanFanin2 = pFanout;
86 }
87 }
88 }
89
90 /**Function*************************************************************
91
92 Synopsis [Add the fanout to the node.]
93
94 Description []
95
96 SideEffects []
97
98 SeeAlso []
99
100 ***********************************************************************/
Fpga_NodeRemoveFaninFanout(Fpga_Node_t * pFanin,Fpga_Node_t * pFanoutToRemove)101 void Fpga_NodeRemoveFaninFanout( Fpga_Node_t * pFanin, Fpga_Node_t * pFanoutToRemove )
102 {
103 Fpga_Node_t * pFanout, * pFanout2, ** ppFanList;
104 // start the linked list of fanouts
105 ppFanList = &pFanin->pFanPivot;
106 // go through the fanouts
107 Fpga_NodeForEachFanoutSafe( pFanin, pFanout, pFanout2 )
108 {
109 // skip the fanout-to-remove
110 if ( pFanout == pFanoutToRemove )
111 continue;
112 // add useful fanouts to the list
113 *ppFanList = pFanout;
114 ppFanList = Fpga_NodeReadNextFanoutPlace( pFanin, pFanout );
115 }
116 *ppFanList = NULL;
117 }
118
119 /**Function*************************************************************
120
121 Synopsis [Returns the number of fanouts of a node.]
122
123 Description []
124
125 SideEffects []
126
127 SeeAlso []
128
129 ***********************************************************************/
Fpga_NodeGetFanoutNum(Fpga_Node_t * pNode)130 int Fpga_NodeGetFanoutNum( Fpga_Node_t * pNode )
131 {
132 Fpga_Node_t * pFanout;
133 int Counter = 0;
134 Fpga_NodeForEachFanout( pNode, pFanout )
135 Counter++;
136 return Counter;
137 }
138
139 ////////////////////////////////////////////////////////////////////////
140 /// END OF FILE ///
141 ////////////////////////////////////////////////////////////////////////
142
143 #endif
144
145 ABC_NAMESPACE_IMPL_END
146
147