/**Function************************************************************* Synopsis [Compute the arrival times.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ float Map_MappingComputeDelayWithFanouts( Map_Man_t * p ) { Map_Node_t * pNode; float Result; int i; for ( i = 0; i < p->vMapObjs->nSize; i++ ) { // skip primary inputs pNode = p->vMapObjs->pArray[i]; if ( !Map_NodeIsAnd( pNode ) ) continue; // skip a secondary node if ( pNode->pRepr ) continue; // count the switching nodes if ( pNode->nRefAct[0] > 0 ) Map_TimeCutComputeArrival( pNode, pNode->pCutBest[0], 0, MAP_FLOAT_LARGE ); if ( pNode->nRefAct[1] > 0 ) Map_TimeCutComputeArrival( pNode, pNode->pCutBest[1], 1, MAP_FLOAT_LARGE ); } Result = Map_TimeComputeArrivalMax(p); printf( "Max arrival times with fanouts = %10.2f.\n", Result ); return Result; }
/**Function************************************************************* Synopsis [Find the best matching of the cut.] Description [The parameters: the node (pNode), the cut (pCut), the phase to be matched (fPhase), and the upper bound on the arrival times of the cut (fWorstLimit). This procedure goes through the matching supergates up to the phase assignment, and selects the best supergate, which will be used to map the cut. As a result of calling this procedure the matching information is written into pMatch.] SideEffects [] SeeAlso [] ***********************************************************************/ int Map_MatchNodeCut( Map_Man_t * p, Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase, float fWorstLimit ) { Map_Match_t MatchBest, * pMatch = pCut->M + fPhase; Map_Super_t * pSuper; int i, Counter; // save the current match of the cut MatchBest = *pMatch; // go through the supergates for ( pSuper = pMatch->pSupers, Counter = 0; pSuper; pSuper = pSuper->pNext, Counter++ ) { p->nMatches++; // this is an attempt to reduce the runtime of matching and area // at the cost of rare and very minor increase in delay // (the supergates are sorted by increasing area) if ( Counter == 30 ) break; // go through different phases of the given match and supergate pMatch->pSuperBest = pSuper; for ( i = 0; i < (int)pSuper->nPhases; i++ ) { p->nPhases++; // find the overall phase of this match pMatch->uPhaseBest = pMatch->uPhase ^ pSuper->uPhases[i]; if ( p->fMappingMode == 0 ) { // get the arrival time Map_TimeCutComputeArrival( pNode, pCut, fPhase, fWorstLimit ); // skip the cut if the arrival times exceed the required times if ( pMatch->tArrive.Worst > fWorstLimit + p->fEpsilon ) continue; // get the area (area flow) pMatch->AreaFlow = Map_CutGetAreaFlow( pCut, fPhase ); } else { // get the area (area flow) if ( p->fMappingMode == 2 || p->fMappingMode == 3 ) pMatch->AreaFlow = Map_CutGetAreaDerefed( pCut, fPhase ); 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 ) continue; // get the arrival time Map_TimeCutComputeArrival( pNode, pCut, fPhase, fWorstLimit ); // skip the cut if the arrival times exceed the required times if ( pMatch->tArrive.Worst > fWorstLimit + p->fEpsilon ) continue; } // if the cut is non-trivial, compare it if ( Map_MatchCompare( p, &MatchBest, pMatch, p->fMappingMode ) ) { MatchBest = *pMatch; // if we are mapping for delay, the worst-case limit should be reduced if ( p->fMappingMode == 0 ) fWorstLimit = MatchBest.tArrive.Worst; } } } // set the best match *pMatch = MatchBest; // recompute the arrival time and area (area flow) of this cut if ( pMatch->pSuperBest ) { Map_TimeCutComputeArrival( pNode, pCut, fPhase, MAP_FLOAT_LARGE ); if ( p->fMappingMode == 2 || p->fMappingMode == 3 ) pMatch->AreaFlow = Map_CutGetAreaDerefed( pCut, fPhase ); else if ( p->fMappingMode == 4 ) pMatch->AreaFlow = Map_SwitchCutGetDerefed( pNode, pCut, fPhase ); else pMatch->AreaFlow = Map_CutGetAreaFlow( pCut, fPhase ); } return 1; }
/**Function************************************************************* Synopsis [Find the matching of one polarity of the node.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Map_MatchNodePhase( Map_Man_t * p, Map_Node_t * pNode, int fPhase ) { Map_Match_t MatchBest, * pMatch; Map_Cut_t * pCut, * pCutBest; float Area1 = 0.0; // Suppress "might be used uninitialized float Area2, fWorstLimit; // skip the cuts that have been unassigned during area recovery pCutBest = pNode->pCutBest[fPhase]; if ( p->fMappingMode != 0 && pCutBest == NULL ) return 1; // recompute the arrival times of the current best match // because the arrival times of the fanins may have changed // as a result of remapping fanins in the topological order if ( p->fMappingMode != 0 ) { Map_TimeCutComputeArrival( pNode, pCutBest, fPhase, MAP_FLOAT_LARGE ); // make sure that the required times are met assert( pCutBest->M[fPhase].tArrive.Rise < pNode->tRequired[fPhase].Rise + p->fEpsilon ); assert( pCutBest->M[fPhase].tArrive.Fall < pNode->tRequired[fPhase].Fall + p->fEpsilon ); } // 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 || p->fMappingMode == 3 ) { pMatch = pCutBest->M + fPhase; if ( pNode->nRefAct[fPhase] > 0 || (pNode->pCutBest[!fPhase] == NULL && pNode->nRefAct[!fPhase] > 0) ) pMatch->AreaFlow = Area1 = Map_CutDeref( pCutBest, 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 ) MatchBest = pCutBest->M[fPhase]; else Map_MatchClean( &MatchBest ); // select the new best cut fWorstLimit = pNode->tRequired[fPhase].Worst; for ( pCut = pNode->pCuts->pNext; pCut; pCut = pCut->pNext ) { pMatch = pCut->M + fPhase; if ( pMatch->pSupers == NULL ) continue; // find the matches for the cut Map_MatchNodeCut( p, pNode, pCut, fPhase, fWorstLimit ); if ( pMatch->pSuperBest == NULL || pMatch->tArrive.Worst > fWorstLimit + p->fEpsilon ) continue; // if the cut can be matched compare the matchings if ( Map_MatchCompare( p, &MatchBest, pMatch, p->fMappingMode ) ) { pCutBest = pCut; MatchBest = *pMatch; // if we are mapping for delay, the worst-case limit should be tightened if ( p->fMappingMode == 0 ) fWorstLimit = MatchBest.tArrive.Worst; } } if ( pCutBest == NULL ) return 1; // set the new mapping pNode->pCutBest[fPhase] = pCutBest; pCutBest->M[fPhase] = MatchBest; // reference the new cut if it used if ( p->fMappingMode >= 2 && (pNode->nRefAct[fPhase] > 0 || (pNode->pCutBest[!fPhase] == NULL && pNode->nRefAct[!fPhase] > 0)) ) { 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 ); } // make sure that the requited times are met assert( MatchBest.tArrive.Rise < pNode->tRequired[fPhase].Rise + p->fEpsilon ); assert( MatchBest.tArrive.Fall < pNode->tRequired[fPhase].Fall + p->fEpsilon ); return 1; }