map: Adds a user configurable dont_use flag to liberty

This flag (-X <glob>) will allow a user to set this flag
multiple times with a glob pattern to exclude cells that
user doesn't want to show up in a mapped netlist.

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
parent c4839c92
...@@ -156,9 +156,13 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -156,9 +156,13 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
int fUnit = 0; int fUnit = 0;
int fVerbose = 1; int fVerbose = 1;
int fVeryVerbose = 0; int fVeryVerbose = 0;
SC_DontUse dont_use = {0};
dont_use.dont_use_list = ABC_ALLOC(char *, argc);
dont_use.size = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "SGMdnuvwh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "SGMXdnuvwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -195,6 +199,16 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -195,6 +199,16 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nGatesMin < 0 ) if ( nGatesMin < 0 )
goto usage; goto usage;
break; break;
case 'X':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-X\" should be followed by a string.\n" );
goto usage;
}
dont_use.dont_use_list[dont_use.size] = argv[globalUtilOptind];
dont_use.size++;
globalUtilOptind++;
break;
case 'd': case 'd':
fDump ^= 1; fDump ^= 1;
break; break;
...@@ -223,11 +237,13 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -223,11 +237,13 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( (pFile = fopen( pFileName, "rb" )) == NULL ) if ( (pFile = fopen( pFileName, "rb" )) == NULL )
{ {
fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName ); fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName );
ABC_FREE(dont_use.dont_use_list);
return 1; return 1;
} }
fclose( pFile ); fclose( pFile );
// read new library // read new library
pLib = Abc_SclReadLiberty( pFileName, fVerbose, fVeryVerbose ); pLib = Abc_SclReadLiberty( pFileName, fVerbose, fVeryVerbose, dont_use);
ABC_FREE(dont_use.dont_use_list);
if ( pLib == NULL ) if ( pLib == NULL )
{ {
fprintf( pAbc->Err, "Reading SCL library from file \"%s\" has failed. \n", pFileName ); fprintf( pAbc->Err, "Reading SCL library from file \"%s\" has failed. \n", pFileName );
...@@ -261,11 +277,12 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -261,11 +277,12 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dnuvwh] <file>\n" ); fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dnuvwh] [-X cell_name] <file>\n" );
fprintf( pAbc->Err, "\t reads Liberty library from file\n" ); fprintf( pAbc->Err, "\t reads Liberty library from file\n" );
fprintf( pAbc->Err, "\t-S float : the slew parameter used to generate the library [default = %.2f]\n", Slew ); fprintf( pAbc->Err, "\t-S float : the slew parameter used to generate the library [default = %.2f]\n", Slew );
fprintf( pAbc->Err, "\t-G float : the gain parameter used to generate the library [default = %.2f]\n", Gain ); fprintf( pAbc->Err, "\t-G float : the gain parameter used to generate the library [default = %.2f]\n", Gain );
fprintf( pAbc->Err, "\t-M num : skip gate classes whose size is less than this [default = %d]\n", nGatesMin ); fprintf( pAbc->Err, "\t-M num : skip gate classes whose size is less than this [default = %d]\n", nGatesMin );
fprintf( pAbc->Err, "\t-X name : adds name to the list of cells ABC shouldn't use. Flag can be passed multiple times\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-d : toggle dumping the parsed library into file \"*_temp.lib\" [default = %s]\n", fDump? "yes": "no" );
fprintf( pAbc->Err, "\t-n : toggle replacing gate/pin names by short strings [default = %s]\n", fShortNames? "yes": "no" ); fprintf( pAbc->Err, "\t-n : toggle replacing gate/pin names by short strings [default = %s]\n", fShortNames? "yes": "no" );
fprintf( pAbc->Err, "\t-u : toggle setting unit area for all cells [default = %s]\n", fUnit? "yes": "no" ); fprintf( pAbc->Err, "\t-u : toggle setting unit area for all cells [default = %s]\n", fUnit? "yes": "no" );
......
...@@ -59,6 +59,13 @@ typedef enum // -- timing sense, positive-, negative- or non-unate ...@@ -59,6 +59,13 @@ typedef enum // -- timing sense, positive-, negative- or non-unate
sc_ts_Non, sc_ts_Non,
} SC_TSense; } SC_TSense;
typedef struct SC_DontUse_ SC_DontUse;
struct SC_DontUse_
{
int size;
char ** dont_use_list;
};
typedef struct SC_Pair_ SC_Pair; typedef struct SC_Pair_ SC_Pair;
struct SC_Pair_ struct SC_Pair_
{ {
...@@ -734,7 +741,7 @@ static inline void Scl_LibHandleInputDriver2( SC_Cell * pCell, SC_PairI * pLoadI ...@@ -734,7 +741,7 @@ static inline void Scl_LibHandleInputDriver2( SC_Cell * pCell, SC_PairI * pLoadI
} }
/*=== sclLiberty.c ===============================================================*/ /*=== sclLiberty.c ===============================================================*/
extern SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose ); extern SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use );
/*=== sclLibScl.c ===============================================================*/ /*=== sclLibScl.c ===============================================================*/
extern SC_Lib * Abc_SclReadFromGenlib( void * pLib ); extern SC_Lib * Abc_SclReadFromGenlib( void * pLib );
extern SC_Lib * Abc_SclReadFromStr( Vec_Str_t * vOut ); extern SC_Lib * Abc_SclReadFromStr( Vec_Str_t * vOut );
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
Revision [$Id: sclLiberty.c,v 1.0 2012/08/24 00:00:00 alanmi Exp $] Revision [$Id: sclLiberty.c,v 1.0 2012/08/24 00:00:00 alanmi Exp $]
***********************************************************************/ ***********************************************************************/
#include <string.h>
#include <fnmatch.h>
#include "sclLib.h" #include "sclLib.h"
#include "misc/st/st.h" #include "misc/st/st.h"
...@@ -635,12 +637,20 @@ int Scl_LibertyReadCellIsFlop( Scl_Tree_t * p, Scl_Item_t * pCell ) ...@@ -635,12 +637,20 @@ int Scl_LibertyReadCellIsFlop( Scl_Tree_t * p, Scl_Item_t * pCell )
return 1; return 1;
return 0; return 0;
} }
int Scl_LibertyReadCellIsDontUse( Scl_Tree_t * p, Scl_Item_t * pCell ) int Scl_LibertyReadCellIsDontUse( Scl_Tree_t * p, Scl_Item_t * pCell, SC_DontUse dont_use )
{ {
Scl_Item_t * pAttr; Scl_Item_t * pAttr;
Scl_ItemForEachChild( p, pCell, pAttr ) Scl_ItemForEachChild( p, pCell, pAttr )
{
if ( !Scl_LibertyCompare(p, pAttr->Key, "dont_use") ) if ( !Scl_LibertyCompare(p, pAttr->Key, "dont_use") )
return 1; return 1;
const char * cell_name = Scl_LibertyReadString(p, pCell->Head);
for (int i = 0; i < dont_use.size; i++) {
if (fnmatch(dont_use.dont_use_list[i], cell_name, 0) == 0) {
return 1;
}
}
}
return 0; return 0;
} }
char * Scl_LibertyReadCellArea( Scl_Tree_t * p, Scl_Item_t * pCell ) char * Scl_LibertyReadCellArea( Scl_Tree_t * p, Scl_Item_t * pCell )
...@@ -703,7 +713,7 @@ int Scl_LibertyReadCellOutputNum( Scl_Tree_t * p, Scl_Item_t * pCell ) ...@@ -703,7 +713,7 @@ int Scl_LibertyReadCellOutputNum( Scl_Tree_t * p, Scl_Item_t * pCell )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Vec_Str_t * Scl_LibertyReadGenlibStr( Scl_Tree_t * p, int fVerbose ) Vec_Str_t * Scl_LibertyReadGenlibStr( Scl_Tree_t * p, int fVerbose, SC_DontUse dont_use )
{ {
Vec_Str_t * vStr; Vec_Str_t * vStr;
Scl_Item_t * pCell, * pOutput, * pInput; Scl_Item_t * pCell, * pOutput, * pInput;
...@@ -718,7 +728,7 @@ Vec_Str_t * Scl_LibertyReadGenlibStr( Scl_Tree_t * p, int fVerbose ) ...@@ -718,7 +728,7 @@ Vec_Str_t * Scl_LibertyReadGenlibStr( Scl_Tree_t * p, int fVerbose )
if ( fVerbose ) printf( "Scl_LibertyReadGenlib() skipped sequential cell \"%s\".\n", Scl_LibertyReadString(p, pCell->Head) ); if ( fVerbose ) printf( "Scl_LibertyReadGenlib() skipped sequential cell \"%s\".\n", Scl_LibertyReadString(p, pCell->Head) );
continue; continue;
} }
if ( Scl_LibertyReadCellIsDontUse(p, pCell) ) if ( Scl_LibertyReadCellIsDontUse(p, pCell, dont_use) )
{ {
if ( fVerbose ) printf( "Scl_LibertyReadGenlib() skipped cell \"%s\" due to dont_use attribute.\n", Scl_LibertyReadString(p, pCell->Head) ); if ( fVerbose ) printf( "Scl_LibertyReadGenlib() skipped cell \"%s\" due to dont_use attribute.\n", Scl_LibertyReadString(p, pCell->Head) );
continue; continue;
...@@ -768,20 +778,6 @@ Vec_Str_t * Scl_LibertyReadGenlibStr( Scl_Tree_t * p, int fVerbose ) ...@@ -768,20 +778,6 @@ Vec_Str_t * Scl_LibertyReadGenlibStr( Scl_Tree_t * p, int fVerbose )
// printf( "%s", Vec_StrArray(vStr) ); // printf( "%s", Vec_StrArray(vStr) );
return vStr; return vStr;
} }
Vec_Str_t * Scl_LibertyParseGenlibStr( char * pFileName, int fVerbose )
{
Scl_Tree_t * p;
Vec_Str_t * vStr;
p = Scl_LibertyParse( pFileName, fVerbose );
if ( p == NULL )
return NULL;
// Scl_LibertyRead( p, "temp_.lib" );
vStr = Scl_LibertyReadGenlibStr( p, fVerbose );
Scl_LibertyStop( p, fVerbose );
// Scl_LibertyStringDump( "test_genlib.lib", vStr );
return vStr;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -1429,7 +1425,7 @@ Vec_Ptr_t * Scl_LibertyReadTemplates( Scl_Tree_t * p ) ...@@ -1429,7 +1425,7 @@ Vec_Ptr_t * Scl_LibertyReadTemplates( Scl_Tree_t * p )
// Scl_LibertyPrintTemplates( vRes ); // Scl_LibertyPrintTemplates( vRes );
return vRes; return vRes;
} }
Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbose ) Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbose, SC_DontUse dont_use )
{ {
int fUseFirstTable = 0; int fUseFirstTable = 0;
Vec_Str_t * vOut; Vec_Str_t * vOut;
...@@ -1472,7 +1468,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos ...@@ -1472,7 +1468,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
nSkipped[0]++; nSkipped[0]++;
continue; continue;
} }
if ( Scl_LibertyReadCellIsDontUse(p, pCell) ) if ( Scl_LibertyReadCellIsDontUse(p, pCell, dont_use) )
{ {
if ( fVeryVerbose ) printf( "Scl_LibertyReadGenlib() skipped cell \"%s\" due to dont_use attribute.\n", Scl_LibertyReadString(p, pCell->Head) ); if ( fVeryVerbose ) printf( "Scl_LibertyReadGenlib() skipped cell \"%s\" due to dont_use attribute.\n", Scl_LibertyReadString(p, pCell->Head) );
nSkipped[3]++; nSkipped[3]++;
...@@ -1500,7 +1496,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos ...@@ -1500,7 +1496,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
{ {
if ( Scl_LibertyReadCellIsFlop(p, pCell) ) if ( Scl_LibertyReadCellIsFlop(p, pCell) )
continue; continue;
if ( Scl_LibertyReadCellIsDontUse(p, pCell) ) if ( Scl_LibertyReadCellIsDontUse(p, pCell, dont_use) )
continue; continue;
if ( Scl_LibertyReadCellIsThreeState(p, pCell) ) if ( Scl_LibertyReadCellIsThreeState(p, pCell) )
continue; continue;
...@@ -1677,7 +1673,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos ...@@ -1677,7 +1673,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
} }
return vOut; return vOut;
} }
SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose ) SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use )
{ {
SC_Lib * pLib; SC_Lib * pLib;
Scl_Tree_t * p; Scl_Tree_t * p;
...@@ -1687,7 +1683,7 @@ SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose ) ...@@ -1687,7 +1683,7 @@ SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose )
return NULL; return NULL;
// Scl_LibertyParseDump( p, "temp_.lib" ); // Scl_LibertyParseDump( p, "temp_.lib" );
// collect relevant data // collect relevant data
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose ); vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use );
Scl_LibertyStop( p, fVeryVerbose ); Scl_LibertyStop( p, fVeryVerbose );
if ( vStr == NULL ) if ( vStr == NULL )
return NULL; return NULL;
...@@ -1725,7 +1721,8 @@ void Scl_LibertyTest() ...@@ -1725,7 +1721,8 @@ void Scl_LibertyTest()
if ( p == NULL ) if ( p == NULL )
return; return;
// Scl_LibertyParseDump( p, "temp_.lib" ); // Scl_LibertyParseDump( p, "temp_.lib" );
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose ); SC_DontUse dont_use = {0};
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use);
Scl_LibertyStringDump( "test_scl.lib", vStr ); Scl_LibertyStringDump( "test_scl.lib", vStr );
Vec_StrFree( vStr ); Vec_StrFree( vStr );
Scl_LibertyStop( p, fVerbose ); Scl_LibertyStop( p, fVerbose );
......
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