00001
00019 #include "mapperInt.h"
00020
00024
00025 static void Map_TimePropagateRequired( Map_Man_t * p, Map_NodeVec_t * vNodes );
00026 static void Map_TimePropagateRequiredPhase( Map_Man_t * p, Map_Node_t * pNode, int fPhase );
00027 static float Map_MatchComputeReqTimes( Map_Cut_t * pCut, int fPhase, Map_Time_t * ptArrRes );
00028
00032
00044 float Map_TimeMatchWithInverter( Map_Man_t * p, Map_Match_t * pMatch )
00045 {
00046 Map_Time_t tArrInv;
00047 tArrInv.Fall = pMatch->tArrive.Rise + p->pSuperLib->tDelayInv.Fall;
00048 tArrInv.Rise = pMatch->tArrive.Fall + p->pSuperLib->tDelayInv.Rise;
00049 tArrInv.Worst = MAP_MAX( tArrInv.Rise, tArrInv.Fall );
00050 return tArrInv.Worst;
00051 }
00052
00066 void Map_TimeCutComputeArrival_rec( Map_Cut_t * pCut, int fPhase )
00067 {
00068 int i, fPhaseLeaf;
00069 for ( i = 0; i < pCut->nLeaves; i++ )
00070 {
00071 fPhaseLeaf = Map_CutGetLeafPhase( pCut, fPhase, i );
00072 if ( pCut->ppLeaves[i]->nRefAct[fPhaseLeaf] > 0 )
00073 continue;
00074 Map_TimeCutComputeArrival_rec( pCut->ppLeaves[i]->pCutBest[fPhaseLeaf], fPhaseLeaf );
00075 }
00076 Map_TimeCutComputeArrival( NULL, pCut, fPhase, MAP_FLOAT_LARGE );
00077 }
00078
00092 float Map_TimeCutComputeArrival( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase, float tWorstLimit )
00093 {
00094 Map_Match_t * pM = pCut->M + fPhase;
00095 Map_Super_t * pSuper = pM->pSuperBest;
00096 unsigned uPhaseTot = pM->uPhaseBest;
00097 Map_Time_t * ptArrRes = &pM->tArrive;
00098 Map_Time_t * ptArrIn;
00099 bool fPinPhase;
00100 float tDelay;
00101 int i;
00102
00103 ptArrRes->Rise = ptArrRes->Fall = 0.0;
00104 ptArrRes->Worst = MAP_FLOAT_LARGE;
00105 for ( i = pCut->nLeaves - 1; i >= 0; i-- )
00106 {
00107
00108 fPinPhase = ((uPhaseTot & (1 << i)) == 0);
00109 ptArrIn = pCut->ppLeaves[i]->tArrival + fPinPhase;
00110
00111
00112 if ( pSuper->tDelaysR[i].Rise > 0 )
00113 {
00114 tDelay = ptArrIn->Rise + pSuper->tDelaysR[i].Rise;
00115 if ( tDelay > tWorstLimit )
00116 return MAP_FLOAT_LARGE;
00117 if ( ptArrRes->Rise < tDelay )
00118 ptArrRes->Rise = tDelay;
00119 }
00120
00121
00122 if ( pSuper->tDelaysR[i].Fall > 0 )
00123 {
00124 tDelay = ptArrIn->Fall + pSuper->tDelaysR[i].Fall;
00125 if ( tDelay > tWorstLimit )
00126 return MAP_FLOAT_LARGE;
00127 if ( ptArrRes->Rise < tDelay )
00128 ptArrRes->Rise = tDelay;
00129 }
00130
00131
00132 if ( pSuper->tDelaysF[i].Rise > 0 )
00133 {
00134 tDelay = ptArrIn->Rise + pSuper->tDelaysF[i].Rise;
00135 if ( tDelay > tWorstLimit )
00136 return MAP_FLOAT_LARGE;
00137 if ( ptArrRes->Fall < tDelay )
00138 ptArrRes->Fall = tDelay;
00139 }
00140
00141
00142 if ( pSuper->tDelaysF[i].Fall > 0 )
00143 {
00144 tDelay = ptArrIn->Fall + pSuper->tDelaysF[i].Fall;
00145 if ( tDelay > tWorstLimit )
00146 return MAP_FLOAT_LARGE;
00147 if ( ptArrRes->Fall < tDelay )
00148 ptArrRes->Fall = tDelay;
00149 }
00150 }
00151
00152 ptArrRes->Worst = MAP_MAX(ptArrRes->Rise, ptArrRes->Fall);
00153 return ptArrRes->Worst;
00154 }
00155
00156
00168 float Map_TimeComputeArrivalMax( Map_Man_t * p )
00169 {
00170 float tReqMax, tReq;
00171 int i, fPhase;
00172
00173 tReqMax = -MAP_FLOAT_LARGE;
00174 for ( i = 0; i < p->nOutputs; i++ )
00175 {
00176 if ( Map_NodeIsConst(p->pOutputs[i]) )
00177 continue;
00178 fPhase = !Map_IsComplement(p->pOutputs[i]);
00179 tReq = Map_Regular(p->pOutputs[i])->tArrival[fPhase].Worst;
00180 tReqMax = MAP_MAX( tReqMax, tReq );
00181 }
00182 return tReqMax;
00183 }
00184
00196 void Map_TimeComputeRequiredGlobal( Map_Man_t * p )
00197 {
00198 p->fRequiredGlo = Map_TimeComputeArrivalMax( p );
00199
00200 if ( p->DelayTarget != -1 )
00201 {
00202 if ( p->fRequiredGlo > p->DelayTarget + p->fEpsilon )
00203 {
00204 if ( p->fMappingMode == 1 )
00205 printf( "Cannot meet the target required times (%4.2f). Continue anyway.\n", p->DelayTarget );
00206 }
00207 else if ( p->fRequiredGlo < p->DelayTarget - p->fEpsilon )
00208 {
00209 if ( p->fMappingMode == 1 )
00210 printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->fRequiredGlo, p->DelayTarget );
00211 p->fRequiredGlo = p->DelayTarget;
00212 }
00213 }
00214 Map_TimeComputeRequired( p, p->fRequiredGlo );
00215 }
00216
00229 void Map_TimeComputeRequired( Map_Man_t * p, float fRequired )
00230 {
00231 Map_Time_t * ptTime;
00232 int fPhase, i;
00233
00234
00235 for ( i = 0; i < p->vAnds->nSize; i++ )
00236 {
00237 p->vAnds->pArray[i]->tRequired[0].Rise = MAP_FLOAT_LARGE;
00238 p->vAnds->pArray[i]->tRequired[0].Fall = MAP_FLOAT_LARGE;
00239 p->vAnds->pArray[i]->tRequired[0].Worst = MAP_FLOAT_LARGE;
00240 p->vAnds->pArray[i]->tRequired[1].Rise = MAP_FLOAT_LARGE;
00241 p->vAnds->pArray[i]->tRequired[1].Fall = MAP_FLOAT_LARGE;
00242 p->vAnds->pArray[i]->tRequired[1].Worst = MAP_FLOAT_LARGE;
00243 }
00244
00245
00246 for ( i = 0; i < p->nOutputs; i++ )
00247 {
00248 fPhase = !Map_IsComplement(p->pOutputs[i]);
00249 ptTime = Map_Regular(p->pOutputs[i])->tRequired + fPhase;
00250 ptTime->Rise = ptTime->Fall = ptTime->Worst = fRequired;
00251 }
00252
00253
00254
00255
00256
00257
00258 Map_TimePropagateRequired( p, p->vMapping );
00259 }
00260
00272 void Map_TimePropagateRequired( Map_Man_t * p, Map_NodeVec_t * vNodes )
00273 {
00274 Map_Node_t * pNode;
00275 Map_Time_t tReqOutTest, * ptReqOutTest = &tReqOutTest;
00276 Map_Time_t * ptReqIn, * ptReqOut;
00277 int fPhase, k;
00278
00279
00280 for ( k = 0; k < vNodes->nSize; k++ )
00281 {
00282 pNode = vNodes->pArray[k];
00283
00284
00285 assert( !Map_IsComplement(pNode) );
00286
00287 assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL );
00288
00289 assert( pNode->nRefAct[0] > 0 || pNode->nRefAct[1] > 0 );
00290
00291
00292 if ( pNode->pCutBest[0] == NULL || pNode->pCutBest[1] == NULL )
00293 {
00294
00295
00296 fPhase = (pNode->pCutBest[1] == NULL);
00297
00298 if ( pNode->nRefAct[fPhase] > 0 )
00299 {
00300
00301 ptReqOut = pNode->tRequired + fPhase;
00302
00303
00304 ptReqIn = pNode->tRequired + !fPhase;
00305
00306
00307
00308 ptReqIn->Fall = MAP_MIN( ptReqIn->Fall, ptReqOut->Rise - p->pSuperLib->tDelayInv.Rise );
00309 ptReqIn->Rise = MAP_MIN( ptReqIn->Rise, ptReqOut->Fall - p->pSuperLib->tDelayInv.Fall );
00310 }
00311 }
00312
00313
00314 pNode->tRequired[0].Worst = MAP_MIN( pNode->tRequired[0].Fall, pNode->tRequired[0].Rise );
00315 pNode->tRequired[1].Worst = MAP_MIN( pNode->tRequired[1].Fall, pNode->tRequired[1].Rise );
00316
00317
00318 if ( !Map_NodeIsAnd(pNode) )
00319 continue;
00320
00321
00322
00323 if ( pNode->pCutBest[0] && pNode->tRequired[0].Worst < MAP_FLOAT_LARGE )
00324 Map_TimePropagateRequiredPhase( p, pNode, 0 );
00325 if ( pNode->pCutBest[1] && pNode->tRequired[1].Worst < MAP_FLOAT_LARGE )
00326 Map_TimePropagateRequiredPhase( p, pNode, 1 );
00327 }
00328
00329
00330
00331
00332
00333 for ( k = 0; k < vNodes->nSize; k++ )
00334 {
00335 pNode = vNodes->pArray[k];
00336 if ( !Map_NodeIsAnd(pNode) )
00337 continue;
00338
00339
00340 if ( pNode->pCutBest[0] && pNode->tRequired[0].Worst < MAP_FLOAT_LARGE )
00341 {
00342 Map_MatchComputeReqTimes( pNode->pCutBest[0], 0, ptReqOutTest );
00343 assert( ptReqOutTest->Rise < pNode->tRequired[0].Rise + p->fEpsilon );
00344 assert( ptReqOutTest->Fall < pNode->tRequired[0].Fall + p->fEpsilon );
00345 }
00346
00347 if ( pNode->pCutBest[1] && pNode->tRequired[1].Worst < MAP_FLOAT_LARGE )
00348 {
00349 Map_MatchComputeReqTimes( pNode->pCutBest[1], 1, ptReqOutTest );
00350 assert( ptReqOutTest->Rise < pNode->tRequired[1].Rise + p->fEpsilon );
00351 assert( ptReqOutTest->Fall < pNode->tRequired[1].Fall + p->fEpsilon );
00352 }
00353 }
00354
00355 }
00356
00368 void Map_TimePropagateRequiredPhase( Map_Man_t * p, Map_Node_t * pNode, int fPhase )
00369 {
00370 Map_Time_t * ptReqIn, * ptReqOut;
00371 Map_Cut_t * pCut;
00372 Map_Super_t * pSuper;
00373 float tNewReqTime;
00374 unsigned uPhase;
00375 int fPinPhase, i;
00376
00377
00378 pCut = pNode->pCutBest[fPhase];
00379 assert( pCut != NULL );
00380
00381 pSuper = pCut->M[fPhase].pSuperBest;
00382 uPhase = pCut->M[fPhase].uPhaseBest;
00383
00384 ptReqOut = pNode->tRequired + fPhase;
00385
00386 for ( i = 0; i < pCut->nLeaves; i++ )
00387 {
00388
00389 fPinPhase = ((uPhase & (1 << i)) == 0);
00390 ptReqIn = pCut->ppLeaves[i]->tRequired + fPinPhase;
00391 assert( pCut->ppLeaves[i]->nRefAct[2] > 0 );
00392
00393
00394
00395
00396 if ( pSuper->tDelaysR[i].Rise > 0 )
00397 {
00398 tNewReqTime = ptReqOut->Rise - pSuper->tDelaysR[i].Rise;
00399 ptReqIn->Rise = MAP_MIN( ptReqIn->Rise, tNewReqTime );
00400 }
00401
00402
00403
00404
00405 if ( pSuper->tDelaysR[i].Fall > 0 )
00406 {
00407 tNewReqTime = ptReqOut->Rise - pSuper->tDelaysR[i].Fall;
00408 ptReqIn->Fall = MAP_MIN( ptReqIn->Fall, tNewReqTime );
00409 }
00410
00411
00412
00413
00414 if ( pSuper->tDelaysF[i].Rise > 0 )
00415 {
00416 tNewReqTime = ptReqOut->Fall - pSuper->tDelaysF[i].Rise;
00417 ptReqIn->Rise = MAP_MIN( ptReqIn->Rise, tNewReqTime );
00418 }
00419
00420
00421
00422
00423 if ( pSuper->tDelaysF[i].Fall > 0 )
00424 {
00425 tNewReqTime = ptReqOut->Fall - pSuper->tDelaysF[i].Fall;
00426 ptReqIn->Fall = MAP_MIN( ptReqIn->Fall, tNewReqTime );
00427 }
00428 }
00429
00430
00431 assert( pNode->tArrival[fPhase].Rise < ptReqOut->Rise + p->fEpsilon );
00432 assert( pNode->tArrival[fPhase].Fall < ptReqOut->Fall + p->fEpsilon );
00433 }
00434
00448 float Map_MatchComputeReqTimes( Map_Cut_t * pCut, int fPhase, Map_Time_t * ptArrRes )
00449 {
00450 Map_Time_t * ptArrIn;
00451 Map_Super_t * pSuper;
00452 unsigned uPhaseTot;
00453 int fPinPhase, i;
00454 float tDelay;
00455
00456
00457 pSuper = pCut->M[fPhase].pSuperBest;
00458 uPhaseTot = pCut->M[fPhase].uPhaseBest;
00459
00460
00461 ptArrRes->Rise = ptArrRes->Fall = -MAP_FLOAT_LARGE;
00462 for ( i = 0; i < pCut->nLeaves; i++ )
00463 {
00464
00465 fPinPhase = ((uPhaseTot & (1 << i)) == 0);
00466 ptArrIn = pCut->ppLeaves[i]->tRequired + fPinPhase;
00467
00468
00469
00470 if ( pSuper->tDelaysR[i].Rise > 0 )
00471 {
00472 tDelay = ptArrIn->Rise + pSuper->tDelaysR[i].Rise;
00473 if ( ptArrRes->Rise < tDelay )
00474 ptArrRes->Rise = tDelay;
00475 }
00476
00477
00478 if ( pSuper->tDelaysR[i].Fall > 0 )
00479 {
00480 tDelay = ptArrIn->Fall + pSuper->tDelaysR[i].Fall;
00481 if ( ptArrRes->Rise < tDelay )
00482 ptArrRes->Rise = tDelay;
00483 }
00484
00485
00486 if ( pSuper->tDelaysF[i].Rise > 0 )
00487 {
00488 tDelay = ptArrIn->Rise + pSuper->tDelaysF[i].Rise;
00489 if ( ptArrRes->Fall < tDelay )
00490 ptArrRes->Fall = tDelay;
00491 }
00492
00493
00494 if ( pSuper->tDelaysF[i].Fall > 0 )
00495 {
00496 tDelay = ptArrIn->Fall + pSuper->tDelaysF[i].Fall;
00497 if ( ptArrRes->Fall < tDelay )
00498 ptArrRes->Fall = tDelay;
00499 }
00500 }
00501
00502 return MAP_MAX(ptArrRes->Rise, ptArrRes->Fall);
00503 }
00504
00505
00509
00510