00001
00021 #include "if.h"
00022
00026
00027 static void If_CutSortInputPins( If_Man_t * p, If_Cut_t * pCut, int * pPinPerm, float * pPinDelays );
00028
00032
00044 float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
00045 {
00046 static int pPinPerm[IF_MAX_LUTSIZE];
00047 static float pPinDelays[IF_MAX_LUTSIZE];
00048 If_Obj_t * pLeaf;
00049 float Delay, DelayCur;
00050 float * pLutDelays;
00051 int i, Shift;
00052 assert( p->pPars->fSeqMap || pCut->nLeaves > 1 );
00053 Delay = -IF_FLOAT_LARGE;
00054 if ( p->pPars->pLutLib )
00055 {
00056 assert( !p->pPars->fLiftLeaves );
00057 pLutDelays = p->pPars->pLutLib->pLutDelays[pCut->nLeaves];
00058 if ( p->pPars->pLutLib->fVarPinDelays )
00059 {
00060
00061 If_CutSortInputPins( p, pCut, pPinPerm, pPinDelays );
00062 for ( i = 0; i < (int)pCut->nLeaves; i++ )
00063 {
00064 DelayCur = pPinDelays[pPinPerm[i]] + pLutDelays[i];
00065 Delay = IF_MAX( Delay, DelayCur );
00066 }
00067 }
00068 else
00069 {
00070 If_CutForEachLeaf( p, pCut, pLeaf, i )
00071 {
00072 DelayCur = If_ObjCutBest(pLeaf)->Delay + pLutDelays[0];
00073 Delay = IF_MAX( Delay, DelayCur );
00074 }
00075 }
00076 }
00077 else
00078 {
00079 if ( pCut->fUser )
00080 {
00081 assert( !p->pPars->fLiftLeaves );
00082 If_CutForEachLeaf( p, pCut, pLeaf, i )
00083 {
00084 DelayCur = If_ObjCutBest(pLeaf)->Delay + (float)pCut->pPerm[i];
00085 Delay = IF_MAX( Delay, DelayCur );
00086 }
00087 }
00088 else
00089 {
00090 if ( p->pPars->fLiftLeaves )
00091 {
00092 If_CutForEachLeafSeq( p, pCut, pLeaf, Shift, i )
00093 {
00094 DelayCur = If_ObjCutBest(pLeaf)->Delay - Shift * p->Period;
00095 Delay = IF_MAX( Delay, DelayCur );
00096 }
00097 }
00098 else
00099 {
00100 If_CutForEachLeaf( p, pCut, pLeaf, i )
00101 {
00102 DelayCur = If_ObjCutBest(pLeaf)->Delay;
00103 Delay = IF_MAX( Delay, DelayCur );
00104 }
00105 }
00106 Delay += 1.0;
00107 }
00108 }
00109 return Delay;
00110 }
00111
00123 void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float ObjRequired )
00124 {
00125 static int pPinPerm[IF_MAX_LUTSIZE];
00126 static float pPinDelays[IF_MAX_LUTSIZE];
00127 If_Obj_t * pLeaf;
00128 float * pLutDelays;
00129 float Required;
00130 int i;
00131 assert( !p->pPars->fLiftLeaves );
00132
00133 if ( p->pPars->pLutLib )
00134 {
00135 pLutDelays = p->pPars->pLutLib->pLutDelays[pCut->nLeaves];
00136 if ( p->pPars->pLutLib->fVarPinDelays )
00137 {
00138
00139 If_CutSortInputPins( p, pCut, pPinPerm, pPinDelays );
00140 for ( i = 0; i < (int)pCut->nLeaves; i++ )
00141 {
00142 Required = ObjRequired - pLutDelays[i];
00143 pLeaf = If_ManObj( p, pCut->pLeaves[pPinPerm[i]] );
00144 pLeaf->Required = IF_MIN( pLeaf->Required, Required );
00145 }
00146 }
00147 else
00148 {
00149 Required = ObjRequired - pLutDelays[0];
00150 If_CutForEachLeaf( p, pCut, pLeaf, i )
00151 pLeaf->Required = IF_MIN( pLeaf->Required, Required );
00152 }
00153 }
00154 else
00155 {
00156 if ( pCut->fUser )
00157 {
00158 If_CutForEachLeaf( p, pCut, pLeaf, i )
00159 {
00160 Required = ObjRequired - (float)pCut->pPerm[i];
00161 pLeaf->Required = IF_MIN( pLeaf->Required, Required );
00162 }
00163 }
00164 else
00165 {
00166 Required = ObjRequired - (float)1.0;
00167 If_CutForEachLeaf( p, pCut, pLeaf, i )
00168 pLeaf->Required = IF_MIN( pLeaf->Required, Required );
00169 }
00170 }
00171 }
00172
00184 void If_CutSortInputPins( If_Man_t * p, If_Cut_t * pCut, int * pPinPerm, float * pPinDelays )
00185 {
00186 If_Obj_t * pLeaf;
00187 int i, j, best_i, temp;
00188
00189 If_CutForEachLeaf( p, pCut, pLeaf, i )
00190 {
00191 pPinPerm[i] = i;
00192 pPinDelays[i] = If_ObjCutBest(pLeaf)->Delay;
00193 }
00194
00195
00196 for ( i = 0; i < (int)pCut->nLeaves-1; i++ )
00197 {
00198 best_i = i;
00199 for ( j = i+1; j < (int)pCut->nLeaves; j++ )
00200 if ( pPinDelays[pPinPerm[j]] > pPinDelays[pPinPerm[best_i]] )
00201 best_i = j;
00202 if ( best_i == i )
00203 continue;
00204 temp = pPinPerm[i];
00205 pPinPerm[i] = pPinPerm[best_i];
00206 pPinPerm[best_i] = temp;
00207 }
00208
00209 assert( pPinPerm[0] < (int)pCut->nLeaves );
00210 for ( i = 1; i < (int)pCut->nLeaves; i++ )
00211 {
00212 assert( pPinPerm[i] < (int)pCut->nLeaves );
00213 assert( pPinDelays[pPinPerm[i-1]] >= pPinDelays[pPinPerm[i]] );
00214 }
00215 }
00216
00220
00221