abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fpgaCutUtils.c File Reference
#include "fpgaInt.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Fpga_Cut_t
Fpga_CutAlloc (Fpga_Man_t *p)
 DECLARATIONS ///. More...
 
Fpga_Cut_tFpga_CutDup (Fpga_Man_t *p, Fpga_Cut_t *pCutOld)
 
void Fpga_CutFree (Fpga_Man_t *p, Fpga_Cut_t *pCut)
 
void Fpga_CutPrint (Fpga_Man_t *p, Fpga_Node_t *pRoot, Fpga_Cut_t *pCut)
 
Fpga_Cut_tFpga_CutCreateSimple (Fpga_Man_t *p, Fpga_Node_t *pNode)
 
float Fpga_CutGetRootArea (Fpga_Man_t *p, Fpga_Cut_t *pCut)
 
Fpga_Cut_tFpga_CutListAppend (Fpga_Cut_t *pSetAll, Fpga_Cut_t *pSets)
 
void Fpga_CutListRecycle (Fpga_Man_t *p, Fpga_Cut_t *pSetList, Fpga_Cut_t *pSave)
 
int Fpga_CutListCount (Fpga_Cut_t *pSets)
 
void Fpga_CutGetParameters (Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
 
float Fpga_CutGetAreaFlow (Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
 
float Fpga_CutGetAreaRefed (Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
 
float Fpga_CutGetAreaDerefed (Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
 
float Fpga_CutRef (Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
 
float Fpga_CutDeref (Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
 
void Fpga_MappingSetUsedCuts (Fpga_Man_t *pMan)
 

Function Documentation

DECLARATIONS ///.

CFile****************************************************************

FileName [fpgaCutUtils.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [Generic technology mapping engine.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - August 18, 2004.]

Revision [

Id:
fpgaCutUtils.h,v 1.0 2003/09/08 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Allocates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 43 of file fpgaCutUtils.c.

44 {
45  Fpga_Cut_t * pCut;
47  memset( pCut, 0, sizeof(Fpga_Cut_t) );
48  return pCut;
49 }
char * memset()
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
Extra_MmFixed_t * mmCuts
Definition: fpgaInt.h:141
Fpga_Cut_t* Fpga_CutCreateSimple ( Fpga_Man_t p,
Fpga_Node_t pNode 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 123 of file fpgaCutUtils.c.

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 }
#define FPGA_SEQ_SIGN(p)
Definition: fpgaInt.h:70
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
unsigned uSign
Definition: fpgaInt.h:239
ABC_NAMESPACE_IMPL_START Fpga_Cut_t * Fpga_CutAlloc(Fpga_Man_t *p)
DECLARATIONS ///.
Definition: fpgaCutUtils.c:43
Fpga_Node_t * pRoot
Definition: fpgaInt.h:236
float Fpga_CutDeref ( Fpga_Man_t pMan,
Fpga_Node_t pNode,
Fpga_Cut_t pCut,
int  fFanouts 
)

function*************************************************************

synopsis [Dereferences the cut.]

description [This procedure is similar to the procedure NodeRecusiveDeref.]

sideeffects []

seealso []

Definition at line 421 of file fpgaCutUtils.c.

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 }
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
for(p=first;p->value< newval;p=p->next)
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
float Fpga_CutDeref(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaCutUtils.c:421
#define assert(ex)
Definition: util_old.h:213
Fpga_LutLib_t * pLutLib
Definition: fpgaInt.h:137
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
Fpga_Cut_t* Fpga_CutDup ( Fpga_Man_t p,
Fpga_Cut_t pCutOld 
)

Function*************************************************************

Synopsis [Duplicates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file fpgaCutUtils.c.

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 }
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
ABC_NAMESPACE_IMPL_START Fpga_Cut_t * Fpga_CutAlloc(Fpga_Man_t *p)
DECLARATIONS ///.
Definition: fpgaCutUtils.c:43
Fpga_Node_t * pRoot
Definition: fpgaInt.h:236
void Fpga_CutFree ( Fpga_Man_t p,
Fpga_Cut_t pCut 
)

Function*************************************************************

Synopsis [Deallocates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file fpgaCutUtils.c.

86 {
87  if ( pCut )
88  Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pCut );
89 }
Extra_MmFixed_t * mmCuts
Definition: fpgaInt.h:141
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
float Fpga_CutGetAreaDerefed ( Fpga_Man_t pMan,
Fpga_Cut_t pCut 
)

function*************************************************************

synopsis [Computes the exact area associated with the cut.]

description []

sideeffects []

seealso []

Definition at line 362 of file fpgaCutUtils.c.

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 }
float Fpga_CutRef(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaCutUtils.c:384
static int Fpga_FloatEqual(Fpga_Man_t *p, float Arg1, float Arg2)
Definition: fpgaInt.h:283
float Fpga_CutDeref(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaCutUtils.c:421
#define assert(ex)
Definition: util_old.h:213
float Fpga_CutGetAreaFlow ( Fpga_Man_t pMan,
Fpga_Cut_t pCut 
)

function*************************************************************

synopsis [Computes the area flow of the cut.]

description []

sideeffects []

seealso []

Definition at line 314 of file fpgaCutUtils.c.

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 }
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
for(p=first;p->value< newval;p=p->next)
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
#define assert(ex)
Definition: util_old.h:213
Fpga_LutLib_t * pLutLib
Definition: fpgaInt.h:137
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
float Fpga_CutGetAreaRefed ( Fpga_Man_t pMan,
Fpga_Cut_t pCut 
)

function*************************************************************

synopsis [Computes the exact area associated with the cut.]

description []

sideeffects []

seealso []

Definition at line 340 of file fpgaCutUtils.c.

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 }
float Fpga_CutRef(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaCutUtils.c:384
static int Fpga_FloatEqual(Fpga_Man_t *p, float Arg1, float Arg2)
Definition: fpgaInt.h:283
float Fpga_CutDeref(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaCutUtils.c:421
#define assert(ex)
Definition: util_old.h:213
void Fpga_CutGetParameters ( Fpga_Man_t pMan,
Fpga_Cut_t pCut 
)

Function*************************************************************

Synopsis [Computes the arrival time and the area flow of the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 279 of file fpgaCutUtils.c.

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 }
float pLutDelays[FPGA_MAX_LUTSIZE+1][FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:176
#define FPGA_FLOAT_LARGE
Definition: fpgaInt.h:65
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
for(p=first;p->value< newval;p=p->next)
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
Fpga_LutLib_t * pLutLib
Definition: fpgaInt.h:137
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
float Fpga_CutGetRootArea ( Fpga_Man_t p,
Fpga_Cut_t pCut 
)

function*************************************************************

synopsis [Computes the exact area associated with the cut.]

description []

sideeffects []

seealso []

Definition at line 146 of file fpgaCutUtils.c.

147 {
148  return p->pLutLib->pLutAreas[(int)pCut->nLeaves];
149 }
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
Fpga_LutLib_t * pLutLib
Definition: fpgaInt.h:137
Fpga_Cut_t* Fpga_CutListAppend ( Fpga_Cut_t pSetAll,
Fpga_Cut_t pSets 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 162 of file fpgaCutUtils.c.

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 }
#define assert(ex)
Definition: util_old.h:213
Fpga_Cut_t * pNext
Definition: fpgaInt.h:246
int Fpga_CutListCount ( Fpga_Cut_t pSets)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 211 of file fpgaCutUtils.c.

212 {
213  Fpga_Cut_t * pTemp;
214  int i;
215  for ( i = 0, pTemp = pSets; pTemp; pTemp = pTemp->pNext, i++ );
216  return i;
217 }
Fpga_Cut_t * pNext
Definition: fpgaInt.h:246
void Fpga_CutListRecycle ( Fpga_Man_t p,
Fpga_Cut_t pSetList,
Fpga_Cut_t pSave 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file fpgaCutUtils.c.

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 }
Extra_MmFixed_t * mmCuts
Definition: fpgaInt.h:141
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
Fpga_Cut_t * pNext
Definition: fpgaInt.h:246
void Fpga_CutPrint ( Fpga_Man_t p,
Fpga_Node_t pRoot,
Fpga_Cut_t pCut 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file fpgaCutUtils.c.

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 }
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
float Fpga_CutRef ( Fpga_Man_t pMan,
Fpga_Node_t pNode,
Fpga_Cut_t pCut,
int  fFanouts 
)

function*************************************************************

synopsis [References the cut.]

description [This procedure is similar to the procedure NodeReclaim.]

sideeffects []

seealso []

Definition at line 384 of file fpgaCutUtils.c.

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 }
float Fpga_CutRef(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaCutUtils.c:384
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
for(p=first;p->value< newval;p=p->next)
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
#define assert(ex)
Definition: util_old.h:213
Fpga_LutLib_t * pLutLib
Definition: fpgaInt.h:137
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
void Fpga_MappingSetUsedCuts ( Fpga_Man_t pMan)

Function*************************************************************

Synopsis [Sets the used cuts to be the currently selected ones.]

Description []

SideEffects []

SeeAlso []

Definition at line 459 of file fpgaCutUtils.c.

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 }
Fpga_Cut_t * pCutOld
Definition: fpgaInt.h:223
Fpga_NodeVec_t * vNodesAll
Definition: fpgaInt.h:111
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222