abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fpgaInt.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "misc/extra/extra.h"
#include "fpga.h"

Go to the source code of this file.

Data Structures

struct  Fpga_ManStruct_t_
 STRUCTURE DEFINITIONS ///. More...
 
struct  Fpga_LutLibStruct_t_
 
struct  Fpga_NodeStruct_t_
 
struct  Fpga_CutStruct_t_
 
struct  Fpga_NodeVecStruct_t_
 

Macros

#define FPGA_MAX_LEAVES   6
 INCLUDES ///. More...
 
#define FPGA_MASK(n)   ((~((unsigned)0)) >> (32-(n)))
 
#define FPGA_FULL   (~((unsigned)0))
 
#define FPGA_NO_VAR   (-9999.0)
 
#define FPGA_NUM_BYTES(n)   (((n)/16 + (((n)%16) > 0))*16)
 
#define FPGA_MIN(a, b)   (((a) < (b))? (a) : (b))
 
#define FPGA_MAX(a, b)   (((a) > (b))? (a) : (b))
 
#define FPGA_FLOAT_LARGE   ((float)1.0e+20)
 
#define FPGA_FLOAT_SMALL   ((float)1.0e-20)
 
#define FPGA_INT_LARGE   (10000000)
 
#define FPGA_SEQ_SIGN(p)   (1 << (((ABC_PTRUINT_T)p)%31));
 
#define Fpga_CutIsComplement(p)   (((int)((ABC_PTRUINT_T)(p) & 01)))
 
#define Fpga_CutRegular(p)   ((Fpga_Cut_t *)((ABC_PTRUINT_T)(p) & ~01))
 
#define Fpga_CutNot(p)   ((Fpga_Cut_t *)((ABC_PTRUINT_T)(p) ^ 01))
 
#define Fpga_CutNotCond(p, c)   ((Fpga_Cut_t *)((ABC_PTRUINT_T)(p) ^ (c)))
 
#define Fpga_SeqIsComplement(p)   (((int)((ABC_PTRUINT_T) (p) & 01)))
 
#define Fpga_SeqRegular(p)   ((Fpga_Node_t *)((ABC_PTRUINT_T)(p) & ~015))
 
#define Fpga_SeqIndex(p)   ((((ABC_PTRUINT_T)(p)) >> 1) & 07)
 
#define Fpga_SeqIndexCreate(p, Ind)   (((ABC_PTRUINT_T)(p)) | (1 << (((ABC_PTRUINT_T)(Ind)) & 07)))
 
#define Fpga_NodeReadRef(p)   ((Fpga_Regular(p))->nRefs)
 
#define Fpga_NodeRef(p)   ((Fpga_Regular(p))->nRefs++)
 
#define Fpga_NodeIsSimComplement(p)   (Fpga_IsComplement(p)? !(Fpga_Regular(p)->fInv) : (p)->fInv)
 
#define FPGA_RANDOM_UNSIGNED   ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand()))
 
#define Fpga_NodeReadNextFanout(pNode, pFanout)
 
#define Fpga_NodeReadNextFanoutPlace(pNode, pFanout)
 
#define Fpga_NodeForEachFanout(pNode, pFanout)
 
#define Fpga_NodeForEachFanoutSafe(pNode, pFanout, pFanout2)
 

Functions

static int Fpga_FloatMoreThan (Fpga_Man_t *p, float Arg1, float Arg2)
 
static int Fpga_FloatLessThan (Fpga_Man_t *p, float Arg1, float Arg2)
 
static int Fpga_FloatEqual (Fpga_Man_t *p, float Arg1, float Arg2)
 
void Fpga_MappingCuts (Fpga_Man_t *p)
 GLOBAL VARIABLES ///. More...
 
void Fpga_MappingCreatePiCuts (Fpga_Man_t *p)
 
int Fpga_CutCountAll (Fpga_Man_t *pMan)
 
Fpga_Cut_tFpga_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_CutRemoveFanouts (Fpga_Man_t *p, Fpga_Node_t *pNode, Fpga_Cut_t *pCut)
 
void Fpga_CutInsertFanouts (Fpga_Man_t *p, Fpga_Node_t *pNode, 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)
 
float Fpga_CutGetAreaFlow (Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
 
void Fpga_CutGetParameters (Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
 
void Fpga_NodeAddFaninFanout (Fpga_Node_t *pFanin, Fpga_Node_t *pFanout)
 
void Fpga_NodeRemoveFaninFanout (Fpga_Node_t *pFanin, Fpga_Node_t *pFanoutToRemove)
 
int Fpga_NodeGetFanoutNum (Fpga_Node_t *pNode)
 
Fpga_LutLib_tFpga_LutLibRead (char *FileName, int fVerbose)
 
void Fpga_LutLibFree (Fpga_LutLib_t *p)
 
void Fpga_LutLibPrint (Fpga_LutLib_t *pLutLib)
 
int Fpga_LutLibDelaysAreDiscrete (Fpga_LutLib_t *pLutLib)
 
int Fpga_MappingMatches (Fpga_Man_t *p, int fDelayOriented)
 FUNCTION DEFINITIONS ///. More...
 
int Fpga_MappingMatchesArea (Fpga_Man_t *p)
 
int Fpga_MappingMatchesSwitch (Fpga_Man_t *p)
 
void Fpga_MappingShow (Fpga_Man_t *pMan, char *pFileName)
 
void Fpga_MappingShowNodes (Fpga_Man_t *pMan, Fpga_Node_t **ppRoots, int nRoots, char *pFileName)
 
float Fpga_CutGetSwitchDerefed (Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut)
 DECLARATIONS ///. More...
 
float Fpga_CutRefSwitch (Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
 
float Fpga_CutDerefSwitch (Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
 
float Fpga_MappingGetSwitching (Fpga_Man_t *pMan, Fpga_NodeVec_t *vMapping)
 
float Fpga_TimeCutComputeArrival (Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
 DECLARATIONS ///. More...
 
float Fpga_TimeCutComputeArrival_rec (Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
 
float Fpga_TimeComputeArrivalMax (Fpga_Man_t *p)
 
void Fpga_TimeComputeRequiredGlobal (Fpga_Man_t *p, int fFirstTime)
 
void Fpga_TimeComputeRequired (Fpga_Man_t *p, float fRequired)
 
void Fpga_TimePropagateRequired (Fpga_Man_t *p, Fpga_NodeVec_t *vNodes)
 
void Fpga_TimePropagateArrival (Fpga_Man_t *p)
 
Fpga_NodeVec_tFpga_NodeVecAlloc (int nCap)
 FUNCTION DEFINITIONS ///. More...
 
void Fpga_NodeVecFree (Fpga_NodeVec_t *p)
 
Fpga_Node_t ** Fpga_NodeVecReadArray (Fpga_NodeVec_t *p)
 
int Fpga_NodeVecReadSize (Fpga_NodeVec_t *p)
 
void Fpga_NodeVecGrow (Fpga_NodeVec_t *p, int nCapMin)
 
void Fpga_NodeVecShrink (Fpga_NodeVec_t *p, int nSizeNew)
 
void Fpga_NodeVecClear (Fpga_NodeVec_t *p)
 
void Fpga_NodeVecPush (Fpga_NodeVec_t *p, Fpga_Node_t *Entry)
 
int Fpga_NodeVecPushUnique (Fpga_NodeVec_t *p, Fpga_Node_t *Entry)
 
Fpga_Node_tFpga_NodeVecPop (Fpga_NodeVec_t *p)
 
void Fpga_NodeVecWriteEntry (Fpga_NodeVec_t *p, int i, Fpga_Node_t *Entry)
 
Fpga_Node_tFpga_NodeVecReadEntry (Fpga_NodeVec_t *p, int i)
 
void Fpga_NodeVecSortByLevel (Fpga_NodeVec_t *p)
 
void Fpga_SortNodesByArrivalTimes (Fpga_NodeVec_t *p)
 
void Fpga_NodeVecUnion (Fpga_NodeVec_t *p, Fpga_NodeVec_t *p1, Fpga_NodeVec_t *p2)
 
void Fpga_NodeVecPushOrder (Fpga_NodeVec_t *vNodes, Fpga_Node_t *pNode, int fIncreasing)
 
void Fpga_NodeVecReverse (Fpga_NodeVec_t *vNodes)
 
Fpga_NodeVec_tFpga_MappingDfs (Fpga_Man_t *pMan, int fCollectEquiv)
 FUNCTION DEFINITIONS ///. More...
 
Fpga_NodeVec_tFpga_MappingDfsNodes (Fpga_Man_t *pMan, Fpga_Node_t **ppNodes, int nNodes, int fEquiv)
 
int Fpga_CountLevels (Fpga_Man_t *pMan)
 
float Fpga_MappingGetAreaFlow (Fpga_Man_t *p)
 
float Fpga_MappingArea (Fpga_Man_t *pMan)
 
float Fpga_MappingAreaTrav (Fpga_Man_t *pMan)
 
float Fpga_MappingSetRefsAndArea (Fpga_Man_t *pMan)
 
void Fpga_MappingPrintOutputArrivals (Fpga_Man_t *p)
 
void Fpga_MappingSetupTruthTables (unsigned uTruths[][2])
 
void Fpga_MappingSetupMask (unsigned uMask[], int nVarsMax)
 
void Fpga_MappingSortByLevel (Fpga_Man_t *pMan, Fpga_NodeVec_t *vNodes, int fIncreasing)
 
Fpga_NodeVec_tFpga_DfsLim (Fpga_Man_t *pMan, Fpga_Node_t *pNode, int nLevels)
 
Fpga_NodeVec_tFpga_MappingLevelize (Fpga_Man_t *pMan, Fpga_NodeVec_t *vNodes)
 
int Fpga_MappingMaxLevel (Fpga_Man_t *pMan)
 
void Fpga_ManReportChoices (Fpga_Man_t *pMan)
 
void Fpga_MappingSetChoiceLevels (Fpga_Man_t *pMan)
 

Macro Definition Documentation

#define Fpga_CutIsComplement (   p)    (((int)((ABC_PTRUINT_T)(p) & 01)))

Definition at line 73 of file fpgaInt.h.

#define Fpga_CutNot (   p)    ((Fpga_Cut_t *)((ABC_PTRUINT_T)(p) ^ 01))

Definition at line 75 of file fpgaInt.h.

#define Fpga_CutNotCond (   p,
 
)    ((Fpga_Cut_t *)((ABC_PTRUINT_T)(p) ^ (c)))

Definition at line 76 of file fpgaInt.h.

#define Fpga_CutRegular (   p)    ((Fpga_Cut_t *)((ABC_PTRUINT_T)(p) & ~01))

Definition at line 74 of file fpgaInt.h.

#define FPGA_FLOAT_LARGE   ((float)1.0e+20)

Definition at line 65 of file fpgaInt.h.

#define FPGA_FLOAT_SMALL   ((float)1.0e-20)

Definition at line 66 of file fpgaInt.h.

#define FPGA_FULL   (~((unsigned)0))

Definition at line 56 of file fpgaInt.h.

#define FPGA_INT_LARGE   (10000000)

Definition at line 67 of file fpgaInt.h.

#define FPGA_MASK (   n)    ((~((unsigned)0)) >> (32-(n)))

Definition at line 55 of file fpgaInt.h.

#define FPGA_MAX (   a,
 
)    (((a) > (b))? (a) : (b))

Definition at line 62 of file fpgaInt.h.

#define FPGA_MAX_LEAVES   6

INCLUDES ///.

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

FileName [fpgaInt.h]

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

Synopsis [Technology mapping for variable-size-LUT FPGAs.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

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

Revision [

Id:
fpgaInt.h,v 1.8 2004/09/30 21:18:10 satrajit Exp

]PARAMETERS ///MACRO DEFINITIONS ///

Definition at line 52 of file fpgaInt.h.

#define FPGA_MIN (   a,
 
)    (((a) < (b))? (a) : (b))

Definition at line 61 of file fpgaInt.h.

#define FPGA_NO_VAR   (-9999.0)

Definition at line 57 of file fpgaInt.h.

#define Fpga_NodeForEachFanout (   pNode,
  pFanout 
)
Value:
for ( pFanout = (pNode)->pFanPivot; pFanout; \
pFanout = Fpga_NodeReadNextFanout(pNode, pFanout) )
#define Fpga_NodeReadNextFanout(pNode, pFanout)
Definition: fpgaInt.h:258

Definition at line 269 of file fpgaInt.h.

#define Fpga_NodeForEachFanoutSafe (   pNode,
  pFanout,
  pFanout2 
)
Value:
for ( pFanout = (pNode)->pFanPivot, \
pFanout2 = Fpga_NodeReadNextFanout(pNode, pFanout); \
pFanout; \
pFanout = pFanout2, \
pFanout2 = Fpga_NodeReadNextFanout(pNode, pFanout) )
#define Fpga_NodeReadNextFanout(pNode, pFanout)
Definition: fpgaInt.h:258

Definition at line 274 of file fpgaInt.h.

#define Fpga_NodeIsSimComplement (   p)    (Fpga_IsComplement(p)? !(Fpga_Regular(p)->fInv) : (p)->fInv)

Definition at line 89 of file fpgaInt.h.

#define Fpga_NodeReadNextFanout (   pNode,
  pFanout 
)
Value:
( ( pFanout == NULL )? NULL : \
((Fpga_Regular((pFanout)->p1) == (pNode))? \
(pFanout)->pFanFanin1 : (pFanout)->pFanFanin2) )
#define Fpga_Regular(p)
Definition: fpga.h:58

Definition at line 258 of file fpgaInt.h.

#define Fpga_NodeReadNextFanoutPlace (   pNode,
  pFanout 
)
Value:
( (Fpga_Regular((pFanout)->p1) == (pNode))? \
&(pFanout)->pFanFanin1 : &(pFanout)->pFanFanin2 )
#define Fpga_Regular(p)
Definition: fpga.h:58

