Commit e7527a47 by Alan Mishchenko

Cleaned up interfaces of genlib/liberty/supergate reading/writing.

parent 1c099166
......@@ -143,11 +143,11 @@ int Map_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
fclose( pFile );
// set the new network
pLib = Map_SuperLibCreate( FileName, ExcludeFile, fAlgorithm, fVerbose );
pLib = Map_SuperLibCreate( NULL, FileName, ExcludeFile, fAlgorithm, fVerbose );
if ( pLib == NULL )
{
fprintf( pErr, "Reading supergate library has failed.\n" );
goto usage;
return 1;
}
// replace the current library
// Map_SuperLibFree( s_pSuperLib );
......
......@@ -378,7 +378,7 @@ extern void Map_NodeAddFaninFanout( Map_Node_t * pFanin, Map_Node_t
extern void Map_NodeRemoveFaninFanout( Map_Node_t * pFanin, Map_Node_t * pFanoutToRemove );
extern int Map_NodeGetFanoutNum( Map_Node_t * pNode );
/*=== mapperLib.c ============================================================*/
extern Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, int fAlgorithm, int fVerbose );
extern Map_SuperLib_t * Map_SuperLibCreate( Vec_Str_t * vStr, char * pFileName, char * pExcludeFile, int fAlgorithm, int fVerbose );
extern void Map_SuperLibFree( Map_SuperLib_t * p );
/*=== mapperMatch.c ===============================================================*/
extern int Map_MappingMatches( Map_Man_t * p );
......@@ -405,6 +405,8 @@ extern float Map_MappingGetArea( Map_Man_t * pMan, Map_NodeVec_t * v
/*=== mapperShow.c =============================================================*/
extern void Map_MappingShow( Map_Man_t * pMan, char * pFileName );
/*=== mapperTree.c ===============================================================*/
extern int Map_LibraryDeriveGateInfo( Map_SuperLib_t * pLib, st_table * tExcludeGate );
extern int Map_LibraryReadFileTreeStr( Map_SuperLib_t * pLib, Vec_Str_t * vStr, char * pFileName );
extern int Map_LibraryReadTree( Map_SuperLib_t * pLib, char * pFileName, char * pExcludeFile );
extern void Map_LibraryPrintTree( Map_SuperLib_t * pLib );
/*=== mapperSuper.c ===============================================================*/
......
......@@ -22,6 +22,8 @@
#endif
#include "mapperInt.h"
#include "map/super/super.h"
#include "map/mapper/mapperInt.h"
ABC_NAMESPACE_IMPL_START
......@@ -53,7 +55,7 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, int fAlgorithm, int fVerbose )
Map_SuperLib_t * Map_SuperLibCreate( Vec_Str_t * vStr, char * pFileName, char * pExcludeFile, int fAlgorithm, int fVerbose )
{
Map_SuperLib_t * p;
clock_t clk;
......@@ -61,7 +63,7 @@ Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, int
// start the supergate library
p = ABC_ALLOC( Map_SuperLib_t, 1 );
memset( p, 0, sizeof(Map_SuperLib_t) );
p->pName = pFileName;
p->pName = Abc_UtilStrsav(pFileName);
p->fVerbose = fVerbose;
p->mmSupers = Extra_MmFixedStart( sizeof(Map_Super_t) );
p->mmEntries = Extra_MmFixedStart( sizeof(Map_HashEntry_t) );
......@@ -74,7 +76,25 @@ Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, int
// read the supergate library from file
clk = clock();
if ( fAlgorithm )
if ( vStr != NULL )
{
// read the supergate library from file
int Status = Map_LibraryReadFileTreeStr( p, vStr, pFileName );
if ( Status == 0 )
{
Map_SuperLibFree( p );
return NULL;
}
// prepare the info about the library
Status = Map_LibraryDeriveGateInfo( p, NULL );
if ( Status == 0 )
{
Map_SuperLibFree( p );
return NULL;
}
assert( p->nVarsMax > 0 );
}
else if ( fAlgorithm )
{
if ( !Map_LibraryReadTree( p, pFileName, pExcludeFile ) )
{
......@@ -162,6 +182,7 @@ void Map_SuperLibFree( Map_SuperLib_t * p )
Extra_MmFixedStop( p->mmEntries );
Extra_MmFlexStop( p->mmForms );
ABC_FREE( p->ppSupers );
ABC_FREE( p->pName );
ABC_FREE( p );
}
......@@ -178,15 +199,47 @@ void Map_SuperLibFree( Map_SuperLib_t * p )
***********************************************************************/
int Map_SuperLibDeriveFromGenlib( Mio_Library_t * pLib, int fVerbose )
{
extern void Super_Precompute( Mio_Library_t * pLibGen, int nInputs, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fWriteOldFormat, int fVerbose );
Map_SuperLib_t * pLibSuper;
Abc_Frame_t * pAbc = Abc_FrameGetGlobalFrame();
Vec_Str_t * vStr;
char * pFileName;
if ( pLib == NULL )
return 0;
// compute supergates
vStr = Super_PrecomputeStr( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0 );
if ( vStr == NULL )
return 0;
// create supergate library
pFileName = Extra_FileNameGenericAppend( Mio_LibraryReadName(pLib), ".super" );
pLibSuper = Map_SuperLibCreate( vStr, pFileName, NULL, 1, 0 );
Vec_StrFree( vStr );
// replace the library
Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() );
Abc_FrameSetLibSuper( pLibSuper );
return 1;
}
/**Function*************************************************************
Synopsis [Derives the library from the genlib library.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Map_SuperLibDeriveFromGenlib2( Mio_Library_t * pLib, int fVerbose )
{
Abc_Frame_t * pAbc = Abc_FrameGetGlobalFrame();
char * pFileName;
if ( pLib == NULL )
return 0;
// compute supergates
Super_Precompute( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0, 0 );
// assuming that it terminated successfully
pFileName = Extra_FileNameGenericAppend(Mio_LibraryReadName(pLib), ".super");
Super_Precompute( pLib, 5, 1, 100000000, 10000000, 10000000, 100, 1, 0, pFileName );
// assuming that it terminated successfully
if ( Cmd_CommandExecute( pAbc, pFileName ) )
{
fprintf( stdout, "Cannot execute command \"read_super %s\".\n", pFileName );
......@@ -195,7 +248,6 @@ int Map_SuperLibDeriveFromGenlib( Mio_Library_t * pLib, int fVerbose )
return 1;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -103,13 +103,13 @@ int Map_LibraryReadFile( Map_SuperLib_t * pLib, FILE * pFile )
pLibName = strtok( pTemp, " \t\r\n" );
if ( strcmp( pLibName, "GATE" ) == 0 )
{
printf( "The input file \"%s\" looks like a GENLIB file and not a supergate library file.\n", pLib->pName );
printf( "The input file \"%s\" looks like a genlib file and not a supergate library file.\n", pLib->pName );
return 0;
}
pFileGen = fopen( pLibName, "r" );
if ( pFileGen == NULL )
{
printf( "Cannot open the GENLIB file \"%s\".\n", pLibName );
printf( "Cannot open the genlib file \"%s\".\n", pLibName );
return 0;
}
fclose( pFileGen );
......@@ -118,7 +118,7 @@ int Map_LibraryReadFile( Map_SuperLib_t * pLib, FILE * pFile )
pLib->pGenlib = Mio_LibraryRead( pLibName, NULL, 0, 0 );
if ( pLib->pGenlib == NULL )
{
printf( "Cannot read GENLIB file \"%s\".\n", pLibName );
printf( "Cannot read genlib file \"%s\".\n", pLibName );
return 0;
}
......
......@@ -40,7 +40,7 @@ static int Mio_CommandWriteGenlib( Abc_Frame_t * pAbc, int argc, char **argv );
static int Mio_CommandPrintGenlib( Abc_Frame_t * pAbc, int argc, char **argv );
/*
// internal version of GENLIB library
// internal version of genlib library
static char * pMcncGenlib[25] = {
"GATE inv1 1 O=!a; PIN * INV 1 999 0.9 0.0 0.9 0.0\n",
"GATE inv2 2 O=!a; PIN * INV 2 999 1.0 0.0 1.0 0.0\n",
......@@ -320,7 +320,7 @@ int Mio_CommandReadGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
pLib = Mio_LibraryRead( pFileName, NULL, pExcludeFile, fVerbose );
if ( pLib == NULL )
{
fprintf( pErr, "Reading GENLIB library has failed.\n" );
fprintf( pErr, "Reading genlib library has failed.\n" );
return 1;
}
// add the fixed number (wire delay) to all delays in the library
......@@ -342,14 +342,14 @@ int Mio_CommandReadGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( pFileName, NULL, 0, 0 );
if ( pLib == NULL )
{
fprintf( pErr, "Reading GENLIB library has failed.\n" );
fprintf( pErr, "Reading genlib library has failed.\n" );
return 1;
}
// replace the current library
Amap_LibFree( (Amap_Lib_t *)Abc_FrameReadLibGen2() );
Abc_FrameSetLibGen2( pLib );
if ( fVerbose )
printf( "Entered GENLIB library with %d gates from file \"%s\".\n", Mio_LibraryReadGateNum(pLib), pFileName );
printf( "Entered genlib library with %d gates from file \"%s\".\n", Mio_LibraryReadGateNum(pLib), pFileName );
return 0;
usage:
......@@ -425,7 +425,7 @@ int Mio_CommandWriteGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
}
Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 );
fclose( pFile );
printf( "The current GENLIB library is written into file \"%s\".\n", pFileName );
printf( "The current genlib library is written into file \"%s\".\n", pFileName );
return 0;
usage:
......
......@@ -129,6 +129,7 @@ extern double Mio_PinReadDelayFanoutFall( Mio_Pin_t * pPin );
extern double Mio_PinReadDelayBlockMax ( Mio_Pin_t * pPin );
extern Mio_Pin_t * Mio_PinReadNext ( Mio_Pin_t * pPin );
/*=== mioRead.c =============================================================*/
extern char * Mio_ReadFile( char * FileName, int fAddEnd );
extern Mio_Library_t * Mio_LibraryRead( char * FileName, char * pBuffer, char * ExcludeFile, int fVerbose );
extern int Mio_LibraryReadExclude( char * ExcludeFile, st_table * tExcludeGate );
/*=== mioFunc.c =============================================================*/
......
......@@ -89,7 +89,7 @@ Mio_Library_t * Mio_LibraryRead( char * FileName, char * pBuffer, char * Exclude
pLib->pName = Abc_UtilStrsav( Extra_FileNameGenericAppend(FileName, ".genlib") );
}
if ( pLib != NULL )
printf ( "Warning: Read extended GENLIB format but ignoring extensions\n" );
printf ( "Warning: Read extended genlib format but ignoring extensions\n" );
}
if ( tExcludeGate )
st_free_table( tExcludeGate );
......@@ -108,7 +108,7 @@ Mio_Library_t * Mio_LibraryRead( char * FileName, char * pBuffer, char * Exclude
SeeAlso []
***********************************************************************/
char * Mio_ReadFile( char * FileName )
char * Mio_ReadFile( char * FileName, int fAddEnd )
{
char * pBuffer;
FILE * pFile;
......@@ -131,6 +131,7 @@ char * Mio_ReadFile( char * FileName )
RetValue = fread( pBuffer, nFileSize, 1, pFile );
// terminate the string with '\0'
pBuffer[ nFileSize ] = '\0';
if ( fAddEnd )
strcat( pBuffer, "\n.end\n" );
// close file
fclose( pFile );
......@@ -201,7 +202,7 @@ Mio_Library_t * Mio_LibraryReadOne( char * FileName, int fExtendedFormat, st_tab
// pBuffer = Io_ReadFileFileContents( FileName, NULL );
// we don't use above function but actually do the same thing explicitly
// to handle open_path expansion correctly
pBuffer = Mio_ReadFile( FileName );
pBuffer = Mio_ReadFile( FileName, 1 );
if ( pBuffer == NULL )
return NULL;
pLib = Mio_LibraryReadBuffer( pBuffer, fExtendedFormat, tExcludeGate, fVerbose );
......@@ -617,7 +618,7 @@ void Mio_LibraryDetectSpecialGates( Mio_Library_t * pLib )
pLib->pGateBuf = Mio_GateCompare( pLib->pGateBuf, pGate, uFuncBuf );
if ( pLib->pGateBuf == NULL )
{
printf( "Warnings: GENLIB library reader cannot detect the buffer gate.\n" );
printf( "Warnings: genlib library reader cannot detect the buffer gate.\n" );
printf( "Some parts of the supergate-based technology mapper may not work correctly.\n" );
}
......@@ -626,7 +627,7 @@ void Mio_LibraryDetectSpecialGates( Mio_Library_t * pLib )
pLib->pGateInv = Mio_GateCompare( pLib->pGateInv, pGate, uFuncInv );
if ( pLib->pGateInv == NULL )
{
printf( "Warnings: GENLIB library reader cannot detect the invertor gate.\n" );
printf( "Warnings: genlib library reader cannot detect the invertor gate.\n" );
printf( "Some parts of the supergate-based technology mapper may not work correctly.\n" );
}
......@@ -637,7 +638,7 @@ void Mio_LibraryDetectSpecialGates( Mio_Library_t * pLib )
pLib->pGateAnd2 = Mio_GateCompare( pLib->pGateAnd2, pGate, uFuncAnd2 );
if ( pLib->pGateAnd2 == NULL && pLib->pGateNand2 == NULL )
{
printf( "Warnings: GENLIB library reader cannot detect the AND2 or NAND2 gate.\n" );
printf( "Warnings: genlib library reader cannot detect the AND2 or NAND2 gate.\n" );
printf( "Some parts of the supergate-based technology mapper may not work correctly.\n" );
}
}
......
......@@ -243,7 +243,7 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv )
if ( argc != globalUtilOptind + 1 )
{
fprintf( pErr, "The GENLIB library file should be given on the command line.\n" );
fprintf( pErr, "The genlib library file should be given on the command line.\n" );
goto usage;
}
......@@ -275,7 +275,8 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv )
}
// compute the gates
Super_Precompute( pLib, nVarsMax, nLevels, nGatesMax, DelayLimit, AreaLimit, TimeLimit, fSkipInvs, fWriteOldFormat, fVerbose );
FileName = Extra_FileNameGenericAppend(Mio_LibraryReadName(pLib), ".super");
Super_Precompute( pLib, nVarsMax, nLevels, nGatesMax, DelayLimit, AreaLimit, TimeLimit, fSkipInvs, fVerbose, FileName );
// delete the library
Mio_LibraryDelete( pLib );
......@@ -283,7 +284,7 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pErr, "usage: super [-ILNT num] [-DA float] [-E file] [-sovh] <genlib_file>\n");
fprintf( pErr, "\t precomputes the supergates for the given GENLIB library\n" );
fprintf( pErr, "\t precomputes the supergates for the given genlib library\n" );
fprintf( pErr, "\t-I num : the max number of supergate inputs [default = %d]\n", nVarsMax );
fprintf( pErr, "\t-L num : the max number of levels of gates [default = %d]\n", nLevels );
fprintf( pErr, "\t-N num : the limit on the number of considered supergates [default = %d]\n", nGatesMax );
......
......@@ -28,11 +28,8 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
......@@ -49,14 +46,15 @@ ABC_NAMESPACE_HEADER_START
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/*=== superCore.c =============================================================*/
/*=== superAnd.c =============================================================*/
extern void Super2_Precompute( int nInputs, int nLevels, int fVerbose );
/*=== superGate.c =============================================================*/
extern Vec_Str_t * Super_PrecomputeStr( Mio_Library_t * pLibGen, int nVarsMax, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fVerbose );
extern void Super_Precompute( Mio_Library_t * pLibGen, int nVarsMax, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fVerbose, char * pFileName );
ABC_NAMESPACE_HEADER_END
#endif
////////////////////////////////////////////////////////////////////////
......
......@@ -54,12 +54,6 @@ ABC_NAMESPACE_HEADER_START
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/*=== superAnd.c =============================================================*/
extern void Super2_Precompute( int nInputs, int nLevels, int fVerbose );
/*=== superGate.c =============================================================*/
extern void Super_Precompute( Mio_Library_t * pLibGen, int nInputs, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fWriteOldFormat, int fVerbose );
ABC_NAMESPACE_HEADER_END
......
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