Commit c1f8baaf by Alan Mishchenko

Added switch '-E <filename>' to 'read_library' to exclude gates listed while reading a Genlib file.

parent b5306c15
/**CFile**************************************************************** /**CFile****************************************************************
FileName [mio.c] pFileName [mio.c]
PackageName [MVSIS 1.3: Multi-valued logic synthesis system.] PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]
...@@ -153,7 +153,7 @@ int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -153,7 +153,7 @@ int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv )
FILE * pFile; FILE * pFile;
FILE * pOut, * pErr; FILE * pOut, * pErr;
Abc_Ntk_t * pNet; Abc_Ntk_t * pNet;
char * FileName; char * pFileName;
int fVerbose; int fVerbose;
int c; int c;
...@@ -186,21 +186,21 @@ int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -186,21 +186,21 @@ int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv )
} }
// get the input file name // get the input file name
FileName = argv[globalUtilOptind]; pFileName = argv[globalUtilOptind];
if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL ) if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL )
{ {
fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); fprintf( pErr, "Cannot open input file \"%s\". ", pFileName );
if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
fprintf( pErr, "Did you mean \"%s\"?", FileName ); fprintf( pErr, "Did you mean \"%s\"?", pFileName );
fprintf( pErr, "\n" ); fprintf( pErr, "\n" );
return 1; return 1;
} }
fclose( pFile ); fclose( pFile );
if ( !Amap_LibertyParse( FileName, fVerbose ) ) if ( !Amap_LibertyParse( pFileName, fVerbose ) )
return 0; return 0;
assert( strlen(FileName) < 900 ); assert( strlen(pFileName) < 900 );
sprintf( Command, "read_library %s", Extra_FileNameGenericAppend(FileName, ".genlib") ); sprintf( Command, "read_library %s", Extra_FileNameGenericAppend(pFileName, ".genlib") );
Cmd_CommandExecute( pAbc, Command ); Cmd_CommandExecute( pAbc, Command );
return 0; return 0;
...@@ -232,7 +232,8 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -232,7 +232,8 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
FILE * pOut, * pErr; FILE * pOut, * pErr;
Mio_Library_t * pLib; Mio_Library_t * pLib;
Abc_Ntk_t * pNet; Abc_Ntk_t * pNet;
char * FileName; char * pFileName;
char * pExcludeFile = NULL;
int fVerbose; int fVerbose;
double WireDelay; double WireDelay;
int c; int c;
...@@ -245,7 +246,7 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -245,7 +246,7 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
WireDelay = 0.0; WireDelay = 0.0;
fVerbose = 1; fVerbose = 1;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( (c = Extra_UtilGetopt(argc, argv, "Wvh")) != EOF ) while ( (c = Extra_UtilGetopt(argc, argv, "WEvh")) != EOF )
{ {
switch (c) switch (c)
{ {
...@@ -260,6 +261,15 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -260,6 +261,15 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
if ( WireDelay <= 0.0 ) if ( WireDelay <= 0.0 )
goto usage; goto usage;
break; break;
case 'E':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-E\" should be followed by a file name.\n" );
goto usage;
}
pExcludeFile = argv[globalUtilOptind];
globalUtilOptind++;
break;
case 'v': case 'v':
fVerbose ^= 1; fVerbose ^= 1;
break; break;
...@@ -270,27 +280,25 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -270,27 +280,25 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
goto usage; goto usage;
} }
} }
if ( argc != globalUtilOptind + 1 ) if ( argc != globalUtilOptind + 1 )
{ {
goto usage; goto usage;
} }
// get the input file name // get the input file name
FileName = argv[globalUtilOptind]; pFileName = argv[globalUtilOptind];
if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL ) if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL )
{ {
fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); fprintf( pErr, "Cannot open input file \"%s\". ", pFileName );
if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
fprintf( pErr, "Did you mean \"%s\"?", FileName ); fprintf( pErr, "Did you mean \"%s\"?", pFileName );
fprintf( pErr, "\n" ); fprintf( pErr, "\n" );
return 1; return 1;
} }
fclose( pFile ); fclose( pFile );
// set the new network // set the new network
pLib = Mio_LibraryRead( FileName, 0, fVerbose ); pLib = Mio_LibraryRead( pFileName, pExcludeFile, fVerbose );
if ( pLib == NULL ) if ( pLib == NULL )
{ {
fprintf( pErr, "Reading GENLIB library has failed.\n" ); fprintf( pErr, "Reading GENLIB library has failed.\n" );
...@@ -312,7 +320,7 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -312,7 +320,7 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_FrameSetLibGen( pLib ); Abc_FrameSetLibGen( pLib );
// set the new network // set the new network
pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( FileName, 0, 0 ); pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( pFileName, 0, 0 );
if ( pLib == NULL ) if ( pLib == NULL )
{ {
fprintf( pErr, "Reading GENLIB library has failed.\n" ); fprintf( pErr, "Reading GENLIB library has failed.\n" );
...@@ -324,12 +332,13 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -324,12 +332,13 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
return 0; return 0;
usage: usage:
fprintf( pErr, "usage: read_library [-W float] [-vh]\n"); fprintf( pErr, "usage: read_library [-W float] [-E filename] [-vh]\n");
fprintf( pErr, "\t read the library from a genlib file\n" ); fprintf( pErr, "\t read the library from a genlib file\n" );
fprintf( pErr, "\t (if the library contains more than one gate\n" ); fprintf( pErr, "\t (if the library contains more than one gate\n" );
fprintf( pErr, "\t with the same Boolean function, only the gate\n" ); fprintf( pErr, "\t with the same Boolean function, only the gate\n" );
fprintf( pErr, "\t with the smallest area will be used)\n" ); fprintf( pErr, "\t with the smallest area will be used)\n" );
Abc_Print( -2, "\t-W float : wire delay (added to pin-to-pin gate delays) [default = %g]\n", WireDelay ); fprintf( pErr, "\t-W float : wire delay (added to pin-to-pin gate delays) [default = %g]\n", WireDelay );
fprintf( pErr, "\t-E file : the file name with gates to be excluded [default = none]\n" );
fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-h : enable verbose output\n"); fprintf( pErr, "\t-h : enable verbose output\n");
return 1; /* error exit */ return 1; /* error exit */
...@@ -352,7 +361,7 @@ int Mio_CommandReadLibrary2( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -352,7 +361,7 @@ int Mio_CommandReadLibrary2( Abc_Frame_t * pAbc, int argc, char **argv )
FILE * pOut, * pErr; FILE * pOut, * pErr;
Mio_Library_t * pLib; Mio_Library_t * pLib;
Abc_Ntk_t * pNet; Abc_Ntk_t * pNet;
char * FileName; char * pFileName;
int fVerbose; int fVerbose;
int fVeryVerbose; int fVeryVerbose;
int c; int c;
...@@ -390,19 +399,19 @@ int Mio_CommandReadLibrary2( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -390,19 +399,19 @@ int Mio_CommandReadLibrary2( Abc_Frame_t * pAbc, int argc, char **argv )
} }
// get the input file name // get the input file name
FileName = argv[globalUtilOptind]; pFileName = argv[globalUtilOptind];
if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL ) if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL )
{ {
fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); fprintf( pErr, "Cannot open input file \"%s\". ", pFileName );
if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".genlib", ".lib", ".gen", ".g", NULL )) )
fprintf( pErr, "Did you mean \"%s\"?", FileName ); fprintf( pErr, "Did you mean \"%s\"?", pFileName );
fprintf( pErr, "\n" ); fprintf( pErr, "\n" );
return 1; return 1;
} }
fclose( pFile ); fclose( pFile );
// set the new network // set the new network
pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( FileName, fVerbose, fVeryVerbose ); pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( pFileName, fVerbose, fVeryVerbose );
if ( pLib == NULL ) if ( pLib == NULL )
{ {
fprintf( pErr, "Reading GENLIB library has failed.\n" ); fprintf( pErr, "Reading GENLIB library has failed.\n" );
...@@ -442,7 +451,7 @@ int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -442,7 +451,7 @@ int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
{ {
FILE * pOut, * pErr, * pFile; FILE * pOut, * pErr, * pFile;
Abc_Ntk_t * pNet; Abc_Ntk_t * pNet;
char * FileName; char * pFileName;
int fVerbose; int fVerbose;
int c; int c;
...@@ -472,18 +481,18 @@ int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -472,18 +481,18 @@ int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
printf( "Library is not available.\n" ); printf( "Library is not available.\n" );
return 1; return 1;
} }
FileName = argv[globalUtilOptind]; pFileName = argv[globalUtilOptind];
if ( argc == globalUtilOptind + 1 ) if ( argc == globalUtilOptind + 1 )
{ {
pFile = fopen( FileName, "w" ); pFile = fopen( pFileName, "w" );
if ( pFile == NULL ) if ( pFile == NULL )
{ {
printf( "Error! Cannot open file \"%s\" for writing the library.\n", FileName ); printf( "Error! Cannot open file \"%s\" for writing the library.\n", pFileName );
return 1; return 1;
} }
Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 ); Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 );
fclose( pFile ); fclose( pFile );
printf( "The current GENLIB library is written into file \"%s\".\n", FileName ); printf( "The current GENLIB library is written into file \"%s\".\n", pFileName );
} }
else if ( argc == globalUtilOptind ) else if ( argc == globalUtilOptind )
Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 ); Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 );
......
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