From 33012d9530c40817e1fc5230b3e663f7690b2e94 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 4 Sep 2005 08:01:00 -0700 Subject: Version abc50904 --- src/map/mapper/mapper.h | 2 + src/map/mapper/mapperCore.c | 83 ++++++++++++--- src/map/mapper/mapperCreate.c | 6 +- src/map/mapper/mapperInt.h | 8 ++ src/map/mapper/mapperLib.c | 1 + src/map/mapper/mapperMatch.c | 34 ++++-- src/map/mapper/mapperRefs.c | 9 +- src/map/mapper/mapperSwitch.c | 243 ++++++++++++++++++++++++++++++++++++++++++ src/map/mapper/module.make | 1 + 9 files changed, 357 insertions(+), 30 deletions(-) create mode 100644 src/map/mapper/mapperSwitch.c (limited to 'src/map/mapper') diff --git a/src/map/mapper/mapper.h b/src/map/mapper/mapper.h index 1322cdfa..c3f1ce81 100644 --- a/src/map/mapper/mapper.h +++ b/src/map/mapper/mapper.h @@ -101,6 +101,7 @@ extern void Map_ManSetFanoutViolations( Map_Man_t * p, int nVio ); extern void Map_ManSetChoiceNodeNum( Map_Man_t * p, int nChoiceNodes ); extern void Map_ManSetChoiceNum( Map_Man_t * p, int nChoices ); extern void Map_ManSetVerbose( Map_Man_t * p, int fVerbose ); +extern void Map_ManSetSwitching( Map_Man_t * p, int fSwitching ); extern Map_Man_t * Map_NodeReadMan( Map_Node_t * p ); extern char * Map_NodeReadData( Map_Node_t * p, int fPhase ); @@ -113,6 +114,7 @@ extern Map_Node_t * Map_NodeReadTwo( Map_Node_t * p ); extern void Map_NodeSetData( Map_Node_t * p, int fPhase, char * pData ); extern void Map_NodeSetNextE( Map_Node_t * p, Map_Node_t * pNextE ); extern void Map_NodeSetRepr( Map_Node_t * p, Map_Node_t * pRepr ); +extern void Map_NodeSetSwitching( Map_Node_t * p, float Switching ); extern int Map_NodeIsConst( Map_Node_t * p ); extern int Map_NodeIsVar( Map_Node_t * p ); diff --git a/src/map/mapper/mapperCore.c b/src/map/mapper/mapperCore.c index 16cbfd5c..629ba59d 100644 --- a/src/map/mapper/mapperCore.c +++ b/src/map/mapper/mapperCore.c @@ -46,9 +46,10 @@ ***********************************************************************/ int Map_Mapping( Map_Man_t * p ) { + int fShowSwitching = 0; int fUseAreaFlow = 1; - int fUseExactArea = 1; - int fUseExactAreaWithPhase = 1; + int fUseExactArea = !p->fSwitching; + int fUseExactAreaWithPhase = !p->fSwitching; int clk; ////////////////////////////////////////////////////////////////////// @@ -83,8 +84,10 @@ int Map_Mapping( Map_Man_t * p ) p->AreaBase = Map_MappingGetArea( p, p->vMapping ); if ( p->fVerbose ) { -printf( "Delay : Delay = %5.2f Flow = %11.1f Area = %11.1f %4.1f %% ", - p->fRequiredGlo, Map_MappingGetAreaFlow(p), p->AreaBase, 0.0 ); +printf( "Delay : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", + fShowSwitching? "Switch" : "Delay", + fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, + Map_MappingGetAreaFlow(p), p->AreaBase, 0.0 ); PRT( "Time", p->timeMatch ); } ////////////////////////////////////////////////////////////////////// @@ -97,7 +100,7 @@ PRT( "Time", p->timeMatch ); clk = clock(); if ( fUseAreaFlow ) { - // compute the required times and the fanouts + // compute the required times Map_TimeComputeRequiredGlobal( p ); // recover area flow p->fMappingMode = 1; @@ -107,8 +110,10 @@ PRT( "Time", p->timeMatch ); p->AreaFinal = Map_MappingGetArea( p, p->vMapping ); if ( p->fVerbose ) { -printf( "AreaFlow : Delay = %5.2f Flow = %11.1f Area = %11.1f %4.1f %% ", - p->fRequiredGlo, Map_MappingGetAreaFlow(p), p->AreaFinal, +printf( "AreaFlow : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", + fShowSwitching? "Switch" : "Delay", + fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, + Map_MappingGetAreaFlow(p), p->AreaFinal, 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); PRT( "Time", clock() - clk ); } @@ -121,9 +126,9 @@ PRT( "Time", clock() - clk ); clk = clock(); if ( fUseExactArea ) { - // compute the required times and the fanouts + // compute the required times Map_TimeComputeRequiredGlobal( p ); - // recover area flow + // recover area p->fMappingMode = 2; Map_MappingMatches( p ); // compute the references and collect the nodes used in the mapping @@ -131,8 +136,10 @@ PRT( "Time", clock() - clk ); p->AreaFinal = Map_MappingGetArea( p, p->vMapping ); if ( p->fVerbose ) { -printf( "Area : Delay = %5.2f Flow = %11.1f Area = %11.1f %4.1f %% ", - p->fRequiredGlo, 0.0, p->AreaFinal, +printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", + fShowSwitching? "Switch" : "Delay", + fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, + 0.0, p->AreaFinal, 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); PRT( "Time", clock() - clk ); } @@ -145,9 +152,9 @@ PRT( "Time", clock() - clk ); clk = clock(); if ( fUseExactAreaWithPhase ) { - // compute the required times and the fanouts + // compute the required times Map_TimeComputeRequiredGlobal( p ); - // recover area flow + // recover area p->fMappingMode = 3; Map_MappingMatches( p ); // compute the references and collect the nodes used in the mapping @@ -155,8 +162,54 @@ PRT( "Time", clock() - clk ); p->AreaFinal = Map_MappingGetArea( p, p->vMapping ); if ( p->fVerbose ) { -printf( "Area : Delay = %5.2f Flow = %11.1f Area = %11.1f %4.1f %% ", - p->fRequiredGlo, 0.0, p->AreaFinal, +printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", + fShowSwitching? "Switch" : "Delay", + fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, + 0.0, p->AreaFinal, + 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); +PRT( "Time", clock() - clk ); +} + } + p->timeArea += clock() - clk; + ////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////// + // perform area recovery using exact area + clk = clock(); + if ( p->fSwitching ) + { + // compute the required times + Map_TimeComputeRequiredGlobal( p ); + // recover switching activity + p->fMappingMode = 4; + Map_MappingMatches( p ); + // compute the references and collect the nodes used in the mapping + Map_MappingSetRefs( p ); + p->AreaFinal = Map_MappingGetArea( p, p->vMapping ); +if ( p->fVerbose ) +{ +printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", + fShowSwitching? "Switch" : "Delay", + fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, + 0.0, p->AreaFinal, + 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); +PRT( "Time", clock() - clk ); +} + + // compute the required times + Map_TimeComputeRequiredGlobal( p ); + // recover switching activity + p->fMappingMode = 4; + Map_MappingMatches( p ); + // compute the references and collect the nodes used in the mapping + Map_MappingSetRefs( p ); + p->AreaFinal = Map_MappingGetArea( p, p->vMapping ); +if ( p->fVerbose ) +{ +printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", + fShowSwitching? "Switch" : "Delay", + fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, + 0.0, p->AreaFinal, 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); PRT( "Time", clock() - clk ); } diff --git a/src/map/mapper/mapperCreate.c b/src/map/mapper/mapperCreate.c index 738d099c..31fbf0ea 100644 --- a/src/map/mapper/mapperCreate.c +++ b/src/map/mapper/mapperCreate.c @@ -69,6 +69,7 @@ void Map_ManSetFanoutViolations( Map_Man_t * p, int nVio ) { p->nFa void Map_ManSetChoiceNodeNum( Map_Man_t * p, int nChoiceNodes ) { p->nChoiceNodes = nChoiceNodes; } void Map_ManSetChoiceNum( Map_Man_t * p, int nChoices ) { p->nChoices = nChoices; } void Map_ManSetVerbose( Map_Man_t * p, int fVerbose ) { p->fVerbose = fVerbose; } +void Map_ManSetSwitching( Map_Man_t * p, int fSwitching ) { p->fSwitching = fSwitching; } /**Function************************************************************* @@ -90,8 +91,9 @@ Map_Cut_t * Map_NodeReadCutBest( Map_Node_t * p, int fPhase ) { return p Map_Node_t * Map_NodeReadOne( Map_Node_t * p ) { return p->p1; } Map_Node_t * Map_NodeReadTwo( Map_Node_t * p ) { return p->p2; } void Map_NodeSetData( Map_Node_t * p, int fPhase, char * pData ) { if (fPhase) p->pData1 = pData; else p->pData0 = pData; } -void Map_NodeSetNextE( Map_Node_t * p, Map_Node_t * pNextE ) { p->pNextE = pNextE; } -void Map_NodeSetRepr( Map_Node_t * p, Map_Node_t * pRepr ) { p->pRepr = pRepr; } +void Map_NodeSetNextE( Map_Node_t * p, Map_Node_t * pNextE ) { p->pNextE = pNextE; } +void Map_NodeSetRepr( Map_Node_t * p, Map_Node_t * pRepr ) { p->pRepr = pRepr; } +void Map_NodeSetSwitching( Map_Node_t * p, float Switching ) { p->Switching = Switching; } /**Function************************************************************* diff --git a/src/map/mapper/mapperInt.h b/src/map/mapper/mapperInt.h index 7d63a804..0acca56c 100644 --- a/src/map/mapper/mapperInt.h +++ b/src/map/mapper/mapperInt.h @@ -117,6 +117,7 @@ struct Map_ManStruct_t_ bool fObeyFanoutLimits;// Should mapper try to obey fanout limits or not float DelayTarget; // the required times set by the user int nTravIds; // the traversal counter + bool fSwitching; // Should mapper try to obey fanout limits or not // the supergate library Map_SuperLib_t * pSuperLib; // the current supergate library @@ -184,6 +185,7 @@ struct Map_SuperLibStruct_t_ Mio_Gate_t * pGateInv; // the pointer to the intertor gate Map_Time_t tDelayInv; // the delay of the inverter float AreaInv; // the area of the inverter + float AreaBuf; // the area of the buffer Map_Super_t * pSuperInv; // the supergate representing the inverter // the memory manager for the internal table @@ -210,6 +212,7 @@ struct Map_NodeStruct_t_ unsigned NumTemp:10; // the level of the given node int nRefAct[3]; // estimated fanout for current covering phase, neg and pos and sum float nRefEst[3]; // actual fanout for previous covering phase, neg and pos and sum + float Switching; // the probability of switching // connectivity Map_Node_t * p1; // the first child @@ -378,6 +381,11 @@ extern int Map_MappingMatches( Map_Man_t * p ); extern float Map_MappingCombinePhases( Map_Man_t * p ); extern void Map_MatchClean( Map_Match_t * pMatch ); extern int Map_MatchCompare( Map_Man_t * pMan, Map_Match_t * pM1, Map_Match_t * pM2, int fDoingArea ); +/*=== mapperPower.c =============================================================*/ +extern float Map_SwitchCutGetDerefed( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase ); +extern float Map_SwitchCutRef( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase ); +extern float Map_SwitchCutDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase ); +extern float Map_MappingGetSwitching( Map_Man_t * pMan, Map_NodeVec_t * vMapping ); /*=== mapperRefs.c =============================================================*/ extern int Map_NodeReadRefPhaseAct( Map_Node_t * pNode, int fPhase ); extern float Map_NodeReadRefPhaseEst( Map_Node_t * pNode, int fPhase ); diff --git a/src/map/mapper/mapperLib.c b/src/map/mapper/mapperLib.c index f9b280fe..5fea1f00 100644 --- a/src/map/mapper/mapperLib.c +++ b/src/map/mapper/mapperLib.c @@ -102,6 +102,7 @@ if ( fVerbose ) { p->tDelayInv.Fall = Mio_LibraryReadDelayInvFall( p->pGenlib ); p->tDelayInv.Worst = MAP_MAX( p->tDelayInv.Rise, p->tDelayInv.Fall ); p->AreaInv = Mio_LibraryReadAreaInv( p->pGenlib ); + p->AreaBuf = Mio_LibraryReadAreaBuf( p->pGenlib ); // assign the interver supergate p->pSuperInv = (Map_Super_t *)Extra_MmFixedEntryFetch( p->mmSupers ); diff --git a/src/map/mapper/mapperMatch.c b/src/map/mapper/mapperMatch.c index 5b72311c..ddb9ebb7 100644 --- a/src/map/mapper/mapperMatch.c +++ b/src/map/mapper/mapperMatch.c @@ -65,7 +65,7 @@ int Map_MappingMatches( Map_Man_t * p ) Map_Node_t * pNode; int i; - assert( p->fMappingMode >= 0 && p->fMappingMode <= 3 ); + assert( p->fMappingMode >= 0 && p->fMappingMode <= 4 ); // use the externally given PI arrival times if ( p->fMappingMode == 0 ) @@ -158,7 +158,7 @@ int Map_MatchNodePhase( Map_Man_t * p, Map_Node_t * pNode, int fPhase ) // recompute the exact area of the current best match // because the exact area of the fanins may have changed // as a result of remapping fanins in the topological order - if ( p->fMappingMode >= 2 ) + if ( p->fMappingMode == 2 || p->fMappingMode == 3 ) { pMatch = pCutBest->M + fPhase; if ( pNode->nRefAct[fPhase] > 0 || @@ -167,6 +167,15 @@ int Map_MatchNodePhase( Map_Man_t * p, Map_Node_t * pNode, int fPhase ) else pMatch->AreaFlow = Area1 = Map_CutGetAreaDerefed( pCutBest, fPhase ); } + else if ( p->fMappingMode == 4 ) + { + pMatch = pCutBest->M + fPhase; + if ( pNode->nRefAct[fPhase] > 0 || + (pNode->pCutBest[!fPhase] == NULL && pNode->nRefAct[!fPhase] > 0) ) + pMatch->AreaFlow = Area1 = Map_SwitchCutDeref( pNode, pCutBest, fPhase ); + else + pMatch->AreaFlow = Area1 = Map_SwitchCutGetDerefed( pNode, pCutBest, fPhase ); + } // save the old mapping if ( pCutBest ) @@ -210,7 +219,12 @@ int Map_MatchNodePhase( Map_Man_t * p, Map_Node_t * pNode, int fPhase ) (pNode->nRefAct[fPhase] > 0 || (pNode->pCutBest[!fPhase] == NULL && pNode->nRefAct[!fPhase] > 0)) ) { - Area2 = Map_CutRef( pNode->pCutBest[fPhase], fPhase ); + if ( p->fMappingMode == 2 || p->fMappingMode == 3 ) + Area2 = Map_CutRef( pNode->pCutBest[fPhase], fPhase ); + else if ( p->fMappingMode == 4 ) + Area2 = Map_SwitchCutRef( pNode, pNode->pCutBest[fPhase], fPhase ); + else + assert( 0 ); assert( Area2 < Area1 + p->fEpsilon ); } @@ -273,9 +287,11 @@ int Map_MatchNodeCut( Map_Man_t * p, Map_Node_t * pNode, Map_Cut_t * pCut, int f else { // get the area (area flow) - if ( p->fMappingMode >= 2 ) + if ( p->fMappingMode == 2 || p->fMappingMode == 3 ) pMatch->AreaFlow = Map_CutGetAreaDerefed( pCut, fPhase ); - else + else if ( p->fMappingMode == 4 ) + pMatch->AreaFlow = Map_SwitchCutGetDerefed( pNode, pCut, fPhase ); + else pMatch->AreaFlow = Map_CutGetAreaFlow( pCut, fPhase ); // skip if the cut is too large if ( pMatch->AreaFlow > MatchBest.AreaFlow + p->fEpsilon ) @@ -304,9 +320,11 @@ int Map_MatchNodeCut( Map_Man_t * p, Map_Node_t * pNode, Map_Cut_t * pCut, int f if ( pMatch->pSuperBest ) { Map_TimeCutComputeArrival( pNode, pCut, fPhase, MAP_FLOAT_LARGE ); - if ( p->fMappingMode >= 2 ) + if ( p->fMappingMode == 2 || p->fMappingMode == 3 ) pMatch->AreaFlow = Map_CutGetAreaDerefed( pCut, fPhase ); - else + else if ( p->fMappingMode == 4 ) + pMatch->AreaFlow = Map_SwitchCutGetDerefed( pNode, pCut, fPhase ); + else pMatch->AreaFlow = Map_CutGetAreaFlow( pCut, fPhase ); } return 1; @@ -482,7 +500,7 @@ void Map_NodeTryDroppingOnePhase( Map_Man_t * p, Map_Node_t * pNode ) fUsePhase0 = (pNode->tRequired[1].Worst > tWorst1Using0 + 3*p->pSuperLib->tDelayInv.Worst + p->fEpsilon); fUsePhase1 = (pNode->tRequired[0].Worst > tWorst0Using1 + 3*p->pSuperLib->tDelayInv.Worst + p->fEpsilon); } - else if ( p->fMappingMode == 3 ) + else if ( p->fMappingMode == 3 || p->fMappingMode == 4 ) { fUsePhase0 = (pNode->tRequired[1].Worst > tWorst1Using0 + p->fEpsilon); fUsePhase1 = (pNode->tRequired[0].Worst > tWorst0Using1 + p->fEpsilon); diff --git a/src/map/mapper/mapperRefs.c b/src/map/mapper/mapperRefs.c index e74bab9a..e4adadae 100644 --- a/src/map/mapper/mapperRefs.c +++ b/src/map/mapper/mapperRefs.c @@ -279,7 +279,7 @@ float Map_CutRef( Map_Cut_t * pCut, int fPhase ) /**function************************************************************* - synopsis [References the cut.] + synopsis [Dereferences the cut.] description [] @@ -298,8 +298,7 @@ float Map_CutDeref( Map_Cut_t * pCut, int fPhase ) synopsis [References or dereferences the cut.] description [This reference part is similar to Cudd_NodeReclaim(). - The dereference part is similar to Cudd_RecursiveDeref(). The - area of the inverter is not counted.] + The dereference part is similar to Cudd_RecursiveDeref().] sideeffects [] @@ -543,10 +542,10 @@ float Map_MappingGetArea( Map_Man_t * pMan, Map_NodeVec_t * vMapping ) (pNode->pCutBest[1] == NULL && pNode->nRefAct[1] > 0) ) Area += pMan->pSuperLib->AreaInv; } - // add two inverters for each PO buffer + // add buffer for each CO driven by a CI for ( i = 0; i < pMan->nOutputs; i++ ) if ( Map_NodeIsVar(pMan->pOutputs[i]) && !Map_IsComplement(pMan->pOutputs[i]) ) - Area += 2 * pMan->pSuperLib->AreaInv; + Area += pMan->pSuperLib->AreaBuf; return Area; } diff --git a/src/map/mapper/mapperSwitch.c b/src/map/mapper/mapperSwitch.c new file mode 100644 index 00000000..02f38396 --- /dev/null +++ b/src/map/mapper/mapperSwitch.c @@ -0,0 +1,243 @@ +/**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 $] + +***********************************************************************/ + +#include "mapperInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +static float Map_SwitchCutRefDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase, int fReference ); +static float Map_CutGetSwitching( Map_Cut_t * pCut ); + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**function************************************************************* + + synopsis [Computes the exact area associated with the cut.] + + description [] + + sideeffects [] + + seealso [] + +***********************************************************************/ +float Map_SwitchCutGetDerefed( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase ) +{ + float aResult, aResult2; +// assert( pNode->Switching > 0 ); + aResult2 = Map_SwitchCutRefDeref( pNode, pCut, fPhase, 1 ); // reference + aResult = Map_SwitchCutRefDeref( pNode, pCut, fPhase, 0 ); // dereference +// assert( aResult == aResult2 ); + return aResult; +} + +/**function************************************************************* + + synopsis [References the cut.] + + description [] + + sideeffects [] + + seealso [] + +***********************************************************************/ +float Map_SwitchCutRef( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase ) +{ + return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 1 ); // reference +} + +/**function************************************************************* + + synopsis [References the cut.] + + description [] + + sideeffects [] + + seealso [] + +***********************************************************************/ +float Map_SwitchCutDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase ) +{ + return Map_SwitchCutRefDeref( pNode, pCut, fPhase, 0 ); // dereference +} + +/**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 [] + +***********************************************************************/ +float Map_SwitchCutRefDeref( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase, int fReference ) +{ + Map_Node_t * pNodeChild; + Map_Cut_t * pCutChild; + float aSwitchActivity; + int i, fPhaseChild; + // consider the elementary variable + if ( pCut->nLeaves == 1 ) + return 0; + // start the area of this cut + aSwitchActivity = Map_CutGetSwitching( pCut ); + // go through the children + assert( pCut->M[fPhase].pSuperBest ); + for ( i = 0; i < pCut->nLeaves; i++ ) + { + pNodeChild = pCut->ppLeaves[i]; + fPhaseChild = Map_CutGetLeafPhase( pCut, fPhase, i ); + // get the reference counter of the child + + if ( fReference ) + { + if ( pNodeChild->pCutBest[0] && pNodeChild->pCutBest[1] ) // both phases are present + { + // if this phase of the node is referenced, there is no recursive call + pNodeChild->nRefAct[2]++; + if ( pNodeChild->nRefAct[fPhaseChild]++ > 0 ) + continue; + } + else // only one phase is present + { + // inverter should be added if the phase + // (a) has no reference and (b) is implemented using other phase + if ( pNodeChild->nRefAct[fPhaseChild]++ == 0 && pNodeChild->pCutBest[fPhaseChild] == NULL ) + aSwitchActivity += pNodeChild->Switching; + // if the node is referenced, there is no recursive call + if ( pNodeChild->nRefAct[2]++ > 0 ) + continue; + } + } + else + { + if ( pNodeChild->pCutBest[0] && pNodeChild->pCutBest[1] ) // both phases are present + { + // if this phase of the node is referenced, there is no recursive call + --pNodeChild->nRefAct[2]; + if ( --pNodeChild->nRefAct[fPhaseChild] > 0 ) + continue; + } + else // only one phase is present + { + // inverter should be added if the phase + // (a) has no reference and (b) is implemented using other phase + if ( --pNodeChild->nRefAct[fPhaseChild] == 0 && pNodeChild->pCutBest[fPhaseChild] == NULL ) + aSwitchActivity += pNodeChild->Switching; + // if the node is referenced, there is no recursive call + if ( --pNodeChild->nRefAct[2] > 0 ) + continue; + } + assert( pNodeChild->nRefAct[fPhaseChild] >= 0 ); + } + + // get the child cut + pCutChild = pNodeChild->pCutBest[fPhaseChild]; + // if the child does not have this phase mapped, take the opposite phase + if ( pCutChild == NULL ) + { + fPhaseChild = !fPhaseChild; + pCutChild = pNodeChild->pCutBest[fPhaseChild]; + } + // reference and compute area recursively + aSwitchActivity += Map_SwitchCutRefDeref( pNodeChild, pCutChild, fPhaseChild, fReference ); + } + return aSwitchActivity; +} + +/**function************************************************************* + + synopsis [Computes the exact area associated with the cut.] + + description [] + + sideeffects [] + + seealso [] + +***********************************************************************/ +float Map_CutGetSwitching( Map_Cut_t * pCut ) +{ + float Result; + int i; + Result = 0.0; + for ( i = 0; i < pCut->nLeaves; i++ ) + Result += pCut->ppLeaves[i]->Switching; + return Result; +} + +/**Function************************************************************* + + Synopsis [Computes the array of mapping.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +float Map_MappingGetSwitching( Map_Man_t * pMan, Map_NodeVec_t * vMapping ) +{ + Map_Node_t * pNode; + float Switch; + int i; + Switch = 0.0; + for ( i = 0; i < vMapping->nSize; i++ ) + { + pNode = vMapping->pArray[i]; + // at least one phase has the best cut assigned + assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL ); + // at least one phase is used in the mapping + assert( pNode->nRefAct[0] > 0 || pNode->nRefAct[1] > 0 ); + // compute the array due to the supergate + if ( Map_NodeIsAnd(pNode) ) + { + // count switching of the negative phase + if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) ) + Switch += pNode->Switching; + // count switching of the positive phase + if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) ) + Switch += pNode->Switching; + } + // count switching of the interver if we need to implement one phase with another phase + if ( (pNode->pCutBest[0] == NULL && pNode->nRefAct[0] > 0) || + (pNode->pCutBest[1] == NULL && pNode->nRefAct[1] > 0) ) + Switch += pNode->Switching; + } + // add buffer for each CO driven by a CI + for ( i = 0; i < pMan->nOutputs; i++ ) + if ( Map_NodeIsVar(pMan->pOutputs[i]) && !Map_IsComplement(pMan->pOutputs[i]) ) + Switch += pMan->pOutputs[i]->Switching; + return Switch; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/map/mapper/module.make b/src/map/mapper/module.make index 1d3b8867..bd6447d8 100644 --- a/src/map/mapper/module.make +++ b/src/map/mapper/module.make @@ -9,6 +9,7 @@ SRC += src/map/mapper/mapper.c \ src/map/mapper/mapperMatch.c \ src/map/mapper/mapperRefs.c \ src/map/mapper/mapperSuper.c \ + src/map/mapper/mapperSwitch.c \ src/map/mapper/mapperTable.c \ src/map/mapper/mapperTime.c \ src/map/mapper/mapperTree.c \ -- cgit v1.2.3