ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
mapperCutUtils.c
Go to the documentation of this file.
1
18
19#include "mapperInt.h"
20
22
23
27
31
44{
45 Map_Cut_t * pCut;
46 Map_Match_t * pMatch;
47 pCut = (Map_Cut_t *)Extra_MmFixedEntryFetch( p->mmCuts );
48 memset( pCut, 0, sizeof(Map_Cut_t) );
49
50 pMatch = pCut->M;
51 pMatch->AreaFlow = MAP_FLOAT_LARGE; // unassigned
52 pMatch->tArrive.Rise = MAP_FLOAT_LARGE; // unassigned
53 pMatch->tArrive.Fall = MAP_FLOAT_LARGE; // unassigned
54 pMatch->tArrive.Worst = MAP_FLOAT_LARGE; // unassigned
55
56 pMatch = pCut->M + 1;
57 pMatch->AreaFlow = MAP_FLOAT_LARGE; // unassigned
58 pMatch->tArrive.Rise = MAP_FLOAT_LARGE; // unassigned
59 pMatch->tArrive.Fall = MAP_FLOAT_LARGE; // unassigned
60 pMatch->tArrive.Worst = MAP_FLOAT_LARGE; // unassigned
61 return pCut;
62}
63
76{
77 if ( pCut )
78 Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pCut );
79}
80
92void Map_CutPrint( Map_Man_t * p, Map_Node_t * pRoot, Map_Cut_t * pCut, int fPhase )
93{
94 int i;
95 printf( "CUT: Delay = (%4.2f, %4.2f). Area = %4.2f. Nodes = %d -> {",
96 pCut->M[fPhase].tArrive.Rise, pCut->M[fPhase].tArrive.Fall, pCut->M[fPhase].AreaFlow, pRoot->Num );
97 for ( i = 0; i < pCut->nLeaves; i++ )
98 printf( " %d", pCut->ppLeaves[i]->Num );
99 printf( " } \n" );
100}
101
102
114float Map_CutGetRootArea( Map_Cut_t * pCut, int fPhase )
115{
116 assert( pCut->M[fPhase].pSuperBest );
117 return pCut->M[fPhase].pSuperBest->Area;
118}
119
131int Map_CutGetLeafPhase( Map_Cut_t * pCut, int fPhase, int iLeaf )
132{
133 assert( pCut->M[fPhase].pSuperBest );
134 return (( pCut->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0);
135}
136
148int Map_NodeGetLeafPhase( Map_Node_t * pNode, int fPhase, int iLeaf )
149{
150 assert( pNode->pCutBest[fPhase]->M[fPhase].pSuperBest );
151 return (( pNode->pCutBest[fPhase]->M[fPhase].uPhaseBest & (1<<iLeaf) ) == 0);
152}
153
166{
167 Map_Cut_t * pPrev = NULL; // Suppress "might be used uninitialized"
168 Map_Cut_t * pTemp;
169 if ( pSetAll == NULL )
170 return pSets;
171 if ( pSets == NULL )
172 return pSetAll;
173 // find the last one
174 for ( pTemp = pSets; pTemp; pTemp = pTemp->pNext )
175 pPrev = pTemp;
176 // append all the end of the current set
177 assert( pPrev->pNext == NULL );
178 pPrev->pNext = pSetAll;
179 return pSets;
180}
181
193void Map_CutListRecycle( Map_Man_t * p, Map_Cut_t * pSetList, Map_Cut_t * pSave )
194{
195 Map_Cut_t * pNext, * pTemp;
196 for ( pTemp = pSetList, pNext = pTemp? pTemp->pNext : NULL;
197 pTemp;
198 pTemp = pNext, pNext = pNext? pNext->pNext : NULL )
199 if ( pTemp != pSave )
200 Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pTemp );
201}
202
215{
216 Map_Cut_t * pTemp;
217 int i;
218 for ( i = 0, pTemp = pSets; pTemp; pTemp = pTemp->pNext, i++ );
219 return i;
220}
221
234{
235 if ( pObj->TravId == pObj->p->nTravIds )
236 return;
237 pObj->TravId = pObj->p->nTravIds;
238 Map_CutInternalNodes_rec( Map_Regular(pObj->p1), vAnds );
239 Map_CutInternalNodes_rec( Map_Regular(pObj->p2), vAnds );
240 Vec_PtrPush( vAnds, pObj );
241}
243{
244 Vec_Ptr_t * vAnds = Vec_PtrAlloc( 4 );
245 Map_Node_t * pTemp; int i;
246 pObj->p->nTravIds++;
247 for ( i = 0; i < pCut->nLeaves; i++ )
248 pCut->ppLeaves[i]->TravId = pObj->p->nTravIds;
249 Map_CutInternalNodes_rec( pObj, vAnds );
250 if ( 0 )
251 {
252 printf( "Leaves:\n" );
253 for ( i = 0; i < pCut->nLeaves; i++ )
254 printf( " %d", pCut->ppLeaves[i]->Num );
255 printf( "\n" );
256 printf( "Nodes:\n" );
257 Vec_PtrForEachEntry( Map_Node_t *, vAnds, pTemp, i )
258 printf( "%d = %s%d & %s%d\n", pTemp->Num,
259 Map_IsComplement(pTemp->p1) ? "~" : " ", Map_Regular(pTemp->p1)->Num,
260 Map_IsComplement(pTemp->p2) ? "~" : " ", Map_Regular(pTemp->p2)->Num );
261 printf( "\n" );
262 }
263 return vAnds;
264}
265
266
267#if 0
268
280void Map_CutRemoveFanouts( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
281{
282 Map_NodeVec_t * vFanouts;
283 int i, k;
284 for ( i = 0; i < pCut->nLeaves; i++ )
285 {
286 vFanouts = pCut->ppLeaves[i]->vFanouts;
287 for ( k = 0; k < vFanouts->nSize; k++ )
288 if ( vFanouts->pArray[k] == pNode )
289 break;
290 assert( k != vFanouts->nSize );
291 for ( k++; k < vFanouts->nSize; k++ )
292 vFanouts->pArray[k-1] = vFanouts->pArray[k];
293 vFanouts->nSize--;
294 }
295}
296
308void Map_CutInsertFanouts( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
309{
310 int i;
311 for ( i = 0; i < pCut->nLeaves; i++ )
312 Map_NodeVecPush( pCut->ppLeaves[i]->vFanouts, pNode );
313}
314
315#endif
316
317
321
322
324
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
Map_Cut_t * Map_CutListAppend(Map_Cut_t *pSetAll, Map_Cut_t *pSets)
ABC_NAMESPACE_IMPL_START Map_Cut_t * Map_CutAlloc(Map_Man_t *p)
DECLARATIONS ///.
void Map_CutPrint(Map_Man_t *p, Map_Node_t *pRoot, Map_Cut_t *pCut, int fPhase)
int Map_CutGetLeafPhase(Map_Cut_t *pCut, int fPhase, int iLeaf)
int Map_NodeGetLeafPhase(Map_Node_t *pNode, int fPhase, int iLeaf)
void Map_CutFree(Map_Man_t *p, Map_Cut_t *pCut)
int Map_CutListCount(Map_Cut_t *pSets)
void Map_CutListRecycle(Map_Man_t *p, Map_Cut_t *pSetList, Map_Cut_t *pSave)
void Map_CutInternalNodes_rec(Map_Node_t *pObj, Vec_Ptr_t *vAnds)
Vec_Ptr_t * Map_CutInternalNodes(Map_Node_t *pObj, Map_Cut_t *pCut)
float Map_CutGetRootArea(Map_Cut_t *pCut, int fPhase)
void Map_CutInsertFanouts(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
void Map_CutRemoveFanouts(Map_Node_t *pNode, Map_Cut_t *pCut, int fPhase)
void Map_NodeVecPush(Map_NodeVec_t *p, Map_Node_t *Entry)
Definition mapperVec.c:190
#define MAP_FLOAT_LARGE
Definition mapperInt.h:61
typedefABC_NAMESPACE_HEADER_START struct Map_ManStruct_t_ Map_Man_t
INCLUDES ///.
Definition mapper.h:40
struct Map_MatchStruct_t_ Map_Match_t
Definition mapper.h:44
struct Map_CutStruct_t_ Map_Cut_t
Definition mapper.h:43
#define Map_Regular(p)
Definition mapper.h:68
#define Map_IsComplement(p)
GLOBAL VARIABLES ///.
Definition mapper.h:67
struct Map_NodeVecStruct_t_ Map_NodeVec_t
Definition mapper.h:42
struct Map_NodeStruct_t_ Map_Node_t
Definition mapper.h:41
Map_Match_t M[2]
Definition mapperInt.h:275
Map_Node_t * ppLeaves[6]
Definition mapperInt.h:269
Map_Cut_t * pNext
Definition mapperInt.h:266
Map_Super_t * pSuperBest
Definition mapperInt.h:257
unsigned uPhaseBest
Definition mapperInt.h:256
Map_Time_t tArrive
Definition mapperInt.h:259
Map_Cut_t * pCutBest[2]
Definition mapperInt.h:243
Map_Man_t * p
Definition mapperInt.h:208
Map_Node_t * p2
Definition mapperInt.h:226
Map_Node_t * p1
Definition mapperInt.h:225
Map_Node_t ** pArray
Definition mapperInt.h:305
#define assert(ex)
Definition util_old.h:213
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55