src/map/fpga/fpgaCutUtils.c File Reference

#include "fpgaInt.h"
Include dependency graph for fpgaCutUtils.c:

Go to the source code of this file.

Functions

Fpga_Cut_tFpga_CutAlloc (Fpga_Man_t *p)
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

Fpga_Cut_t* Fpga_CutAlloc ( Fpga_Man_t p  ) 

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

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

Synopsis [Allocates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 40 of file fpgaCutUtils.c.

00041 {
00042     Fpga_Cut_t * pCut;
00043     pCut = (Fpga_Cut_t *)Extra_MmFixedEntryFetch( p->mmCuts );
00044     memset( pCut, 0, sizeof(Fpga_Cut_t) );
00045     return pCut;
00046 }

Fpga_Cut_t* Fpga_CutCreateSimple ( Fpga_Man_t p,
Fpga_Node_t pNode 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file fpgaCutUtils.c.

00121 {
00122     Fpga_Cut_t * pCut;
00123     pCut = Fpga_CutAlloc( p );
00124     pCut->pRoot       = pNode;
00125     pCut->nLeaves     = 1;
00126     pCut->ppLeaves[0] = pNode;
00127     pCut->uSign = FPGA_SEQ_SIGN(pCut->ppLeaves[0]);
00128     return pCut;
00129 }

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 417 of file fpgaCutUtils.c.

00418 {
00419     Fpga_Node_t * pNodeChild;
00420     float aArea;
00421     int i;
00422 
00423     // deref the fanouts
00424 //    if ( fFanouts ) 
00425 //        Fpga_CutRemoveFanouts( pMan, pNode, pCut );
00426 
00427     // start the area of this cut
00428     aArea = pMan->pLutLib->pLutAreas[pCut->nLeaves];
00429     // go through the children
00430     for ( i = 0; i < pCut->nLeaves; i++ )
00431     {
00432         pNodeChild = pCut->ppLeaves[i];
00433         assert( pNodeChild->nRefs > 0 );
00434         if ( --pNodeChild->nRefs > 0 )  
00435             continue;
00436         if ( !Fpga_NodeIsAnd(pNodeChild) ) 
00437             continue;
00438         aArea += Fpga_CutDeref( pMan, pNodeChild, pNodeChild->pCutBest, fFanouts );
00439     }
00440     return aArea;
00441 }

Fpga_Cut_t* Fpga_CutDup ( Fpga_Man_t p,
Fpga_Cut_t pCutOld 
)

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

Synopsis [Duplicates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 59 of file fpgaCutUtils.c.

00060 {
00061     Fpga_Cut_t * pCutNew;
00062     int i;
00063     pCutNew = Fpga_CutAlloc( p );
00064     pCutNew->pRoot   = pCutOld->pRoot;
00065     pCutNew->nLeaves = pCutOld->nLeaves;
00066     for ( i = 0; i < pCutOld->nLeaves; i++ )
00067         pCutNew->ppLeaves[i] = pCutOld->ppLeaves[i];
00068     return pCutNew;
00069 }

void Fpga_CutFree ( Fpga_Man_t p,
Fpga_Cut_t pCut 
)

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

Synopsis [Deallocates the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 82 of file fpgaCutUtils.c.

00083 {
00084     if ( pCut )
00085     Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pCut );
00086 }

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 358 of file fpgaCutUtils.c.

00359 {
00360     float aResult, aResult2;
00361     if ( pCut->nLeaves == 1 )
00362         return 0;
00363     aResult2 = Fpga_CutRef( pMan, NULL, pCut, 0 );
00364     aResult  = Fpga_CutDeref( pMan, NULL, pCut, 0 );
00365     assert( Fpga_FloatEqual( pMan, aResult, aResult2 ) );
00366     return aResult;
00367 }

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 310 of file fpgaCutUtils.c.

00311 {
00312     Fpga_Cut_t * pCutFanin;
00313     int i;
00314     pCut->aFlow = pMan->pLutLib->pLutAreas[pCut->nLeaves];
00315     for ( i = 0; i < pCut->nLeaves; i++ )
00316     {
00317         // get the cut implementing this phase of the fanin
00318         pCutFanin  = pCut->ppLeaves[i]->pCutBest;   
00319         assert( pCutFanin );
00320         pCut->aFlow  += pCutFanin->aFlow / pCut->ppLeaves[i]->nRefs;
00321     }
00322     return pCut->aFlow;
00323 }

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 336 of file fpgaCutUtils.c.

00337 {
00338     float aResult, aResult2;
00339     if ( pCut->nLeaves == 1 )
00340         return 0;
00341     aResult  = Fpga_CutDeref( pMan, NULL, pCut, 0 );
00342     aResult2 = Fpga_CutRef( pMan, NULL, pCut, 0 );
00343     assert( Fpga_FloatEqual( pMan, aResult, aResult2 ) );
00344     return aResult;
00345 }

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 275 of file fpgaCutUtils.c.

00276 {
00277     Fpga_Cut_t * pFaninCut;
00278     int i;
00279     pCut->tArrival = -FPGA_FLOAT_LARGE;
00280     pCut->aFlow    = pMan->pLutLib->pLutAreas[pCut->nLeaves];
00281     for ( i = 0; i < pCut->nLeaves; i++ )
00282     {
00283         pFaninCut = pCut->ppLeaves[i]->pCutBest;
00284         if ( pCut->tArrival < pFaninCut->tArrival )
00285              pCut->tArrival = pFaninCut->tArrival;
00286         // if the fanout count is not set, assume it to be 1
00287         if ( pCut->ppLeaves[i]->nRefs == 0 )
00288             pCut->aFlow += pFaninCut->aFlow;
00289         else
00290 //            pCut->aFlow += pFaninCut->aFlow / pCut->ppLeaves[i]->nRefs;
00291             pCut->aFlow += pFaninCut->aFlow / pCut->ppLeaves[i]->aEstFanouts;
00292     }
00293     // use the first pin to compute the delay of the LUT 
00294     // (this mapper does not support the variable pin delay model)
00295     pCut->tArrival += pMan->pLutLib->pLutDelays[pCut->nLeaves][0];
00296 }

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 143 of file fpgaCutUtils.c.

00144 {
00145     return p->pLutLib->pLutAreas[pCut->nLeaves];
00146 }

Fpga_Cut_t* Fpga_CutListAppend ( Fpga_Cut_t pSetAll,
Fpga_Cut_t pSets 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file fpgaCutUtils.c.

00160 {
00161     Fpga_Cut_t * pPrev, * pTemp;
00162     if ( pSetAll == NULL )
00163         return pSets;
00164     if ( pSets == NULL )
00165         return pSetAll;
00166     // find the last one
00167     for ( pTemp = pSets; pTemp; pTemp = pTemp->pNext )
00168         pPrev = pTemp;
00169     // append all the end of the current set
00170     assert( pPrev->pNext == NULL );
00171     pPrev->pNext = pSetAll;
00172     return pSets;
00173 }

int Fpga_CutListCount ( Fpga_Cut_t pSets  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 207 of file fpgaCutUtils.c.

00208 {
00209     Fpga_Cut_t * pTemp;
00210     int i;
00211     for ( i = 0, pTemp = pSets; pTemp; pTemp = pTemp->pNext, i++ );
00212     return i;
00213 }

void Fpga_CutListRecycle ( Fpga_Man_t p,
Fpga_Cut_t pSetList,
Fpga_Cut_t pSave 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 186 of file fpgaCutUtils.c.

00187 {
00188     Fpga_Cut_t * pNext, * pTemp;
00189     for ( pTemp = pSetList, pNext = pTemp? pTemp->pNext : NULL; 
00190           pTemp; 
00191           pTemp = pNext, pNext = pNext? pNext->pNext : NULL )
00192         if ( pTemp != pSave )
00193             Extra_MmFixedEntryRecycle( p->mmCuts, (char *)pTemp );
00194 }

void Fpga_CutPrint ( Fpga_Man_t p,
Fpga_Node_t pRoot,
Fpga_Cut_t pCut 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file fpgaCutUtils.c.

00100 {
00101     int i;
00102     printf( "CUT:  Delay = %4.2f. Area = %4.2f. Nodes = %d -> {", 
00103         pCut->tArrival, pCut->aFlow, pRoot->Num );
00104     for ( i = 0; i < pCut->nLeaves; i++ )
00105         printf( " %d", pCut->ppLeaves[i]->Num );
00106     printf( " } \n" );
00107 }

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 380 of file fpgaCutUtils.c.

00381 {
00382     Fpga_Node_t * pNodeChild;
00383     float aArea;
00384     int i;
00385 
00386     // deref the fanouts
00387 //    if ( fFanouts ) 
00388 //        Fpga_CutInsertFanouts( pMan, pNode, pCut );
00389 
00390     // start the area of this cut
00391     aArea = pMan->pLutLib->pLutAreas[pCut->nLeaves];
00392     // go through the children
00393     for ( i = 0; i < pCut->nLeaves; i++ )
00394     {
00395         pNodeChild = pCut->ppLeaves[i];
00396         assert( pNodeChild->nRefs >= 0 );
00397         if ( pNodeChild->nRefs++ > 0 )  
00398             continue;
00399         if ( !Fpga_NodeIsAnd(pNodeChild) ) 
00400             continue;
00401         aArea += Fpga_CutRef( pMan, pNodeChild, pNodeChild->pCutBest, fFanouts );
00402     }
00403     return aArea;
00404 }

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 455 of file fpgaCutUtils.c.

00456 {
00457     int i;
00458     for ( i = 0; i < pMan->vNodesAll->nSize; i++ )
00459         if ( pMan->vNodesAll->pArray[i]->pCutOld )
00460         {
00461             pMan->vNodesAll->pArray[i]->pCutBest = pMan->vNodesAll->pArray[i]->pCutOld;
00462             pMan->vNodesAll->pArray[i]->pCutOld  = NULL;
00463         }
00464 }


Generated on Tue Jan 5 12:19:02 2010 for abc70930 by  doxygen 1.6.1