From 5eedc74a153fd2242a56f06f208bee7e3b0dfaf7 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 10 Dec 2012 00:59:54 -0800 Subject: Adding box library. --- src/base/abci/abc.c | 12 +- src/base/main/main.h | 2 + src/base/main/mainFrame.c | 2 + src/base/main/mainInit.c | 8 +- src/base/main/mainInt.h | 1 + src/map/if/if.h | 27 +++- src/map/if/ifCom.c | 366 ++++++++++++++++++++++++++++++++++++++++++++++ src/map/if/ifLib.c | 346 ------------------------------------------- src/map/if/ifLibBox.c | 254 ++++++++++++++++++++++++++++++++ src/map/if/ifLibLut.c | 346 +++++++++++++++++++++++++++++++++++++++++++ src/map/if/module.make | 6 +- 11 files changed, 1012 insertions(+), 358 deletions(-) create mode 100644 src/map/if/ifCom.c delete mode 100644 src/map/if/ifLib.c create mode 100644 src/map/if/ifLibBox.c create mode 100644 src/map/if/ifLibLut.c (limited to 'src') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 69621f37..3dc788e0 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -233,8 +233,8 @@ static int Abc_CommandAttach ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandSuperChoice ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSuperChoiceLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandFpga ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandFpgaFast ( Abc_Frame_t * pAbc, int argc, char ** argv ); +//static int Abc_CommandFpga ( Abc_Frame_t * pAbc, int argc, char ** argv ); +//static int Abc_CommandFpgaFast ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandIf ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandIfif ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -694,8 +694,8 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "SC mapping", "superc", Abc_CommandSuperChoice, 1 ); Cmd_CommandAdd( pAbc, "SC mapping", "supercl", Abc_CommandSuperChoiceLut, 1 ); - Cmd_CommandAdd( pAbc, "FPGA mapping", "fpga", Abc_CommandFpga, 1 ); - Cmd_CommandAdd( pAbc, "FPGA mapping", "ffpga", Abc_CommandFpgaFast, 1 ); +// Cmd_CommandAdd( pAbc, "FPGA mapping", "fpga", Abc_CommandFpga, 1 ); +// Cmd_CommandAdd( pAbc, "FPGA mapping", "ffpga", Abc_CommandFpgaFast, 1 ); Cmd_CommandAdd( pAbc, "FPGA mapping", "if", Abc_CommandIf, 1 ); Cmd_CommandAdd( pAbc, "FPGA mapping", "ifif", Abc_CommandIfif, 1 ); @@ -14241,6 +14241,7 @@ usage: SeeAlso [] ***********************************************************************/ +#if 0 int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv ) { char Buffer[100]; @@ -14518,6 +14519,7 @@ usage: Abc_Print( -2, "\t-h : prints the command usage\n"); return 1; } +#endif /**Function************************************************************* @@ -27335,7 +27337,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( pAbc->pLibLut == NULL ) { Abc_Print( -1, "LUT library is not given. Using default LUT library.\n" ); - pAbc->pLibLut = If_SetSimpleLutLib( 6 ); + pAbc->pLibLut = If_LutLibSetSimple( 6 ); } Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGDEWSqaflepmrsdbgyojikcvh" ) ) != EOF ) diff --git a/src/base/main/main.h b/src/base/main/main.h index 849e1956..6fc2c356 100644 --- a/src/base/main/main.h +++ b/src/base/main/main.h @@ -96,6 +96,7 @@ extern ABC_DLL Abc_Frame_t * Abc_FrameReadGlobalFrame(); extern ABC_DLL Vec_Ptr_t * Abc_FrameReadStore(); extern ABC_DLL int Abc_FrameReadStoreSize(); extern ABC_DLL void * Abc_FrameReadLibLut(); +extern ABC_DLL void * Abc_FrameReadLibBox(); extern ABC_DLL void * Abc_FrameReadLibGen(); extern ABC_DLL void * Abc_FrameReadLibGen2(); extern ABC_DLL void * Abc_FrameReadLibSuper(); @@ -122,6 +123,7 @@ extern ABC_DLL int Abc_FrameReadCexFrame( Abc_Frame_t * p ); extern ABC_DLL void Abc_FrameSetNtkStore( Abc_Ntk_t * pNtk ); extern ABC_DLL void Abc_FrameSetNtkStoreSize( int nStored ); extern ABC_DLL void Abc_FrameSetLibLut( void * pLib ); +extern ABC_DLL void Abc_FrameSetLibBox( void * pLib ); extern ABC_DLL void Abc_FrameSetLibGen( void * pLib ); extern ABC_DLL void Abc_FrameSetLibGen2( void * pLib ); extern ABC_DLL void Abc_FrameSetLibSuper( void * pLib ); diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index deb0ddca..df1b385e 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -51,6 +51,7 @@ static Abc_Frame_t * s_GlobalFrame = NULL; Vec_Ptr_t * Abc_FrameReadStore() { return s_GlobalFrame->vStore; } int Abc_FrameReadStoreSize() { return Vec_PtrSize(s_GlobalFrame->vStore); } void * Abc_FrameReadLibLut() { return s_GlobalFrame->pLibLut; } +void * Abc_FrameReadLibBox() { return s_GlobalFrame->pLibBox; } void * Abc_FrameReadLibGen() { return s_GlobalFrame->pLibGen; } void * Abc_FrameReadLibGen2() { return s_GlobalFrame->pLibGen2; } void * Abc_FrameReadLibSuper() { return s_GlobalFrame->pLibSuper; } @@ -71,6 +72,7 @@ int Abc_FrameReadCexPo( Abc_Frame_t * p ) { return s_GlobalFr int Abc_FrameReadCexFrame( Abc_Frame_t * p ) { return s_GlobalFrame->pCex->iFrame; } void Abc_FrameSetLibLut( void * pLib ) { s_GlobalFrame->pLibLut = pLib; } +void Abc_FrameSetLibBox( void * pLib ) { s_GlobalFrame->pLibBox = pLib; } void Abc_FrameSetLibGen( void * pLib ) { s_GlobalFrame->pLibGen = pLib; } void Abc_FrameSetLibGen2( void * pLib ) { s_GlobalFrame->pLibGen2 = pLib; } void Abc_FrameSetLibSuper( void * pLib ) { s_GlobalFrame->pLibSuper = pLib; } diff --git a/src/base/main/mainInit.c b/src/base/main/mainInit.c index a3caba05..bbe0bbd1 100644 --- a/src/base/main/mainInit.c +++ b/src/base/main/mainInit.c @@ -36,8 +36,8 @@ extern void Io_Init( Abc_Frame_t * pAbc ); extern void Io_End ( Abc_Frame_t * pAbc ); extern void Cmd_Init( Abc_Frame_t * pAbc ); extern void Cmd_End ( Abc_Frame_t * pAbc ); -extern void Fpga_Init( Abc_Frame_t * pAbc ); -extern void Fpga_End ( Abc_Frame_t * pAbc ); +extern void If_Init( Abc_Frame_t * pAbc ); +extern void If_End ( Abc_Frame_t * pAbc ); extern void Map_Init( Abc_Frame_t * pAbc ); extern void Map_End ( Abc_Frame_t * pAbc ); extern void Mio_Init( Abc_Frame_t * pAbc ); @@ -78,7 +78,7 @@ void Abc_FrameInit( Abc_Frame_t * pAbc ) Cmd_CommandExecute( pAbc, "set checkread" ); Io_Init( pAbc ); Abc_Init( pAbc ); - Fpga_Init( pAbc ); + If_Init( pAbc ); Map_Init( pAbc ); Mio_Init( pAbc ); Super_Init( pAbc ); @@ -112,7 +112,7 @@ void Abc_FrameEnd( Abc_Frame_t * pAbc ) Abc_End( pAbc ); Io_End( pAbc ); Cmd_End( pAbc ); - Fpga_End( pAbc ); + If_End( pAbc ); Map_End( pAbc ); Mio_End( pAbc ); Super_End( pAbc ); diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index 9450462d..9b2640c5 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -87,6 +87,7 @@ struct Abc_Frame_t_ DdManager * dd; // temporary BDD package // libraries for mapping void * pLibLut; // the current LUT library + void * pLibBox; // the current box library void * pLibGen; // the current genlib void * pLibGen2; // the current genlib void * pLibSuper; // the current supergate library diff --git a/src/map/if/if.h b/src/map/if/if.h index 4505f6d4..a2d047af 100644 --- a/src/map/if/if.h +++ b/src/map/if/if.h @@ -312,6 +312,23 @@ struct If_And_t_ unsigned Delay : 16; // delay }; +typedef struct If_Box_t_ If_Box_t; +struct If_Box_t_ +{ + char * pName; + int Id; + int fWhite; + int nPis; + int nPos; + int * pDelays; +}; + +typedef struct If_LibBox_t_ If_LibBox_t; +struct If_LibBox_t_ +{ + Vec_Ptr_t * vBoxes; +}; + static inline If_Obj_t * If_Regular( If_Obj_t * p ) { return (If_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); } static inline If_Obj_t * If_Not( If_Obj_t * p ) { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); } static inline If_Obj_t * If_NotCond( If_Obj_t * p, int c ) { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); } @@ -481,9 +498,17 @@ extern void If_LutLibFree( If_Lib_t * pLutLib ); extern void If_LutLibPrint( If_Lib_t * pLutLib ); extern int If_LutLibDelaysAreDiscrete( If_Lib_t * pLutLib ); extern int If_LutLibDelaysAreDifferent( If_Lib_t * pLutLib ); -extern If_Lib_t * If_SetSimpleLutLib( int nLutSize ); +extern If_Lib_t * If_LutLibSetSimple( int nLutSize ); extern float If_LutLibFastestPinDelay( If_Lib_t * p ); extern float If_LutLibSlowestPinDelay( If_Lib_t * p ); +/*=== ifLibBox.c =============================================================*/ +extern If_LibBox_t * If_LibBoxStart(); +extern void If_LibBoxFree( If_LibBox_t * p ); +extern If_Box_t * If_LibBoxReadBox( If_LibBox_t * p, int Id ); +extern void If_LibBoxAdd( If_LibBox_t * p, If_Box_t * pBox ); +extern If_LibBox_t * If_LibBoxRead( char * pFileName ); +extern void If_LibBoxPrint( FILE * pFile, If_LibBox_t * p ); +extern void If_LibBoxWrite( char * pFileName, If_LibBox_t * p ); /*=== ifMan.c =============================================================*/ extern If_Man_t * If_ManStart( If_Par_t * pPars ); extern void If_ManRestart( If_Man_t * p ); diff --git a/src/map/if/ifCom.c b/src/map/if/ifCom.c new file mode 100644 index 00000000..a6af038f --- /dev/null +++ b/src/map/if/ifCom.c @@ -0,0 +1,366 @@ +/**CFile**************************************************************** + + FileName [ifCom.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [FPGA mapping based on priority cuts.] + + Synopsis [Command handlers.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - November 21, 2006.] + + Revision [$Id: ifCom.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "if.h" +#include "base/main/main.h" + +ABC_NAMESPACE_IMPL_START + + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +static int If_CommandReadLut ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int If_CommandPrintLut( Abc_Frame_t * pAbc, int argc, char **argv ); +static int If_CommandReadBox ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int If_CommandPrintBox( Abc_Frame_t * pAbc, int argc, char **argv ); + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Package initialization procedure.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void If_Init( Abc_Frame_t * pAbc ) +{ + // set the default library + If_Lib_t s_LutLib = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} }; + Abc_FrameSetLibLut( If_LutLibDup(&s_LutLib) ); + + Cmd_CommandAdd( pAbc, "FPGA mapping", "read_lut", If_CommandReadLut, 0 ); + Cmd_CommandAdd( pAbc, "FPGA mapping", "print_lut", If_CommandPrintLut, 0 ); + + Cmd_CommandAdd( pAbc, "FPGA mapping", "read_box", If_CommandReadBox, 0 ); + Cmd_CommandAdd( pAbc, "FPGA mapping", "print_box", If_CommandPrintBox, 0 ); +} + +/**Function************************************************************* + + Synopsis [Package ending procedure.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void If_End( Abc_Frame_t * pAbc ) +{ + If_LutLibFree( (If_Lib_t *) Abc_FrameReadLibLut() ); + If_LibBoxFree( (If_LibBox_t *)Abc_FrameReadLibBox() ); +} + +/**Function************************************************************* + + Synopsis [Command procedure to read LUT libraries.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int If_CommandReadLut( Abc_Frame_t * pAbc, int argc, char **argv ) +{ + FILE * pFile; + FILE * pOut, * pErr; + If_Lib_t * pLib; + Abc_Ntk_t * pNet; + char * FileName; + int fVerbose; + int c; + + pNet = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + // set the defaults + fVerbose = 1; + Extra_UtilGetoptReset(); + while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) + { + switch (c) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + break; + default: + goto usage; + } + } + + if ( argc != globalUtilOptind + 1 ) + goto usage; + + // get the input file name + FileName = argv[globalUtilOptind]; + if ( (pFile = fopen( FileName, "r" )) == NULL ) + { + fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); + if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) + fprintf( pErr, "Did you mean \"%s\"?", FileName ); + fprintf( pErr, "\n" ); + return 1; + } + fclose( pFile ); + + // set the new network + pLib = If_LutLibRead( FileName ); + if ( pLib == NULL ) + { + fprintf( pErr, "Reading LUT library has failed.\n" ); + goto usage; + } + // replace the current library + If_LutLibFree( (If_Lib_t *)Abc_FrameReadLibLut() ); + Abc_FrameSetLibLut( pLib ); + return 0; + +usage: + fprintf( pErr, "\nusage: read_lut [-vh]\n"); + fprintf( pErr, "\t read the LUT library from the file\n" ); + fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); + fprintf( pErr, "\t-h : print the command usage\n"); + fprintf( pErr, "\t \n"); + fprintf( pErr, "\t File format for a LUT library:\n"); + fprintf( pErr, "\t (the default library is shown)\n"); + fprintf( pErr, "\t \n"); + fprintf( pErr, "\t # The area/delay of k-variable LUTs:\n"); + fprintf( pErr, "\t # k area delay\n"); + fprintf( pErr, "\t 1 1 1\n"); + fprintf( pErr, "\t 2 2 2\n"); + fprintf( pErr, "\t 3 4 3\n"); + fprintf( pErr, "\t 4 8 4\n"); + fprintf( pErr, "\t 5 16 5\n"); + fprintf( pErr, "\t 6 32 6\n"); + return 1; /* error exit */ +} + +/**Function************************************************************* + + Synopsis [Command procedure to read LUT libraries.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int If_CommandPrintLut( Abc_Frame_t * pAbc, int argc, char **argv ) +{ + FILE * pOut, * pErr; + Abc_Ntk_t * pNet; + int fVerbose; + int c; + + pNet = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + // set the defaults + fVerbose = 1; + Extra_UtilGetoptReset(); + while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) + { + switch (c) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + break; + default: + goto usage; + } + } + + if ( argc != globalUtilOptind ) + goto usage; + + // set the new network + If_LutLibPrint( (If_Lib_t *)Abc_FrameReadLibLut() ); + return 0; + +usage: + fprintf( pErr, "\nusage: print_lut [-vh]\n"); + fprintf( pErr, "\t print the current LUT library\n" ); + fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); + fprintf( pErr, "\t-h : print the command usage\n"); + return 1; /* error exit */ +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int If_CommandReadBox( Abc_Frame_t * pAbc, int argc, char **argv ) +{ + FILE * pFile; + FILE * pOut, * pErr; + If_LibBox_t * pLib; + Abc_Ntk_t * pNet; + char * FileName; + int fVerbose; + int c; + + pNet = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + // set the defaults + fVerbose = 1; + Extra_UtilGetoptReset(); + while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) + { + switch (c) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + break; + default: + goto usage; + } + } + + if ( argc != globalUtilOptind + 1 ) + goto usage; + + // get the input file name + FileName = argv[globalUtilOptind]; + if ( (pFile = fopen( FileName, "r" )) == NULL ) + { + fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); + if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) + fprintf( pErr, "Did you mean \"%s\"?", FileName ); + fprintf( pErr, "\n" ); + return 1; + } + fclose( pFile ); + + // set the new network + pLib = If_LibBoxRead( FileName ); + if ( pLib == NULL ) + { + fprintf( pErr, "Reading LUT library has failed.\n" ); + goto usage; + } + // replace the current library + If_LibBoxFree( (If_LibBox_t *)Abc_FrameReadLibBox() ); + Abc_FrameSetLibBox( pLib ); + return 0; + +usage: + fprintf( pErr, "\nusage: read_box [-vh]\n"); + fprintf( pErr, "\t read the box library from the file\n" ); + fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); + fprintf( pErr, "\t-h : print the command usage\n"); + return 1; /* error exit */ +} + +/**Function************************************************************* + + Synopsis [Command procedure to read LUT libraries.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int If_CommandPrintBox( Abc_Frame_t * pAbc, int argc, char **argv ) +{ + FILE * pOut, * pErr; + Abc_Ntk_t * pNet; + int fVerbose; + int c; + + pNet = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + // set the defaults + fVerbose = 1; + Extra_UtilGetoptReset(); + while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) + { + switch (c) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + break; + default: + goto usage; + } + } + + if ( argc != globalUtilOptind ) + goto usage; + + // set the new network + If_LibBoxPrint( stdout, (If_LibBox_t *)Abc_FrameReadLibBox() ); + return 0; + +usage: + fprintf( pErr, "\nusage: print_box [-vh]\n"); + fprintf( pErr, "\t print the current box library\n" ); + fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); + fprintf( pErr, "\t-h : print the command usage\n"); + return 1; /* error exit */ +} + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + +ABC_NAMESPACE_IMPL_END + diff --git a/src/map/if/ifLib.c b/src/map/if/ifLib.c deleted file mode 100644 index 3822302e..00000000 --- a/src/map/if/ifLib.c +++ /dev/null @@ -1,346 +0,0 @@ -/**CFile**************************************************************** - - FileName [ifLib.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: ifLib.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#include "if.h" - -ABC_NAMESPACE_IMPL_START - - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -static inline char * If_UtilStrsav( char *s ) { return !s ? s : strcpy(ABC_ALLOC(char, strlen(s)+1), s); } - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [Reads the description of LUTs from the LUT library file.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -If_Lib_t * If_LutLibRead( char * FileName ) -{ - char pBuffer[1000], * pToken; - If_Lib_t * p; - FILE * pFile; - int i, k; - - pFile = fopen( FileName, "r" ); - if ( pFile == NULL ) - { - Abc_Print( -1, "Cannot open LUT library file \"%s\".\n", FileName ); - return NULL; - } - - p = ABC_ALLOC( If_Lib_t, 1 ); - memset( p, 0, sizeof(If_Lib_t) ); - p->pName = If_UtilStrsav( FileName ); - - i = 1; - while ( fgets( pBuffer, 1000, pFile ) != NULL ) - { - pToken = strtok( pBuffer, " \t\n" ); - if ( pToken == NULL ) - continue; - if ( pToken[0] == '#' ) - continue; - if ( i != atoi(pToken) ) - { - Abc_Print( 1, "Error in the LUT library file \"%s\".\n", FileName ); - ABC_FREE( p->pName ); - ABC_FREE( p ); - return NULL; - } - - // read area - pToken = strtok( NULL, " \t\n" ); - p->pLutAreas[i] = (float)atof(pToken); - - // read delays - k = 0; - while ( (pToken = strtok( NULL, " \t\n" )) ) - p->pLutDelays[i][k++] = (float)atof(pToken); - - // check for out-of-bound - if ( k > i ) - { - ABC_FREE( p->pName ); - ABC_FREE( p ); - Abc_Print( 1, "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i ); - return NULL; - } - - // check if var delays are specified - if ( k > 1 ) - p->fVarPinDelays = 1; - - if ( i == IF_MAX_LUTSIZE ) - { - ABC_FREE( p->pName ); - ABC_FREE( p ); - Abc_Print( 1, "Skipping LUTs of size more than %d.\n", i ); - return NULL; - } - i++; - } - p->LutMax = i-1; - - // check the library - if ( p->fVarPinDelays ) - { - for ( i = 1; i <= p->LutMax; i++ ) - for ( k = 0; k < i; k++ ) - { - if ( p->pLutDelays[i][k] <= 0.0 ) - 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", - k, i, p->pLutDelays[i][k] ); - if ( k && p->pLutDelays[i][k-1] > p->pLutDelays[i][k] ) - 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", - k-1, i, p->pLutDelays[i][k-1], - k, i, p->pLutDelays[i][k] ); - } - } - else - { - for ( i = 1; i <= p->LutMax; i++ ) - { - if ( p->pLutDelays[i][0] <= 0.0 ) - Abc_Print( 0, "LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n", - i, p->pLutDelays[i][0] ); - } - } - - return p; -} - -/**Function************************************************************* - - Synopsis [Duplicates the LUT library.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -If_Lib_t * If_LutLibDup( If_Lib_t * p ) -{ - If_Lib_t * pNew; - pNew = ABC_ALLOC( If_Lib_t, 1 ); - *pNew = *p; - pNew->pName = If_UtilStrsav( pNew->pName ); - return pNew; -} - -/**Function************************************************************* - - Synopsis [Frees the LUT library.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void If_LutLibFree( If_Lib_t * pLutLib ) -{ - if ( pLutLib == NULL ) - return; - ABC_FREE( pLutLib->pName ); - ABC_FREE( pLutLib ); -} - - -/**Function************************************************************* - - Synopsis [Prints the LUT library.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void If_LutLibPrint( If_Lib_t * pLutLib ) -{ - int i, k; - Abc_Print( 1, "# The area/delay of k-variable LUTs:\n" ); - Abc_Print( 1, "# k area delay\n" ); - if ( pLutLib->fVarPinDelays ) - { - for ( i = 1; i <= pLutLib->LutMax; i++ ) - { - Abc_Print( 1, "%d %7.2f ", i, pLutLib->pLutAreas[i] ); - for ( k = 0; k < i; k++ ) - Abc_Print( 1, " %7.2f", pLutLib->pLutDelays[i][k] ); - Abc_Print( 1, "\n" ); - } - } - else - for ( i = 1; i <= pLutLib->LutMax; i++ ) - Abc_Print( 1, "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] ); -} - -/**Function************************************************************* - - Synopsis [Returns 1 if the delays are discrete.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int If_LutLibDelaysAreDiscrete( If_Lib_t * pLutLib ) -{ - float Delay; - int i; - for ( i = 1; i <= pLutLib->LutMax; i++ ) - { - Delay = pLutLib->pLutDelays[i][0]; - if ( ((float)((int)Delay)) != Delay ) - return 0; - } - return 1; -} - -/**Function************************************************************* - - Synopsis [Returns 1 if the delays are discrete.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int If_LutLibDelaysAreDifferent( If_Lib_t * pLutLib ) -{ - int i, k; - float Delay = pLutLib->pLutDelays[1][0]; - if ( pLutLib->fVarPinDelays ) - { - for ( i = 2; i <= pLutLib->LutMax; i++ ) - for ( k = 0; k < i; k++ ) - if ( pLutLib->pLutDelays[i][k] != Delay ) - return 1; - } - else - { - for ( i = 2; i <= pLutLib->LutMax; i++ ) - if ( pLutLib->pLutDelays[i][0] != Delay ) - return 1; - } - return 0; -} - -/**Function************************************************************* - - Synopsis [Sets simple LUT library.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -If_Lib_t * If_SetSimpleLutLib( int nLutSize ) -{ - If_Lib_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}} }; - If_Lib_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}} }; - If_Lib_t s_LutLib8 = { "lutlib", 8, 0, {0,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1}} }; - If_Lib_t s_LutLib7 = { "lutlib", 7, 0, {0,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1}} }; - If_Lib_t s_LutLib6 = { "lutlib", 6, 0, {0,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1}} }; - If_Lib_t s_LutLib5 = { "lutlib", 5, 0, {0,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1}} }; - If_Lib_t s_LutLib4 = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} }; - If_Lib_t s_LutLib3 = { "lutlib", 3, 0, {0,1,1,1}, {{0},{1},{1},{1}} }; - If_Lib_t * pLutLib; - assert( nLutSize >= 3 && nLutSize <= 10 ); - switch ( nLutSize ) - { - case 3: pLutLib = &s_LutLib3; break; - case 4: pLutLib = &s_LutLib4; break; - case 5: pLutLib = &s_LutLib5; break; - case 6: pLutLib = &s_LutLib6; break; - case 7: pLutLib = &s_LutLib7; break; - case 8: pLutLib = &s_LutLib8; break; - case 9: pLutLib = &s_LutLib9; break; - case 10: pLutLib = &s_LutLib10; break; - default: pLutLib = NULL; break; - } - if ( pLutLib == NULL ) - return NULL; - return If_LutLibDup(pLutLib); -} - -/**Function************************************************************* - - Synopsis [Gets the delay of the fastest pin.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -float If_LutLibFastestPinDelay( If_Lib_t * p ) -{ - return !p? 1.0 : p->pLutDelays[p->LutMax][0]; -} - -/**Function************************************************************* - - Synopsis [Gets the delay of the slowest pin.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -float If_LutLibSlowestPinDelay( If_Lib_t * p ) -{ - return !p? 1.0 : (p->fVarPinDelays? p->pLutDelays[p->LutMax][p->LutMax-1]: p->pLutDelays[p->LutMax][0]); -} - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - -ABC_NAMESPACE_IMPL_END - diff --git a/src/map/if/ifLibBox.c b/src/map/if/ifLibBox.c new file mode 100644 index 00000000..678f4e68 --- /dev/null +++ b/src/map/if/ifLibBox.c @@ -0,0 +1,254 @@ +/**CFile**************************************************************** + + FileName [ifLibBox.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [FPGA mapping based on priority cuts.] + + Synopsis [Box library.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - November 21, 2006.] + + Revision [$Id: ifLibBox.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "if.h" +#include "misc/extra/extra.h" + +ABC_NAMESPACE_IMPL_START + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +#define If_LibBoxForEachBox( p, pBox, i ) \ + Vec_PtrForEachEntry( If_Box_t *, p->vBoxes, pBox, i ) if ( pBox == NULL ) {} else + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +If_Box_t * If_BoxStart( char * pName, int Id, int fWhite, int nPis, int nPos ) +{ + If_Box_t * p; + p = ABC_CALLOC( If_Box_t, 1 ); + p->pName = pName; // consumes memory + p->Id = Id; + p->fWhite = fWhite; + p->nPis = nPis; + p->nPos = nPos; + p->pDelays = ABC_CALLOC( int, nPis * nPos ); + return p; +} +If_Box_t * If_BoxDup( If_Box_t * p ) +{ + If_Box_t * pNew = NULL; + return pNew; +} +void If_BoxFree( If_Box_t * p ) +{ + ABC_FREE( p->pDelays ); + ABC_FREE( p->pName ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +If_LibBox_t * If_LibBoxStart() +{ + If_LibBox_t * p; + p = ABC_CALLOC( If_LibBox_t, 1 ); + p->vBoxes = Vec_PtrAlloc( 100 ); + return p; +} +If_LibBox_t * If_LibBoxDup( If_Box_t * p ) +{ + If_LibBox_t * pNew = NULL; + return pNew; +} +void If_LibBoxFree( If_LibBox_t * p ) +{ + If_Box_t * pBox; + int i; + if ( p == NULL ) + return; + If_LibBoxForEachBox( p, pBox, i ) + If_BoxFree( pBox ); + Vec_PtrFree( p->vBoxes ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +If_Box_t * If_LibBoxReadBox( If_LibBox_t * p, int Id ) +{ + return (If_Box_t *)Vec_PtrEntry( p->vBoxes, Id ); +} +void If_LibBoxAdd( If_LibBox_t * p, If_Box_t * pBox ) +{ + if ( pBox->Id >= Vec_PtrSize(p->vBoxes) ) + Vec_PtrFillExtra( p->vBoxes, 2 * pBox->Id + 10, NULL ); + assert( Vec_PtrEntry( p->vBoxes, pBox->Id ) == NULL ); + Vec_PtrWriteEntry( p->vBoxes, pBox->Id, pBox ); +} + + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +char * If_LibBoxGetToken( FILE * pFile ) +{ + static char pBuffer[1000]; + char c, * pTemp = pBuffer; + while ( (c = fgetc(pFile)) != EOF ) + { + if ( c == '#' ) + { + while ( (c = fgetc(pFile)) != EOF ) + if ( c == '\n' ) + break; + } + if ( c == ' ' || c == '\t' || c == '\n' || c == '\r' ) + { + if ( pTemp > pBuffer ) + break; + continue; + } + *pTemp++ = c; + } + *pTemp = 0; + return pTemp > pBuffer ? pBuffer : NULL; +} +If_LibBox_t * If_LibBoxRead( char * pFileName ) +{ + FILE * pFile; + If_LibBox_t * p; + If_Box_t * pBox; + char * pToken; + char * pName; + int i, Id, fWhite, nPis, nPos; + pFile = fopen( pFileName, "rb" ); + if ( pFile == NULL ) + { + printf( "Cannot open file \"%s\".\n", pFileName ); + return NULL; + } + // get the library name + pToken = If_LibBoxGetToken( pFile ); + if ( pToken == NULL ) + { + printf( "Cannot read library name from file \"%s\".\n", pFileName ); + return NULL; + } + // create library + p = If_LibBoxStart(); + while ( pToken ) + { + // save name + pName = Abc_UtilStrsav(pToken); + // save ID + pToken = If_LibBoxGetToken( pFile ); + Id = atoi( pToken ); + // save white/black + pToken = If_LibBoxGetToken( pFile ); + fWhite = atoi( pToken ); + // save PIs + pToken = If_LibBoxGetToken( pFile ); + nPis = atoi( pToken ); + // save POs + pToken = If_LibBoxGetToken( pFile ); + nPos = atoi( pToken ); + // create box + pBox = If_BoxStart( pName, Id, fWhite, nPis, nPos ); + If_LibBoxAdd( p, pBox ); + // read the table + for ( i = 0; i < nPis * nPos; i++ ) + { + pToken = If_LibBoxGetToken( pFile ); + pBox->pDelays[i] = (pToken[0] == '-') ? -1 : atoi(pToken); + } + // extract next name + pToken = If_LibBoxGetToken( pFile ); + } + fclose( pFile ); + return p; +} +void If_LibBoxPrint( FILE * pFile, If_LibBox_t * p ) +{ + If_Box_t * pBox; + int i, j, k; + fprintf( pFile, "# Box library written by ABC on %s.\n", Extra_TimeStamp() ); + If_LibBoxForEachBox( p, pBox, i ) + { + fprintf( pFile, "%s %d %d %d %d\n", pBox->pName, pBox->Id, pBox->fWhite, pBox->nPis, pBox->nPos ); + for ( j = 0; j < pBox->nPos; j++, printf("\n") ) + for ( k = 0; k < pBox->nPis; k++ ) + if ( pBox->pDelays[j * pBox->nPis + k] == -1 ) + fprintf( pFile, " - " ); + else + fprintf( pFile, "%5d ", pBox->pDelays[j * pBox->nPis + k] ); + } +} +void If_LibBoxWrite( char * pFileName, If_LibBox_t * p ) +{ + FILE * pFile; + pFile = fopen( pFileName, "wb" ); + if ( pFile == NULL ) + { + printf( "Cannot open file \"%s\".\n", pFileName ); + return; + } + If_LibBoxPrint( pFile, p ); + fclose( pFile ); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + +ABC_NAMESPACE_IMPL_END + diff --git a/src/map/if/ifLibLut.c b/src/map/if/ifLibLut.c new file mode 100644 index 00000000..b1e6c680 --- /dev/null +++ b/src/map/if/ifLibLut.c @@ -0,0 +1,346 @@ +/**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 $] + +***********************************************************************/ + +#include "if.h" + +ABC_NAMESPACE_IMPL_START + + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +static inline char * If_UtilStrsav( char *s ) { return !s ? s : strcpy(ABC_ALLOC(char, strlen(s)+1), s); } + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Reads the description of LUTs from the LUT library file.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +If_Lib_t * If_LutLibRead( char * FileName ) +{ + char pBuffer[1000], * pToken; + If_Lib_t * p; + FILE * pFile; + int i, k; + + pFile = fopen( FileName, "r" ); + if ( pFile == NULL ) + { + Abc_Print( -1, "Cannot open LUT library file \"%s\".\n", FileName ); + return NULL; + } + + p = ABC_ALLOC( If_Lib_t, 1 ); + memset( p, 0, sizeof(If_Lib_t) ); + p->pName = If_UtilStrsav( FileName ); + + i = 1; + while ( fgets( pBuffer, 1000, pFile ) != NULL ) + { + pToken = strtok( pBuffer, " \t\n" ); + if ( pToken == NULL ) + continue; + if ( pToken[0] == '#' ) + continue; + if ( i != atoi(pToken) ) + { + Abc_Print( 1, "Error in the LUT library file \"%s\".\n", FileName ); + ABC_FREE( p->pName ); + ABC_FREE( p ); + return NULL; + } + + // read area + pToken = strtok( NULL, " \t\n" ); + p->pLutAreas[i] = (float)atof(pToken); + + // read delays + k = 0; + while ( (pToken = strtok( NULL, " \t\n" )) ) + p->pLutDelays[i][k++] = (float)atof(pToken); + + // check for out-of-bound + if ( k > i ) + { + ABC_FREE( p->pName ); + ABC_FREE( p ); + Abc_Print( 1, "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i ); + return NULL; + } + + // check if var delays are specified + if ( k > 1 ) + p->fVarPinDelays = 1; + + if ( i == IF_MAX_LUTSIZE ) + { + ABC_FREE( p->pName ); + ABC_FREE( p ); + Abc_Print( 1, "Skipping LUTs of size more than %d.\n", i ); + return NULL; + } + i++; + } + p->LutMax = i-1; + + // check the library + if ( p->fVarPinDelays ) + { + for ( i = 1; i <= p->LutMax; i++ ) + for ( k = 0; k < i; k++ ) + { + if ( p->pLutDelays[i][k] <= 0.0 ) + 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", + k, i, p->pLutDelays[i][k] ); + if ( k && p->pLutDelays[i][k-1] > p->pLutDelays[i][k] ) + 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", + k-1, i, p->pLutDelays[i][k-1], + k, i, p->pLutDelays[i][k] ); + } + } + else + { + for ( i = 1; i <= p->LutMax; i++ ) + { + if ( p->pLutDelays[i][0] <= 0.0 ) + Abc_Print( 0, "LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n", + i, p->pLutDelays[i][0] ); + } + } + + return p; +} + +/**Function************************************************************* + + Synopsis [Duplicates the LUT library.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +If_Lib_t * If_LutLibDup( If_Lib_t * p ) +{ + If_Lib_t * pNew; + pNew = ABC_ALLOC( If_Lib_t, 1 ); + *pNew = *p; + pNew->pName = If_UtilStrsav( pNew->pName ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Frees the LUT library.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void If_LutLibFree( If_Lib_t * pLutLib ) +{ + if ( pLutLib == NULL ) + return; + ABC_FREE( pLutLib->pName ); + ABC_FREE( pLutLib ); +} + + +/**Function************************************************************* + + Synopsis [Prints the LUT library.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void If_LutLibPrint( If_Lib_t * pLutLib ) +{ + int i, k; + Abc_Print( 1, "# The area/delay of k-variable LUTs:\n" ); + Abc_Print( 1, "# k area delay\n" ); + if ( pLutLib->fVarPinDelays ) + { + for ( i = 1; i <= pLutLib->LutMax; i++ ) + { + Abc_Print( 1, "%d %7.2f ", i, pLutLib->pLutAreas[i] ); + for ( k = 0; k < i; k++ ) + Abc_Print( 1, " %7.2f", pLutLib->pLutDelays[i][k] ); + Abc_Print( 1, "\n" ); + } + } + else + for ( i = 1; i <= pLutLib->LutMax; i++ ) + Abc_Print( 1, "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] ); +} + +/**Function************************************************************* + + Synopsis [Returns 1 if the delays are discrete.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int If_LutLibDelaysAreDiscrete( If_Lib_t * pLutLib ) +{ + float Delay; + int i; + for ( i = 1; i <= pLutLib->LutMax; i++ ) + { + Delay = pLutLib->pLutDelays[i][0]; + if ( ((float)((int)Delay)) != Delay ) + return 0; + } + return 1; +} + +/**Function************************************************************* + + Synopsis [Returns 1 if the delays are discrete.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int If_LutLibDelaysAreDifferent( If_Lib_t * pLutLib ) +{ + int i, k; + float Delay = pLutLib->pLutDelays[1][0]; + if ( pLutLib->fVarPinDelays ) + { + for ( i = 2; i <= pLutLib->LutMax; i++ ) + for ( k = 0; k < i; k++ ) + if ( pLutLib->pLutDelays[i][k] != Delay ) + return 1; + } + else + { + for ( i = 2; i <= pLutLib->LutMax; i++ ) + if ( pLutLib->pLutDelays[i][0] != Delay ) + return 1; + } + return 0; +} + +/**Function************************************************************* + + Synopsis [Sets simple LUT library.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +If_Lib_t * If_LutLibSetSimple( int nLutSize ) +{ + If_Lib_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}} }; + If_Lib_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}} }; + If_Lib_t s_LutLib8 = { "lutlib", 8, 0, {0,1,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1},{1}} }; + If_Lib_t s_LutLib7 = { "lutlib", 7, 0, {0,1,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1},{1}} }; + If_Lib_t s_LutLib6 = { "lutlib", 6, 0, {0,1,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1},{1}} }; + If_Lib_t s_LutLib5 = { "lutlib", 5, 0, {0,1,1,1,1,1}, {{0},{1},{1},{1},{1},{1}} }; + If_Lib_t s_LutLib4 = { "lutlib", 4, 0, {0,1,1,1,1}, {{0},{1},{1},{1},{1}} }; + If_Lib_t s_LutLib3 = { "lutlib", 3, 0, {0,1,1,1}, {{0},{1},{1},{1}} }; + If_Lib_t * pLutLib; + assert( nLutSize >= 3 && nLutSize <= 10 ); + switch ( nLutSize ) + { + case 3: pLutLib = &s_LutLib3; break; + case 4: pLutLib = &s_LutLib4; break; + case 5: pLutLib = &s_LutLib5; break; + case 6: pLutLib = &s_LutLib6; break; + case 7: pLutLib = &s_LutLib7; break; + case 8: pLutLib = &s_LutLib8; break; + case 9: pLutLib = &s_LutLib9; break; + case 10: pLutLib = &s_LutLib10; break; + default: pLutLib = NULL; break; + } + if ( pLutLib == NULL ) + return NULL; + return If_LutLibDup(pLutLib); +} + +/**Function************************************************************* + + Synopsis [Gets the delay of the fastest pin.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +float If_LutLibFastestPinDelay( If_Lib_t * p ) +{ + return !p? 1.0 : p->pLutDelays[p->LutMax][0]; +} + +/**Function************************************************************* + + Synopsis [Gets the delay of the slowest pin.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +float If_LutLibSlowestPinDelay( If_Lib_t * p ) +{ + return !p? 1.0 : (p->fVarPinDelays? p->pLutDelays[p->LutMax][p->LutMax-1]: p->pLutDelays[p->LutMax][0]); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + +ABC_NAMESPACE_IMPL_END + diff --git a/src/map/if/module.make b/src/map/if/module.make index eda5e13e..2ae46fc0 100644 --- a/src/map/if/module.make +++ b/src/map/if/module.make @@ -1,10 +1,12 @@ -SRC += src/map/if/ifCore.c \ +SRC += src/map/if/ifCom.c \ + src/map/if/ifCore.c \ src/map/if/ifCut.c \ src/map/if/ifDec07.c \ src/map/if/ifDec08.c \ src/map/if/ifDec10.c \ src/map/if/ifDec16.c \ - src/map/if/ifLib.c \ + src/map/if/ifLibBox.c \ + src/map/if/ifLibLut.c \ src/map/if/ifMan.c \ src/map/if/ifMap.c \ src/map/if/ifReduce.c \ -- cgit v1.2.3