Commit 5eedc74a by Alan Mishchenko

Adding box library.

parent 8355eb1d
......@@ -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
......
......@@ -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 )
......
......@@ -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 );
......
......@@ -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; }
......
......@@ -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 );
......
......@@ -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
......
......@@ -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 );
......
/**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
/**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
/**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}} };
......
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 \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment