/**Function************************************************************* Synopsis [Computes the array of mapping.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ float Map_MappingGetArea( Map_Man_t * pMan ) { Map_Node_t * pNode; float Area = 0.0; int i; if ( pMan->fUseProfile ) Mio_LibraryCleanProfile2( pMan->pSuperLib->pGenlib ); for ( i = 0; i < pMan->vMapObjs->nSize; i++ ) { pNode = pMan->vMapObjs->pArray[i]; if ( pNode->nRefAct[2] == 0 ) continue; if ( Map_NodeIsBuf(pNode) ) continue; // 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 area of the negative phase if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) ) { Area += pNode->pCutBest[0]->M[0].pSuperBest->Area; if ( pMan->fUseProfile ) Mio_GateIncProfile2( pNode->pCutBest[0]->M[0].pSuperBest->pRoot ); } // count area of the positive phase if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) ) { Area += pNode->pCutBest[1]->M[1].pSuperBest->Area; if ( pMan->fUseProfile ) Mio_GateIncProfile2( pNode->pCutBest[1]->M[1].pSuperBest->pRoot ); } } // count area 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) ) Area += pMan->pSuperLib->AreaInv; } // add buffers 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 += pMan->pSuperLib->AreaBuf; return Area; }
/**Function************************************************************* Synopsis [Computes actual reference counters.] Description [Collects the nodes used in the mapping in array pMan->vMapping. Nodes are collected in reverse topological order to facilitate the computation of required times.] SideEffects [] SeeAlso [] ***********************************************************************/ void Map_MappingSetRefs_rec( Map_Man_t * pMan, Map_Node_t * pNode ) { Map_Cut_t * pCut; Map_Node_t * pNodeR; unsigned uPhase; int i, fPhase, fInvPin; // get the regular node and its phase pNodeR = Map_Regular(pNode); fPhase = !Map_IsComplement(pNode); pNodeR->nRefAct[2]++; // quit if the node was already visited in this phase if ( pNodeR->nRefAct[fPhase]++ ) return; // quit if this is a PI node if ( Map_NodeIsVar(pNodeR) ) return; // propagate through buffer if ( Map_NodeIsBuf(pNodeR) ) { Map_MappingSetRefs_rec( pMan, Map_NotCond(pNodeR->p1, Map_IsComplement(pNode)) ); return; } assert( Map_NodeIsAnd(pNode) ); // get the cut implementing this or opposite polarity pCut = pNodeR->pCutBest[fPhase]; if ( pCut == NULL ) { fPhase = !fPhase; pCut = pNodeR->pCutBest[fPhase]; } if ( pMan->fUseProfile ) Mio_GateIncProfile2( pCut->M[fPhase].pSuperBest->pRoot ); // visit the transitive fanin uPhase = pCut->M[fPhase].uPhaseBest; for ( i = 0; i < pCut->nLeaves; i++ ) { fInvPin = ((uPhase & (1 << i)) > 0); Map_MappingSetRefs_rec( pMan, Map_NotCond(pCut->ppLeaves[i], fInvPin) ); } }
/**Function************************************************************* Synopsis [Computes the required times of all nodes.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Map_TimePropagateRequired( Map_Man_t * p ) { Map_Node_t * pNode; Map_Time_t tReqOutTest, * ptReqOutTest = &tReqOutTest; Map_Time_t * ptReqIn, * ptReqOut; int fPhase, k; // go through the nodes in the reverse topological order for ( k = p->vMapObjs->nSize - 1; k >= 0; k-- ) { pNode = p->vMapObjs->pArray[k]; if ( pNode->nRefAct[2] == 0 ) continue; // propagate required times through the buffer if ( Map_NodeIsBuf(pNode) ) { assert( pNode->p2 == NULL ); Map_Regular(pNode->p1)->tRequired[ Map_IsComplement(pNode->p1)] = pNode->tRequired[0]; Map_Regular(pNode->p1)->tRequired[!Map_IsComplement(pNode->p1)] = pNode->tRequired[1]; continue; } // this computation works for regular nodes only assert( !Map_IsComplement(pNode) ); // at least one phase should be mapped assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL ); // the node should be used in the currently assigned mapping assert( pNode->nRefAct[0] > 0 || pNode->nRefAct[1] > 0 ); // if one of the cuts is not given, project the required times from the other cut if ( pNode->pCutBest[0] == NULL || pNode->pCutBest[1] == NULL ) { // assert( 0 ); // get the missing phase fPhase = (pNode->pCutBest[1] == NULL); // check if the missing phase is needed in the mapping if ( pNode->nRefAct[fPhase] > 0 ) { // get the pointers to the required times of the missing phase ptReqOut = pNode->tRequired + fPhase; // assert( ptReqOut->Fall < MAP_FLOAT_LARGE ); // get the pointers to the required times of the present phase ptReqIn = pNode->tRequired + !fPhase; // propagate the required times from the missing phase to the present phase // tArrInv.Fall = pMatch->tArrive.Rise + p->pSuperLib->tDelayInv.Fall; // tArrInv.Rise = pMatch->tArrive.Fall + p->pSuperLib->tDelayInv.Rise; ptReqIn->Fall = MAP_MIN( ptReqIn->Fall, ptReqOut->Rise - p->pSuperLib->tDelayInv.Rise ); ptReqIn->Rise = MAP_MIN( ptReqIn->Rise, ptReqOut->Fall - p->pSuperLib->tDelayInv.Fall ); } } // finalize the worst case computation pNode->tRequired[0].Worst = MAP_MIN( pNode->tRequired[0].Fall, pNode->tRequired[0].Rise ); pNode->tRequired[1].Worst = MAP_MIN( pNode->tRequired[1].Fall, pNode->tRequired[1].Rise ); // skip the PIs if ( !Map_NodeIsAnd(pNode) ) continue; // propagate required times of different phases of the node // the ordering of phases does not matter since they are mapped independently if ( pNode->pCutBest[0] && pNode->tRequired[0].Worst < MAP_FLOAT_LARGE ) Map_TimePropagateRequiredPhase( p, pNode, 0 ); if ( pNode->pCutBest[1] && pNode->tRequired[1].Worst < MAP_FLOAT_LARGE ) Map_TimePropagateRequiredPhase( p, pNode, 1 ); } // in the end, we verify the required times // for this, we compute the arrival times of the outputs of each phase // of the supergates using the fanins' required times as the fanins' arrival times // the resulting arrival time of the supergate should be less than the actual required time for ( k = p->vMapObjs->nSize - 1; k >= 0; k-- ) { pNode = p->vMapObjs->pArray[k]; if ( pNode->nRefAct[2] == 0 ) continue; if ( !Map_NodeIsAnd(pNode) ) continue; // verify that the required times are propagated correctly // if ( pNode->pCutBest[0] && (pNode->nRefAct[0] > 0 || pNode->pCutBest[1] == NULL) ) if ( pNode->pCutBest[0] && pNode->tRequired[0].Worst < MAP_FLOAT_LARGE/2 ) { Map_MatchComputeReqTimes( pNode->pCutBest[0], 0, ptReqOutTest ); // assert( ptReqOutTest->Rise < pNode->tRequired[0].Rise + p->fEpsilon ); // assert( ptReqOutTest->Fall < pNode->tRequired[0].Fall + p->fEpsilon ); } // if ( pNode->pCutBest[1] && (pNode->nRefAct[1] > 0 || pNode->pCutBest[0] == NULL) ) if ( pNode->pCutBest[1] && pNode->tRequired[1].Worst < MAP_FLOAT_LARGE/2 ) { Map_MatchComputeReqTimes( pNode->pCutBest[1], 1, ptReqOutTest ); // assert( ptReqOutTest->Rise < pNode->tRequired[1].Rise + p->fEpsilon ); // assert( ptReqOutTest->Fall < pNode->tRequired[1].Fall + p->fEpsilon ); } } }
/**Function************************************************************* Synopsis [Computes the best matches of the nodes.] Description [Uses parameter p->fMappingMode to decide how to assign the matches for both polarities of the node. While the matches are being assigned, one of them may turn out to be better than the other (in terms of delay, for example). In this case, the worse match can be permanently dropped, and the corresponding pointer set to NULL.] SideEffects [] SeeAlso [] ***********************************************************************/ int Map_MappingMatches( Map_Man_t * p ) { ProgressBar * pProgress; Map_Node_t * pNode; int i; assert( p->fMappingMode >= 0 && p->fMappingMode <= 4 ); // use the externally given PI arrival times if ( p->fMappingMode == 0 ) Map_MappingSetPiArrivalTimes( p ); // estimate the fanouts if ( p->fMappingMode == 0 ) Map_MappingEstimateRefsInit( p ); else if ( p->fMappingMode == 1 ) Map_MappingEstimateRefs( p ); // the PI cuts are matched in the cut computation package // in the loop below we match the internal nodes pProgress = Extra_ProgressBarStart( stdout, p->vMapObjs->nSize ); for ( i = 0; i < p->vMapObjs->nSize; i++ ) { pNode = p->vMapObjs->pArray[i]; if ( Map_NodeIsBuf(pNode) ) { assert( pNode->p2 == NULL ); pNode->tArrival[0] = Map_Regular(pNode->p1)->tArrival[ Map_IsComplement(pNode->p1)]; pNode->tArrival[1] = Map_Regular(pNode->p1)->tArrival[!Map_IsComplement(pNode->p1)]; continue; } // skip primary inputs and secondary nodes if mapping with choices if ( !Map_NodeIsAnd( pNode ) || pNode->pRepr ) continue; // make sure that at least one non-trival cut is present if ( pNode->pCuts->pNext == NULL ) { Extra_ProgressBarStop( pProgress ); printf( "\nError: A node in the mapping graph does not have feasible cuts.\n" ); return 0; } // match negative phase if ( !Map_MatchNodePhase( p, pNode, 0 ) ) { Extra_ProgressBarStop( pProgress ); return 0; } // match positive phase if ( !Map_MatchNodePhase( p, pNode, 1 ) ) { Extra_ProgressBarStop( pProgress ); return 0; } // make sure that at least one phase is mapped if ( pNode->pCutBest[0] == NULL && pNode->pCutBest[1] == NULL ) { printf( "\nError: Could not match both phases of AIG node %d.\n", pNode->Num ); printf( "Please make sure that the supergate library has equivalents of AND2 or NAND2.\n" ); printf( "If such supergates exist in the library, report a bug.\n" ); Extra_ProgressBarStop( pProgress ); return 0; } // if both phases are assigned, check if one of them can be dropped Map_NodeTryDroppingOnePhase( p, pNode ); // set the arrival times of the node using the best cuts Map_NodeTransferArrivalTimes( p, pNode ); // update the progress bar Extra_ProgressBarUpdate( pProgress, i, "Matches ..." ); } Extra_ProgressBarStop( pProgress ); return 1; }