diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/map/scl/scl.c | 73 | ||||
| -rw-r--r-- | src/map/scl/sclLib.h | 4 | ||||
| -rw-r--r-- | src/map/scl/sclLibScl.c | 9 | ||||
| -rw-r--r-- | src/map/scl/sclLibUtil.c | 22 | ||||
| -rw-r--r-- | src/map/scl/sclLiberty.c | 19 | 
5 files changed, 122 insertions, 5 deletions
diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c index ac490c73..53672073 100644 --- a/src/map/scl/scl.c +++ b/src/map/scl/scl.c @@ -33,6 +33,7 @@ static int Scl_CommandWriteLib   ( Abc_Frame_t * pAbc, int argc, char ** argv );  static int Scl_CommandReadScl    ( Abc_Frame_t * pAbc, int argc, char ** argv );  static int Scl_CommandWriteScl   ( Abc_Frame_t * pAbc, int argc, char ** argv );  static int Scl_CommandPrintLib   ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Scl_CommandLeak2Area  ( Abc_Frame_t * pAbc, int argc, char ** argv );  static int Scl_CommandDumpGen    ( Abc_Frame_t * pAbc, int argc, char ** argv );  static int Scl_CommandPrintGS    ( Abc_Frame_t * pAbc, int argc, char ** argv );  static int Scl_CommandStime      ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -92,6 +93,7 @@ void Scl_Init( Abc_Frame_t * pAbc )      Cmd_CommandAdd( pAbc, "SCL mapping",  "read_lib",      Scl_CommandReadLib,     0 );       Cmd_CommandAdd( pAbc, "SCL mapping",  "write_lib",     Scl_CommandWriteLib,    0 );       Cmd_CommandAdd( pAbc, "SCL mapping",  "print_lib",     Scl_CommandPrintLib,    0 );  +    Cmd_CommandAdd( pAbc, "SCL mapping",  "leak2area",     Scl_CommandLeak2Area,   0 );       Cmd_CommandAdd( pAbc, "SCL mapping",  "read_scl",      Scl_CommandReadScl,     0 );       Cmd_CommandAdd( pAbc, "SCL mapping",  "write_scl",     Scl_CommandWriteScl,    0 );       Cmd_CommandAdd( pAbc, "SCL mapping",  "dump_genlib",   Scl_CommandDumpGen,     0 );  @@ -373,6 +375,77 @@ usage:      return 1;  } +/**Function************************************************************* + +  Synopsis    [] + +  Description [] +                +  SideEffects [] + +  SeeAlso     [] + +***********************************************************************/ +int Scl_CommandLeak2Area( Abc_Frame_t * pAbc, int argc, char **argv ) +{ +    float A = 1, B = 1; +    int c, fVerbose = 0; +    Extra_UtilGetoptReset(); +    while ( ( c = Extra_UtilGetopt( argc, argv, "ABvh" ) ) != EOF ) +    { +        switch ( c ) +        { +        case 'A': +            if ( globalUtilOptind >= argc ) +            { +                Abc_Print( -1, "Command line switch \"-A\" should be followed by a floating point number.\n" ); +                goto usage; +            } +            A = (float)atof(argv[globalUtilOptind]); +            globalUtilOptind++; +            if ( A <= 0.0 ) +                goto usage; +            break; +        case 'B': +            if ( globalUtilOptind >= argc ) +            { +                Abc_Print( -1, "Command line switch \"-B\" should be followed by a floating point number.\n" ); +                goto usage; +            } +            B = (float)atof(argv[globalUtilOptind]); +            globalUtilOptind++; +            if ( B <= 0.0 ) +                goto usage; +            break; +        case 'v': +            fVerbose ^= 1; +            break; +        case 'h': +            goto usage; +        default: +            goto usage; +        } +    } +    if ( pAbc->pLibScl == NULL ) +    { +        fprintf( pAbc->Err, "There is no Liberty library available.\n" ); +        return 1; +    } +    // update the current library +    Abc_SclConvertLeakageIntoArea( (SC_Lib *)pAbc->pLibScl, A, B ); +    return 0; + +usage: +    fprintf( pAbc->Err, "usage: leak2area [-AB float] [-v]\n" ); +    fprintf( pAbc->Err, "\t           converts leakage into area: Area = A * Area + B * Leakage\n" ); +    fprintf( pAbc->Err, "\t-A float : the multiplicative coefficient to transform area [default = %.2f]\n", A ); +    fprintf( pAbc->Err, "\t-B float : the multiplicative coefficient to transform leakage [default = %.2f]\n", B ); +    fprintf( pAbc->Err, "\t-v       : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); +    fprintf( pAbc->Err, "\t-h       : print the help massage\n" ); +    return 1; +} + +  /**Function************************************************************* diff --git a/src/map/scl/sclLib.h b/src/map/scl/sclLib.h index e7c70e51..09242d01 100644 --- a/src/map/scl/sclLib.h +++ b/src/map/scl/sclLib.h @@ -40,7 +40,7 @@ ABC_NAMESPACE_HEADER_START  ///                         PARAMETERS                               ///  //////////////////////////////////////////////////////////////////////// -#define ABC_SCL_CUR_VERSION 7 +#define ABC_SCL_CUR_VERSION 8  typedef enum    { @@ -186,6 +186,7 @@ struct SC_Cell_      int            seq;            // -- set to TRUE by parser if a sequential element      int            unsupp;         // -- set to TRUE by parser if cell contains information we cannot handle      float          area; +    float          leakage;      int            drive_strength; // -- some library files provide this field (currently unused, but may be a good hint for sizing) (not used)      Vec_Ptr_t *    vPins;          // NamedSet<SC_Pin>       int            n_inputs;       // -- 'pins[0 .. n_inputs-1]' are input pins @@ -616,6 +617,7 @@ 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 void          Abc_SclConvertLeakageIntoArea( SC_Lib * p, float A, float B );  extern void          Abc_SclLibNormalize( SC_Lib * p );  extern SC_Cell *     Abc_SclFindInvertor( SC_Lib * p, int fFindBuff );  extern SC_Cell *     Abc_SclFindSmallestGate( SC_Cell * p, float CinMin ); diff --git a/src/map/scl/sclLibScl.c b/src/map/scl/sclLibScl.c index 7947d8a3..f47c1721 100644 --- a/src/map/scl/sclLibScl.c +++ b/src/map/scl/sclLibScl.c @@ -132,6 +132,7 @@ static int Abc_SclReadLibrary( Vec_Str_t * vOut, int * pPos, SC_Lib * p )          pCell->pName           = Vec_StrGetS(vOut, pPos);               pCell->area           = Vec_StrGetF(vOut, pPos); +        pCell->leakage        = Vec_StrGetF(vOut, pPos);          pCell->drive_strength = Vec_StrGetI(vOut, pPos);          pCell->n_inputs       = Vec_StrGetI(vOut, pPos); @@ -380,6 +381,7 @@ static void Abc_SclWriteLibrary( Vec_Str_t * vOut, SC_Lib * p )          Vec_StrPutS( vOut, pCell->pName );          Vec_StrPutF( vOut, pCell->area ); +        Vec_StrPutF( vOut, pCell->leakage );          Vec_StrPutI( vOut, pCell->drive_strength );          // Write 'pins': (sorted at this point; first inputs, then outputs) @@ -582,10 +584,11 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p )              continue;          fprintf( s, "\n" ); -        fprintf( s, "  cell(%s) {\n", pCell->pName ); +        fprintf( s, "  cell(%s) {\n",                             pCell->pName );          fprintf( s, "    /*  n_inputs = %d  n_outputs = %d */\n", pCell->n_inputs, pCell->n_outputs ); -        fprintf( s, "    area : %f;\n", pCell->area ); -        fprintf( s, "    drive_strength : %d;\n", pCell->drive_strength ); +        fprintf( s, "    area : %f;\n",                           pCell->area ); +        fprintf( s, "    cell_leakage_power : %f;\n",             pCell->leakage ); +        fprintf( s, "    drive_strength : %d;\n",                 pCell->drive_strength );          SC_CellForEachPinIn( pCell, pPin, j )          { diff --git a/src/map/scl/sclLibUtil.c b/src/map/scl/sclLibUtil.c index 54635404..bb70ee9b 100644 --- a/src/map/scl/sclLibUtil.c +++ b/src/map/scl/sclLibUtil.c @@ -549,7 +549,8 @@ void Abc_SclPrintCells( SC_Lib * p, float SlewInit, float Gain, int fInvOnly, in                  printf( " : " );                  printf( "%-*s  ",           nLength, pCell->pName );                  printf( "%2d   ",           pCell->drive_strength ); -                printf( "A =%8.2f    ",     pCell->area ); +                printf( "A =%8.2f  ",       pCell->area ); +                printf( "L =%8.2f  ",       pCell->leakage );                  if ( pCell->n_outputs == 1 )                  {                      if ( Abc_SclComputeParametersCell( p, pCell, Slew, &LD, &PD ) ) @@ -571,6 +572,25 @@ void Abc_SclPrintCells( SC_Lib * p, float SlewInit, float Gain, int fInvOnly, in  /**Function************************************************************* +  Synopsis    [] + +  Description [] +                +  SideEffects [] + +  SeeAlso     [] + +***********************************************************************/ +void Abc_SclConvertLeakageIntoArea( SC_Lib * p, float A, float B ) +{ +    SC_Cell * pCell; int i; +    SC_LibForEachCell( p, pCell, i ) +        pCell->area = A * pCell->area + B * pCell->leakage; +} + + +/**Function************************************************************* +    Synopsis    [Print cells]    Description [] diff --git a/src/map/scl/sclLiberty.c b/src/map/scl/sclLiberty.c index 36d01c1b..23258b7c 100644 --- a/src/map/scl/sclLiberty.c +++ b/src/map/scl/sclLiberty.c @@ -619,6 +619,23 @@ char * Scl_LibertyReadCellArea( Scl_Tree_t * p, Scl_Item_t * pCell )          return Scl_LibertyReadString(p, pArea->Head);      return 0;  } +char * Scl_LibertyReadCellLeakage( Scl_Tree_t * p, Scl_Item_t * pCell ) +{ +    Scl_Item_t * pItem, * pChild; +    Scl_ItemForEachChildName( p, pCell, pItem, "cell_leakage_power" ) +        return Scl_LibertyReadString(p, pItem->Head); +    // look for another type +    Scl_ItemForEachChildName( p, pCell, pItem, "leakage_power" ) +    { +        Scl_ItemForEachChildName( p, pItem, pChild, "when" ) +            break; +        if ( pChild && !Scl_LibertyCompare(p, pChild->Key, "when") ) +            continue; +        Scl_ItemForEachChildName( p, pItem, pChild, "value" ) +            return Scl_LibertyReadString(p, pChild->Head); +    } +    return 0; +}  char * Scl_LibertyReadPinFormula( Scl_Tree_t * p, Scl_Item_t * pPin )  {      Scl_Item_t * pFunc; @@ -1447,6 +1464,8 @@ Vec_Str_t * Scl_LibertyReadSclStr( Scl_Tree_t * p, int fVerbose, int fVeryVerbos          Vec_StrPutS_( vOut, Scl_LibertyReadString(p, pCell->Head) );          pName = Scl_LibertyReadCellArea(p, pCell);          Vec_StrPutF_( vOut, pName ? atof(pName) : 1 ); +        pName = Scl_LibertyReadCellLeakage(p, pCell); +        Vec_StrPutF_( vOut, pName ? atof(pName) : 0 );          Vec_StrPutI_( vOut, Scl_LibertyReadDeriveStrength(p, pCell) );          // pin count          nOutputs = Scl_LibertyReadCellOutputNum( p, pCell );  | 
