Adding flag to skip two-output cells in "read_lib".

This commit is contained in:
Alan Mishchenko 2025-05-14 17:01:48 -07:00
parent d34821e768
commit 57966de4b4
3 changed files with 30 additions and 16 deletions

View File

@ -141,7 +141,7 @@ void Scl_End( Abc_Frame_t * pAbc )
SeeAlso []
***********************************************************************/
SC_Lib * Scl_ReadLibraryFile( Abc_Frame_t * pAbc, char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use )
SC_Lib * Scl_ReadLibraryFile( Abc_Frame_t * pAbc, char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts )
{
SC_Lib * pLib;
FILE * pFile;
@ -152,7 +152,7 @@ SC_Lib * Scl_ReadLibraryFile( Abc_Frame_t * pAbc, char * pFileName, int fVerbose
}
fclose( pFile );
// read new library
pLib = Abc_SclReadLiberty( pFileName, fVerbose, fVeryVerbose, dont_use);
pLib = Abc_SclReadLiberty( pFileName, fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts);
if ( pLib == NULL )
{
fprintf( pAbc->Err, "Reading SCL library from file \"%s\" has failed. \n", pFileName );
@ -186,13 +186,14 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
int fMerge = 0;
int fUsePrefix = 0;
int fUseAll = 0;
int fSkipMultiOuts = 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, "SGMXdnuvwmpah" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "SGMXdnuvwmpash" ) ) != EOF )
{
switch ( c )
{
@ -263,6 +264,9 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'a':
fUseAll ^= 1;
break;
case 's':
fSkipMultiOuts ^= 1;
break;
case 'h':
goto usage;
default:
@ -270,8 +274,8 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
}
}
if ( argc == globalUtilOptind + 2 ) { // expecting two files
SC_Lib * pLib1 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind], fVerbose, fVeryVerbose, dont_use );
SC_Lib * pLib2 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind+1], fVerbose, fVeryVerbose, dont_use );
SC_Lib * pLib1 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind], fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts );
SC_Lib * pLib2 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind+1], fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts );
ABC_FREE(dont_use.dont_use_list);
if ( pLib1 == NULL || pLib2 == NULL ) {
if (pLib1) Abc_SclLibFree(pLib1);
@ -283,7 +287,7 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_SclLibFree(pLib2);
}
else if ( argc == globalUtilOptind + 1 ) { // expecting one file
SC_Lib * pLib1 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind], fVerbose, fVeryVerbose, dont_use );
SC_Lib * pLib1 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind], fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts );
SC_Lib * pLib_ext = (SC_Lib *)pAbc->pLibScl;
if ( fMerge && pLib_ext != NULL && pLib1 != NULL ) {
@ -328,7 +332,7 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dnuvwmpah] [-X cell_name] <file> <file2>\n" );
fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dnuvwmpash] [-X cell_name] <file> <file2>\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 );
@ -340,8 +344,9 @@ usage:
fprintf( pAbc->Err, "\t-v : toggle writing verbose information [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pAbc->Err, "\t-w : toggle writing information about skipped gates [default = %s]\n", fVeryVerbose? "yes": "no" );
fprintf( pAbc->Err, "\t-m : toggle merging library with exisiting library [default = %s]\n", fMerge? "yes": "no" );
fprintf( pAbc->Err, "\t-a : toggle reading all cells when using gain-based modeling [default = %s]\n", fUseAll? "yes": "no" );
fprintf( pAbc->Err, "\t-p : toggle using prefix for the cell names [default = %s]\n", fUsePrefix? "yes": "no" );
fprintf( pAbc->Err, "\t-a : toggle reading all cells when using gain-based modeling [default = %s]\n", fUseAll? "yes": "no" );
fprintf( pAbc->Err, "\t-s : toggle skipping cells with two outputs [default = %s]\n", fSkipMultiOuts? "yes": "no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\t<file> : the name of a file to read\n" );
fprintf( pAbc->Err, "\t<file2> : the name of a file to read (optional)\n" );

View File

@ -741,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, SC_DontUse dont_use );
extern SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts );
/*=== sclLibScl.c ===============================================================*/
extern SC_Lib * Abc_SclReadFromGenlib( void * pLib );
extern SC_Lib * Abc_SclReadFromStr( Vec_Str_t * vOut );

View File

@ -1500,7 +1500,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, SC_DontUse dont_use )
Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts )
{
int fUseFirstTable = 0;
Vec_Str_t * vOut;
@ -1509,7 +1509,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
Vec_Wrd_t * vTruth;
char * pFormula, * pName;
int i, k, Counter, nOutputs, nCells;
int nSkipped[5] = {0};
int nSkipped[6] = {0};
// read delay-table templates
vTemples = Scl_LibertyReadTemplates( p );
@ -1567,6 +1567,12 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
nSkipped[4]++;
continue;
}
if ( fSkipMultiOuts && Counter > 1 )
{
if ( fVeryVerbose ) printf( "Scl_LibertyReadGenlib() skipped cell \"%s\" with two outputs.\n", Scl_LibertyReadString(p, pCell->Head) );
nSkipped[5]++;
continue;
}
nCells++;
}
// read cells
@ -1585,6 +1591,8 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
continue;
if ( Counter > 2 )
continue;
if ( fSkipMultiOuts && Counter > 1 )
continue;
// top level information
Vec_StrPutS_( vOut, Scl_LibertyReadString(p, pCell->Head) );
pName = Scl_LibertyReadCellArea(p, pCell);
@ -1750,13 +1758,14 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
{
printf( "Library \"%s\" from \"%s\" has %d cells ",
Scl_LibertyReadString(p, Scl_LibertyRoot(p)->Head), p->pFileName, nCells );
printf( "(%d skipped: %d seq; %d tri-state; %d no func; %d dont_use; %d with 3+ outputs). ",
nSkipped[0]+nSkipped[1]+nSkipped[2]+nSkipped[3]+nSkipped[4], nSkipped[0], nSkipped[1], nSkipped[2], nSkipped[3], nSkipped[4] );
printf( "(%d skipped: %d seq; %d tri-state; %d no func; %d dont_use; %d with 2 outputs; %d with 3+ outputs). ",
nSkipped[0]+nSkipped[1]+nSkipped[2]+nSkipped[3]+nSkipped[4]+nSkipped[5],
nSkipped[0],nSkipped[1],nSkipped[2],nSkipped[3],nSkipped[5],nSkipped[4] );
Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
}
return vOut;
}
SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use )
SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts )
{
SC_Lib * pLib;
Scl_Tree_t * p;
@ -1766,7 +1775,7 @@ SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, S
return NULL;
// Scl_LibertyParseDump( p, "temp_.lib" );
// collect relevant data
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use );
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts );
Scl_LibertyStop( p, fVeryVerbose );
if ( vStr == NULL )
return NULL;
@ -1805,7 +1814,7 @@ void Scl_LibertyTest()
return;
// Scl_LibertyParseDump( p, "temp_.lib" );
SC_DontUse dont_use = {0};
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use);
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use, 0);
Scl_LibertyStringDump( "test_scl.lib", vStr );
Vec_StrFree( vStr );
Scl_LibertyStop( p, fVerbose );