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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START float 
Map_SwitchCutRefDeref (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, int fReference)
 DECLARATIONS ///. More...
 
float Map_SwitchCutGetDerefed (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
 FUNCTION DEFINITIONS ///. More...
 
float Map_SwitchCutRef (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
 
float Map_SwitchCutDeref (Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
 
float Map_MappingGetSwitching (Map_Man_t *pMan)
 

Function Documentation

float Map_MappingGetSwitching ( Map_Man_t pMan)

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

Synopsis [Computes the array of mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file mapperSwitch.c.

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 }
int Map_NodeIsAnd(Map_Node_t *p)
Definition: mapperCreate.c:115
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: mapper.h:67
int Map_NodeIsVar(Map_Node_t *p)
Definition: mapperCreate.c:113
#define assert(ex)
Definition: util_old.h:213
float Map_SwitchCutDeref ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase 
)

function*************************************************************

synopsis [References the cut.]

description []

sideeffects []

seealso []

Definition at line 82 of file mapperSwitch.c.

83 {
84  return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 0 ); // dereference
85 }
static ABC_NAMESPACE_IMPL_START float Map_SwitchCutRefDeref(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, int fReference)
DECLARATIONS ///.
Definition: mapperSwitch.c:99
float Map_SwitchCutGetDerefed ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase 
)

FUNCTION DEFINITIONS ///.

function*************************************************************

synopsis [Computes the exact area associated with the cut.]

description []

sideeffects []

seealso []

Definition at line 45 of file mapperSwitch.c.

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 }
static ABC_NAMESPACE_IMPL_START float Map_SwitchCutRefDeref(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, int fReference)
DECLARATIONS ///.
Definition: mapperSwitch.c:99
float Map_SwitchCutRef ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase 
)

function*************************************************************

synopsis [References the cut.]

description []

sideeffects []

seealso []

Definition at line 66 of file mapperSwitch.c.

67 {
68  return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 1 ); // reference
69 }
static ABC_NAMESPACE_IMPL_START float Map_SwitchCutRefDeref(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, int fReference)
DECLARATIONS ///.
Definition: mapperSwitch.c:99
float Map_SwitchCutRefDeref ( Map_Node_t pNode,
Map_Cut_t pCut,
int  fPhase,
int  fReference 
)
static

DECLARATIONS ///.

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

FileName [mapperSwitch.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [Generic technology mapping engine.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 8, 2003.]

Revision [

Id:
mapperSwitch.h,v 1.0 2003/09/08 00:00:00 alanmi Exp

]

function*************************************************************

synopsis [References or dereferences the cut.]

description [This reference part is similar to Cudd_NodeReclaim(). The dereference part is similar to Cudd_RecursiveDeref().]

sideeffects []

seealso []

Definition at line 99 of file mapperSwitch.c.

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 }
Map_Cut_t * pCutBest[2]
Definition: mapperInt.h:239
Map_Super_t * pSuperBest
Definition: mapperInt.h:253
int Map_CutGetLeafPhase(Map_Cut_t *pCut, int fPhase, int iLeaf)
static ABC_NAMESPACE_IMPL_START float Map_SwitchCutRefDeref(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase, int fReference)
DECLARATIONS ///.
Definition: mapperSwitch.c:99
#define assert(ex)
Definition: util_old.h:213
Map_Match_t M[2]
Definition: mapperInt.h:271
Map_Node_t * ppLeaves[6]
Definition: mapperInt.h:265