00001
00019 #include "mapperInt.h"
00020
00024
00028
00040 Map_Cut_t * Map_CutAlloc( Map_Man_t * p )
00041 {
00042 Map_Cut_t * pCut;
00043 Map_Match_t * pMatch;
00044 pCut = (Map_Cut_t *)Extra_MmFixedEntryFetch( p->mmCuts );
00045 memset( pCut, 0, sizeof(Map_Cut_t) );
00046
00047 pMatch = pCut->M;
00048 pMatch->AreaFlow = MAP_FLOAT_LARGE;
00049 pMatch->tArrive.Rise = MAP_FLOAT_LARGE;
00050 pMatch->tArrive.Fall = MAP_FLOAT_LARGE;
00051 pMatch->tArrive.Worst = MAP_FLOAT_LARGE;
00052
00053 pMatch = pCut->M + 1;
00054 pMatch->AreaFlow = MAP_FLOAT_LARGE;
00055 pMatch->tArrive.Rise = MAP_FLOAT_LARGE;
00056 pMatch->tArrive.Fall = MAP_FLOAT_LARGE;
00057 pMatch->tArrive.Worst = MAP_FLOAT_LARGE;
00058 return pCut;
00059 }
00060
00072 void Map_CutFree( Map_Man_t * p, Map_Cut_t * pCut )
00073 {
00074 if ( pCut )
00075 Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pCut );
00076 }
00077
00089 void Map_CutPrint( Map_Man_t * p, Map_Node_t * pRoot, Map_Cut_t * pCut, int fPhase )
00090 {
00091 int i;
00092 printf( "CUT: Delay = (%4.2f, %4.2f). Area = %4.2f. Nodes = %d -> {",
00093 pCut->M[fPhase].tArrive.Rise, pCut->M[fPhase].tArrive.Fall, pCut->M[fPhase].AreaFlow, pRoot->Num );
00094 for ( i = 0; i < pCut->nLeaves; i++ )
00095 printf( " %d", pCut->ppLeaves[i]->Num );
00096 printf( " } \n" );
00097 }
00098
00099
00111 float Map_CutGetRootArea( Map_Cut_t * pCut, int fPhase )
00112 {
00113 assert( pCut->M[fPhase].pSuperBest );
00114 return pCut->M[fPhase].pSuperBest->Area;
00115 }
00116
00128 int Map_CutGetLeafPhase( Map_Cut_t * pCut, int fPhase, int iLeaf )
00129 {
00130 assert( pCut->M[fPhase].pSuperBest );
00131 return (( pCut->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0);
00132 }
00133
00145 int Map_NodeGetLeafPhase( Map_Node_t * pNode, int fPhase, int iLeaf )
00146 {
00147 assert( pNode->pCutBest[fPhase]->M[fPhase].pSuperBest );
00148 return (( pNode->pCutBest[fPhase]->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0);
00149 }
00150
00162 Map_Cut_t * Map_CutListAppend( Map_Cut_t * pSetAll, Map_Cut_t * pSets )
00163 {
00164 Map_Cut_t * pPrev, * pTemp;
00165 if ( pSetAll == NULL )
00166 return pSets;
00167 if ( pSets == NULL )
00168 return pSetAll;
00169
00170 for ( pTemp = pSets; pTemp; pTemp = pTemp->pNext )
00171 pPrev = pTemp;
00172
00173 assert( pPrev->pNext == NULL );
00174 pPrev->pNext = pSetAll;
00175 return pSets;
00176 }
00177
00189 void Map_CutListRecycle( Map_Man_t * p, Map_Cut_t * pSetList, Map_Cut_t * pSave )
00190 {
00191 Map_Cut_t * pNext, * pTemp;
00192 for ( pTemp = pSetList, pNext = pTemp? pTemp->pNext : NULL;
00193 pTemp;
00194 pTemp = pNext, pNext = pNext? pNext->pNext : NULL )
00195 if ( pTemp != pSave )
00196 Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pTemp );
00197 }
00198
00210 int Map_CutListCount( Map_Cut_t * pSets )
00211 {
00212 Map_Cut_t * pTemp;
00213 int i;
00214 for ( i = 0, pTemp = pSets; pTemp; pTemp = pTemp->pNext, i++ );
00215 return i;
00216 }
00217
00218 #if 0
00219
00231 void Map_CutRemoveFanouts( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
00232 {
00233 Map_NodeVec_t * vFanouts;
00234 int i, k;
00235 for ( i = 0; i < pCut->nLeaves; i++ )
00236 {
00237 vFanouts = pCut->ppLeaves[i]->vFanouts;
00238 for ( k = 0; k < vFanouts->nSize; k++ )
00239 if ( vFanouts->pArray[k] == pNode )
00240 break;
00241 assert( k != vFanouts->nSize );
00242 for ( k++; k < vFanouts->nSize; k++ )
00243 vFanouts->pArray[k-1] = vFanouts->pArray[k];
00244 vFanouts->nSize--;
00245 }
00246 }
00247
00259 void Map_CutInsertFanouts( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
00260 {
00261 int i;
00262 for ( i = 0; i < pCut->nLeaves; i++ )
00263 Map_NodeVecPush( pCut->ppLeaves[i]->vFanouts, pNode );
00264 }
00265
00266 #endif
00267
00268
00272
00273