From aed3b3a13acf9113cc4ec254933efce6114519be Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 25 Sep 2012 01:34:26 -0700 Subject: Cleaned up interfaces of genlib/liberty/supergate reading/writing. --- src/map/mio/mio.c | 268 ++++++++++++++++++-------------------------------- src/map/mio/mio.h | 2 +- src/map/mio/mioRead.c | 131 ++++++++++++++++-------- 3 files changed, 183 insertions(+), 218 deletions(-) (limited to 'src/map/mio') diff --git a/src/map/mio/mio.c b/src/map/mio/mio.c index 04b46ee9..791a7ac0 100644 --- a/src/map/mio/mio.c +++ b/src/map/mio/mio.c @@ -35,12 +35,10 @@ ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// static int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Mio_CommandReadGenlib( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Mio_CommandWriteGenlib( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Mio_CommandPrintGenlib( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ); - -static int Mio_CommandReadLibrary2( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Mio_CommandPrintLibrary2( Abc_Frame_t * pAbc, int argc, char **argv ); /* // internal version of GENLIB library static char * pMcncGenlib[25] = { @@ -84,37 +82,15 @@ static char * pMcncGenlib[25] = { ***********************************************************************/ void Mio_Init( Abc_Frame_t * pAbc ) { -/* - char * pFileTemp = "mcnc_temp.genlib"; - void * pLibGen; - FILE * pFile; - int i; - - // write genlib into file - pFile = fopen( pFileTemp, "w" ); - for ( i = 0; pMcncGenlib[i]; i++ ) - fputs( pMcncGenlib[i], pFile ); - fclose( pFile ); - // read genlib from file - pLibGen = Mio_LibraryRead( pAbc, pFileTemp, NULL, 0 ); - Abc_FrameSetLibGen( pLibGen ); - pLibGen = Amap_LibReadAndPrepare( pFileTemp, 0, 0 ); - Abc_FrameSetLibGen2( pLibGen ); - -#ifdef WIN32 - _unlink( pFileTemp ); -#else - unlink( pFileTemp ); -#endif -*/ - Cmd_CommandAdd( pAbc, "SC mapping", "read_liberty", Mio_CommandReadLiberty, 0 ); - Cmd_CommandAdd( pAbc, "SC mapping", "read_library", Mio_CommandReadLibrary, 0 ); - Cmd_CommandAdd( pAbc, "SC mapping", "print_library", Mio_CommandPrintLibrary, 0 ); + Cmd_CommandAdd( pAbc, "SC mapping", "read_genlib", Mio_CommandReadGenlib, 0 ); + Cmd_CommandAdd( pAbc, "SC mapping", "write_genlib", Mio_CommandWriteGenlib, 0 ); + Cmd_CommandAdd( pAbc, "SC mapping", "print_genlib", Mio_CommandPrintGenlib, 0 ); - Cmd_CommandAdd( pAbc, "SC mapping", "read_library2", Mio_CommandReadLibrary2, 0 ); - Cmd_CommandAdd( pAbc, "SC mapping", "print_library2", Mio_CommandPrintLibrary2, 0 ); + Cmd_CommandAdd( pAbc, "SC mapping", "read_library", Mio_CommandReadGenlib, 0 ); + Cmd_CommandAdd( pAbc, "SC mapping", "write_library", Mio_CommandWriteGenlib, 0 ); + Cmd_CommandAdd( pAbc, "SC mapping", "print_library", Mio_CommandPrintGenlib, 0 ); } /**Function************************************************************* @@ -130,7 +106,6 @@ void Mio_Init( Abc_Frame_t * pAbc ) ***********************************************************************/ void Mio_End( Abc_Frame_t * pAbc ) { -// Mio_LibraryDelete( s_pLib ); Mio_LibraryDelete( (Mio_Library_t *)Abc_FrameReadLibGen() ); Amap_LibFree( (Amap_Lib_t *)Abc_FrameReadLibGen2() ); } @@ -149,6 +124,7 @@ void Mio_End( Abc_Frame_t * pAbc ) ***********************************************************************/ int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv ) { + int fUseFileInterface = 0; char Command[1000]; FILE * pFile; FILE * pOut, * pErr; @@ -197,11 +173,54 @@ int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv ) } fclose( pFile ); - if ( !Amap_LibertyParse( pFileName, fVerbose ) ) - return 0; - assert( strlen(pFileName) < 900 ); - sprintf( Command, "read_library %s", Extra_FileNameGenericAppend(pFileName, ".genlib") ); - Cmd_CommandExecute( pAbc, Command ); + if ( fUseFileInterface ) + { + if ( !Amap_LibertyParse( pFileName, fVerbose ) ) + return 0; + assert( strlen(pFileName) < 900 ); + sprintf( Command, "read_genlib %s", Extra_FileNameGenericAppend(pFileName, ".genlib") ); + Cmd_CommandExecute( pAbc, Command ); + } + else + { + Mio_Library_t * pLib; + Vec_Str_t * vStr, * vStr2; + + vStr = Amap_LibertyParseStr( pFileName, fVerbose ); + if ( vStr == NULL ) + return 0; + vStr2 = Vec_StrDup( vStr ); + + // set the new network + pLib = Mio_LibraryRead( pFileName, Vec_StrArray(vStr), NULL, fVerbose ); + Vec_StrFree( vStr ); + if ( pLib == NULL ) + { + Vec_StrFree( vStr2 ); + return 0; + } + + // free the current superlib because it depends on the old Mio library + if ( Abc_FrameReadLibSuper() ) + { + Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() ); + Abc_FrameSetLibSuper( NULL ); + } + + // replace the current library + Mio_LibraryDelete( (Mio_Library_t *)Abc_FrameReadLibGen() ); + Abc_FrameSetLibGen( pLib ); + + // set the new network + pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( pFileName, Vec_StrArray(vStr2), 0, 0 ); + Vec_StrFree( vStr2 ); + if ( pLib == NULL ) + return 0; + + // replace the current library + Amap_LibFree( (Amap_Lib_t *)Abc_FrameReadLibGen2() ); + Abc_FrameSetLibGen2( pLib ); + } return 0; usage: @@ -212,7 +231,7 @@ usage: fprintf( pErr, "\t with the smallest area will be used)\n" ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : enable verbose output\n"); - return 1; /* error exit */ + return 1; } /**Function************************************************************* @@ -226,7 +245,7 @@ usage: SeeAlso [] ***********************************************************************/ -int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) +int Mio_CommandReadGenlib( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pFile; FILE * pOut, * pErr; @@ -298,7 +317,7 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) fclose( pFile ); // set the new network - pLib = Mio_LibraryRead( pFileName, pExcludeFile, fVerbose ); + pLib = Mio_LibraryRead( pFileName, NULL, pExcludeFile, fVerbose ); if ( pLib == NULL ) { fprintf( pErr, "Reading GENLIB library has failed.\n" ); @@ -320,7 +339,7 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) Abc_FrameSetLibGen( pLib ); // set the new network - pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( pFileName, 0, 0 ); + pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( pFileName, NULL, 0, 0 ); if ( pLib == NULL ) { fprintf( pErr, "Reading GENLIB library has failed.\n" ); @@ -329,10 +348,12 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) // 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 ); return 0; usage: - fprintf( pErr, "usage: read_library [-W float] [-E filename] [-vh]\n"); + fprintf( pErr, "usage: read_genlib [-W float] [-E filename] [-vh]\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 with the same Boolean function, only the gate\n" ); @@ -341,101 +362,9 @@ usage: 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-h : enable verbose output\n"); - return 1; /* error exit */ -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Mio_CommandReadLibrary2( Abc_Frame_t * pAbc, int argc, char **argv ) -{ - FILE * pFile; - FILE * pOut, * pErr; - Mio_Library_t * pLib; - Abc_Ntk_t * pNet; - char * pFileName; - int fVerbose; - int fVeryVerbose; - int c; - - pNet = Abc_FrameReadNtk(pAbc); - pOut = Abc_FrameReadOut(pAbc); - pErr = Abc_FrameReadErr(pAbc); - - // set the defaults - fVerbose = 1; - fVeryVerbose = 0; - Extra_UtilGetoptReset(); - while ( (c = Extra_UtilGetopt(argc, argv, "vwh")) != EOF ) - { - switch (c) - { - case 'v': - fVerbose ^= 1; - break; - case 'w': - fVeryVerbose ^= 1; - break; - case 'h': - goto usage; - break; - default: - goto usage; - } - } - - - if ( argc != globalUtilOptind + 1 ) - { - goto usage; - } - - // get the input file name - pFileName = argv[globalUtilOptind]; - if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL ) - { - fprintf( pErr, "Cannot open input file \"%s\". ", pFileName ); - if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) - fprintf( pErr, "Did you mean \"%s\"?", pFileName ); - fprintf( pErr, "\n" ); - return 1; - } - fclose( pFile ); - - // set the new network - pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( pFileName, fVerbose, fVeryVerbose ); - if ( pLib == NULL ) - { - fprintf( pErr, "Reading GENLIB library has failed.\n" ); - return 1; - } - - // replace the current library - Amap_LibFree( (Amap_Lib_t *)Abc_FrameReadLibGen2() ); - Abc_FrameSetLibGen2( pLib ); - return 0; - -usage: - fprintf( pErr, "usage: read_library2 [-vh]\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 with the same Boolean function, only the gate\n" ); - fprintf( pErr, "\t with the smallest area will be used)\n" ); - fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); - fprintf( pErr, "\t-w : toggle detailed printout [default = %s]\n", fVeryVerbose? "yes": "no" ); - fprintf( pErr, "\t-h : enable verbose output\n"); - return 1; /* error exit */ + return 1; } - /**Function************************************************************* Synopsis [Command procedure to read LUT libraries.] @@ -447,7 +376,7 @@ usage: SeeAlso [] ***********************************************************************/ -int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) +int Mio_CommandWriteGenlib( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pOut, * pErr, * pFile; Abc_Ntk_t * pNet; @@ -481,35 +410,33 @@ int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) printf( "Library is not available.\n" ); return 1; } + if ( argc != globalUtilOptind + 1 ) + { + printf( "The file name is not given.\n" ); + return 1; + } + pFileName = argv[globalUtilOptind]; - if ( argc == globalUtilOptind + 1 ) + pFile = fopen( pFileName, "w" ); + if ( pFile == NULL ) { - pFile = fopen( pFileName, "w" ); - if ( pFile == NULL ) - { - printf( "Error! Cannot open file \"%s\" for writing the library.\n", pFileName ); - return 1; - } - Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 ); - fclose( pFile ); - printf( "The current GENLIB library is written into file \"%s\".\n", pFileName ); + printf( "Error! Cannot open file \"%s\" for writing the library.\n", pFileName ); + return 1; } - else if ( argc == globalUtilOptind ) - Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 ); - else - goto usage; + Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 ); + fclose( pFile ); + printf( "The current GENLIB library is written into file \"%s\".\n", pFileName ); return 0; usage: - fprintf( pErr, "\nusage: print_library [-vh] \n"); - fprintf( pErr, "\t print the current genlib library\n" ); + fprintf( pErr, "\nusage: write_genlib [-vh] \n"); + fprintf( pErr, "\t writes the current genlib library into a 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 : optional file name to write the library\n"); - return 1; /* error exit */ + return 1; } - /**Function************************************************************* Synopsis [Command procedure to read LUT libraries.] @@ -521,11 +448,10 @@ usage: SeeAlso [] ***********************************************************************/ -int Mio_CommandPrintLibrary2( Abc_Frame_t * pAbc, int argc, char **argv ) +int Mio_CommandPrintGenlib( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNet; - int fPrintAll; int fVerbose; int c; @@ -534,16 +460,12 @@ int Mio_CommandPrintLibrary2( Abc_Frame_t * pAbc, int argc, char **argv ) pErr = Abc_FrameReadErr(pAbc); // set the defaults - fPrintAll = 0; fVerbose = 1; Extra_UtilGetoptReset(); - while ( (c = Extra_UtilGetopt(argc, argv, "avh")) != EOF ) + while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) { switch (c) { - case 'a': - fPrintAll ^= 1; - break; case 'v': fVerbose ^= 1; break; @@ -554,24 +476,20 @@ int Mio_CommandPrintLibrary2( Abc_Frame_t * pAbc, int argc, char **argv ) goto usage; } } - - - if ( argc != globalUtilOptind ) + if ( Abc_FrameReadLibGen() == NULL ) { - goto usage; + printf( "Library is not available.\n" ); + return 1; } - - // set the new network - Amap_LibPrintSelectedGates( (Amap_Lib_t *)Abc_FrameReadLibGen2(), fPrintAll ); + Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 ); return 0; usage: - fprintf( pErr, "\nusage: print_library2 [-avh]\n"); - fprintf( pErr, "\t print gates used for area-oriented tech-mapping\n" ); - fprintf( pErr, "\t-a : toggles printing all gates [default = %s]\n", (fPrintAll? "yes" : "no") ); - fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); + fprintf( pErr, "\nusage: print_genlib [-vh]\n"); + fprintf( pErr, "\t print the current genlib 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 */ + return 1; } //////////////////////////////////////////////////////////////////////// diff --git a/src/map/mio/mio.h b/src/map/mio/mio.h index e6a0cc8f..f2899654 100644 --- a/src/map/mio/mio.h +++ b/src/map/mio/mio.h @@ -129,7 +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 Mio_Library_t * Mio_LibraryRead( char * FileName, char * ExcludeFile, int fVerbose ); +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 =============================================================*/ extern int Mio_LibraryParseFormulas( Mio_Library_t * pLib ); diff --git a/src/map/mio/mioRead.c b/src/map/mio/mioRead.c index 9a46ac8a..aa92c9cd 100644 --- a/src/map/mio/mioRead.c +++ b/src/map/mio/mioRead.c @@ -32,6 +32,7 @@ ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// static Mio_Library_t * Mio_LibraryReadOne( char * FileName, int fExtendedFormat, st_table * tExcludeGate, int fVerbose ); +static Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st_table * tExcludeGate, int fVerbose ); static int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, int fExtendedFormat, st_table * tExcludeGate, int fVerbose ); static Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, int fExtendedFormat ); static Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, int fExtendedFormat ); @@ -50,7 +51,7 @@ static void Io_ReadFileRemoveComments( char * pBuffer, int * pnDots, SeeAlso [] ***********************************************************************/ -Mio_Library_t * Mio_LibraryRead( char * FileName, char * ExcludeFile, int fVerbose ) +Mio_Library_t * Mio_LibraryRead( char * FileName, char * pBuffer, char * ExcludeFile, int fVerbose ) { Mio_Library_t * pLib; int num; @@ -69,10 +70,24 @@ Mio_Library_t * Mio_LibraryRead( char * FileName, char * ExcludeFile, int fVerbo fprintf ( stdout, "Read %d gates from exclude file\n", num ); } - pLib = Mio_LibraryReadOne( FileName, 0, tExcludeGate, fVerbose ); // try normal format first .. + if ( pBuffer == NULL ) + pLib = Mio_LibraryReadOne( FileName, 0, tExcludeGate, fVerbose ); // try normal format first .. + else + { + pLib = Mio_LibraryReadBuffer( pBuffer, 0, tExcludeGate, fVerbose ); // try normal format first .. + if ( pLib ) + pLib->pName = Abc_UtilStrsav( Extra_FileNameGenericAppend(FileName, ".genlib") ); + } if ( pLib == NULL ) { - pLib = Mio_LibraryReadOne( FileName, 1, tExcludeGate, fVerbose ); // .. otherwise try extended format + if ( pBuffer == NULL ) + pLib = Mio_LibraryReadOne( FileName, 1, tExcludeGate, fVerbose ); // try normal format first .. + else + { + pLib = Mio_LibraryReadBuffer( pBuffer, 1, tExcludeGate, fVerbose ); // try normal format first .. + if ( pLib ) + pLib->pName = Abc_UtilStrsav( Extra_FileNameGenericAppend(FileName, ".genlib") ); + } if ( pLib != NULL ) printf ( "Warning: Read extended GENLIB format but ignoring extensions\n" ); } @@ -82,6 +97,46 @@ Mio_Library_t * Mio_LibraryRead( char * FileName, char * ExcludeFile, int fVerbo return pLib; } +/**Function************************************************************* + + Synopsis [Read contents of the file.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +char * Mio_ReadFile( char * FileName ) +{ + char * pBuffer; + FILE * pFile; + int nFileSize; + int RetValue; + + // open the BLIF file for binary reading + pFile = Io_FileOpen( FileName, "open_path", "rb", 1 ); +// pFile = fopen( FileName, "rb" ); + // if we got this far, file should be okay otherwise would + // have been detected by caller + assert ( pFile != NULL ); + // get the file size, in bytes + fseek( pFile, 0, SEEK_END ); + nFileSize = ftell( pFile ); + // move the file current reading position to the beginning + rewind( pFile ); + // load the contents of the file into memory + pBuffer = ABC_ALLOC( char, nFileSize + 10 ); + RetValue = fread( pBuffer, nFileSize, 1, pFile ); + // terminate the string with '\0' + pBuffer[ nFileSize ] = '\0'; + strcat( pBuffer, "\n.end\n" ); + // close file + fclose( pFile ); + return pBuffer; +} + /**Function************************************************************* Synopsis [Read the genlib type of library.] @@ -93,60 +148,25 @@ Mio_Library_t * Mio_LibraryRead( char * FileName, char * ExcludeFile, int fVerbo SeeAlso [] ***********************************************************************/ -Mio_Library_t * Mio_LibraryReadOne( char * FileName, int fExtendedFormat, st_table * tExcludeGate, int fVerbose ) +Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st_table * tExcludeGate, int fVerbose ) { Mio_Library_t * pLib; - char * pBuffer = 0; // allocate the genlib structure pLib = ABC_ALLOC( Mio_Library_t, 1 ); memset( pLib, 0, sizeof(Mio_Library_t) ); - pLib->pName = Mio_UtilStrsav( FileName ); pLib->tName2Gate = st_init_table(strcmp, st_strhash); pLib->pMmFlex = Mem_FlexStart(); pLib->vCube = Vec_StrAlloc( 100 ); - // read the file and clean comments - // pBuffer = Io_ReadFileFileContents( FileName, NULL ); - // we don't use above function but actually do the same thing explicitly - // to handle open_path expansion correctly - - { - FILE * pFile; - int nFileSize; - int RetValue; - - // open the BLIF file for binary reading - pFile = Io_FileOpen( FileName, "open_path", "rb", 1 ); -// pFile = fopen( FileName, "rb" ); - // if we got this far, file should be okay otherwise would - // have been detected by caller - assert ( pFile != NULL ); - // get the file size, in bytes - fseek( pFile, 0, SEEK_END ); - nFileSize = ftell( pFile ); - // move the file current reading position to the beginning - rewind( pFile ); - // load the contents of the file into memory - pBuffer = ABC_ALLOC( char, nFileSize + 10 ); - RetValue = fread( pBuffer, nFileSize, 1, pFile ); - // terminate the string with '\0' - pBuffer[ nFileSize ] = '\0'; - strcat( pBuffer, "\n.end\n" ); - // close file - fclose( pFile ); - } - Io_ReadFileRemoveComments( pBuffer, NULL, NULL ); // parse the contents of the file if ( Mio_LibraryReadInternal( pLib, pBuffer, fExtendedFormat, tExcludeGate, fVerbose ) ) { Mio_LibraryDelete( pLib ); - ABC_FREE( pBuffer ); return NULL; } - ABC_FREE( pBuffer ); // derive the functinality of gates if ( Mio_LibraryParseFormulas( pLib ) ) @@ -162,6 +182,35 @@ Mio_Library_t * Mio_LibraryReadOne( char * FileName, int fExtendedFormat, st_tab return pLib; } +/**Function************************************************************* + + Synopsis [Read the genlib type of library.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Mio_Library_t * Mio_LibraryReadOne( char * FileName, int fExtendedFormat, st_table * tExcludeGate, int fVerbose ) +{ + Mio_Library_t * pLib; + char * pBuffer; + // read the file and clean comments + // 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 ); + if ( pBuffer == NULL ) + return NULL; + pLib = Mio_LibraryReadBuffer( pBuffer, fExtendedFormat, tExcludeGate, fVerbose ); + ABC_FREE( pBuffer ); + if ( pLib ) + pLib->pName = Mio_UtilStrsav( FileName ); + return pLib; +} + /**Function************************************************************* Synopsis [Read the genlib type of library.] @@ -248,12 +297,10 @@ int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, int fExtended } pBase->pTwin = pGate; pGate->pTwin = pBase; - printf( "Gate \"%s\" appears two times. Creating a 2-output gate.\n", pGate->pName ); +// printf( "Gate \"%s\" appears two times. Creating a 2-output gate.\n", pGate->pName ); } } } - if ( fVerbose ) - printf( "Entered GENLIB library with %d gates from file \"%s\".\n", nGates, pLib->pName ); if ( nGates == 0 ) { -- cgit v1.2.3