ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fpgaLib.c
Go to the documentation of this file.
1
18
19#include "fpgaInt.h"
20
22
23
27
31
43int Fpga_LutLibReadVarMax( Fpga_LutLib_t * p ) { return p->LutMax; }
44float * Fpga_LutLibReadLutAreas( Fpga_LutLib_t * p ) { return p->pLutAreas; }
45float Fpga_LutLibReadLutArea( Fpga_LutLib_t * p, int Size ) { assert( Size <= p->LutMax ); return p->pLutAreas[Size]; }
46
58Fpga_LutLib_t * Fpga_LutLibRead( char * FileName, int fVerbose )
59{
60 char pBuffer[1000], * pToken;
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
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}
153
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}
173
186{
187 if ( pLutLib == NULL )
188 return;
189 ABC_FREE( pLutLib->pName );
190 ABC_FREE( pLutLib );
191}
192
193
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}
224
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}
248
252
253
255
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
char * Extra_UtilStrsav(const char *s)
void Fpga_LutLibPrint(Fpga_LutLib_t *pLutLib)
Definition fpgaLib.c:205
int Fpga_LutLibDelaysAreDiscrete(Fpga_LutLib_t *pLutLib)
Definition fpgaLib.c:236
Fpga_LutLib_t * Fpga_LutLibDup(Fpga_LutLib_t *p)
Definition fpgaLib.c:165
void Fpga_LutLibFree(Fpga_LutLib_t *pLutLib)
Definition fpgaLib.c:185
float Fpga_LutLibReadLutArea(Fpga_LutLib_t *p, int Size)
Definition fpgaLib.c:45
Fpga_LutLib_t * Fpga_LutLibRead(char *FileName, int fVerbose)
Definition fpgaLib.c:58
float * Fpga_LutLibReadLutAreas(Fpga_LutLib_t *p)
Definition fpgaLib.c:44
ABC_NAMESPACE_IMPL_START int Fpga_LutLibReadVarMax(Fpga_LutLib_t *p)
DECLARATIONS ///.
Definition fpgaLib.c:43
#define FPGA_MAX_LUTSIZE
INCLUDES ///.
Definition fpga.h:37
struct Fpga_LutLibStruct_t_ Fpga_LutLib_t
Definition fpga.h:47
float pLutAreas[FPGA_MAX_LUTSIZE+1]
Definition fpgaInt.h:175
float pLutDelays[FPGA_MAX_LUTSIZE+1][FPGA_MAX_LUTSIZE+1]
Definition fpgaInt.h:176
#define assert(ex)
Definition util_old.h:213
char * memset()
char * strtok()
double atof()