summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2013-10-02 18:22:14 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2013-10-02 18:22:14 -0700
commite01174c6db703a4d9f50a5ef3d494ea68c7640c2 (patch)
tree63bc7e087781cd442a874936f02e9cc68bc1e707
parentfb2ae7c22f42e05c920dd9366313422ff073749f (diff)
downloadabc-e01174c6db703a4d9f50a5ef3d494ea68c7640c2.tar.gz
abc-e01174c6db703a4d9f50a5ef3d494ea68c7640c2.tar.bz2
abc-e01174c6db703a4d9f50a5ef3d494ea68c7640c2.zip
Bug fixes in the library processing,.
-rw-r--r--src/map/mio/mioParse.c16
-rw-r--r--src/map/scl/scl.c6
-rw-r--r--src/map/scl/sclLib.h1
-rw-r--r--src/map/scl/sclLibUtil.c25
-rw-r--r--src/map/scl/sclLiberty.c29
5 files changed, 55 insertions, 22 deletions
diff --git a/src/map/mio/mioParse.c b/src/map/mio/mioParse.c
index 11b2a708..cac21596 100644
--- a/src/map/mio/mioParse.c
+++ b/src/map/mio/mioParse.c
@@ -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;
- }
- return -1;
+ 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 )
{
diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c
index 48295868..70b11288 100644
--- a/src/map/scl/scl.c
+++ b/src/map/scl/scl.c
@@ -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 )
diff --git a/src/map/scl/sclLib.h b/src/map/scl/sclLib.h
index bdd870ac..ae799f55 100644
--- a/src/map/scl/sclLib.h
+++ b/src/map/scl/sclLib.h
@@ -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 );
diff --git a/src/map/scl/sclLibUtil.c b/src/map/scl/sclLibUtil.c
index 48c62512..f62b8b71 100644
--- a/src/map/scl/sclLibUtil.c
+++ b/src/map/scl/sclLibUtil.c
@@ -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 );
- 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) );
+ 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;
diff --git a/src/map/scl/sclLiberty.c b/src/map/scl/sclLiberty.c
index 789473ad..ea8d0f05 100644
--- a/src/map/scl/sclLiberty.c
+++ b/src/map/scl/sclLiberty.c
@@ -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 );