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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START char * 
If_UtilStrsav (char *s)
 DECLARATIONS ///. More...
 
If_LibLut_tIf_LibLutRead (char *FileName)
 FUNCTION DEFINITIONS ///. More...
 
If_LibLut_tIf_LibLutDup (If_LibLut_t *p)
 
void If_LibLutFree (If_LibLut_t *pLutLib)
 
void If_LibLutPrint (If_LibLut_t *pLutLib)
 
int If_LibLutDelaysAreDiscrete (If_LibLut_t *pLutLib)
 
int If_LibLutDelaysAreDifferent (If_LibLut_t *pLutLib)
 
If_LibLut_tIf_LibLutSetSimple (int nLutSize)
 
float If_LibLutFastestPinDelay (If_LibLut_t *p)
 
float If_LibLutSlowestPinDelay (If_LibLut_t *p)
 

Function Documentation

int If_LibLutDelaysAreDifferent ( If_LibLut_t pLutLib)

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

Synopsis [Returns 1 if the delays are discrete.]

Description []

SideEffects []

SeeAlso []

Definition at line 248 of file ifLibLut.c.

249 {
250  int i, k;
251  float Delay = pLutLib->pLutDelays[1][0];
252  if ( pLutLib->fVarPinDelays )
253  {
254  for ( i = 2; i <= pLutLib->LutMax; i++ )
255  for ( k = 0; k < i; k++ )
256  if ( pLutLib->pLutDelays[i][k] != Delay )
257  return 1;
258  }
259  else
260  {
261  for ( i = 2; i <= pLutLib->LutMax; i++ )
262  if ( pLutLib->pLutDelays[i][0] != Delay )
263  return 1;
264  }
265  return 0;
266 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
int fVarPinDelays
Definition: if.h:174
int If_LibLutDelaysAreDiscrete ( If_LibLut_t pLutLib)

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

Synopsis [Returns 1 if the delays are discrete.]

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file ifLibLut.c.

225 {
226  float Delay;
227  int i;
228  for ( i = 1; i <= pLutLib->LutMax; i++ )
229  {
230  Delay = pLutLib->pLutDelays[i][0];
231  if ( ((float)((int)Delay)) != Delay )
232  return 0;
233  }
234  return 1;
235 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
If_LibLut_t* If_LibLutDup ( If_LibLut_t p)

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

Synopsis [Duplicates the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file ifLibLut.c.

154 {
155  If_LibLut_t * pNew;
156  pNew = ABC_ALLOC( If_LibLut_t, 1 );
157  *pNew = *p;
158  pNew->pName = If_UtilStrsav( pNew->pName );
159  return pNew;
160 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * pName
Definition: if.h:172
static ABC_NAMESPACE_IMPL_START char * If_UtilStrsav(char *s)
DECLARATIONS ///.
Definition: ifLibLut.c:30
float If_LibLutFastestPinDelay ( If_LibLut_t p)

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

Synopsis [Gets the delay of the fastest pin.]

Description []

SideEffects []

SeeAlso []

Definition at line 319 of file ifLibLut.c.

320 {
321  return !p? 1.0 : p->pLutDelays[p->LutMax][0];
322 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
void If_LibLutFree ( If_LibLut_t pLutLib)

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

Synopsis [Frees the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 173 of file ifLibLut.c.

174 {
175  if ( pLutLib == NULL )
176  return;
177  ABC_FREE( pLutLib->pName );
178  ABC_FREE( pLutLib );
179 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
char * pName
Definition: if.h:172
void If_LibLutPrint ( If_LibLut_t pLutLib)

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

Synopsis [Prints the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 193 of file ifLibLut.c.

194 {
195  int i, k;
196  Abc_Print( 1, "# The area/delay of k-variable LUTs:\n" );
197  Abc_Print( 1, "# k area delay\n" );
198  if ( pLutLib->fVarPinDelays )
199  {
200  for ( i = 1; i <= pLutLib->LutMax; i++ )
201  {
202  Abc_Print( 1, "%d %7.2f ", i, pLutLib->pLutAreas[i] );
203  for ( k = 0; k < i; k++ )
204  Abc_Print( 1, " %7.2f", pLutLib->pLutDelays[i][k] );
205  Abc_Print( 1, "\n" );
206  }
207  }
208  else
209  for ( i = 1; i <= pLutLib->LutMax; i++ )
210  Abc_Print( 1, "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] );
211 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
int fVarPinDelays
Definition: if.h:174
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
float pLutAreas[IF_MAX_LUTSIZE+1]
Definition: if.h:175
If_LibLut_t* If_LibLutRead ( char *  FileName)

FUNCTION DEFINITIONS ///.

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file ifLibLut.c.

48 {
49  char pBuffer[1000], * pToken;
50  If_LibLut_t * p;
51  FILE * pFile;
52  int i, k;
53 
54  pFile = fopen( FileName, "r" );
55  if ( pFile == NULL )
56  {
57  Abc_Print( -1, "Cannot open LUT library file \"%s\".\n", FileName );
58  return NULL;
59  }
60 
61  p = ABC_ALLOC( If_LibLut_t, 1 );
62  memset( p, 0, sizeof(If_LibLut_t) );
63  p->pName = If_UtilStrsav( FileName );
64 
65  i = 1;
66  while ( fgets( pBuffer, 1000, pFile ) != NULL )
67  {
68  pToken = strtok( pBuffer, " \t\n" );
69  if ( pToken == NULL )
70  continue;
71  if ( pToken[0] == '#' )
72  continue;
73  if ( i != atoi(pToken) )
74  {
75  Abc_Print( 1, "Error in the LUT library file \"%s\".\n", FileName );
76  ABC_FREE( p->pName );
77  ABC_FREE( p );
78  return NULL;
79  }
80 
81  // read area
82  pToken = strtok( NULL, " \t\n" );
83  p->pLutAreas[i] = (float)atof(pToken);
84 
85  // read delays
86  k = 0;
87  while ( (pToken = strtok( NULL, " \t\n" )) )
88  p->pLutDelays[i][k++] = (float)atof(pToken);
89 
90  // check for out-of-bound
91  if ( k > i )
92  {
93  ABC_FREE( p->pName );
94  ABC_FREE( p );
95  Abc_Print( 1, "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i );
96  return NULL;
97  }
98 
99  // check if var delays are specified
100  if ( k > 1 )
101  p->fVarPinDelays = 1;
102 
103  if ( i == IF_MAX_LUTSIZE )
104  {
105  ABC_FREE( p->pName );
106  ABC_FREE( p );
107  Abc_Print( 1, "Skipping LUTs of size more than %d.\n", i );
108  return NULL;
109  }
110  i++;
111  }
112  p->LutMax = i-1;
113 
114  // check the library
115  if ( p->fVarPinDelays )
116  {
117  for ( i = 1; i <= p->LutMax; i++ )
118  for ( k = 0; k < i; k++ )
119  {
120  if ( p->pLutDelays[i][k] <= 0.0 )
121  Abc_Print( 0, "Pin %d of LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
122  k, i, p->pLutDelays[i][k] );
123  if ( k && p->pLutDelays[i][k-1] > p->pLutDelays[i][k] )
124  Abc_Print( 0, "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",
125  k-1, i, p->pLutDelays[i][k-1],
126  k, i, p->pLutDelays[i][k] );
127  }
128  }
129  else
130  {
131  for ( i = 1; i <= p->LutMax; i++ )
132  {
133  if ( p->pLutDelays[i][0] <= 0.0 )
134  Abc_Print( 0, "LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
135  i, p->pLutDelays[i][0] );
136  }
137  }
138 
139  return p;
140 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int LutMax
Definition: if.h:173
char * strtok()
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int fVarPinDelays
Definition: if.h:174
#define IF_MAX_LUTSIZE
INCLUDES ///.
Definition: if.h:52
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
double atof()
#define ABC_FREE(obj)
Definition: abc_global.h:232
float pLutAreas[IF_MAX_LUTSIZE+1]
Definition: if.h:175
char * pName
Definition: if.h:172
static ABC_NAMESPACE_IMPL_START char * If_UtilStrsav(char *s)
DECLARATIONS ///.
Definition: ifLibLut.c:30
If_LibLut_t* If_LibLutSetSimple ( int  nLutSize)

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

Synopsis [Sets simple LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 279 of file ifLibLut.c.

280 {
281  If_LibLut_t s_LutLib10= { "lutlib",10, 0, {0,1,1,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1},{1},{1}} };
282  If_LibLut_t s_LutLib9 = { "lutlib", 9, 0, {0,1,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1},{1}} };
283  If_LibLut_t s_LutLib8 = { "lutlib", 8, 0, {0,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1}} };
284  If_LibLut_t s_LutLib7 = { "lutlib", 7, 0, {0,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1}} };
285  If_LibLut_t s_LutLib6 = { "lutlib", 6, 0, {0,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1}} };
286  If_LibLut_t s_LutLib5 = { "lutlib", 5, 0, {0,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1}} };
287  If_LibLut_t s_LutLib4 = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} };
288  If_LibLut_t s_LutLib3 = { "lutlib", 3, 0, {0,1,1,1}, {{0},{1},{1},{1}} };
289  If_LibLut_t * pLutLib;
290  assert( nLutSize >= 3 && nLutSize <= 10 );
291  switch ( nLutSize )
292  {
293  case 3: pLutLib = &s_LutLib3; break;
294  case 4: pLutLib = &s_LutLib4; break;
295  case 5: pLutLib = &s_LutLib5; break;
296  case 6: pLutLib = &s_LutLib6; break;
297  case 7: pLutLib = &s_LutLib7; break;
298  case 8: pLutLib = &s_LutLib8; break;
299  case 9: pLutLib = &s_LutLib9; break;
300  case 10: pLutLib = &s_LutLib10; break;
301  default: pLutLib = NULL; break;
302  }
303  if ( pLutLib == NULL )
304  return NULL;
305  return If_LibLutDup(pLutLib);
306 }
If_LibLut_t * If_LibLutDup(If_LibLut_t *p)
Definition: ifLibLut.c:153
#define assert(ex)
Definition: util_old.h:213
float If_LibLutSlowestPinDelay ( If_LibLut_t p)

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

Synopsis [Gets the delay of the slowest pin.]

Description []

SideEffects []

SeeAlso []

Definition at line 335 of file ifLibLut.c.

336 {
337  return !p? 1.0 : (p->fVarPinDelays? p->pLutDelays[p->LutMax][p->LutMax-1]: p->pLutDelays[p->LutMax][0]);
338 }
int LutMax
Definition: if.h:173
float pLutDelays[IF_MAX_LUTSIZE+1][IF_MAX_LUTSIZE+1]
Definition: if.h:176
int fVarPinDelays
Definition: if.h:174
static ABC_NAMESPACE_IMPL_START char* If_UtilStrsav ( char *  s)
inlinestatic

DECLARATIONS ///.

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

FileName [ifLibLut.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [FPGA mapping based on priority cuts.]

Synopsis [LUT library.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - November 21, 2006.]

Revision [

Id:
ifLibLut.c,v 1.00 2006/11/21 00:00:00 alanmi Exp

]

Definition at line 30 of file ifLibLut.c.

30 { return !s ? s : strcpy(ABC_ALLOC(char, strlen(s)+1), s); }
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * strcpy()
int strlen()