mirror of https://github.com/YosysHQ/abc.git
Merge pull request #239 from QuantamHD/dont_use
map: Adds a user configurable dont_use flag to liberty
This commit is contained in:
commit
5405d4787a
|
|
@ -156,9 +156,13 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
int fUnit = 0;
|
||||
int fVerbose = 1;
|
||||
int fVeryVerbose = 0;
|
||||
|
||||
SC_DontUse dont_use = {0};
|
||||
dont_use.dont_use_list = ABC_ALLOC(char *, argc);
|
||||
dont_use.size = 0;
|
||||
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "SGMdnuvwh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "SGMXdnuvwh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -195,6 +199,16 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
if ( nGatesMin < 0 )
|
||||
goto usage;
|
||||
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':
|
||||
fDump ^= 1;
|
||||
break;
|
||||
|
|
@ -223,11 +237,13 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
if ( (pFile = fopen( pFileName, "rb" )) == NULL )
|
||||
{
|
||||
fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName );
|
||||
ABC_FREE(dont_use.dont_use_list);
|
||||
return 1;
|
||||
}
|
||||
fclose( pFile );
|
||||
// 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 )
|
||||
{
|
||||
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 )
|
|||
return 0;
|
||||
|
||||
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-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-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-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" );
|
||||
|
|
|
|||
|
|
@ -59,6 +59,13 @@ typedef enum // -- timing sense, positive-, negative- or non-unate
|
|||
sc_ts_Non,
|
||||
} SC_TSense;
|
||||
|
||||
typedef struct SC_DontUse_ SC_DontUse;
|
||||
struct SC_DontUse_
|
||||
{
|
||||
int size;
|
||||
char ** dont_use_list;
|
||||
};
|
||||
|
||||
typedef struct SC_Pair_ SC_Pair;
|
||||
struct SC_Pair_
|
||||
{
|
||||
|
|
@ -734,7 +741,7 @@ static inline void Scl_LibHandleInputDriver2( SC_Cell * pCell, SC_PairI * pLoadI
|
|||
}
|
||||
|
||||
/*=== 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 ===============================================================*/
|
||||
extern SC_Lib * Abc_SclReadFromGenlib( void * pLib );
|
||||
extern SC_Lib * Abc_SclReadFromStr( Vec_Str_t * vOut );
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
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 "misc/st/st.h"
|
||||
|
|
@ -635,12 +637,20 @@ int Scl_LibertyReadCellIsFlop( Scl_Tree_t * p, Scl_Item_t * pCell )
|
|||
return 1;
|
||||
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_ItemForEachChild( p, pCell, pAttr )
|
||||
{
|
||||
if ( !Scl_LibertyCompare(p, pAttr->Key, "dont_use") )
|
||||
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;
|
||||
}
|
||||
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 )
|
|||
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;
|
||||
Scl_Item_t * pCell, * pOutput, * pInput;
|
||||
|
|
@ -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) );
|
||||
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) );
|
||||
continue;
|
||||
|
|
@ -768,20 +778,6 @@ Vec_Str_t * Scl_LibertyReadGenlibStr( Scl_Tree_t * p, int fVerbose )
|
|||
// printf( "%s", Vec_StrArray(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*************************************************************
|
||||
|
||||
|
|
@ -1429,7 +1425,7 @@ Vec_Ptr_t * Scl_LibertyReadTemplates( Scl_Tree_t * p )
|
|||
// Scl_LibertyPrintTemplates( 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;
|
||||
Vec_Str_t * vOut;
|
||||
|
|
@ -1472,7 +1468,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
|
|||
nSkipped[0]++;
|
||||
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) );
|
||||
nSkipped[3]++;
|
||||
|
|
@ -1500,7 +1496,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
|
|||
{
|
||||
if ( Scl_LibertyReadCellIsFlop(p, pCell) )
|
||||
continue;
|
||||
if ( Scl_LibertyReadCellIsDontUse(p, pCell) )
|
||||
if ( Scl_LibertyReadCellIsDontUse(p, pCell, dont_use) )
|
||||
continue;
|
||||
if ( Scl_LibertyReadCellIsThreeState(p, pCell) )
|
||||
continue;
|
||||
|
|
@ -1677,7 +1673,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
|
|||
}
|
||||
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;
|
||||
Scl_Tree_t * p;
|
||||
|
|
@ -1687,7 +1683,7 @@ SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose )
|
|||
return NULL;
|
||||
// Scl_LibertyParseDump( p, "temp_.lib" );
|
||||
// collect relevant data
|
||||
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose );
|
||||
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use );
|
||||
Scl_LibertyStop( p, fVeryVerbose );
|
||||
if ( vStr == NULL )
|
||||
return NULL;
|
||||
|
|
@ -1725,7 +1721,8 @@ void Scl_LibertyTest()
|
|||
if ( p == NULL )
|
||||
return;
|
||||
// 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 );
|
||||
Vec_StrFree( vStr );
|
||||
Scl_LibertyStop( p, fVerbose );
|
||||
|
|
|
|||
Loading…
Reference in New Issue