Skip to content

Commit 57966de

Browse files
committed
Adding flag to skip two-output cells in "read_lib".
1 parent d34821e commit 57966de

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

src/map/scl/scl.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void Scl_End( Abc_Frame_t * pAbc )
141141
SeeAlso []
142142
143143
***********************************************************************/
144-
SC_Lib * Scl_ReadLibraryFile( Abc_Frame_t * pAbc, char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use )
144+
SC_Lib * Scl_ReadLibraryFile( Abc_Frame_t * pAbc, char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts )
145145
{
146146
SC_Lib * pLib;
147147
FILE * pFile;
@@ -152,7 +152,7 @@ SC_Lib * Scl_ReadLibraryFile( Abc_Frame_t * pAbc, char * pFileName, int fVerbose
152152
}
153153
fclose( pFile );
154154
// read new library
155-
pLib = Abc_SclReadLiberty( pFileName, fVerbose, fVeryVerbose, dont_use);
155+
pLib = Abc_SclReadLiberty( pFileName, fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts);
156156
if ( pLib == NULL )
157157
{
158158
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 )
186186
int fMerge = 0;
187187
int fUsePrefix = 0;
188188
int fUseAll = 0;
189+
int fSkipMultiOuts = 0;
189190

190191
SC_DontUse dont_use = {0};
191192
dont_use.dont_use_list = ABC_ALLOC(char *, argc);
192193
dont_use.size = 0;
193194

194195
Extra_UtilGetoptReset();
195-
while ( ( c = Extra_UtilGetopt( argc, argv, "SGMXdnuvwmpah" ) ) != EOF )
196+
while ( ( c = Extra_UtilGetopt( argc, argv, "SGMXdnuvwmpash" ) ) != EOF )
196197
{
197198
switch ( c )
198199
{
@@ -263,15 +264,18 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
263264
case 'a':
264265
fUseAll ^= 1;
265266
break;
267+
case 's':
268+
fSkipMultiOuts ^= 1;
269+
break;
266270
case 'h':
267271
goto usage;
268272
default:
269273
goto usage;
270274
}
271275
}
272276
if ( argc == globalUtilOptind + 2 ) { // expecting two files
273-
SC_Lib * pLib1 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind], fVerbose, fVeryVerbose, dont_use );
274-
SC_Lib * pLib2 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind+1], fVerbose, fVeryVerbose, dont_use );
277+
SC_Lib * pLib1 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind], fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts );
278+
SC_Lib * pLib2 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind+1], fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts );
275279
ABC_FREE(dont_use.dont_use_list);
276280
if ( pLib1 == NULL || pLib2 == NULL ) {
277281
if (pLib1) Abc_SclLibFree(pLib1);
@@ -283,7 +287,7 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
283287
Abc_SclLibFree(pLib2);
284288
}
285289
else if ( argc == globalUtilOptind + 1 ) { // expecting one file
286-
SC_Lib * pLib1 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind], fVerbose, fVeryVerbose, dont_use );
290+
SC_Lib * pLib1 = Scl_ReadLibraryFile( pAbc, argv[globalUtilOptind], fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts );
287291

288292
SC_Lib * pLib_ext = (SC_Lib *)pAbc->pLibScl;
289293
if ( fMerge && pLib_ext != NULL && pLib1 != NULL ) {
@@ -328,7 +332,7 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
328332
return 0;
329333

330334
usage:
331-
fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dnuvwmpah] [-X cell_name] <file> <file2>\n" );
335+
fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dnuvwmpash] [-X cell_name] <file> <file2>\n" );
332336
fprintf( pAbc->Err, "\t reads Liberty library from file\n" );
333337
fprintf( pAbc->Err, "\t-S float : the slew parameter used to generate the library [default = %.2f]\n", Slew );
334338
fprintf( pAbc->Err, "\t-G float : the gain parameter used to generate the library [default = %.2f]\n", Gain );
@@ -340,8 +344,9 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
340344
fprintf( pAbc->Err, "\t-v : toggle writing verbose information [default = %s]\n", fVerbose? "yes": "no" );
341345
fprintf( pAbc->Err, "\t-w : toggle writing information about skipped gates [default = %s]\n", fVeryVerbose? "yes": "no" );
342346
fprintf( pAbc->Err, "\t-m : toggle merging library with exisiting library [default = %s]\n", fMerge? "yes": "no" );
343-
fprintf( pAbc->Err, "\t-a : toggle reading all cells when using gain-based modeling [default = %s]\n", fUseAll? "yes": "no" );
344347
fprintf( pAbc->Err, "\t-p : toggle using prefix for the cell names [default = %s]\n", fUsePrefix? "yes": "no" );
348+
fprintf( pAbc->Err, "\t-a : toggle reading all cells when using gain-based modeling [default = %s]\n", fUseAll? "yes": "no" );
349+
fprintf( pAbc->Err, "\t-s : toggle skipping cells with two outputs [default = %s]\n", fSkipMultiOuts? "yes": "no" );
345350
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
346351
fprintf( pAbc->Err, "\t<file> : the name of a file to read\n" );
347352
fprintf( pAbc->Err, "\t<file2> : the name of a file to read (optional)\n" );

src/map/scl/sclLib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ static inline void Scl_LibHandleInputDriver2( SC_Cell * pCell, SC_PairI * pLoadI
741741
}
742742

743743
/*=== sclLiberty.c ===============================================================*/
744-
extern SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use );
744+
extern SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts );
745745
/*=== sclLibScl.c ===============================================================*/
746746
extern SC_Lib * Abc_SclReadFromGenlib( void * pLib );
747747
extern SC_Lib * Abc_SclReadFromStr( Vec_Str_t * vOut );

src/map/scl/sclLiberty.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ Vec_Ptr_t * Scl_LibertyReadTemplates( Scl_Tree_t * p )
15001500
// Scl_LibertyPrintTemplates( vRes );
15011501
return vRes;
15021502
}
1503-
Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbose, SC_DontUse dont_use )
1503+
Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts )
15041504
{
15051505
int fUseFirstTable = 0;
15061506
Vec_Str_t * vOut;
@@ -1509,7 +1509,7 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
15091509
Vec_Wrd_t * vTruth;
15101510
char * pFormula, * pName;
15111511
int i, k, Counter, nOutputs, nCells;
1512-
int nSkipped[5] = {0};
1512+
int nSkipped[6] = {0};
15131513

15141514
// read delay-table templates
15151515
vTemples = Scl_LibertyReadTemplates( p );
@@ -1567,6 +1567,12 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
15671567
nSkipped[4]++;
15681568
continue;
15691569
}
1570+
if ( fSkipMultiOuts && Counter > 1 )
1571+
{
1572+
if ( fVeryVerbose ) printf( "Scl_LibertyReadGenlib() skipped cell \"%s\" with two outputs.\n", Scl_LibertyReadString(p, pCell->Head) );
1573+
nSkipped[5]++;
1574+
continue;
1575+
}
15701576
nCells++;
15711577
}
15721578
// read cells
@@ -1585,6 +1591,8 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
15851591
continue;
15861592
if ( Counter > 2 )
15871593
continue;
1594+
if ( fSkipMultiOuts && Counter > 1 )
1595+
continue;
15881596
// top level information
15891597
Vec_StrPutS_( vOut, Scl_LibertyReadString(p, pCell->Head) );
15901598
pName = Scl_LibertyReadCellArea(p, pCell);
@@ -1750,13 +1758,14 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
17501758
{
17511759
printf( "Library \"%s\" from \"%s\" has %d cells ",
17521760
Scl_LibertyReadString(p, Scl_LibertyRoot(p)->Head), p->pFileName, nCells );
1753-
printf( "(%d skipped: %d seq; %d tri-state; %d no func; %d dont_use; %d with 3+ outputs). ",
1754-
nSkipped[0]+nSkipped[1]+nSkipped[2]+nSkipped[3]+nSkipped[4], nSkipped[0], nSkipped[1], nSkipped[2], nSkipped[3], nSkipped[4] );
1761+
printf( "(%d skipped: %d seq; %d tri-state; %d no func; %d dont_use; %d with 2 outputs; %d with 3+ outputs). ",
1762+
nSkipped[0]+nSkipped[1]+nSkipped[2]+nSkipped[3]+nSkipped[4]+nSkipped[5],
1763+
nSkipped[0],nSkipped[1],nSkipped[2],nSkipped[3],nSkipped[5],nSkipped[4] );
17551764
Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
17561765
}
17571766
return vOut;
17581767
}
1759-
SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use )
1768+
SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts )
17601769
{
17611770
SC_Lib * pLib;
17621771
Scl_Tree_t * p;
@@ -1766,7 +1775,7 @@ SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, S
17661775
return NULL;
17671776
// Scl_LibertyParseDump( p, "temp_.lib" );
17681777
// collect relevant data
1769-
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use );
1778+
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts );
17701779
Scl_LibertyStop( p, fVeryVerbose );
17711780
if ( vStr == NULL )
17721781
return NULL;
@@ -1805,7 +1814,7 @@ void Scl_LibertyTest()
18051814
return;
18061815
// Scl_LibertyParseDump( p, "temp_.lib" );
18071816
SC_DontUse dont_use = {0};
1808-
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use);
1817+
vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use, 0);
18091818
Scl_LibertyStringDump( "test_scl.lib", vStr );
18101819
Vec_StrFree( vStr );
18111820
Scl_LibertyStop( p, fVerbose );

0 commit comments

Comments
 (0)