Definition at line 264 of file fpgaInt.h.

#define Fpga_NodeReadRef (   p)    ((Fpga_Regular(p))->nRefs)

Definition at line 85 of file fpgaInt.h.

#define Fpga_NodeRef (   p)    ((Fpga_Regular(p))->nRefs++)

Definition at line 86 of file fpgaInt.h.

#define FPGA_NUM_BYTES (   n)    (((n)/16 + (((n)%16) > 0))*16)

Definition at line 58 of file fpgaInt.h.

#define FPGA_RANDOM_UNSIGNED   ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand()))

Definition at line 92 of file fpgaInt.h.

#define FPGA_SEQ_SIGN (   p)    (1 << (((ABC_PTRUINT_T)p)%31));

Definition at line 70 of file fpgaInt.h.

#define Fpga_SeqIndex (   p)    ((((ABC_PTRUINT_T)(p)) >> 1) & 07)

Definition at line 81 of file fpgaInt.h.

#define Fpga_SeqIndexCreate (   p,
  Ind 
)    (((ABC_PTRUINT_T)(p)) | (1 << (((ABC_PTRUINT_T)(Ind)) & 07)))

Definition at line 82 of file fpgaInt.h.

#define Fpga_SeqIsComplement (   p)    (((int)((ABC_PTRUINT_T) (p) & 01)))

Definition at line 79 of file fpgaInt.h.

#define Fpga_SeqRegular (   p)    ((Fpga_Node_t *)((ABC_PTRUINT_T)(p) & ~015))

Definition at line 80 of file fpgaInt.h.

Function Documentation

int Fpga_CountLevels ( Fpga_Man_t pMan)
Fpga_Cut_t* Fpga_CutAlloc ( Fpga_Man_t p)

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
int Fpga_CutCountAll ( Fpga_Man_t pMan)

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

