Commit e01174c6 by Alan Mishchenko

Bug fixes in the library processing,.

parent fb2ae7c2
......@@ -429,14 +429,18 @@ void Mio_ParseFormulaTruthTest( char * pFormInit, char ** ppVarNames, int nVars
int Mio_ParseCheckName( Mio_Gate_t * pGate, char ** ppStr )
{
Mio_Pin_t * pPin;
int i;
int i, iBest;
// find the longest pin name that matches substring
char * pNameBest = NULL;
for ( pPin = Mio_GateReadPins(pGate), i = 0; pPin; pPin = Mio_PinReadNext(pPin), i++ )
if ( !strncmp( *ppStr, Mio_PinReadName(pPin), strlen(Mio_PinReadName(pPin)) ) )
{
*ppStr += strlen(Mio_PinReadName(pPin)) - 1;
return i;
}
if ( pNameBest == NULL || strlen(pNameBest) < strlen(Mio_PinReadName(pPin)) )
pNameBest = Mio_PinReadName(pPin), iBest = i;
// if pin is not found, return -1
if ( pNameBest == NULL )
return -1;
*ppStr += strlen(pNameBest) - 1;
return iBest;
}
int Mio_ParseCheckFormula( Mio_Gate_t * pGate, char * pForm )
{
......
......@@ -212,6 +212,12 @@ int Scl_CommandReadLib( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( pAbc->Err, "Reading SCL library from file \"%s\" has failed. \n", pFileName );
return 1;
}
if ( Abc_SclLibClassNum(pLib) < 3 )
{
fprintf( pAbc->Err, "Library with only %d cell classes cannot be used.\n", Abc_SclLibClassNum(pLib) );
Abc_SclLibFree(pLib);
return 0;
}
Abc_SclLoad( pLib, (SC_Lib **)&pAbc->pLibScl );
// dump the resulting library
if ( fDump && pAbc->pLibScl )
......
......@@ -607,6 +607,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 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 );
extern SC_Cell * Abc_SclFindInvertor( SC_Lib * p, int fFindBuff );
......
......@@ -90,6 +90,14 @@ int Abc_SclClassCellNum( SC_Cell * pClass )
Count++;
return Count;
}
int Abc_SclLibClassNum( SC_Lib * pLib )
{
SC_Cell * pRepr;
int i, Count = 0;
SC_LibForEachCellClass( pLib, pRepr, i )
Count++;
return Count;
}
/**Function*************************************************************
......@@ -472,19 +480,22 @@ void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fS
continue;
SC_RingForEachCell( pRepr, pCell, j )
{
Abc_SclComputeParametersCell( p, pCell, Slew, &LD, &PD );
printf( " %3d ", j+1 );
printf( "%s", pCell->fSkip ? "s" : " " );
printf( " : " );
printf( "%-*s ", nLength, pCell->pName );
printf( "%2d ", pCell->drive_strength );
printf( "A =%8.2f ", pCell->area );
if ( pCell->n_outputs == 1 )
{
Abc_SclComputeParametersCell( p, pCell, Slew, &LD, &PD );
printf( "D =%6.1f ps ", 0.01 * Gain * LD + PD );
printf( "LD =%6.1f ps ", LD );
printf( "PD =%6.1f ps ", PD );
printf( "C =%5.1f ff ", SC_LibCapFf(p, SC_CellPinCapAve(pCell)) );
printf( "Cm =%5.0f ff ", SC_LibCapFf(p, SC_CellPin(pCell, pCell->n_inputs)->max_out_cap) );
printf( "Sm =%5.1f ps ", SC_LibTimePs(p, SC_CellPin(pCell, pCell->n_inputs)->max_out_slew) );
}
printf( "\n" );
}
break;
......
......@@ -921,7 +921,7 @@ Vec_Flt_t * Scl_LibertyReadFloatVec( char * pName )
Vec_FltPush( vValues, atof(pToken) );
return vValues;
}
void Scl_LibertyReadTable( Scl_Tree_t * p, Vec_Str_t * vOut, Scl_Item_t * pTiming, char * pName, Vec_Ptr_t * vTemples )
int Scl_LibertyReadTable( Scl_Tree_t * p, Vec_Str_t * vOut, Scl_Item_t * pTiming, char * pName, Vec_Ptr_t * vTemples )
{
Vec_Flt_t * vIndex1 = NULL;
Vec_Flt_t * vIndex2 = NULL;
......@@ -935,7 +935,7 @@ void Scl_LibertyReadTable( Scl_Tree_t * p, Vec_Str_t * vOut, Scl_Item_t * pTimin
Scl_ItemForEachChildName( p, pTiming, pTable, pName )
break;
if ( pTable == NULL )
{ printf( "Table cannot be found\n" ); return; }
return 0;
// find the template
pTempl = Scl_LibertyReadString(p, pTable->Head);
if ( pTempl == NULL || pTempl[0] == 0 )
......@@ -951,7 +951,7 @@ void Scl_LibertyReadTable( Scl_Tree_t * p, Vec_Str_t * vOut, Scl_Item_t * pTimin
assert(vValues == NULL), vValues = Scl_LibertyReadFloatVec( Scl_LibertyReadString(p, pItem->Head) );
}
if ( vIndex1 == NULL || vIndex2 == NULL || vValues == NULL )
{ printf( "Incomplete table specification\n" ); return; }
{ printf( "Incomplete table specification\n" ); return 0; }
// dump the table
vInd1 = vIndex1;
vInd2 = vIndex2;
......@@ -986,7 +986,7 @@ void Scl_LibertyReadTable( Scl_Tree_t * p, Vec_Str_t * vOut, Scl_Item_t * pTimin
break;
}
if ( iPlace == -1 )
{ printf( "Template cannot be found in the template library\n" ); return; }
{ printf( "Template cannot be found in the template library\n" ); return 0; }
// read the numbers
Scl_ItemForEachChild( p, pTable, pItem )
{
......@@ -1068,6 +1068,7 @@ void Scl_LibertyReadTable( Scl_Tree_t * p, Vec_Str_t * vOut, Scl_Item_t * pTimin
Vec_FltFreeP( &vValues );
Vec_StrPut_( vOut );
Vec_StrPut_( vOut );
return 1;
}
void Scl_LibertyPrintTemplates( Vec_Ptr_t * vRes )
{
......@@ -1210,7 +1211,8 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
continue;
// top level information
Vec_StrPutS_( vOut, Scl_LibertyReadString(p, pCell->Head) );
Vec_StrPutF_( vOut, Scl_LibertyReadCellArea(p, pCell) ? atof(Scl_LibertyReadCellArea(p, pCell)) : 1 );
pName = Scl_LibertyReadCellArea(p, pCell);
Vec_StrPutF_( vOut, pName ? atof(pName) : 1 );
Vec_StrPutI_( vOut, Scl_LibertyReadDeriveStrength(p, pCell) );
// pin count
nOutputs = Scl_LibertyReadCellOutputNum( p, pCell );
......@@ -1274,10 +1276,19 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos
Vec_StrPutI_( vOut, Scl_LibertyReadTimingSense(p, pTiming) );
Vec_StrPut_( vOut );
Vec_StrPut_( vOut );
Scl_LibertyReadTable( p, vOut, pTiming, "cell_rise", vTemples );
Scl_LibertyReadTable( p, vOut, pTiming, "cell_fall", vTemples );
Scl_LibertyReadTable( p, vOut, pTiming, "rise_transition", vTemples );
Scl_LibertyReadTable( p, vOut, pTiming, "fall_transition", vTemples );
// some cells only have 'rise' or 'fall' but not both - here we work around this
if ( !Scl_LibertyReadTable( p, vOut, pTiming, "cell_rise", vTemples ) )
if ( !Scl_LibertyReadTable( p, vOut, pTiming, "cell_fall", vTemples ) )
{ printf( "Table cannot be found\n" ); return NULL; }
if ( !Scl_LibertyReadTable( p, vOut, pTiming, "cell_fall", vTemples ) )
if ( !Scl_LibertyReadTable( p, vOut, pTiming, "cell_rise", vTemples ) )
{ printf( "Table cannot be found\n" ); return NULL; }
if ( !Scl_LibertyReadTable( p, vOut, pTiming, "rise_transition", vTemples ) )
if ( !Scl_LibertyReadTable( p, vOut, pTiming, "fall_transition", vTemples ) )
{ printf( "Table cannot be found\n" ); return NULL; }
if ( !Scl_LibertyReadTable( p, vOut, pTiming, "fall_transition", vTemples ) )
if ( !Scl_LibertyReadTable( p, vOut, pTiming, "rise_transition", vTemples ) )
{ printf( "Table cannot be found\n" ); return NULL; }
}
}
Vec_StrPut_( vOut );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment