summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-12-10 00:59:54 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2012-12-10 00:59:54 -0800
commit5eedc74a153fd2242a56f06f208bee7e3b0dfaf7 (patch)
tree318e31a46f319a30ae79b1286158d344fc56bce7
parent8355eb1d41cde28c5acca0790124bd15790d906f (diff)
downloadabc-5eedc74a153fd2242a56f06f208bee7e3b0dfaf7.tar.gz
abc-5eedc74a153fd2242a56f06f208bee7e3b0dfaf7.tar.bz2
abc-5eedc74a153fd2242a56f06f208bee7e3b0dfaf7.zip
Adding box library.
-rw-r--r--abclib.dsp10
-rw-r--r--src/base/abci/abc.c12
-rw-r--r--src/base/main/main.h2
-rw-r--r--src/base/main/mainFrame.c2
-rw-r--r--src/base/main/mainInit.c8
-rw-r--r--src/base/main/mainInt.h1
-rw-r--r--src/map/if/if.h27
-rw-r--r--src/map/if/ifCom.c366
-rw-r--r--src/map/if/ifLibBox.c254
-rw-r--r--src/map/if/ifLibLut.c (renamed from src/map/if/ifLib.c)6
-rw-r--r--src/map/if/module.make6
11 files changed, 678 insertions, 16 deletions
diff --git a/abclib.dsp b/abclib.dsp
index 1cd12143..189063dc 100644
--- a/abclib.dsp
+++ b/abclib.dsp
@@ -2279,6 +2279,10 @@ SOURCE=.\src\map\if\if.h
# End Source File
# Begin Source File
+SOURCE=.\src\map\if\ifCom.c
+# End Source File
+# Begin Source File
+
SOURCE=.\src\map\if\ifCore.c
# End Source File
# Begin Source File
@@ -2303,7 +2307,11 @@ SOURCE=.\src\map\if\ifDec16.c
# End Source File
# Begin Source File
-SOURCE=.\src\map\if\ifLib.c
+SOURCE=.\src\map\if\ifLibBox.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\map\if\ifLibLut.c
# End Source File
# Begin Source File
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/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/ifLib.c b/src/map/if/ifLibLut.c
index 3822302e..b1e6c680 100644
--- a/src/map/if/ifLib.c
+++ b/src/map/if/ifLibLut.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [ifLib.c]
+ FileName [ifLibLut.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,7 +14,7 @@
Date [Ver. 1.0. Started - November 21, 2006.]
- Revision [$Id: ifLib.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
+ Revision [$Id: ifLibLut.c,v 1.00 2006/11/21 00:00:00 alanmi Exp $]
***********************************************************************/
@@ -276,7 +276,7 @@ int If_LutLibDelaysAreDifferent( If_Lib_t * pLutLib )
SeeAlso []
***********************************************************************/
-If_Lib_t * If_SetSimpleLutLib( int nLutSize )
+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}} };
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 \