Synopsis [Counts all the cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 767 of file fpgaCut.c.

768 {
769  Fpga_Node_t * pNode;
770  Fpga_Cut_t * pCut;
771  int i, nCuts;
772  // go through all the nodes in the unique table of the manager
773  nCuts = 0;
774  for ( i = 0; i < pMan->nBins; i++ )
775  for ( pNode = pMan->pBins[i]; pNode; pNode = pNode->pNext )
776  for ( pCut = pNode->pCuts; pCut; pCut = pCut->pNext )
777  if ( pCut->nLeaves > 1 ) // skip the elementary cuts
778  {
779 // Fpga_CutVolume( pCut );
780  nCuts++;
781  }
782  return nCuts;
783 }
Fpga_Cut_t * pCuts
Definition: fpgaInt.h:224
Fpga_Node_t * pNext
Definition: fpgaInt.h:183
Fpga_Cut_t * pNext
Definition: fpgaInt.h:246
Fpga_Node_t ** pBins
Definition: fpgaInt.h:102
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
float Fpga_CutDerefSwitch ( 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 95 of file fpgaSwitch.c.

96 {
97  Fpga_Node_t * pNodeChild;
98  float aArea;
99  int i;
100  // start the area of this cut
101  aArea = pNode->Switching;
102  if ( pCut->nLeaves == 1 )
103  return aArea;
104  // go through the children
105  for ( i = 0; i < pCut->nLeaves; i++ )
106  {
107  pNodeChild = pCut->ppLeaves[i];
108  assert( pNodeChild->nRefs > 0 );
109  if ( --pNodeChild->nRefs > 0 )
110  continue;
111  aArea += Fpga_CutDerefSwitch( pMan, pNodeChild, pNodeChild->pCutBest, fFanouts );
112  }
113  return aArea;
114 }
float Fpga_CutDerefSwitch(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaSwitch.c:95
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
#define assert(ex)
Definition: util_old.h:213
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
float Fpga_CutGetSwitchDerefed ( Fpga_Man_t pMan,
Fpga_Node_t pNode,
Fpga_Cut_t pCut 
)

DECLARATIONS ///.

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

FileName [fpgaSwitch.c]

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

Synopsis [Generic technology mapping engine.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 8, 2003.]

Revision [

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

]FUNCTION DEFINITIONS /// function*************************************************************

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

description []

sideeffects []

seealso []

Definition at line 43 of file fpgaSwitch.c.

44 {
45  float aResult, aResult2;
46  aResult2 = Fpga_CutRefSwitch( pMan, pNode, pCut, 0 );
47  aResult = Fpga_CutDerefSwitch( pMan, pNode, pCut, 0 );
48 // assert( aResult == aResult2 );
49  return aResult;
50 }
float Fpga_CutDerefSwitch(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaSwitch.c:95
float Fpga_CutRefSwitch(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaSwitch.c:63
void Fpga_CutInsertFanouts ( Fpga_Man_t p,
Fpga_Node_t pNode,
Fpga_Cut_t pCut 
)
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
float Fpga_CutRefSwitch ( 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 63 of file fpgaSwitch.c.

64 {
65  Fpga_Node_t * pNodeChild;
66  float aArea;
67  int i;
68  // start the area of this cut
69  aArea = pNode->Switching;
70  if ( pCut->nLeaves == 1 )
71  return aArea;
72  // go through the children
73  for ( i = 0; i < pCut->nLeaves; i++ )
74  {
75  pNodeChild = pCut->ppLeaves[i];
76  assert( pNodeChild->nRefs >= 0 );
77  if ( pNodeChild->nRefs++ > 0 )
78  continue;
79  aArea += Fpga_CutRefSwitch( pMan, pNodeChild, pNodeChild->pCutBest, fFanouts );
80  }
81  return aArea;
82 }
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
#define assert(ex)
Definition: util_old.h:213
float Fpga_CutRefSwitch(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Cut_t *pCut, int fFanouts)
Definition: fpgaSwitch.c:63
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
void Fpga_CutRemoveFanouts ( Fpga_Man_t p,
Fpga_Node_t pNode,
Fpga_Cut_t pCut 
)
Fpga_NodeVec_t* Fpga_DfsLim ( Fpga_Man_t pMan,
Fpga_Node_t pNode,
int  nLevels 
)

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

Synopsis [Computes the limited DFS ordering for one node.]

Description []

SideEffects []

SeeAlso []

Definition at line 606 of file fpgaUtils.c.

607 {
608  Fpga_NodeVec_t * vNodes;
609  int i;
610  // perform the traversal
611  vNodes = Fpga_NodeVecAlloc( 100 );
612  Fpga_DfsLim_rec( pNode, nLevels, vNodes );
613  for ( i = 0; i < vNodes->nSize; i++ )
614  vNodes->pArray[i]->fMark0 = 0;
615  return vNodes;
616 }
static void Fpga_DfsLim_rec(Fpga_Node_t *pNode, int Level, Fpga_NodeVec_t *vNodes)
Definition: fpgaUtils.c:629
unsigned fMark0
Definition: fpgaInt.h:189
Fpga_NodeVec_t * Fpga_NodeVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: fpgaVec.c:45
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
static int Fpga_FloatEqual ( Fpga_Man_t p,
float  Arg1,
float  Arg2 
)
inlinestatic

Definition at line 283 of file fpgaInt.h.

283 { return Arg1 > Arg2 - p->fEpsilon && Arg1 < Arg2 + p->fEpsilon; }
static int Fpga_FloatLessThan ( Fpga_Man_t p,
float  Arg1,
float  Arg2 
)
inlinestatic

Definition at line 282 of file fpgaInt.h.

282 { return Arg1 < Arg2 - p->fEpsilon; }
static int Fpga_FloatMoreThan ( Fpga_Man_t p,
float  Arg1,
float  Arg2 
)
inlinestatic

Definition at line 281 of file fpgaInt.h.

281 { return Arg1 > Arg2 + p->fEpsilon; }
int Fpga_LutLibDelaysAreDiscrete ( Fpga_LutLib_t pLutLib)

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

Synopsis [Returns 1 if the delays are discrete.]

Description []

SideEffects []

SeeAlso []

Definition at line 236 of file fpgaLib.c.

237 {
238  float Delay;
239  int i;
240  for ( i = 1; i <= pLutLib->LutMax; i++ )
241  {
242  Delay = pLutLib->pLutDelays[i][0];
243  if ( ((float)((int)Delay)) != Delay )
244  return 0;
245  }
246  return 1;
247 }
float pLutDelays[FPGA_MAX_LUTSIZE+1][FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:176
void Fpga_LutLibFree ( Fpga_LutLib_t pLutLib)

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

Synopsis [Frees the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 185 of file fpgaLib.c.

186 {
187  if ( pLutLib == NULL )
188  return;
189  ABC_FREE( pLutLib->pName );
190  ABC_FREE( pLutLib );
191 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Fpga_LutLibPrint ( Fpga_LutLib_t pLutLib)

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

Synopsis [Prints the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 205 of file fpgaLib.c.

206 {
207  int i, k;
208  printf( "# The area/delay of k-variable LUTs:\n" );
209  printf( "# k area delay\n" );
210  if ( pLutLib->fVarPinDelays )
211  {
212  for ( i = 1; i <= pLutLib->LutMax; i++ )
213  {
214  printf( "%d %7.2f ", i, pLutLib->pLutAreas[i] );
215  for ( k = 0; k < i; k++ )
216  printf( " %7.2f", pLutLib->pLutDelays[i][k] );
217  printf( "\n" );
218  }
219  }
220  else
221  for ( i = 1; i <= pLutLib->LutMax; i++ )
222  printf( "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] );
223 }
float pLutDelays[FPGA_MAX_LUTSIZE+1][FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:176
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
Fpga_LutLib_t* Fpga_LutLibRead ( char *  FileName,
int  fVerbose 
)

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

Synopsis [Reads the description of LUTs from the LUT library file.]

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file fpgaLib.c.

59 {
60  char pBuffer[1000], * pToken;
61  Fpga_LutLib_t * p;
62  FILE * pFile;
63  int i, k;
64 
65  pFile = fopen( FileName, "r" );
66  if ( pFile == NULL )
67  {
68  printf( "Cannot open LUT library file \"%s\".\n", FileName );
69  return NULL;
70  }
71 
72  p = ABC_ALLOC( Fpga_LutLib_t, 1 );
73  memset( p, 0, sizeof(Fpga_LutLib_t) );
74  p->pName = Extra_UtilStrsav( FileName );
75 
76  i = 1;
77  while ( fgets( pBuffer, 1000, pFile ) != NULL )
78  {
79  pToken = strtok( pBuffer, " \t\n" );
80  if ( pToken == NULL )
81  continue;
82  if ( pToken[0] == '#' )
83  continue;
84  if ( i != atoi(pToken) )
85  {
86  printf( "Error in the LUT library file \"%s\".\n", FileName );
87  ABC_FREE( p );
88  return NULL;
89  }
90 
91  // read area
92  pToken = strtok( NULL, " \t\n" );
93  p->pLutAreas[i] = (float)atof(pToken);
94 
95  // read delays
96  k = 0;
97  while ( (pToken = strtok( NULL, " \t\n" )) )
98  p->pLutDelays[i][k++] = (float)atof(pToken);
99 
100  // check for out-of-bound
101  if ( k > i )
102  {
103  printf( "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i );
104  return NULL;
105  }
106 
107  // check if var delays are specifies
108  if ( k > 1 )
109  p->fVarPinDelays = 1;
110 
111  if ( i == FPGA_MAX_LUTSIZE )
112  {
113  printf( "Skipping LUTs of size more than %d.\n", i );
114  return NULL;
115  }
116  i++;
117  }
118  p->LutMax = i-1;
119 /*
120  if ( p->LutMax > FPGA_MAX_LEAVES )
121  {
122  p->LutMax = FPGA_MAX_LEAVES;
123  printf( "Warning: LUTs with more than %d inputs will not be used.\n", FPGA_MAX_LEAVES );
124  }
125 */
126  // check the library
127  if ( p->fVarPinDelays )
128  {
129  for ( i = 1; i <= p->LutMax; i++ )
130  for ( k = 0; k < i; k++ )
131  {
132  if ( p->pLutDelays[i][k] <= 0.0 )
133  printf( "Warning: Pin %d of LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
134  k, i, p->pLutDelays[i][k] );
135  if ( k && p->pLutDelays[i][k-1] > p->pLutDelays[i][k] )
136  printf( "Warning: Pin %d of LUT %d has delay %f. Pin %d of LUT %d has delay %f. Pin delays should be in non-decreasing order. Technology mapping may not work correctly.\n",
137  k-1, i, p->pLutDelays[i][k-1],
138  k, i, p->pLutDelays[i][k] );
139  }
140  }
141  else
142  {
143  for ( i = 1; i <= p->LutMax; i++ )
144  {
145  if ( p->pLutDelays[i][0] <= 0.0 )
146  printf( "Warning: LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
147  i, p->pLutDelays[i][0] );
148  }
149  }
150 
151  return p;
152 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float pLutDelays[FPGA_MAX_LUTSIZE+1][FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:176
char * strtok()
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
char * Extra_UtilStrsav(const char *s)
#define FPGA_MAX_LUTSIZE
INCLUDES ///.
Definition: fpga.h:37
double atof()
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Fpga_ManReportChoices ( Fpga_Man_t pMan)

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

Synopsis [Reports statistics on choice nodes.]

Description [The number of choice nodes is the number of primary nodes, which has pNextE set to a pointer. The number of choices is the number of entries in the equivalent-node lists of the primary nodes.]

SideEffects []

SeeAlso []

Definition at line 897 of file fpgaUtils.c.

898 {
899  Fpga_Node_t * pNode, * pTemp;
900  int nChoiceNodes, nChoices;
901  int i, LevelMax1, LevelMax2;
902 
903  // report the number of levels
904  LevelMax1 = Fpga_MappingMaxLevel( pMan );
905  pMan->nTravIds++;
906  for ( i = 0; i < pMan->nOutputs; i++ )
907  Fpga_MappingUpdateLevel_rec( pMan, Fpga_Regular(pMan->pOutputs[i]), 0 );
908  LevelMax2 = Fpga_MappingMaxLevel( pMan );
909 
910  // report statistics about choices
911  nChoiceNodes = nChoices = 0;
912  for ( i = 0; i < pMan->vAnds->nSize; i++ )
913  {
914  pNode = pMan->vAnds->pArray[i];
915  if ( pNode->pRepr == NULL && pNode->pNextE != NULL )
916  { // this is a choice node = the primary node that has equivalent nodes
917  nChoiceNodes++;
918  for ( pTemp = pNode; pTemp; pTemp = pTemp->pNextE )
919  nChoices++;
920  }
921  }
922  if ( pMan->fVerbose )
923  {
924  printf( "Maximum level: Original = %d. Reduced due to choices = %d.\n", LevelMax1, LevelMax2 );
925  printf( "Choice stats: Choice nodes = %d. Total choices = %d.\n", nChoiceNodes, nChoices );
926  }
927 /*
928  {
929  FILE * pTable;
930  pTable = fopen( "stats_choice.txt", "a+" );
931  fprintf( pTable, "%s ", pMan->pFileName );
932  fprintf( pTable, "%4d ", LevelMax1 );
933  fprintf( pTable, "%4d ", pMan->vAnds->nSize - pMan->nInputs );
934  fprintf( pTable, "%4d ", LevelMax2 );
935  fprintf( pTable, "%7d ", nChoiceNodes );
936  fprintf( pTable, "%7d ", nChoices + nChoiceNodes );
937  fprintf( pTable, "\n" );
938  fclose( pTable );
939  }
940 */
941 }
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
int Fpga_MappingUpdateLevel_rec(Fpga_Man_t *pMan, Fpga_Node_t *pNode, int fMaximum)
Definition: fpgaUtils.c:826
int Fpga_MappingMaxLevel(Fpga_Man_t *pMan)
Definition: fpgaUtils.c:804
Fpga_Node_t * pRepr
Definition: fpgaInt.h:203
#define Fpga_Regular(p)
Definition: fpga.h:58
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Node_t * pNextE
Definition: fpgaInt.h:202
Fpga_NodeVec_t * vAnds
Definition: fpgaInt.h:112
float Fpga_MappingArea ( Fpga_Man_t pMan)

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

Synopsis [Computes the area of the current mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 177 of file fpgaUtils.c.

178 {
179  Fpga_Node_t * pNode;
180  float aTotal;
181  int i;
182  // perform the traversal
183  aTotal = 0;
184  for ( i = 0; i < pMan->vMapping->nSize; i++ )
185  {
186  pNode = pMan->vMapping->pArray[i];
187  aTotal += pMan->pLutLib->pLutAreas[(int)pNode->pCutBest->nLeaves];
188  }
189  return aTotal;
190 }
Fpga_NodeVec_t * vMapping
Definition: fpgaInt.h:113
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
Fpga_LutLib_t * pLutLib
Definition: fpgaInt.h:137
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
float Fpga_MappingAreaTrav ( Fpga_Man_t pMan)

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

Synopsis [Computes the area of the current mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 239 of file fpgaUtils.c.

240 {
241  Fpga_NodeVec_t * vNodes;
242  float aTotal;
243  int i;
244  // perform the traversal
245  aTotal = 0;
246  vNodes = Fpga_NodeVecAlloc( 100 );
247  for ( i = 0; i < pMan->nOutputs; i++ )
248  aTotal += Fpga_MappingArea_rec( pMan, Fpga_Regular(pMan->pOutputs[i]), vNodes );
249  for ( i = 0; i < vNodes->nSize; i++ )
250  vNodes->pArray[i]->fMark0 = 0;
251  Fpga_NodeVecFree( vNodes );
252  return aTotal;
253 }
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
unsigned fMark0
Definition: fpgaInt.h:189
Fpga_NodeVec_t * Fpga_NodeVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: fpgaVec.c:45
void Fpga_NodeVecFree(Fpga_NodeVec_t *p)
Definition: fpgaVec.c:68
float Fpga_MappingArea_rec(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_NodeVec_t *vNodes)
Definition: fpgaUtils.c:203
#define Fpga_Regular(p)
Definition: fpga.h:58
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_MappingCreatePiCuts ( Fpga_Man_t p)

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

Synopsis [Performs technology mapping for variable-size-LUTs.]

Description []

SideEffects []

SeeAlso []

Definition at line 181 of file fpgaCut.c.

182 {
183  Fpga_Cut_t * pCut;
184  int i;
185 
186  // set the elementary cuts for the PI variables
187  for ( i = 0; i < p->nInputs; i++ )
188  {
189  pCut = Fpga_CutAlloc( p );
190  pCut->nLeaves = 1;
191  pCut->ppLeaves[0] = p->pInputs[i];
192  pCut->uSign = (1 << (i%31));
193  p->pInputs[i]->pCuts = pCut;
194  p->pInputs[i]->pCutBest = pCut;
195  // set the input arrival times
196 // p->pInputs[i]->pCut[1]->tArrival = p->pInputArrivals[i];
197  }
198 }
Fpga_Node_t ** pInputs
Definition: fpgaInt.h:104
Fpga_Cut_t * Fpga_CutAlloc(Fpga_Man_t *p)
DECLARATIONS ///.
Definition: fpgaCutUtils.c:43
Fpga_Cut_t * pCuts
Definition: fpgaInt.h:224
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
unsigned uSign
Definition: fpgaInt.h:239
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
void Fpga_MappingCuts ( Fpga_Man_t p)

GLOBAL VARIABLES ///.

FUNCTION DEFINITIONS ///

GLOBAL VARIABLES ///.

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

Synopsis [Computes the cuts for each node in the object graph.]

Description [The cuts are computed in one sweep over the mapping graph. First, the elementary cuts, which include the node itself, are assigned to the PI nodes. The internal nodes are considered in the DFS order. Each node is two-input AND-gate. So to compute the cuts at a node, we need to merge the sets of cuts of its two predecessors. The merged set contains only unique cuts with the number of inputs equal to k or less. Finally, the elementary cut, composed of the node itself, is added to the set of cuts for the node.

This procedure is pretty fast for 5-feasible cuts, but it dramatically slows down on some "dense" networks when computing 6-feasible cuts. The problem is that there are too many cuts in this case. We should think how to heuristically trim the number of cuts in such cases, to have reasonable runtime.]

SideEffects []

SeeAlso []

Definition at line 130 of file fpgaCut.c.

131 {
132  ProgressBar * pProgress;
133  Fpga_CutTable_t * pTable;
134  Fpga_Node_t * pNode;
135  int nCuts, nNodes, i;
136  clock_t clk = clock();
137 
138  // set the elementary cuts for the PI variables
139  assert( p->nVarsMax > 1 && p->nVarsMax < 11 );
141 
142  // compute the cuts for the internal nodes
143  nNodes = p->vAnds->nSize;
144  pProgress = Extra_ProgressBarStart( stdout, nNodes );
145  pTable = Fpga_CutTableStart( p );
146  for ( i = 0; i < nNodes; i++ )
147  {
148  Extra_ProgressBarUpdate( pProgress, i, "Cuts ..." );
149  pNode = p->vAnds->pArray[i];
150  if ( !Fpga_NodeIsAnd( pNode ) )
151  continue;
152  Fpga_CutCompute( p, pTable, pNode );
153  }
154  Extra_ProgressBarStop( pProgress );
155  Fpga_CutTableStop( pTable );
156 
157  // report the stats
158  if ( p->fVerbose )
159  {
160  nCuts = Fpga_CutCountAll(p);
161  printf( "Nodes = %6d. Total %d-cuts = %d. Cuts per node = %.1f. ",
162  p->nNodes, p->nVarsMax, nCuts, ((float)nCuts)/p->nNodes );
163  ABC_PRT( "Time", clock() - clk );
164  }
165 
166  // print the cuts for the first primary output
167 // Fpga_CutListPrint( p, Fpga_Regular(p->pOutputs[0]) );
168 }
static Fpga_Cut_t * Fpga_CutCompute(Fpga_Man_t *p, Fpga_CutTable_t *pTable, Fpga_Node_t *pNode)
Definition: fpgaCut.c:211
int Fpga_CutCountAll(Fpga_Man_t *pMan)
Definition: fpgaCut.c:767
DECLARATIONS ///.
typedefABC_NAMESPACE_IMPL_START struct Fpga_CutTableStrutct_t Fpga_CutTable_t
DECLARATIONS ///.
Definition: fpgaCut.c:28
void Fpga_MappingCreatePiCuts(Fpga_Man_t *p)
Definition: fpgaCut.c:181
static Fpga_CutTable_t * Fpga_CutTableStart(Fpga_Man_t *pMan)
Definition: fpgaCut.c:915
void Extra_ProgressBarStop(ProgressBar *p)
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_NodeVec_t * vAnds
Definition: fpgaInt.h:112
static void Fpga_CutTableStop(Fpga_CutTable_t *p)
Definition: fpgaCut.c:942
Fpga_NodeVec_t* Fpga_MappingDfs ( Fpga_Man_t pMan,
int  fCollectEquiv 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Computes the DFS ordering of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 54 of file fpgaUtils.c.

55 {
56  Fpga_NodeVec_t * vNodes;//, * vNodesCo;
57  Fpga_Node_t * pNode;
58  int i;
59  // collect the CO nodes by level
60 // vNodesCo = Fpga_MappingOrderCosByLevel( pMan );
61  // start the array
62  vNodes = Fpga_NodeVecAlloc( 100 );
63  // collect the PIs
64  for ( i = 0; i < pMan->nInputs; i++ )
65  {
66  pNode = pMan->pInputs[i];
67  Fpga_NodeVecPush( vNodes, pNode );
68  pNode->fMark0 = 1;
69  }
70  // perform the traversal
71  for ( i = 0; i < pMan->nOutputs; i++ )
72  Fpga_MappingDfs_rec( Fpga_Regular(pMan->pOutputs[i]), vNodes, fCollectEquiv );
73 // for ( i = vNodesCo->nSize - 1; i >= 0 ; i-- )
74 // for ( pNode = vNodesCo->pArray[i]; pNode; pNode = (Fpga_Node_t *)pNode->pData0 )
75 // Fpga_MappingDfs_rec( pNode, vNodes, fCollectEquiv );
76  // clean the node marks
77  for ( i = 0; i < vNodes->nSize; i++ )
78  vNodes->pArray[i]->fMark0 = 0;
79 // for ( i = 0; i < pMan->nOutputs; i++ )
80 // Fpga_MappingUnmark_rec( Fpga_Regular(pMan->pOutputs[i]) );
81 // Fpga_NodeVecFree( vNodesCo );
82  return vNodes;
83 }
Fpga_Node_t ** pInputs
Definition: fpgaInt.h:104
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
unsigned fMark0
Definition: fpgaInt.h:189
Fpga_NodeVec_t * Fpga_NodeVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: fpgaVec.c:45
#define Fpga_Regular(p)
Definition: fpga.h:58
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
static void Fpga_MappingDfs_rec(Fpga_Node_t *pNode, Fpga_NodeVec_t *vNodes, int fCollectEquiv)
Definition: fpgaUtils.c:96
void Fpga_NodeVecPush(Fpga_NodeVec_t *p, Fpga_Node_t *Entry)
Definition: fpgaVec.c:169
Fpga_NodeVec_t* Fpga_MappingDfsNodes ( Fpga_Man_t pMan,
Fpga_Node_t **  ppNodes,
int  nNodes,
int  fEquiv 
)

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

Synopsis [Computes the DFS ordering of the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 129 of file fpgaUtils.c.

130 {
131  Fpga_NodeVec_t * vNodes;
132  int i;
133  // perform the traversal
134  vNodes = Fpga_NodeVecAlloc( 200 );
135  for ( i = 0; i < nNodes; i++ )
136  Fpga_MappingDfs_rec( ppNodes[i], vNodes, fEquiv );
137  for ( i = 0; i < vNodes->nSize; i++ )
138  vNodes->pArray[i]->fMark0 = 0;
139  return vNodes;
140 }
unsigned fMark0
Definition: fpgaInt.h:189
Fpga_NodeVec_t * Fpga_NodeVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: fpgaVec.c:45
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
static void Fpga_MappingDfs_rec(Fpga_Node_t *pNode, Fpga_NodeVec_t *vNodes, int fCollectEquiv)
Definition: fpgaUtils.c:96
float Fpga_MappingGetAreaFlow ( Fpga_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file fpgaUtils.c.

154 {
155  float aFlowFlowTotal = 0;
156  int i;
157  for ( i = 0; i < p->nOutputs; i++ )
158  {
159  if ( Fpga_NodeIsConst(p->pOutputs[i]) )
160  continue;
161  aFlowFlowTotal += Fpga_Regular(p->pOutputs[i])->pCutBest->aFlow;
162  }
163  return aFlowFlowTotal;
164 }
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
int Fpga_NodeIsConst(Fpga_Node_t *p)
Definition: fpgaCreate.c:125
#define Fpga_Regular(p)
Definition: fpga.h:58
float Fpga_MappingGetSwitching ( Fpga_Man_t pMan,
Fpga_NodeVec_t vMapping 
)

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

Synopsis [Computes the array of mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 127 of file fpgaSwitch.c.

128 {
129  Fpga_Node_t * pNode;
130  float Switch;
131  int i;
132  Switch = 0.0;
133  for ( i = 0; i < vMapping->nSize; i++ )
134  {
135  pNode = vMapping->pArray[i];
136  // at least one phase has the best cut assigned
137  assert( !Fpga_NodeIsAnd(pNode) || pNode->pCutBest != NULL );
138  // at least one phase is used in the mapping
139  assert( pNode->nRefs > 0 );
140  // compute the array due to the supergate
141  Switch += pNode->Switching;
142  }
143  // add buffer for each CO driven by a CI
144  for ( i = 0; i < pMan->nOutputs; i++ )
145  if ( Fpga_NodeIsVar(Fpga_Regular(pMan->pOutputs[i])) && !Fpga_IsComplement(pMan->pOutputs[i]) )
146  Switch += Fpga_Regular(pMan->pOutputs[i])->Switching;
147  return Switch;
148 }
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
int Fpga_NodeIsVar(Fpga_Node_t *p)
Definition: fpgaCreate.c:126
#define Fpga_Regular(p)
Definition: fpga.h:58
#define assert(ex)
Definition: util_old.h:213
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
#define Fpga_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: fpga.h:57
Fpga_NodeVec_t* Fpga_MappingLevelize ( Fpga_Man_t pMan,
Fpga_NodeVec_t vNodes 
)

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

Synopsis [Levelizes the nodes accessible from the POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 747 of file fpgaUtils.c.

748 {
749  Fpga_NodeVec_t * vLevels;
750  Fpga_Node_t ** ppNodes;
751  Fpga_Node_t * pNode;
752  int nNodes, nLevelsMax, i;
753 
754  // reassign the levels (this may be necessary for networks which choices)
755  ppNodes = vNodes->pArray;
756  nNodes = vNodes->nSize;
757  for ( i = 0; i < nNodes; i++ )
758  {
759  pNode = ppNodes[i];
760  if ( !Fpga_NodeIsAnd(pNode) )
761  {
762  pNode->Level = 0;
763  continue;
764  }
765  pNode->Level = 1 + FPGA_MAX( Fpga_Regular(pNode->p1)->Level, Fpga_Regular(pNode->p2)->Level );
766  }
767 
768  // get the max levels
769  nLevelsMax = 0;
770  for ( i = 0; i < pMan->nOutputs; i++ )
771  nLevelsMax = FPGA_MAX( nLevelsMax, (int)Fpga_Regular(pMan->pOutputs[i])->Level );
772  nLevelsMax++;
773 
774  // allocate storage for levels
775  vLevels = Fpga_NodeVecAlloc( nLevelsMax );
776  for ( i = 0; i < nLevelsMax; i++ )
777  Fpga_NodeVecPush( vLevels, NULL );
778 
779  // go through the nodes and add them to the levels
780  for ( i = 0; i < nNodes; i++ )
781  {
782  pNode = ppNodes[i];
783  pNode->pLevel = NULL;
784  if ( !Fpga_NodeIsAnd(pNode) )
785  continue;
786  // attach the node to this level
787  pNode->pLevel = Fpga_NodeVecReadEntry( vLevels, pNode->Level );
788  Fpga_NodeVecWriteEntry( vLevels, pNode->Level, pNode );
789  }
790  return vLevels;
791 }
unsigned Level
Definition: fpgaInt.h:195
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
Fpga_Node_t * pLevel
Definition: fpgaInt.h:184
#define FPGA_MAX(a, b)
Definition: fpgaInt.h:62
Fpga_Node_t * p1
Definition: fpgaInt.h:200
Fpga_NodeVec_t * Fpga_NodeVecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: fpgaVec.c:45
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
#define Fpga_Regular(p)
Definition: fpga.h:58
Fpga_Node_t * Fpga_NodeVecReadEntry(Fpga_NodeVec_t *p, int i)
Definition: fpgaVec.c:246
void Fpga_NodeVecWriteEntry(Fpga_NodeVec_t *p, int i, Fpga_Node_t *Entry)
Definition: fpgaVec.c:229
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Node_t * p2
Definition: fpgaInt.h:201
void Fpga_NodeVecPush(Fpga_NodeVec_t *p, Fpga_Node_t *Entry)
Definition: fpgaVec.c:169
int Fpga_MappingMatches ( Fpga_Man_t p,
int  fDelayOriented 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Finds the best delay assignment of LUTs.]

Description [This procedure iterates through all the nodes of the object graph reachable from the POs and assigns the best match to each of them. If the flag fDelayOriented is set to 1, it tries to minimize the arrival time and uses the area flow as a tie-breaker. If the flag is set to 0, it considers all the cuts, whose arrival times matches the required time at the node, and minimizes the area flow using the arrival time as a tie-breaker.

Before this procedure is called, the required times should be set and the fanout counts should be computed. In the first iteration, the required times are set to very large number (by NodeCreate) and the fanout counts are set to the number of fanouts in the AIG. In the following iterations, the required times are set by the backward traversal, while the fanouts are estimated approximately.

If the arrival times of the PI nodes are given, they should be assigned to the PIs after the cuts are computed and before this procedure is called for the first time.]

SideEffects []

SeeAlso []

Definition at line 67 of file fpgaMatch.c.

68 {
69  ProgressBar * pProgress;
70  Fpga_Node_t * pNode;
71  int i, nNodes;
72 
73  // assign the arrival times of the PIs
74  for ( i = 0; i < p->nInputs; i++ )
75  p->pInputs[i]->pCutBest->tArrival = p->pInputArrivals[i];
76 
77  // match LUTs with nodes in the topological order
78  nNodes = p->vAnds->nSize;
79  pProgress = Extra_ProgressBarStart( stdout, nNodes );
80  for ( i = 0; i < nNodes; i++ )
81  {
82  pNode = p->vAnds->pArray[i];
83  if ( !Fpga_NodeIsAnd( pNode ) )
84  continue;
85  // skip a secondary node
86  if ( pNode->pRepr )
87  continue;
88  // match the node
89  Fpga_MatchNode( p, pNode, fDelayOriented );
90  Extra_ProgressBarUpdate( pProgress, i, "Matches ..." );
91  }
92  Extra_ProgressBarStop( pProgress );
93 /*
94  if ( !fDelayOriented )
95  {
96  float Area = 0.0;
97  for ( i = 0; i < p->nOutputs; i++ )
98  {
99  printf( "%5.2f ", Fpga_Regular(p->pOutputs[i])->pCutBest->aFlow );
100  Area += Fpga_Regular(p->pOutputs[i])->pCutBest->aFlow;
101  }
102  printf( "\nTotal = %5.2f\n", Area );
103  }
104 */
105  return 1;
106 }
float * pInputArrivals
Definition: fpgaInt.h:118
Fpga_Node_t ** pInputs
Definition: fpgaInt.h:104
static ABC_NAMESPACE_IMPL_START int Fpga_MatchNode(Fpga_Man_t *p, Fpga_Node_t *pNode, int fDelayOriented)
DECLARATIONS ///.
Definition: fpgaMatch.c:119
DECLARATIONS ///.
Fpga_Node_t * pRepr
Definition: fpgaInt.h:203
void Extra_ProgressBarStop(ProgressBar *p)
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
Fpga_NodeVec_t * vAnds
Definition: fpgaInt.h:112
int Fpga_MappingMatchesArea ( Fpga_Man_t p)

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

Synopsis [Finds the best area assignment of LUTs.]

Description []

SideEffects []

SeeAlso []

Definition at line 196 of file fpgaMatch.c.

197 {
198  ProgressBar * pProgress;
199  Fpga_Node_t * pNode;
200  int i, nNodes;
201 
202  // assign the arrival times of the PIs
203  for ( i = 0; i < p->nInputs; i++ )
204  p->pInputs[i]->pCutBest->tArrival = p->pInputArrivals[i];
205 
206  // match LUTs with nodes in the topological order
207  nNodes = p->vAnds->nSize;
208  pProgress = Extra_ProgressBarStart( stdout, nNodes );
209  for ( i = 0; i < nNodes; i++ )
210  {
211  pNode = p->vAnds->pArray[i];
212  if ( !Fpga_NodeIsAnd( pNode ) )
213  continue;
214  // skip a secondary node
215  if ( pNode->pRepr )
216  continue;
217  // match the node
218  Fpga_MatchNodeArea( p, pNode );
219  Extra_ProgressBarUpdate( pProgress, i, "Matches ..." );
220  }
221  Extra_ProgressBarStop( pProgress );
222  return 1;
223 }
float * pInputArrivals
Definition: fpgaInt.h:118
Fpga_Node_t ** pInputs
Definition: fpgaInt.h:104
static int Fpga_MatchNodeArea(Fpga_Man_t *p, Fpga_Node_t *pNode)
Definition: fpgaMatch.c:268
DECLARATIONS ///.
Fpga_Node_t * pRepr
Definition: fpgaInt.h:203
void Extra_ProgressBarStop(ProgressBar *p)
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
Fpga_NodeVec_t * vAnds
Definition: fpgaInt.h:112
int Fpga_MappingMatchesSwitch ( Fpga_Man_t p)

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

Synopsis [Finds the best area assignment of LUTs.]

Description []

SideEffects []

SeeAlso []

Definition at line 349 of file fpgaMatch.c.

350 {
351  ProgressBar * pProgress;
352  Fpga_Node_t * pNode;
353  int i, nNodes;
354 
355  // assign the arrival times of the PIs
356  for ( i = 0; i < p->nInputs; i++ )
357  p->pInputs[i]->pCutBest->tArrival = p->pInputArrivals[i];
358 
359  // match LUTs with nodes in the topological order
360  nNodes = p->vAnds->nSize;
361  pProgress = Extra_ProgressBarStart( stdout, nNodes );
362  for ( i = 0; i < nNodes; i++ )
363  {
364  pNode = p->vAnds->pArray[i];
365  if ( !Fpga_NodeIsAnd( pNode ) )
366  continue;
367  // skip a secondary node
368  if ( pNode->pRepr )
369  continue;
370  // match the node
371  Fpga_MatchNodeSwitch( p, pNode );
372  Extra_ProgressBarUpdate( pProgress, i, "Matches ..." );
373  }
374  Extra_ProgressBarStop( pProgress );
375  return 1;
376 }
static int Fpga_MatchNodeSwitch(Fpga_Man_t *p, Fpga_Node_t *pNode)
Definition: fpgaMatch.c:389
float * pInputArrivals
Definition: fpgaInt.h:118
Fpga_Node_t ** pInputs
Definition: fpgaInt.h:104
DECLARATIONS ///.
Fpga_Node_t * pRepr
Definition: fpgaInt.h:203
void Extra_ProgressBarStop(ProgressBar *p)
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
Fpga_NodeVec_t * vAnds
Definition: fpgaInt.h:112
int Fpga_MappingMaxLevel ( Fpga_Man_t pMan)

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

Synopsis [Sets up the mask.]

Description []

SideEffects []

SeeAlso []

Definition at line 804 of file fpgaUtils.c.

805 {
806  int nLevelMax, i;
807  nLevelMax = 0;
808  for ( i = 0; i < pMan->nOutputs; i++ )
809  nLevelMax = nLevelMax > (int)Fpga_Regular(pMan->pOutputs[i])->Level?
810  nLevelMax : (int)Fpga_Regular(pMan->pOutputs[i])->Level;
811  return nLevelMax;
812 }
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
#define Fpga_Regular(p)
Definition: fpga.h:58
void Fpga_MappingPrintOutputArrivals ( Fpga_Man_t p)

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

Synopsis [Prints a bunch of latest arriving outputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 402 of file fpgaUtils.c.

403 {
404  Fpga_Node_t * pNode;
405  int pSorted[FPGA_CO_LIST_SIZE];
406  int fCompl, Limit, MaxNameSize, i;
407 
408  // determine the number of nodes to print
410 
411  // determine the order
412  Fpga_MappingFindLatest( p, pSorted, Limit );
413 
414  // determine max size of the node's name
415  MaxNameSize = 0;
416  for ( i = 0; i < Limit; i++ )
417  if ( MaxNameSize < (int)strlen(p->ppOutputNames[pSorted[i]]) )
418  MaxNameSize = strlen(p->ppOutputNames[pSorted[i]]);
419 
420  // print the latest outputs
421  for ( i = 0; i < Limit; i++ )
422  {
423  // get the i-th latest output
424  pNode = Fpga_Regular(p->pOutputs[pSorted[i]]);
425  fCompl = Fpga_IsComplement(p->pOutputs[pSorted[i]]);
426  // print out the best arrival time
427  printf( "Output %-*s : ", MaxNameSize + 3, p->ppOutputNames[pSorted[i]] );
428  printf( "Delay = %8.2f ", (double)pNode->pCutBest->tArrival );
429  if ( fCompl )
430  printf( "NEG" );
431  else
432  printf( "POS" );
433  printf( "\n" );
434  }
435 }
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
char ** ppOutputNames
Definition: fpgaInt.h:117
static void Fpga_MappingFindLatest(Fpga_Man_t *p, int *pNodes, int nNodesMax)
Definition: fpgaUtils.c:370
#define Fpga_Regular(p)
Definition: fpga.h:58
#define FPGA_CO_LIST_SIZE
DECLARATIONS ///.
Definition: fpgaUtils.c:28
int strlen()
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
#define Fpga_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: fpga.h:57
void Fpga_MappingSetChoiceLevels ( Fpga_Man_t pMan)

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

Synopsis [Resets the levels of the nodes in the choice graph.]

Description [Makes the level of the choice nodes to be equal to the maximum of the level of the nodes in the equivalence class. This way sorting by level leads to the reverse topological order, which is needed for the required time computation.]

SideEffects []

SeeAlso []

Definition at line 876 of file fpgaUtils.c.

877 {
878  int i;
879  pMan->nTravIds++;
880  for ( i = 0; i < pMan->nOutputs; i++ )
881  Fpga_MappingUpdateLevel_rec( pMan, Fpga_Regular(pMan->pOutputs[i]), 1 );
882 }
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
int Fpga_MappingUpdateLevel_rec(Fpga_Man_t *pMan, Fpga_Node_t *pNode, int fMaximum)
Definition: fpgaUtils.c:826
#define Fpga_Regular(p)
Definition: fpga.h:58
float Fpga_MappingSetRefsAndArea ( Fpga_Man_t pMan)

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

Synopsis [Sets the correct reference counts for the mapping.]

Description [Collects the nodes in reverse topological order and places in them in array pMan->vMapping.]

SideEffects []

SeeAlso []

Definition at line 299 of file fpgaUtils.c.

300 {
301  Fpga_Node_t * pNode, ** ppStore;
302  float aArea;
303  int i, LevelMax;
304 
305  // clean all references
306  for ( i = 0; i < pMan->vNodesAll->nSize; i++ )
307  pMan->vNodesAll->pArray[i]->nRefs = 0;
308 
309  // allocate place to store the nodes
310  LevelMax = Fpga_MappingMaxLevel( pMan );
311  ppStore = ABC_ALLOC( Fpga_Node_t *, LevelMax + 1 );
312  memset( ppStore, 0, sizeof(Fpga_Node_t *) * (LevelMax + 1) );
313 
314  // collect nodes reachable from POs in the DFS order through the best cuts
315  aArea = 0;
316  for ( i = 0; i < pMan->nOutputs; i++ )
317  {
318  pNode = Fpga_Regular(pMan->pOutputs[i]);
319  if ( pNode == pMan->pConst1 )
320  continue;
321  aArea += Fpga_MappingSetRefsAndArea_rec( pMan, pNode, ppStore );
322  pNode->nRefs++;
323  }
324 
325  // reconnect the nodes in reverse topological order
326  pMan->vMapping->nSize = 0;
327  for ( i = LevelMax; i >= 0; i-- )
328  for ( pNode = ppStore[i]; pNode; pNode = (Fpga_Node_t *)pNode->pData0 )
329  Fpga_NodeVecPush( pMan->vMapping, pNode );
330  ABC_FREE( ppStore );
331  return aArea;
332 }
char * memset()
float Fpga_MappingSetRefsAndArea_rec(Fpga_Man_t *pMan, Fpga_Node_t *pNode, Fpga_Node_t **ppStore)
Definition: fpgaUtils.c:267
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
int Fpga_MappingMaxLevel(Fpga_Man_t *pMan)
Definition: fpgaUtils.c:804
Fpga_NodeVec_t * vMapping
Definition: fpgaInt.h:113
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Fpga_NodeVec_t * vNodesAll
Definition: fpgaInt.h:111
Fpga_Node_t * pConst1
Definition: fpgaInt.h:110
#define Fpga_Regular(p)
Definition: fpga.h:58
#define ABC_FREE(obj)
Definition: abc_global.h:232
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_NodeVecPush(Fpga_NodeVec_t *p, Fpga_Node_t *Entry)
Definition: fpgaVec.c:169
void Fpga_MappingSetupMask ( unsigned  uMask[],
int  nVarsMax 
)

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

Synopsis [Sets up the mask.]

Description []

SideEffects []

SeeAlso []

Definition at line 475 of file fpgaUtils.c.

476 {
477  if ( nVarsMax == 6 )
478  uMask[0] = uMask[1] = FPGA_FULL;
479  else
480  {
481  uMask[0] = FPGA_MASK(1 << nVarsMax);
482  uMask[1] = 0;
483  }
484 }
#define FPGA_FULL
Definition: fpgaInt.h:56
#define FPGA_MASK(n)
Definition: fpgaInt.h:55
void Fpga_MappingSetupTruthTables ( unsigned  uTruths[][2])

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

Synopsis [Sets up the truth tables.]

Description []

SideEffects []

SeeAlso []

Definition at line 449 of file fpgaUtils.c.

450 {
451  int m, v;
452  // set up the truth tables
453  for ( m = 0; m < 32; m++ )
454  for ( v = 0; v < 5; v++ )
455  if ( m & (1 << v) )
456  uTruths[v][0] |= (1 << m);
457  // make adjustments for the case of 6 variables
458  for ( v = 0; v < 5; v++ )
459  uTruths[v][1] = uTruths[v][0];
460  uTruths[5][0] = 0;
461  uTruths[5][1] = FPGA_FULL;
462 }
#define FPGA_FULL
Definition: fpgaInt.h:56
void Fpga_MappingShow ( Fpga_Man_t pMan,
char *  pFileName 
)
void Fpga_MappingShowNodes ( Fpga_Man_t pMan,
Fpga_Node_t **  ppRoots,
int  nRoots,
char *  pFileName 
)
void Fpga_MappingSortByLevel ( Fpga_Man_t pMan,
Fpga_NodeVec_t vNodes,
int  fIncreasing 
)

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

Synopsis [Orders the nodes in the decreasing order of levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 584 of file fpgaUtils.c.

585 {
586  if ( fIncreasing )
587  qsort( (void *)vNodes->pArray, vNodes->nSize, sizeof(Fpga_Node_t *),
588  (int (*)(const void *, const void *)) Fpga_CompareNodesByLevelIncreasing );
589  else
590  qsort( (void *)vNodes->pArray, vNodes->nSize, sizeof(Fpga_Node_t *),
591  (int (*)(const void *, const void *)) Fpga_CompareNodesByLevelDecreasing );
592 // assert( Fpga_CompareNodesByLevel( vNodes->pArray, vNodes->pArray + vNodes->nSize - 1 ) <= 0 );
593 }
int Fpga_CompareNodesByLevelIncreasing(Fpga_Node_t **ppS1, Fpga_Node_t **ppS2)
Definition: fpgaUtils.c:564
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
int Fpga_CompareNodesByLevelDecreasing(Fpga_Node_t **ppS1, Fpga_Node_t **ppS2)
Definition: fpgaUtils.c:544
void Fpga_NodeAddFaninFanout ( Fpga_Node_t pFanin,
Fpga_Node_t pFanout 
)
int Fpga_NodeGetFanoutNum ( Fpga_Node_t pNode)
void Fpga_NodeRemoveFaninFanout ( Fpga_Node_t pFanin,
Fpga_Node_t pFanoutToRemove 
)
Fpga_NodeVec_t* Fpga_NodeVecAlloc ( int  nCap)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates a vector with the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file fpgaVec.c.

46 {
47  Fpga_NodeVec_t * p;
48  p = ABC_ALLOC( Fpga_NodeVec_t, 1 );
49  if ( nCap > 0 && nCap < 16 )
50  nCap = 16;
51  p->nSize = 0;
52  p->nCap = nCap;
53  p->pArray = p->nCap? ABC_ALLOC( Fpga_Node_t *, p->nCap ) : NULL;
54  return p;
55 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_NodeVecClear ( Fpga_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file fpgaVec.c.

154 {
155  p->nSize = 0;
156 }
void Fpga_NodeVecFree ( Fpga_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 68 of file fpgaVec.c.

69 {
70  ABC_FREE( p->pArray );
71  ABC_FREE( p );
72 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_NodeVecGrow ( Fpga_NodeVec_t p,
int  nCapMin 
)

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

Synopsis [Resizes the vector to the given capacity.]

Description []

SideEffects []

SeeAlso []

Definition at line 117 of file fpgaVec.c.

118 {
119  if ( p->nCap >= nCapMin )
120  return;
121  p->pArray = ABC_REALLOC( Fpga_Node_t *, p->pArray, nCapMin );
122  p->nCap = nCapMin;
123 }
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Node_t* Fpga_NodeVecPop ( Fpga_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 213 of file fpgaVec.c.

214 {
215  return p->pArray[--p->nSize];
216 }
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_NodeVecPush ( Fpga_NodeVec_t p,
Fpga_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 169 of file fpgaVec.c.

170 {
171  if ( p->nSize == p->nCap )
172  {
173  if ( p->nCap < 16 )
174  Fpga_NodeVecGrow( p, 16 );
175  else
176  Fpga_NodeVecGrow( p, 2 * p->nCap );
177  }
178  p->pArray[p->nSize++] = Entry;
179 }
void Fpga_NodeVecGrow(Fpga_NodeVec_t *p, int nCapMin)
Definition: fpgaVec.c:117
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_NodeVecPushOrder ( Fpga_NodeVec_t vNodes,
Fpga_Node_t pNode,
int  fIncreasing 
)

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

Synopsis [Inserts a new node in the order by arrival times.]

Description []

SideEffects []

SeeAlso []

Definition at line 366 of file fpgaVec.c.

367 {
368  Fpga_Node_t * pNode1, * pNode2;
369  int i;
370  Fpga_NodeVecPush( vNodes, pNode );
371  // find the place of the node
372  for ( i = vNodes->nSize-1; i > 0; i-- )
373  {
374  pNode1 = vNodes->pArray[i ];
375  pNode2 = vNodes->pArray[i-1];
376  if (( fIncreasing && pNode1->pCutBest->tArrival >= pNode2->pCutBest->tArrival) ||
377  (!fIncreasing && pNode1->pCutBest->tArrival <= pNode2->pCutBest->tArrival) )
378  break;
379  vNodes->pArray[i ] = pNode2;
380  vNodes->pArray[i-1] = pNode1;
381  }
382 }
void Fpga_NodeVecPush(Fpga_NodeVec_t *p, Fpga_Node_t *Entry)
Definition: fpgaVec.c:169
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
int Fpga_NodeVecPushUnique ( Fpga_NodeVec_t p,
Fpga_Node_t Entry 
)

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

Synopsis [Add the element while ensuring uniqueness.]

Description [Returns 1 if the element was found, and 0 if it was new. ]

SideEffects []

SeeAlso []

Definition at line 192 of file fpgaVec.c.

193 {
194  int i;
195  for ( i = 0; i < p->nSize; i++ )
196  if ( p->pArray[i] == Entry )
197  return 1;
198  Fpga_NodeVecPush( p, Entry );
199  return 0;
200 }
void Fpga_NodeVecPush(Fpga_NodeVec_t *p, Fpga_Node_t *Entry)
Definition: fpgaVec.c:169
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Node_t** Fpga_NodeVecReadArray ( Fpga_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file fpgaVec.c.

86 {
87  return p->pArray;
88 }
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Node_t* Fpga_NodeVecReadEntry ( Fpga_NodeVec_t p,
int  i 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 246 of file fpgaVec.c.

247 {
248  assert( i >= 0 && i < p->nSize );
249  return p->pArray[i];
250 }
#define assert(ex)
Definition: util_old.h:213
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
int Fpga_NodeVecReadSize ( Fpga_NodeVec_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file fpgaVec.c.

102 {
103  return p->nSize;
104 }
void Fpga_NodeVecReverse ( Fpga_NodeVec_t vNodes)

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

Synopsis [Inserts a new node in the order by arrival times.]

Description []

SideEffects []

SeeAlso []

Definition at line 395 of file fpgaVec.c.

396 {
397  Fpga_Node_t * pNode1, * pNode2;
398  int i;
399  for ( i = 0; i < vNodes->nSize/2; i++ )
400  {
401  pNode1 = vNodes->pArray[i];
402  pNode2 = vNodes->pArray[vNodes->nSize-1-i];
403  vNodes->pArray[i] = pNode2;
404  vNodes->pArray[vNodes->nSize-1-i] = pNode1;
405  }
406 }
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_NodeVecShrink ( Fpga_NodeVec_t p,
int  nSizeNew 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file fpgaVec.c.

137 {
138  assert( p->nSize >= nSizeNew );
139  p->nSize = nSizeNew;
140 }
#define assert(ex)
Definition: util_old.h:213
void Fpga_NodeVecSortByLevel ( Fpga_NodeVec_t p)

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

Synopsis [Sorting the entries by their integer value.]

Description []

SideEffects []

SeeAlso []

Definition at line 289 of file fpgaVec.c.

290 {
291  qsort( (void *)p->pArray, p->nSize, sizeof(Fpga_Node_t *),
292  (int (*)(const void *, const void *)) Fpga_NodeVecCompareLevels );
293 }
static ABC_NAMESPACE_IMPL_START int Fpga_NodeVecCompareLevels(Fpga_Node_t **pp1, Fpga_Node_t **pp2)
DECLARATIONS ///.
Definition: fpgaVec.c:263
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_NodeVecUnion ( Fpga_NodeVec_t p,
Fpga_NodeVec_t p1,
Fpga_NodeVec_t p2 
)

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

Synopsis [Computes the union of nodes in two arrays.]

Description []

SideEffects []

SeeAlso []

Definition at line 345 of file fpgaVec.c.

346 {
347  int i;
348  Fpga_NodeVecClear( p );
349  for ( i = 0; i < p1->nSize; i++ )
350  Fpga_NodeVecPush( p, p1->pArray[i] );
351  for ( i = 0; i < p2->nSize; i++ )
352  Fpga_NodeVecPush( p, p2->pArray[i] );
353 }
void Fpga_NodeVecPush(Fpga_NodeVec_t *p, Fpga_Node_t *Entry)
Definition: fpgaVec.c:169
void Fpga_NodeVecClear(Fpga_NodeVec_t *p)
Definition: fpgaVec.c:153
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_NodeVecWriteEntry ( Fpga_NodeVec_t p,
int  i,
Fpga_Node_t Entry 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file fpgaVec.c.

230 {
231  assert( i >= 0 && i < p->nSize );
232  p->pArray[i] = Entry;
233 }
#define assert(ex)
Definition: util_old.h:213
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
void Fpga_SortNodesByArrivalTimes ( Fpga_NodeVec_t p)

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

Synopsis [Orders the nodes in the increasing order of the arrival times.]

Description []

SideEffects []

SeeAlso []

Definition at line 326 of file fpgaVec.c.

327 {
328  qsort( (void *)p->pArray, p->nSize, sizeof(Fpga_Node_t *),
329  (int (*)(const void *, const void *)) Fpga_NodeVecCompareArrivals );
330 // assert( Fpga_CompareNodesByLevel( p->pArray, p->pArray + p->nSize - 1 ) <= 0 );
331 }
int Fpga_NodeVecCompareArrivals(Fpga_Node_t **ppS1, Fpga_Node_t **ppS2)
Definition: fpgaVec.c:306
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
float Fpga_TimeComputeArrivalMax ( Fpga_Man_t p)

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

Synopsis [Computes the maximum arrival times.]

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file fpgaTime.c.

90 {
91  float fRequired;
92  int i;
93  if ( p->fLatchPaths && p->nLatches == 0 )
94  {
95  printf( "Delay optimization of latch path is not performed because there is no latches.\n" );
96  p->fLatchPaths = 0;
97  }
98  // get the critical PO arrival time
99  fRequired = -FPGA_FLOAT_LARGE;
100  if ( p->fLatchPaths )
101  {
102  for ( i = p->nOutputs - p->nLatches; i < p->nOutputs; i++ )
103  {
104  if ( Fpga_NodeIsConst(p->pOutputs[i]) )
105  continue;
106  fRequired = FPGA_MAX( fRequired, Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
107 // printf( " %5.1f", Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
108  }
109 // printf( "Required latches = %5.1f\n", fRequired );
110  }
111  else
112  {
113  for ( i = 0; i < p->nOutputs; i++ )
114  {
115  if ( Fpga_NodeIsConst(p->pOutputs[i]) )
116  continue;
117  fRequired = FPGA_MAX( fRequired, Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
118 // printf( " %5.1f", Fpga_Regular(p->pOutputs[i])->pCutBest->tArrival );
119  }
120 // printf( "Required outputs = %5.1f\n", fRequired );
121  }
122  return fRequired;
123 }
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
#define FPGA_FLOAT_LARGE
Definition: fpgaInt.h:65
#define FPGA_MAX(a, b)
Definition: fpgaInt.h:62
int Fpga_NodeIsConst(Fpga_Node_t *p)
Definition: fpgaCreate.c:125
#define Fpga_Regular(p)
Definition: fpga.h:58
void Fpga_TimeComputeRequired ( Fpga_Man_t p,
float  fRequired 
)

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

Synopsis [Computes the required times of all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 168 of file fpgaTime.c.

169 {
170  int i;
171  // clean the required times and the fanout counts for all nodes
172  for ( i = 0; i < p->vAnds->nSize; i++ )
174  // set the required times for the POs
175  if ( p->fLatchPaths )
176  for ( i = p->nOutputs - p->nLatches; i < p->nOutputs; i++ )
177  Fpga_Regular(p->pOutputs[i])->tRequired = fRequired;
178  else
179  for ( i = 0; i < p->nOutputs; i++ )
180  Fpga_Regular(p->pOutputs[i])->tRequired = fRequired;
181  // collect nodes reachable from POs in the DFS order through the best cuts
183 /*
184  {
185  int Counter = 0;
186  for ( i = 0; i < p->vAnds->nSize; i++ )
187  if ( p->vAnds->pArray[i]->tRequired > FPGA_FLOAT_LARGE - 100 )
188  Counter++;
189  printf( "The number of nodes with large required times = %d.\n", Counter );
190  }
191 */
192 }
Fpga_Node_t ** pOutputs
Definition: fpgaInt.h:106
#define FPGA_FLOAT_LARGE
Definition: fpgaInt.h:65
Fpga_NodeVec_t * vMapping
Definition: fpgaInt.h:113
if(last==0)
Definition: sparse_int.h:34
#define Fpga_Regular(p)
Definition: fpga.h:58
void Fpga_TimePropagateRequired(Fpga_Man_t *p, Fpga_NodeVec_t *vNodes)
Definition: fpgaTime.c:205
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_NodeVec_t * vAnds
Definition: fpgaInt.h:112
void Fpga_TimeComputeRequiredGlobal ( Fpga_Man_t p,
int  fFirstTime 
)

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

Synopsis [Computes the required times of all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file fpgaTime.c.

137 {
139  // update the required times according to the target
140  if ( p->DelayTarget != -1 )
141  {
142  if ( p->fRequiredGlo > p->DelayTarget + p->fEpsilon )
143  {
144  if ( fFirstTime )
145  printf( "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->DelayTarget );
146  }
147  else if ( p->fRequiredGlo < p->DelayTarget - p->fEpsilon )
148  {
149  if ( fFirstTime )
150  printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->fRequiredGlo, p->DelayTarget );
151  p->fRequiredGlo = p->DelayTarget;
152  }
153  }
155 }
float Fpga_TimeComputeArrivalMax(Fpga_Man_t *p)
Definition: fpgaTime.c:89
void Fpga_TimeComputeRequired(Fpga_Man_t *p, float fRequired)
Definition: fpgaTime.c:168
float DelayTarget
Definition: fpgaInt.h:127
float fRequiredGlo
Definition: fpgaInt.h:145
float Fpga_TimeCutComputeArrival ( Fpga_Man_t pMan,
Fpga_Cut_t pCut 
)

DECLARATIONS ///.

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

FileName [fpgaTime.c]

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

Synopsis [Technology mapping for variable-size-LUT FPGAs.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

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

Revision [

Id:
fpgaTime.c,v 1.1 2005/01/23 06:59:42 alanmi Exp

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

Synopsis [Computes the arrival times of the cut.]

Description [Computes the maximum arrival time of the cut leaves and adds the delay of the LUT.]

SideEffects []

SeeAlso []

Definition at line 44 of file fpgaTime.c.

45 {
46  int i;
47  float tArrival;
48  tArrival = -FPGA_FLOAT_LARGE;
49  for ( i = 0; i < pCut->nLeaves; i++ )
50  if ( tArrival < pCut->ppLeaves[i]->pCutBest->tArrival )
51  tArrival = pCut->ppLeaves[i]->pCutBest->tArrival;
52  tArrival += pMan->pLutLib->pLutDelays[(int)pCut->nLeaves][0];
53  return tArrival;
54 }
float pLutDelays[FPGA_MAX_LUTSIZE+1][FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:176
#define FPGA_FLOAT_LARGE
Definition: fpgaInt.h:65
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_TimeCutComputeArrival_rec ( Fpga_Man_t pMan,
Fpga_Cut_t pCut 
)

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

Synopsis [Computes the arrival times of the cut recursively.]

Description [When computing the arrival time for the previously unused cuts, their arrival time may be incorrect because their fanins have incorrect arrival time. This procedure is called to fix this problem.]

SideEffects []

SeeAlso []

Definition at line 69 of file fpgaTime.c.

70 {
71  int i;
72  for ( i = 0; i < pCut->nLeaves; i++ )
73  if ( pCut->ppLeaves[i]->nRefs == 0 )
75  return Fpga_TimeCutComputeArrival( pMan, pCut );
76 }
float Fpga_TimeCutComputeArrival_rec(Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
Definition: fpgaTime.c:69
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222
ABC_NAMESPACE_IMPL_START float Fpga_TimeCutComputeArrival(Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
DECLARATIONS ///.
Definition: fpgaTime.c:44
void Fpga_TimePropagateArrival ( Fpga_Man_t p)

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

Synopsis [Computes the required times of all nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file fpgaTime.c.

246 {
247  Fpga_Node_t * pNode;
248  Fpga_Cut_t * pCut;
249  int i;
250 
251  // clean the required times and the fanout counts for all nodes
252  for ( i = 0; i < p->vAnds->nSize; i++ )
253  {
254  pNode = p->vAnds->pArray[i];
255  for ( pCut = pNode->pCuts->pNext; pCut; pCut = pCut->pNext )
256  pCut->tArrival = Fpga_TimeCutComputeArrival( p, pCut );
257  }
258 }
Fpga_Cut_t * pCuts
Definition: fpgaInt.h:224
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pNext
Definition: fpgaInt.h:246
ABC_NAMESPACE_IMPL_START float Fpga_TimeCutComputeArrival(Fpga_Man_t *pMan, Fpga_Cut_t *pCut)
DECLARATIONS ///.
Definition: fpgaTime.c:44
Fpga_NodeVec_t * vAnds
Definition: fpgaInt.h:112
void Fpga_TimePropagateRequired ( Fpga_Man_t p,
Fpga_NodeVec_t vNodes 
)

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

Synopsis [Computes the required times of the given nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 205 of file fpgaTime.c.

206 {
207  Fpga_Node_t * pNode, * pChild;
208  float fRequired;
209  int i, k;
210 
211  // sorts the nodes in the decreasing order of levels
212 // Fpga_MappingSortByLevel( p, vNodes, 0 );
213  // the nodes area already sorted in Fpga_MappingSetRefsAndArea()
214 
215  // go through the nodes in the reverse topological order
216  for ( k = 0; k < vNodes->nSize; k++ )
217  {
218  pNode = vNodes->pArray[k];
219  if ( !Fpga_NodeIsAnd(pNode) )
220  continue;
221  // get the required time for children
222  fRequired = pNode->tRequired - p->pLutLib->pLutDelays[(int)pNode->pCutBest->nLeaves][0];
223  // update the required time of the children
224  for ( i = 0; i < pNode->pCutBest->nLeaves; i++ )
225  {
226  pChild = pNode->pCutBest->ppLeaves[i];
227  pChild->tRequired = FPGA_MIN( pChild->tRequired, fRequired );
228  }
229  }
230 }
float pLutDelays[FPGA_MAX_LUTSIZE+1][FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:176
for(p=first;p->value< newval;p=p->next)
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
Definition: fpgaInt.h:237
#define FPGA_MIN(a, b)
Definition: fpgaInt.h:61
int Fpga_NodeIsAnd(Fpga_Node_t *p)
Definition: fpgaCreate.c:127
Fpga_LutLib_t * pLutLib
Definition: fpgaInt.h:137
Fpga_Node_t ** pArray
Definition: fpgaInt.h:252
Fpga_Cut_t * pCutBest
Definition: fpgaInt.h:222