mirror of https://github.com/YosysHQ/abc.git
New switch in 'read_lib' to replace gate/pin names by short strings.
This commit is contained in:
parent
73bfe00f82
commit
5bf0f86450
|
|
@ -139,11 +139,12 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
float Slew = 0;
|
||||
float Gain = 0;
|
||||
int nGatesMin = 0;
|
||||
int fShortNames = 0;
|
||||
int fVerbose = 1;
|
||||
int fVeryVerbose = 0;
|
||||
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "SGMdvwh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "SGMdnvwh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -183,6 +184,9 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
case 'd':
|
||||
fDump ^= 1;
|
||||
break;
|
||||
case 'n':
|
||||
fShortNames ^= 1;
|
||||
break;
|
||||
case 'v':
|
||||
fVerbose ^= 1;
|
||||
break;
|
||||
|
|
@ -219,6 +223,9 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 0;
|
||||
}
|
||||
Abc_SclLoad( pLib, (SC_Lib **)&pAbc->pLibScl );
|
||||
// convert the library if needed
|
||||
if ( fShortNames )
|
||||
Abc_SclShortNames( pLib );
|
||||
// dump the resulting library
|
||||
if ( fDump && pAbc->pLibScl )
|
||||
Abc_SclWriteLiberty( Extra_FileNameGenericAppend(pFileName, "_temp.lib"), (SC_Lib *)pAbc->pLibScl );
|
||||
|
|
@ -228,12 +235,13 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 0;
|
||||
|
||||
usage:
|
||||
fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dvwh] <file>\n" );
|
||||
fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dnvwh] <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-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-v : toggle writing verbose information [default = %s]\n", fVerbose? "yes": "no" );
|
||||
fprintf( pAbc->Err, "\t-v : toggle writing information about skipped gates [default = %s]\n", fVeryVerbose? "yes": "no" );
|
||||
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
|
||||
|
|
|
|||
|
|
@ -615,6 +615,7 @@ extern void Abc_SclWriteLiberty( char * pFileName, SC_Lib * p );
|
|||
extern void Abc_SclHashCells( SC_Lib * p );
|
||||
extern int Abc_SclCellFind( SC_Lib * p, char * pName );
|
||||
extern int Abc_SclClassCellNum( SC_Cell * pClass );
|
||||
extern void Abc_SclShortNames( SC_Lib * p );
|
||||
extern int Abc_SclLibClassNum( SC_Lib * pLib );
|
||||
extern void Abc_SclLinkCells( SC_Lib * p );
|
||||
extern void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fShort );
|
||||
|
|
|
|||
|
|
@ -99,6 +99,100 @@ int Abc_SclLibClassNum( SC_Lib * pLib )
|
|||
return Count;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Change cell names and pin names.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline int Abc_SclIsChar( char c )
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
|
||||
}
|
||||
static inline int Abc_SclIsName( char c )
|
||||
{
|
||||
return Abc_SclIsChar(c) || (c >= '0' && c <= '9');
|
||||
}
|
||||
static inline char * Abc_SclFindLimit( char * pName )
|
||||
{
|
||||
assert( Abc_SclIsChar(*pName) );
|
||||
while ( Abc_SclIsName(*pName) )
|
||||
pName++;
|
||||
return pName;
|
||||
}
|
||||
static inline int Abc_SclAreEqual( char * pBase, char * pName, char * pLimit )
|
||||
{
|
||||
return !strncmp( pBase, pName, pLimit - pName );
|
||||
}
|
||||
void Abc_SclShortFormula( SC_Cell * pCell, char * pForm, char * pBuffer )
|
||||
{
|
||||
SC_Pin * pPin; int i;
|
||||
char * pTemp, * pLimit;
|
||||
for ( pTemp = pForm; *pTemp; )
|
||||
{
|
||||
if ( !Abc_SclIsChar(*pTemp) )
|
||||
{
|
||||
*pBuffer++ = *pTemp++;
|
||||
continue;
|
||||
}
|
||||
pLimit = Abc_SclFindLimit( pTemp );
|
||||
SC_CellForEachPinIn( pCell, pPin, i )
|
||||
if ( Abc_SclAreEqual( pPin->pName, pTemp, pLimit ) )
|
||||
{
|
||||
*pBuffer++ = 'a' + i;
|
||||
break;
|
||||
}
|
||||
assert( i < pCell->n_inputs );
|
||||
pTemp = pLimit;
|
||||
}
|
||||
*pBuffer++ = 0;
|
||||
}
|
||||
void Abc_SclShortNames( SC_Lib * p )
|
||||
{
|
||||
char Buffer[10000];
|
||||
SC_Cell * pClass, * pCell; SC_Pin * pPin;
|
||||
int i, k, n, nClasses = Abc_SclLibClassNum(p);
|
||||
int nDigits = Abc_Base10Log( nClasses );
|
||||
// itereate through classes
|
||||
SC_LibForEachCellClass( p, pClass, i )
|
||||
{
|
||||
int nDigits2 = Abc_Base10Log( Abc_SclClassCellNum(pClass) );
|
||||
SC_RingForEachCell( pClass, pCell, k )
|
||||
{
|
||||
ABC_FREE( pCell->pName );
|
||||
sprintf( Buffer, "g%0*d_%0*d", nDigits, i, nDigits2, k );
|
||||
pCell->pName = Abc_UtilStrsav( Buffer );
|
||||
// formula
|
||||
SC_CellForEachPinOut( pCell, pPin, n )
|
||||
{
|
||||
Abc_SclShortFormula( pCell, pPin->func_text, Buffer );
|
||||
ABC_FREE( pPin->func_text );
|
||||
pPin->func_text = Abc_UtilStrsav( Buffer );
|
||||
}
|
||||
// pin names
|
||||
SC_CellForEachPinIn( pCell, pPin, n )
|
||||
{
|
||||
ABC_FREE( pPin->pName );
|
||||
sprintf( Buffer, "%c", 'a'+n );
|
||||
pPin->pName = Abc_UtilStrsav( Buffer );
|
||||
}
|
||||
SC_CellForEachPinOut( pCell, pPin, n )
|
||||
{
|
||||
ABC_FREE( pPin->pName );
|
||||
sprintf( Buffer, "%c", 'z'-n+pCell->n_inputs );
|
||||
pPin->pName = Abc_UtilStrsav( Buffer );
|
||||
}
|
||||
}
|
||||
}
|
||||
p->nBins = 0;
|
||||
ABC_FREE( p->pBins );
|
||||
Abc_SclHashCells( p );
|
||||
}
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Links equal gates into rings while sorting them by area.]
|
||||
|
|
|
|||
Loading…
Reference in New Issue