ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fpgaCutUtils.c
Go to the documentation of this file.
1
18
19#include "fpgaInt.h"
20
22
23
27
31
44{
45 Fpga_Cut_t * pCut;
46 pCut = (Fpga_Cut_t *)Extra_MmFixedEntryFetch( p->mmCuts );
47 memset( pCut, 0, sizeof(Fpga_Cut_t) );
48 return pCut;
49}
50
63{
64 Fpga_Cut_t * pCutNew;
65 int i;
66 pCutNew = Fpga_CutAlloc( p );
67 pCutNew->pRoot = pCutOld->pRoot;
68 pCutNew->nLeaves = pCutOld->nLeaves;
69 for ( i = 0; i < pCutOld->nLeaves; i++ )
70 pCutNew->ppLeaves[i] = pCutOld->ppLeaves[i];
71 return pCutNew;
72}
73
86{
87 if ( pCut )
88 Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pCut );
89}
90
103{
104 int i;
105 printf( "CUT: Delay = %4.2f. Area = %4.2f. Nodes = %d -> {",
106 pCut->tArrival, pCut->aFlow, pRoot->Num );
107 for ( i = 0; i < pCut->nLeaves; i++ )
108 printf( " %d", pCut->ppLeaves[i]->Num );
109 printf( " } \n" );
110}
111
124{
125 Fpga_Cut_t * pCut;
126 pCut = Fpga_CutAlloc( p );
127 pCut->pRoot = pNode;
128 pCut->nLeaves = 1;
129 pCut->ppLeaves[0] = pNode;
130 pCut->uSign = FPGA_SEQ_SIGN(pCut->ppLeaves[0]);
131 return pCut;
132}
133
134
147{
148 return p->pLutLib->pLutAreas[(int)pCut->nLeaves];
149}
150
163{
164 Fpga_Cut_t * pPrev = NULL; // Suppress "might be used uninitialized"
165 Fpga_Cut_t * pTemp;
166 if ( pSetAll == NULL )
167 return pSets;
168 if ( pSets == NULL )
169 return pSetAll;
170 // find the last one
171 for ( pTemp = pSets; pTemp; pTemp = pTemp->pNext )
172 pPrev = pTemp;
173 // append all the end of the current set
174 assert( pPrev->pNext == NULL );
175 pPrev->pNext = pSetAll;
176 return pSets;
177}
178
191{
192 Fpga_Cut_t * pNext, * pTemp;
193 for ( pTemp = pSetList, pNext = pTemp? pTemp->pNext : NULL;
194 pTemp;
195 pTemp = pNext, pNext = pNext? pNext->pNext : NULL )
196 if ( pTemp != pSave )
197 Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pTemp );
198}
199
212{
213 Fpga_Cut_t * pTemp;
214 int i;
215 for ( i = 0, pTemp = pSets; pTemp; pTemp = pTemp->pNext, i++ );
216 return i;
217}
218
219#if 0
220
233{
234 Fpga_NodeVec_t * vFanouts;
235 int i, k;
236 for ( i = 0; i < pCut->nLeaves; i++ )
237 {
238 vFanouts = pCut->ppLeaves[i]->vFanouts;
239 for ( k = 0; k < vFanouts->nSize; k++ )
240 if ( vFanouts->pArray[k] == pNode )
241 break;
242 assert( k != vFanouts->nSize );
243 for ( k++; k < vFanouts->nSize; k++ )
244 vFanouts->pArray[k-1] = vFanouts->pArray[k];
245 vFanouts->nSize--;
246 }
247}
248
261{
262 int i;
263 for ( i = 0; i < pCut->nLeaves; i++ )
264 Fpga_NodeVecPush( pCut->ppLeaves[i]->vFanouts, pNode );
265}
266#endif
267
280{
281 Fpga_Cut_t * pFaninCut;
282 int i;
283 pCut->tArrival = -FPGA_FLOAT_LARGE;
284 pCut->aFlow = pMan->pLutLib->pLutAreas[(int)pCut->nLeaves];
285 for ( i = 0; i < pCut->nLeaves; i++ )
286 {
287 pFaninCut = pCut->ppLeaves[i]->pCutBest;
288 if ( pCut->tArrival < pFaninCut->tArrival )
289 pCut->tArrival = pFaninCut->tArrival;
290 // if the fanout count is not set, assume it to be 1
291 if ( pCut->ppLeaves[i]->nRefs == 0 )
292 pCut->aFlow += pFaninCut->aFlow;
293 else
294// pCut->aFlow += pFaninCut->aFlow / pCut->ppLeaves[i]->nRefs;
295 pCut->aFlow += pFaninCut->aFlow / pCut->ppLeaves[i]->aEstFanouts;
296 }
297 // use the first pin to compute the delay of the LUT
298 // (this mapper does not support the variable pin delay model)
299 pCut->tArrival += pMan->pLutLib->pLutDelays[(int)pCut->nLeaves][0];
300}
301
302
315{
316 Fpga_Cut_t * pCutFanin;
317 int i;
318 pCut->aFlow = pMan->pLutLib->pLutAreas[(int)pCut->nLeaves];
319 for ( i = 0; i < pCut->nLeaves; i++ )
320 {
321 // get the cut implementing this phase of the fanin
322 pCutFanin = pCut->ppLeaves[i]->pCutBest;
323 assert( pCutFanin );
324 pCut->aFlow += pCutFanin->aFlow / pCut->ppLeaves[i]->nRefs;
325 }
326 return pCut->aFlow;
327}
328
341{
342 float aResult, aResult2;
343 if ( pCut->nLeaves == 1 )
344 return 0;
345 aResult = Fpga_CutDeref( pMan, NULL, pCut, 0 );
346 aResult2 = Fpga_CutRef( pMan, NULL, pCut, 0 );
347 assert( Fpga_FloatEqual( pMan, aResult, aResult2 ) );
348 return aResult;
349}
350
363{
364 float aResult, aResult2;
365 if ( pCut->nLeaves == 1 )
366 return 0;
367 aResult2 = Fpga_CutRef( pMan, NULL, pCut, 0 );
368 aResult = Fpga_CutDeref( pMan, NULL, pCut, 0 );
369 assert( Fpga_FloatEqual( pMan, aResult, aResult2 ) );
370 return aResult;
371}
372
384float Fpga_CutRef( Fpga_Man_t * pMan, Fpga_Node_t * pNode, Fpga_Cut_t * pCut, int fFanouts )
385{
386 Fpga_Node_t * pNodeChild;
387 float aArea;
388 int i;
389
390 // deref the fanouts
391// if ( fFanouts )
392// Fpga_CutInsertFanouts( pMan, pNode, pCut );
393
394 // start the area of this cut
395 aArea = pMan->pLutLib->pLutAreas[(int)pCut->nLeaves];
396 // go through the children
397 for ( i = 0; i < pCut->nLeaves; i++ )
398 {
399 pNodeChild = pCut->ppLeaves[i];
400 assert( pNodeChild->nRefs >= 0 );
401 if ( pNodeChild->nRefs++ > 0 )
402 continue;
403 if ( !Fpga_NodeIsAnd(pNodeChild) )
404 continue;
405 aArea += Fpga_CutRef( pMan, pNodeChild, pNodeChild->pCutBest, fFanouts );
406 }
407 return aArea;
408}
409
421float Fpga_CutDeref( Fpga_Man_t * pMan, Fpga_Node_t * pNode, Fpga_Cut_t * pCut, int fFanouts )
422{
423 Fpga_Node_t * pNodeChild;
424 float aArea;
425 int i;
426
427 // deref the fanouts
428// if ( fFanouts )
429// Fpga_CutRemoveFanouts( pMan, pNode, pCut );
430
431 // start the area of this cut
432 aArea = pMan->pLutLib->pLutAreas[(int)pCut->nLeaves];
433 // go through the children
434 for ( i = 0; i < pCut->nLeaves; i++ )
435 {
436 pNodeChild = pCut->ppLeaves[i];
437 assert( pNodeChild->nRefs > 0 );
438 if ( --pNodeChild->nRefs > 0 )
439 continue;
440 if ( !Fpga_NodeIsAnd(pNodeChild) )
441 continue;
442 aArea += Fpga_CutDeref( pMan, pNodeChild, pNodeChild->pCutBest, fFanouts );
443 }
444 return aArea;
445}
446
447
460{
461 int i;
462 for ( i = 0; i < pMan->vNodesAll->nSize; i++ )
463 if ( pMan->vNodesAll->pArray[i]->pCutOld )
464 {
465 pMan->vNodesAll->pArray[i]->pCutBest = pMan->vNodesAll->pArray[i]->pCutOld;
466 pMan->vNodesAll->pArray[i]->pCutOld = NULL;
467 }
468}
469
473
474
476
#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)
int Fpga_CutListCount(Fpga_Cut_t *pSets)
float Fpga_CutGetRootArea(Fpga_Man_t *p, Fpga_Cut_t *pCut)
Fpga_Cut_t * Fpga_CutDup(Fpga_Man_t *p, Fpga_Cut_t *pCutOld)
float Fpga_CutGetAreaDerefed(Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
float Fpga_CutGetAreaRefed(Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
Fpga_Cut_t * Fpga_CutCreateSimple(Fpga_Man_t *p, Fpga_Node_t *pNode)
void Fpga_CutGetParameters(Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
void Fpga_CutPrint(Fpga_Man_t *p, Fpga_Node_t *pRoot, Fpga_Cut_t *pCut)
ABC_NAMESPACE_IMPL_START Fpga_Cut_t * Fpga_CutAlloc(Fpga_Man_t *p)
DECLARATIONS ///.
float Fpga_CutGetAreaFlow(Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
void Fpga_CutListRecycle(Fpga_Man_t *p, Fpga_Cut_t *pSetList, Fpga_Cut_t *pSave)
float Fpga_CutDeref(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
void Fpga_CutFree(Fpga_Man_t *p, Fpga_Cut_t *pCut)
void Fpga_MappingSetUsedCuts(Fpga_Man_t *pMan)
float Fpga_CutRef(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Fpga_Cut_t * Fpga_CutListAppend(Fpga_Cut_t *pSetAll, Fpga_Cut_t *pSets)
void Fpga_CutRemoveFanouts(Fpga_Man_t *p, Fpga_Node_t *pNode, Fpga_Cut_t *pCut)
#define FPGA_SEQ_SIGN(p)
Definition fpgaInt.h:70
void Fpga_CutInsertFanouts(Fpga_Man_t *p, Fpga_Node_t *pNode, Fpga_Cut_t *pCut)
void Fpga_NodeVecPush(Fpga_NodeVec_t *p, Fpga_Node_t *Entry)
Definition fpgaVec.c:169
#define FPGA_FLOAT_LARGE
Definition fpgaInt.h:65
struct Fpga_NodeStruct_t_ Fpga_Node_t
Definition fpga.h:44
struct Fpga_NodeVecStruct_t_ Fpga_NodeVec_t
Definition fpga.h:45
struct Fpga_ManStruct_t_ Fpga_Man_t
STRUCTURE DEFINITIONS ///.
Definition fpga.h:43
struct Fpga_CutStruct_t_ Fpga_Cut_t
Definition fpga.h:46
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition fpgaCreate.c:127
Fpga_Node_t * pRoot
Definition fpgaInt.h:236
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition fpgaInt.h:237
Fpga_Cut_t * pNext
Definition fpgaInt.h:246
unsigned uSign
Definition fpgaInt.h:239
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition fpgaInt.h:175
float pLutDelays[FPGA_MAX_LUTSIZE+1][FPGA_MAX_LUTSIZE+1]
Definition fpgaInt.h:176
Fpga_NodeVec_t * vNodesAll
Definition fpgaInt.h:111
Fpga_LutLib_t * pLutLib
Definition fpgaInt.h:137
Fpga_Cut_t * pCutBest
Definition fpgaInt.h:222
Fpga_Cut_t * pCutOld
Definition fpgaInt.h:223
Fpga_Node_t ** pArray
Definition fpgaInt.h:252
#define assert(ex)
Definition util_old.h:213
char * memset()