src/map/fpga/fpgaLib.c File Reference

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

Go to the source code of this file.

Functions

int Fpga_LutLibReadVarMax (Fpga_LutLib_t *p)
float * Fpga_LutLibReadLutAreas (Fpga_LutLib_t *p)
float Fpga_LutLibReadLutArea (Fpga_LutLib_t *p, int Size)
Fpga_LutLib_tFpga_LutLibCreate (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

Fpga_LutLib_t* Fpga_LutLibCreate ( char *  FileName,
int  fVerbose 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 55 of file fpgaLib.c.

00056 {
00057     char pBuffer[1000], * pToken;
00058     Fpga_LutLib_t * p;
00059     FILE * pFile;
00060     int i, k;
00061 
00062     pFile = fopen( FileName, "r" );
00063     if ( pFile == NULL )
00064     {
00065         printf( "Cannot open LUT library file \"%s\".\n", FileName );
00066         return NULL;
00067     }
00068 
00069     p = ALLOC( Fpga_LutLib_t, 1 );
00070     memset( p, 0, sizeof(Fpga_LutLib_t) );
00071     p->pName = Extra_UtilStrsav( FileName );
00072 
00073     i = 1;
00074     while ( fgets( pBuffer, 1000, pFile ) != NULL )
00075     {
00076         pToken = strtok( pBuffer, " \t\n" );
00077         if ( pToken == NULL )
00078             continue;
00079         if ( pToken[0] == '#' )
00080             continue;
00081         if ( i != atoi(pToken) )
00082         {
00083             printf( "Error in the LUT library file \"%s\".\n", FileName );
00084             free( p );
00085             return NULL;
00086         }
00087 
00088         // read area
00089         pToken = strtok( NULL, " \t\n" );
00090         p->pLutAreas[i] = (float)atof(pToken);
00091 
00092         // read delays
00093         k = 0;
00094         while ( pToken = strtok( NULL, " \t\n" ) )
00095             p->pLutDelays[i][k++] = (float)atof(pToken);
00096 
00097         // check for out-of-bound
00098         if ( k > i )
00099         {
00100             printf( "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i );
00101             return NULL;
00102         }
00103 
00104         // check if var delays are specifies
00105         if ( k > 1 )
00106             p->fVarPinDelays = 1;
00107 
00108         if ( i == FPGA_MAX_LUTSIZE )
00109         {
00110             printf( "Skipping LUTs of size more than %d.\n", i );
00111             return NULL;
00112         }
00113         i++;
00114     }
00115     p->LutMax = i-1;
00116     if ( p->LutMax > FPGA_MAX_LEAVES )
00117     {
00118         p->LutMax = FPGA_MAX_LEAVES;
00119         printf( "Warning: LUTs with more than %d input will not be used.\n", FPGA_MAX_LEAVES );
00120     }
00121 
00122     // check the library
00123     if ( p->fVarPinDelays )
00124     {
00125         for ( i = 1; i <= p->LutMax; i++ )
00126             for ( k = 0; k < i; k++ )
00127             {
00128                 if ( p->pLutDelays[i][k] <= 0.0 )
00129                     printf( "Warning: Pin %d of LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n", 
00130                         k, i, p->pLutDelays[i][k] );
00131                 if ( k && p->pLutDelays[i][k-1] > p->pLutDelays[i][k] )
00132                     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", 
00133                         k-1, i, p->pLutDelays[i][k-1], 
00134                         k, i, p->pLutDelays[i][k] );
00135             }
00136     }
00137     else
00138     {
00139         for ( i = 1; i <= p->LutMax; i++ )
00140         {
00141             if ( p->pLutDelays[i][0] <= 0.0 )
00142                 printf( "Warning: LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n", 
00143                     k, i, p->pLutDelays[i][0] );
00144         }
00145     }
00146 
00147     return p;
00148 }

int Fpga_LutLibDelaysAreDiscrete ( Fpga_LutLib_t pLutLib  ) 

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

Synopsis [Returns 1 if the delays are discrete.]

Description []

SideEffects []

SeeAlso []

Definition at line 232 of file fpgaLib.c.

00233 {
00234     float Delay;
00235     int i;
00236     for ( i = 1; i <= pLutLib->LutMax; i++ )
00237     {
00238         Delay = pLutLib->pLutDelays[i][0];
00239         if ( ((float)((int)Delay)) != Delay )
00240             return 0;
00241     }
00242     return 1;
00243 }

Fpga_LutLib_t* Fpga_LutLibDup ( Fpga_LutLib_t p  ) 

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

Synopsis [Duplicates the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 161 of file fpgaLib.c.

00162 {
00163     Fpga_LutLib_t * pNew;
00164     pNew = ALLOC( Fpga_LutLib_t, 1 );
00165     *pNew = *p;
00166     pNew->pName = Extra_UtilStrsav( pNew->pName );
00167     return pNew;
00168 }

void Fpga_LutLibFree ( Fpga_LutLib_t pLutLib  ) 

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

Synopsis [Frees the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 181 of file fpgaLib.c.

00182 {
00183     if ( pLutLib == NULL )
00184         return;
00185     FREE( pLutLib->pName );
00186     FREE( pLutLib );
00187 }

void Fpga_LutLibPrint ( Fpga_LutLib_t pLutLib  ) 

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

Synopsis [Prints the LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 201 of file fpgaLib.c.

00202 {
00203     int i, k;
00204     printf( "# The area/delay of k-variable LUTs:\n" );
00205     printf( "# k    area     delay\n" );
00206     if ( pLutLib->fVarPinDelays )
00207     {
00208         for ( i = 1; i <= pLutLib->LutMax; i++ )
00209         {
00210             printf( "%d   %7.2f  ", i, pLutLib->pLutAreas[i] );
00211             for ( k = 0; k < i; k++ )
00212                 printf( " %7.2f", pLutLib->pLutDelays[i][k] );
00213             printf( "\n" );
00214         }
00215     }
00216     else
00217         for ( i = 1; i <= pLutLib->LutMax; i++ )
00218             printf( "%d   %7.2f   %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] );
00219 }

float Fpga_LutLibReadLutArea ( Fpga_LutLib_t p,
int  Size 
)

Definition at line 42 of file fpgaLib.c.

00042 { assert( Size <= p->LutMax ); return p->pLutAreas[Size];  }

float* Fpga_LutLibReadLutAreas ( Fpga_LutLib_t p  ) 

Definition at line 41 of file fpgaLib.c.

00041 { return p->pLutAreas;  }

int Fpga_LutLibReadVarMax ( Fpga_LutLib_t p  ) 

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

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

Synopsis [APIs to access LUT library.]

Description []

SideEffects []

SeeAlso []

Definition at line 40 of file fpgaLib.c.

00040 { return p->LutMax;     }


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