mirror of https://github.com/YosysHQ/abc.git
Updating "read_lib" to output all gates when gain-based modeling is used.
This commit is contained in:
parent
3de73f2756
commit
3ddd46131c
|
|
@ -185,13 +185,14 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
int fVeryVerbose = 0;
|
||||
int fMerge = 0;
|
||||
int fUsePrefix = 0;
|
||||
int fUseAll = 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, "SGMXdnuvwmph" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "SGMXdnuvwmpah" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -259,6 +260,9 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
case 'p':
|
||||
fUsePrefix ^= 1;
|
||||
break;
|
||||
case 'a':
|
||||
fUseAll ^= 1;
|
||||
break;
|
||||
case 'h':
|
||||
goto usage;
|
||||
default:
|
||||
|
|
@ -318,13 +322,13 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
// extract genlib library
|
||||
if ( pAbc->pLibScl )
|
||||
{
|
||||
Abc_SclInstallGenlib( pAbc->pLibScl, Slew, Gain, nGatesMin );
|
||||
Abc_SclInstallGenlib( pAbc->pLibScl, Slew, Gain, fUseAll, nGatesMin );
|
||||
Mio_LibraryTransferCellIds();
|
||||
}
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dnuvwmph] [-X cell_name] <file> <file2>\n" );
|
||||
fprintf( pAbc->Err, "usage: read_lib [-SG float] [-M num] [-dnuvwmpah] [-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 );
|
||||
|
|
@ -336,6 +340,7 @@ 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 using prefix for the cell names [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-h : prints the command summary\n" );
|
||||
fprintf( pAbc->Err, "\t<file> : the name of a file to read\n" );
|
||||
|
|
@ -606,7 +611,7 @@ int Scl_CommandReadScl( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
// extract genlib library
|
||||
if ( pAbc->pLibScl )
|
||||
{
|
||||
Abc_SclInstallGenlib( pAbc->pLibScl, 0, 0, 0 );
|
||||
Abc_SclInstallGenlib( pAbc->pLibScl, 0, 0, 0, 0 );
|
||||
Mio_LibraryTransferCellIds();
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -766,7 +766,7 @@ extern SC_WireLoad * Abc_SclFetchWireLoadModel( SC_Lib * p, char * pName );
|
|||
extern int Abc_SclHasDelayInfo( void * pScl );
|
||||
extern float Abc_SclComputeAverageSlew( SC_Lib * p );
|
||||
extern void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin );
|
||||
extern void Abc_SclInstallGenlib( void * pScl, float Slew, float Gain, int nGatesMin );
|
||||
extern void Abc_SclInstallGenlib( void * pScl, float Slew, float Gain, int fUseAll, int nGatesMin );
|
||||
|
||||
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
|
|
|||
|
|
@ -867,13 +867,13 @@ Mio_Library_t * Abc_SclDeriveGenlibSimple( void * pScl )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Str_t * Abc_SclProduceGenlibStr( SC_Lib * p, float Slew, float Gain, int nGatesMin, int * pnCellCount )
|
||||
Vec_Str_t * Abc_SclProduceGenlibStr( SC_Lib * p, float Slew, float Gain, int nGatesMin, int fUseAll, int * pnCellCount )
|
||||
{
|
||||
char Buffer[200];
|
||||
Vec_Str_t * vStr;
|
||||
SC_Cell * pRepr;
|
||||
SC_Pin * pPin;
|
||||
int i, k, Count = 2, nClassMax = 0;
|
||||
SC_Pin * pPin, * pPinOut;
|
||||
int i, j, k, Count = 2, nClassMax = 0;
|
||||
// find the largest number of cells in a class
|
||||
SC_LibForEachCellClass( p, pRepr, i )
|
||||
if ( pRepr->n_outputs == 1 )
|
||||
|
|
@ -886,38 +886,80 @@ Vec_Str_t * Abc_SclProduceGenlibStr( SC_Lib * p, float Slew, float Gain, int nGa
|
|||
vStr = Vec_StrAlloc( 1000 );
|
||||
Vec_StrPrintStr( vStr, "GATE _const0_ 0.00 z=CONST0;\n" );
|
||||
Vec_StrPrintStr( vStr, "GATE _const1_ 0.00 z=CONST1;\n" );
|
||||
SC_LibForEachCellClass( p, pRepr, i )
|
||||
if ( fUseAll )
|
||||
{
|
||||
if ( pRepr->n_inputs == 0 )
|
||||
continue;
|
||||
if ( pRepr->n_outputs > 1 )
|
||||
continue;
|
||||
if ( nGatesMin && pRepr->n_inputs > 2 && Abc_SclClassCellNum(pRepr) < nGatesMin )
|
||||
continue;
|
||||
assert( strlen(pRepr->pName) < 200 );
|
||||
Vec_StrPrintStr( vStr, "GATE " );
|
||||
sprintf( Buffer, "%-16s", pRepr->pName );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
Vec_StrPrintStr( vStr, " " );
|
||||
// sprintf( Buffer, "%7.2f", Abc_SclComputeAreaClass(pRepr) );
|
||||
sprintf( Buffer, "%7.2f", pRepr->area );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
Vec_StrPrintStr( vStr, " " );
|
||||
Vec_StrPrintStr( vStr, SC_CellPinName(pRepr, pRepr->n_inputs) );
|
||||
Vec_StrPrintStr( vStr, "=" );
|
||||
Vec_StrPrintStr( vStr, SC_CellPinOutFunc(pRepr, 0) ? SC_CellPinOutFunc(pRepr, 0) : "?" );
|
||||
Vec_StrPrintStr( vStr, ";\n" );
|
||||
SC_CellForEachPinIn( pRepr, pPin, k )
|
||||
SC_LibForEachCell( p, pRepr, i )
|
||||
{
|
||||
float Delay = Abc_SclComputeDelayClassPin( p, pRepr, k, Slew, Gain );
|
||||
assert( Delay > 0 );
|
||||
Vec_StrPrintStr( vStr, " PIN " );
|
||||
sprintf( Buffer, "%-4s", pPin->pName );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
sprintf( Buffer, " UNKNOWN 1 999 %7.2f 0.00 %7.2f 0.00\n", Delay, Delay );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
if ( pRepr->n_inputs == 0 )
|
||||
continue;
|
||||
//if ( pRepr->n_outputs > 1 )
|
||||
// continue;
|
||||
if ( nGatesMin && pRepr->n_inputs > 2 && Abc_SclClassCellNum(pRepr) < nGatesMin )
|
||||
continue;
|
||||
SC_CellForEachPinOut( pRepr, pPinOut, j )
|
||||
{
|
||||
assert( strlen(pRepr->pName) < 200 );
|
||||
Vec_StrPrintStr( vStr, "GATE " );
|
||||
sprintf( Buffer, "%-16s", pRepr->pName );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
Vec_StrPrintStr( vStr, " " );
|
||||
// sprintf( Buffer, "%7.2f", Abc_SclComputeAreaClass(pRepr) );
|
||||
sprintf( Buffer, "%7.2f", pRepr->area );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
Vec_StrPrintStr( vStr, " " );
|
||||
Vec_StrPrintStr( vStr, SC_CellPinName(pRepr, j) );
|
||||
Vec_StrPrintStr( vStr, "=" );
|
||||
Vec_StrPrintStr( vStr, SC_CellPinOutFunc(pRepr, j-pRepr->n_inputs) ? SC_CellPinOutFunc(pRepr, j-pRepr->n_inputs) : "?" );
|
||||
Vec_StrPrintStr( vStr, ";\n" );
|
||||
SC_CellForEachPinIn( pRepr, pPin, k )
|
||||
{
|
||||
float Delay = Abc_SclComputeDelayClassPin( p, pRepr, k, Slew, Gain );
|
||||
assert( Delay > 0 );
|
||||
Vec_StrPrintStr( vStr, " PIN " );
|
||||
sprintf( Buffer, "%-4s", pPin->pName );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
sprintf( Buffer, " UNKNOWN 1 999 %7.2f 0.00 %7.2f 0.00\n", Delay, Delay );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
}
|
||||
Count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SC_LibForEachCellClass( p, pRepr, i )
|
||||
{
|
||||
if ( pRepr->n_inputs == 0 )
|
||||
continue;
|
||||
if ( pRepr->n_outputs > 1 )
|
||||
continue;
|
||||
if ( nGatesMin && pRepr->n_inputs > 2 && Abc_SclClassCellNum(pRepr) < nGatesMin )
|
||||
continue;
|
||||
assert( strlen(pRepr->pName) < 200 );
|
||||
Vec_StrPrintStr( vStr, "GATE " );
|
||||
sprintf( Buffer, "%-16s", pRepr->pName );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
Vec_StrPrintStr( vStr, " " );
|
||||
// sprintf( Buffer, "%7.2f", Abc_SclComputeAreaClass(pRepr) );
|
||||
sprintf( Buffer, "%7.2f", pRepr->area );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
Vec_StrPrintStr( vStr, " " );
|
||||
Vec_StrPrintStr( vStr, SC_CellPinName(pRepr, pRepr->n_inputs) );
|
||||
Vec_StrPrintStr( vStr, "=" );
|
||||
Vec_StrPrintStr( vStr, SC_CellPinOutFunc(pRepr, 0) ? SC_CellPinOutFunc(pRepr, 0) : "?" );
|
||||
Vec_StrPrintStr( vStr, ";\n" );
|
||||
SC_CellForEachPinIn( pRepr, pPin, k )
|
||||
{
|
||||
float Delay = Abc_SclComputeDelayClassPin( p, pRepr, k, Slew, Gain );
|
||||
assert( Delay > 0 );
|
||||
Vec_StrPrintStr( vStr, " PIN " );
|
||||
sprintf( Buffer, "%-4s", pPin->pName );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
sprintf( Buffer, " UNKNOWN 1 999 %7.2f 0.00 %7.2f 0.00\n", Delay, Delay );
|
||||
Vec_StrPrintStr( vStr, Buffer );
|
||||
}
|
||||
Count++;
|
||||
}
|
||||
Count++;
|
||||
}
|
||||
Vec_StrPrintStr( vStr, "\n.end\n" );
|
||||
Vec_StrPush( vStr, '\0' );
|
||||
|
|
@ -1012,7 +1054,7 @@ void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float SlewInit, float Gain
|
|||
printf( "Cannot open file \"%s\" for writing.\n", FileName );
|
||||
return;
|
||||
}
|
||||
vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount );
|
||||
vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, 0, &nCellCount );
|
||||
fprintf( pFile, "%s", Vec_StrArray(vStr) );
|
||||
Vec_StrFree( vStr );
|
||||
fclose( pFile );
|
||||
|
|
@ -1026,7 +1068,7 @@ Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, void * pMio, float SlewInit, f
|
|||
Vec_Str_t * vStr;
|
||||
Mio_Library_t * pLib;
|
||||
if ( pMio == NULL )
|
||||
vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount );
|
||||
vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, 0, &nCellCount );
|
||||
else
|
||||
vStr = Abc_SclProduceGenlibStrProfile( p, (Mio_Library_t *)pMio, Slew, Gain, nGatesMin, &nCellCount );
|
||||
pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0, 0 );
|
||||
|
|
@ -1049,7 +1091,7 @@ Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, void * pMio, float SlewInit, f
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Abc_SclInstallGenlib( void * pScl, float SlewInit, float Gain, int nGatesMin )
|
||||
void Abc_SclInstallGenlib( void * pScl, float SlewInit, float Gain, int fUseAll, int nGatesMin )
|
||||
{
|
||||
SC_Lib * p = (SC_Lib *)pScl;
|
||||
Vec_Str_t * vStr, * vStr2;
|
||||
|
|
@ -1058,7 +1100,7 @@ void Abc_SclInstallGenlib( void * pScl, float SlewInit, float Gain, int nGatesMi
|
|||
if ( Gain == 0 )
|
||||
vStr = Abc_SclProduceGenlibStrSimple(p);
|
||||
else
|
||||
vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nGateCount );
|
||||
vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, fUseAll, &nGateCount );
|
||||
vStr2 = Vec_StrDup( vStr );
|
||||
RetValue = Mio_UpdateGenlib2( vStr, vStr2, p->pName, 0 );
|
||||
Vec_StrFree( vStr );
|
||||
|
|
|
|||
Loading…
Reference in New Issue