00001
00019 #include "fpgaInt.h"
00020
00024
00028
00041 float Fpga_TimeCutComputeArrival( Fpga_Man_t * pMan, Fpga_Cut_t * pCut )
00042 {
00043 int i;
00044 float tArrival;
00045 tArrival = -FPGA_FLOAT_LARGE;
00046 for ( i = 0; i < pCut->nLeaves; i++ )
00047 if ( tArrival < pCut->ppLeaves[i]->pCutBest->tArrival )
00048 tArrival = pCut->ppLeaves[i]->pCutBest->tArrival;
00049 tArrival += pMan->pLutLib->pLutDelays[pCut->nLeaves][0];
00050 return tArrival;
00051 }
00052
00066 float Fpga_TimeCutComputeArrival_rec( Fpga_Man_t * pMan, Fpga_Cut_t * pCut )
00067 {
00068 int i;
00069 for ( i = 0; i < pCut->nLeaves; i++ )
00070 if ( pCut->ppLeaves[i]->nRefs == 0 )
00071 Fpga_TimeCutComputeArrival_rec( pMan, pCut->ppLeaves[i]->pCutBest );
00072 return Fpga_TimeCutComputeArrival( pMan, pCut );
00073 }
00074
00086 float Fpga_TimeComputeArrivalMax( Fpga_Man_t * p )
00087 {
00088 float fRequired;
00089 int i;
00090 if ( p->fLatchPaths && p->nLatches == 0 )
00091 {
00092 printf( "Delay optimization of latch path is not performed because there is no latches.\n" );
00093 p->fLatchPaths = 0;
00094 }
00095
00096 fRequired = -FPGA_FLOAT_LARGE;
00097 if ( p->fLatchPaths )
00098 {
00099 for ( i = p->nOutputs - p->nLatches; i < p->nOutputs; i++ )
00100 {
00101 if ( Fpga_NodeIsConst(p->pOutputs[i]) )
00102 continue;
00103 fRequired = FPGA_MAX( fRequired, Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
00104
00105 }
00106
00107 }
00108 else
00109 {
00110 for ( i = 0; i < p->nOutputs; i++ )
00111 {
00112 if ( Fpga_NodeIsConst(p->pOutputs[i]) )
00113 continue;
00114 fRequired = FPGA_MAX( fRequired, Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
00115
00116 }
00117
00118 }
00119 return fRequired;
00120 }
00121
00133 void Fpga_TimeComputeRequiredGlobal( Fpga_Man_t * p, int fFirstTime )
00134 {
00135 p->fRequiredGlo = Fpga_TimeComputeArrivalMax( p );
00136
00137 if ( p->DelayTarget != -1 )
00138 {
00139 if ( p->fRequiredGlo > p->DelayTarget + p->fEpsilon )
00140 {
00141 if ( fFirstTime )
00142 printf( "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->DelayTarget );
00143 }
00144 else if ( p->fRequiredGlo < p->DelayTarget - p->fEpsilon )
00145 {
00146 if ( fFirstTime )
00147 printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->fRequiredGlo, p->DelayTarget );
00148 p->fRequiredGlo = p->DelayTarget;
00149 }
00150 }
00151 Fpga_TimeComputeRequired( p, p->fRequiredGlo );
00152 }
00153
00165 void Fpga_TimeComputeRequired( Fpga_Man_t * p, float fRequired )
00166 {
00167 int i;
00168
00169 for ( i = 0; i < p->vAnds->nSize; i++ )
00170 p->vAnds->pArray[i]->tRequired = FPGA_FLOAT_LARGE;
00171
00172 if ( p->fLatchPaths )
00173 for ( i = p->nOutputs - p->nLatches; i < p->nOutputs; i++ )
00174 Fpga_Regular(p->pOutputs[i])->tRequired = fRequired;
00175 else
00176 for ( i = 0; i < p->nOutputs; i++ )
00177 Fpga_Regular(p->pOutputs[i])->tRequired = fRequired;
00178
00179 Fpga_TimePropagateRequired( p, p->vMapping );
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 }
00190
00202 void Fpga_TimePropagateRequired( Fpga_Man_t * p, Fpga_NodeVec_t * vNodes )
00203 {
00204 Fpga_Node_t * pNode, * pChild;
00205 float fRequired;
00206 int i, k;
00207
00208
00209
00210
00211
00212
00213 for ( k = 0; k < vNodes->nSize; k++ )
00214 {
00215 pNode = vNodes->pArray[k];
00216 if ( !Fpga_NodeIsAnd(pNode) )
00217 continue;
00218
00219 fRequired = pNode->tRequired - p->pLutLib->pLutDelays[pNode->pCutBest->nLeaves][0];
00220
00221 for ( i = 0; i < pNode->pCutBest->nLeaves; i++ )
00222 {
00223 pChild = pNode->pCutBest->ppLeaves[i];
00224 pChild->tRequired = FPGA_MIN( pChild->tRequired, fRequired );
00225 }
00226 }
00227 }
00228
00229
00230
00242 void Fpga_TimePropagateArrival( Fpga_Man_t * p )
00243 {
00244 Fpga_Node_t * pNode;
00245 Fpga_Cut_t * pCut;
00246 int i;
00247
00248
00249 for ( i = 0; i < p->vAnds->nSize; i++ )
00250 {
00251 pNode = p->vAnds->pArray[i];
00252 for ( pCut = pNode->pCuts->pNext; pCut; pCut = pCut->pNext )
00253 pCut->tArrival = Fpga_TimeCutComputeArrival( p, pCut );
00254 }
00255 }
00256
00257
00261
00262