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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Fpga_LutLibReadVarMax (Fpga_LutLib_t *p)
 DECLARATIONS ///. More...
 
float * Fpga_LutLibReadLutAreas (Fpga_LutLib_t *p)
 
float Fpga_LutLibReadLutArea (Fpga_LutLib_t *p, int Size)
 
Fpga_LutLib_tFpga_LutLibRead (char *FileName, int fVerbose)
 
Fpga_LutLib_tFpga_LutLibDup (Fpga_LutLib_t *p)
 
void Fpga_LutLibFree (Fpga_LutLib_t *pLutLib)
 
void Fpga_LutLibPrint (Fpga_LutLib_t *pLutLib)
 
int Fpga_LutLibDelaysAreDiscrete (Fpga_LutLib_t *pLutLib)
 

Function Documentation

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
Fpga_LutLib_t* Fpga_LutLibDup ( Fpga_LutLib_t p)

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

Synopsis [Duplicates the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 165 of file fpgaLib.c.

166 {
167  Fpga_LutLib_t * pNew;
168  pNew = ABC_ALLOC( Fpga_LutLib_t, 1 );
169  *pNew = *p;
170  pNew->pName = Extra_UtilStrsav( pNew->pName );
171  return pNew;
172 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * Extra_UtilStrsav(const char *s)
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
float Fpga_LutLibReadLutArea ( Fpga_LutLib_t p,
int  Size 
)

Definition at line 45 of file fpgaLib.c.

45 { assert( Size <= p->LutMax ); return p->pLutAreas[Size]; }
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
#define assert(ex)
Definition: util_old.h:213
float* Fpga_LutLibReadLutAreas ( Fpga_LutLib_t p)

Definition at line 44 of file fpgaLib.c.

44 { return p->pLutAreas; }
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition: fpgaInt.h:175
ABC_NAMESPACE_IMPL_START int Fpga_LutLibReadVarMax ( Fpga_LutLib_t p)

DECLARATIONS ///.

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

FileName [fpgaLib.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:
fpgaLib.c,v 1.4 2005/01/23 06:59:41 alanmi Exp

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

Synopsis [APIs to access LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 43 of file fpgaLib.c.

43 { return p->LutMax; }