ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
mapperSwitch.c
Go to the documentation of this file.
1
18
19#include "mapperInt.h"
20
22
23
27
28static float Map_SwitchCutRefDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase, int fReference );
29
33
45float Map_SwitchCutGetDerefed( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
46{
47 float aResult, aResult2;
48// assert( pNode->Switching > 0 );
49 aResult2 = Map_SwitchCutRefDeref( pNode, pCut, fPhase, 1 ); // reference
50 aResult = Map_SwitchCutRefDeref( pNode, pCut, fPhase, 0 ); // dereference
51// assert( aResult == aResult2 );
52 return aResult;
53}
54
66float Map_SwitchCutRef( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
67{
68 return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 1 ); // reference
69}
70
82float Map_SwitchCutDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
83{
84 return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 0 ); // dereference
85}
86
99float Map_SwitchCutRefDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase, int fReference )
100{
101 Map_Node_t * pNodeChild;
102 Map_Cut_t * pCutChild;
103 float aSwitchActivity;
104 int i, fPhaseChild;
105
106 // start switching activity for the node
107 aSwitchActivity = pNode->Switching;
108 // consider the elementary variable
109 if ( pCut->nLeaves == 1 )
110 return aSwitchActivity;
111
112 // go through the children
113 assert( pCut->M[fPhase].pSuperBest );
114 for ( i = 0; i < pCut->nLeaves; i++ )
115 {
116 pNodeChild = pCut->ppLeaves[i];
117 fPhaseChild = Map_CutGetLeafPhase( pCut, fPhase, i );
118 // get the reference counter of the child
119
120 if ( fReference )
121 {
122 if ( pNodeChild->pCutBest[0] && pNodeChild->pCutBest[1] ) // both phases are present
123 {
124 // if this phase of the node is referenced, there is no recursive call
125 pNodeChild->nRefAct[2]++;
126 if ( pNodeChild->nRefAct[fPhaseChild]++ > 0 )
127 continue;
128 }
129 else // only one phase is present
130 {
131 // inverter should be added if the phase
132 // (a) has no reference and (b) is implemented using other phase
133 if ( pNodeChild->nRefAct[fPhaseChild]++ == 0 && pNodeChild->pCutBest[fPhaseChild] == NULL )
134 aSwitchActivity += pNodeChild->Switching; // inverter switches the same as the node
135 // if the node is referenced, there is no recursive call
136 if ( pNodeChild->nRefAct[2]++ > 0 )
137 continue;
138 }
139 }
140 else
141 {
142 if ( pNodeChild->pCutBest[0] && pNodeChild->pCutBest[1] ) // both phases are present
143 {
144 // if this phase of the node is referenced, there is no recursive call
145 --pNodeChild->nRefAct[2];
146 if ( --pNodeChild->nRefAct[fPhaseChild] > 0 )
147 continue;
148 }
149 else // only one phase is present
150 {
151 // inverter should be added if the phase
152 // (a) has no reference and (b) is implemented using other phase
153 if ( --pNodeChild->nRefAct[fPhaseChild] == 0 && pNodeChild->pCutBest[fPhaseChild] == NULL )
154 aSwitchActivity += pNodeChild->Switching; // inverter switches the same as the node
155 // if the node is referenced, there is no recursive call
156 if ( --pNodeChild->nRefAct[2] > 0 )
157 continue;
158 }
159 assert( pNodeChild->nRefAct[fPhaseChild] >= 0 );
160 }
161
162 // get the child cut
163 pCutChild = pNodeChild->pCutBest[fPhaseChild];
164 // if the child does not have this phase mapped, take the opposite phase
165 if ( pCutChild == NULL )
166 {
167 fPhaseChild = !fPhaseChild;
168 pCutChild = pNodeChild->pCutBest[fPhaseChild];
169 }
170 // reference and compute area recursively
171 aSwitchActivity += Map_SwitchCutRefDeref( pNodeChild, pCutChild, fPhaseChild, fReference );
172 }
173 return aSwitchActivity;
174}
175
188{
189 Map_Node_t * pNode;
190 float Switch = 0.0;
191 int i;
192 for ( i = 0; i < pMan->vMapObjs->nSize; i++ )
193 {
194 pNode = pMan->vMapObjs->pArray[i];
195 if ( pNode->nRefAct[2] == 0 )
196 continue;
197 // at least one phase has the best cut assigned
198 assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL );
199 // at least one phase is used in the mapping
200 assert( pNode->nRefAct[0] > 0 || pNode->nRefAct[1] > 0 );
201 // compute the array due to the supergate
202 if ( Map_NodeIsAnd(pNode) )
203 {
204 // count switching of the negative phase
205 if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) )
206 Switch += pNode->Switching;
207 // count switching of the positive phase
208 if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) )
209 Switch += pNode->Switching;
210 }
211 // count switching of the interver if we need to implement one phase with another phase
212 if ( (pNode->pCutBest[0] == NULL && pNode->nRefAct[0] > 0) ||
213 (pNode->pCutBest[1] == NULL && pNode->nRefAct[1] > 0) )
214 Switch += pNode->Switching; // inverter switches the same as the node
215 }
216 // add buffers for each CO driven by a CI
217 for ( i = 0; i < pMan->nOutputs; i++ )
218 if ( Map_NodeIsVar(pMan->pOutputs[i]) && !Map_IsComplement(pMan->pOutputs[i]) )
219 Switch += pMan->pOutputs[i]->Switching;
220 return Switch;
221}
222
226
227
229
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
int Map_CutGetLeafPhase(Map_Cut_t *pCut, int fPhase, int iLeaf)
float Map_SwitchCutRef(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
float Map_SwitchCutGetDerefed(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
FUNCTION DEFINITIONS ///.
float Map_SwitchCutDeref(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
float Map_MappingGetSwitching(Map_Man_t *pMan)
typedefABC_NAMESPACE_HEADER_START struct Map_ManStruct_t_ Map_Man_t
INCLUDES ///.
Definition mapper.h:40
struct Map_CutStruct_t_ Map_Cut_t
Definition mapper.h:43
int Map_NodeIsVar(Map_Node_t *p)
int Map_NodeIsAnd(Map_Node_t *p)
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition mapper.h:67
struct Map_NodeStruct_t_ Map_Node_t
Definition mapper.h:41
Map_Match_t M[2]
Definition mapperInt.h:275
Map_Node_t * ppLeaves[6]
Definition mapperInt.h:269
Map_Super_t * pSuperBest
Definition mapperInt.h:257
Map_Cut_t * pCutBest[2]
Definition mapperInt.h:243
#define assert(ex)
Definition util_old.h:213