From 7d3976a76353b4a89588925285e80ea33efa0797 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 17 Sep 2013 13:16:20 -0700 Subject: Unifying standard cell library representations. --- src/map/scl/scl.c | 214 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 136 insertions(+), 78 deletions(-) (limited to 'src/map/scl/scl.c') diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c index f8545646..2957a325 100644 --- a/src/map/scl/scl.c +++ b/src/map/scl/scl.c @@ -29,8 +29,9 @@ ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// static int Scl_CommandReadLib ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandRead ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int Scl_CommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandWriteLib( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandReadScl ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int Scl_CommandWriteScl( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandPrintLib( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandDumpGen ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandPrintGS ( Abc_Frame_t * pAbc, int argc, char **argv ); @@ -87,9 +88,10 @@ void Abc_SclLoad( SC_Lib * pLib, SC_Lib ** ppScl ) void Scl_Init( Abc_Frame_t * pAbc ) { Cmd_CommandAdd( pAbc, "SCL mapping", "read_lib", Scl_CommandReadLib, 0 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "read_scl", Scl_CommandRead, 0 ); - Cmd_CommandAdd( pAbc, "SCL mapping", "write_scl", Scl_CommandWrite, 0 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "write_lib", Scl_CommandWriteLib, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "print_lib", Scl_CommandPrintLib, 0 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "read_scl", Scl_CommandReadScl, 0 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "write_scl", Scl_CommandWriteScl, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "dump_genlib", Scl_CommandDumpGen, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "print_gs", Scl_CommandPrintGS, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 ); @@ -128,9 +130,9 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv ) FILE * pFile; SC_Lib * pLib; int c, fDump = 0; - float Slew = 200; - float Gain = 100; - int nGatesMin = 4; + float Slew = 0; + float Gain = 0; + int nGatesMin = 0; int fVerbose = 1; int fVeryVerbose = 0; @@ -210,7 +212,7 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl ); // extract genlib library if ( pAbc->pLibScl ) - Abc_SclDeriveGenlib( pAbc->pLibScl, Slew, Gain, nGatesMin ); + Abc_SclInstallGenlib( pAbc->pLibScl, Slew, Gain, nGatesMin ); return 0; usage: @@ -227,72 +229,6 @@ usage: return 1; } - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Scl_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) -{ - FILE * pFile; - SC_Lib * pLib; - char * pFileName; - int c, fDump = 0; - - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF ) - { - switch ( c ) - { - case 'd': - fDump ^= 1; - break; - case 'h': - goto usage; - default: - goto usage; - } - } - if ( argc != globalUtilOptind + 1 ) - goto usage; - - // get the input file name - pFileName = argv[globalUtilOptind]; - if ( (pFile = fopen( pFileName, "rb" )) == NULL ) - { - fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName ); - return 1; - } - fclose( pFile ); - - // read new library - pLib = Abc_SclReadFromFile( pFileName ); - if ( pLib == NULL ) - { - fprintf( pAbc->Err, "Reading SCL library from file \"%s\" has failed. \n", pFileName ); - return 1; - } - Abc_SclLoad( pLib, (SC_Lib **)&pAbc->pLibScl ); - if ( fDump ) - Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl ); - return 0; - -usage: - fprintf( pAbc->Err, "usage: read_scl [-dh] \n" ); - fprintf( pAbc->Err, "\t reads extracted Liberty library from file\n" ); - fprintf( pAbc->Err, "\t-d : toggle dumping the parsed library into file \"*_temp.lib\" [default = %s]\n", fDump? "yes": "no" ); - fprintf( pAbc->Err, "\t-h : prints the command summary\n" ); - fprintf( pAbc->Err, "\t : the name of a file to read\n" ); - return 1; -} - /**Function************************************************************* Synopsis [] @@ -304,7 +240,7 @@ usage: SeeAlso [] ***********************************************************************/ -int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv ) +int Scl_CommandWriteLib( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pFile; char * pFileName; @@ -338,12 +274,12 @@ int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv ) fclose( pFile ); // save current library - Abc_SclWriteScl( pFileName, (SC_Lib *)pAbc->pLibScl ); + Abc_SclWriteLiberty( pFileName, (SC_Lib *)pAbc->pLibScl ); return 0; usage: - fprintf( pAbc->Err, "usage: write_scl [-h] \n" ); - fprintf( pAbc->Err, "\t write extracted Liberty library into file\n" ); + fprintf( pAbc->Err, "usage: write_lib [-h] \n" ); + fprintf( pAbc->Err, "\t write current Liberty library into file\n" ); fprintf( pAbc->Err, "\t-h : print the help massage\n" ); fprintf( pAbc->Err, "\t : the name of the file to write\n" ); return 1; @@ -427,6 +363,128 @@ usage: return 1; } + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Scl_CommandReadScl( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + FILE * pFile; + SC_Lib * pLib; + char * pFileName; + int c, fDump = 0; + + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF ) + { + switch ( c ) + { + case 'd': + fDump ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( argc != globalUtilOptind + 1 ) + goto usage; + + // get the input file name + pFileName = argv[globalUtilOptind]; + if ( (pFile = fopen( pFileName, "rb" )) == NULL ) + { + fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName ); + return 1; + } + fclose( pFile ); + + // read new library + pLib = Abc_SclReadFromFile( pFileName ); + if ( pLib == NULL ) + { + fprintf( pAbc->Err, "Reading SCL library from file \"%s\" has failed. \n", pFileName ); + return 1; + } + Abc_SclLoad( pLib, (SC_Lib **)&pAbc->pLibScl ); + if ( fDump ) + Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl ); + return 0; + +usage: + fprintf( pAbc->Err, "usage: read_scl [-dh] \n" ); + fprintf( pAbc->Err, "\t reads extracted Liberty library from file\n" ); + fprintf( pAbc->Err, "\t-d : toggle dumping the parsed library into file \"*_temp.lib\" [default = %s]\n", fDump? "yes": "no" ); + fprintf( pAbc->Err, "\t-h : prints the command summary\n" ); + fprintf( pAbc->Err, "\t : the name of a file to read\n" ); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Scl_CommandWriteScl( Abc_Frame_t * pAbc, int argc, char **argv ) +{ + FILE * pFile; + char * pFileName; + int c; + + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + if ( argc != globalUtilOptind + 1 ) + goto usage; + if ( pAbc->pLibScl == NULL ) + { + fprintf( pAbc->Err, "There is no Liberty library available.\n" ); + return 1; + } + // get the input file name + pFileName = argv[globalUtilOptind]; + if ( (pFile = fopen( pFileName, "wb" )) == NULL ) + { + fprintf( pAbc->Err, "Cannot open output file \"%s\". \n", pFileName ); + return 1; + } + fclose( pFile ); + + // save current library + Abc_SclWriteScl( pFileName, (SC_Lib *)pAbc->pLibScl ); + return 0; + +usage: + fprintf( pAbc->Err, "usage: write_scl [-h] \n" ); + fprintf( pAbc->Err, "\t write extracted Liberty library into file\n" ); + fprintf( pAbc->Err, "\t-h : print the help massage\n" ); + fprintf( pAbc->Err, "\t : the name of the file to write\n" ); + return 1; +} + /**Function************************************************************* Synopsis [] -- cgit v1.2.3