Commit 1ba1e657 by Alan Mishchenko

New package to read/write a subset of Liberty for STA.

parent 95e14cd7
...@@ -30,6 +30,7 @@ ABC_NAMESPACE_IMPL_START ...@@ -30,6 +30,7 @@ ABC_NAMESPACE_IMPL_START
static int Scl_CommandRead ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandRead ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandStime( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandStime( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -51,6 +52,7 @@ void Scl_Init( Abc_Frame_t * pAbc ) ...@@ -51,6 +52,7 @@ void Scl_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "SC mapping", "read_scl", Scl_CommandRead, 0 ); Cmd_CommandAdd( pAbc, "SC mapping", "read_scl", Scl_CommandRead, 0 );
Cmd_CommandAdd( pAbc, "SC mapping", "write_scl", Scl_CommandWrite, 0 ); Cmd_CommandAdd( pAbc, "SC mapping", "write_scl", Scl_CommandWrite, 0 );
Cmd_CommandAdd( pAbc, "SC mapping", "stime", Scl_CommandStime, 0 ); Cmd_CommandAdd( pAbc, "SC mapping", "stime", Scl_CommandStime, 0 );
Cmd_CommandAdd( pAbc, "SC mapping", "gsize", Scl_CommandGsize, 1 );
} }
void Scl_End( Abc_Frame_t * pAbc ) void Scl_End( Abc_Frame_t * pAbc )
{ {
...@@ -144,7 +146,7 @@ int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -144,7 +146,7 @@ int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv )
goto usage; goto usage;
if ( pAbc->pLibScl == NULL ) if ( pAbc->pLibScl == NULL )
{ {
fprintf( pAbc->Err, "There is no Liberty Library available.\n" ); fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1; return 1;
} }
// get the input file name // get the input file name
...@@ -207,7 +209,7 @@ int Scl_CommandStime( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -207,7 +209,7 @@ int Scl_CommandStime( Abc_Frame_t * pAbc, int argc, char **argv )
} }
if ( pAbc->pLibScl == NULL ) if ( pAbc->pLibScl == NULL )
{ {
fprintf( pAbc->Err, "There is no Liberty Library available.\n" ); fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1; return 1;
} }
...@@ -221,6 +223,59 @@ usage: ...@@ -221,6 +223,59 @@ usage:
return 1; return 1;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv )
{
int c;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
if ( Abc_FrameReadNtk(pAbc) == NULL )
{
fprintf( pAbc->Err, "There is no current network.\n" );
return 1;
}
if ( !Abc_NtkHasMapping(Abc_FrameReadNtk(pAbc)) )
{
fprintf( pAbc->Err, "The current network is not mapped.\n" );
return 1;
}
if ( pAbc->pLibScl == NULL )
{
fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1;
}
Abc_SclSizingPerform( pAbc->pLibScl, Abc_FrameReadNtk(pAbc) );
return 0;
usage:
fprintf( pAbc->Err, "usage: gsize [-h]\n" );
fprintf( pAbc->Err, "\t performs gate sizing using Liberty library\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
return 1;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -51,7 +51,8 @@ extern void Abc_SclLoad( char * pFileName, void ** ppScl ); ...@@ -51,7 +51,8 @@ extern void Abc_SclLoad( char * pFileName, void ** ppScl );
extern void Abc_SclSave( char * pFileName, void * pScl ); extern void Abc_SclSave( char * pFileName, void * pScl );
/*=== sclTime.c =============================================================*/ /*=== sclTime.c =============================================================*/
extern void Abc_SclTimePerform( SC_Lib * pLib, void * pNtk ); extern void Abc_SclTimePerform( SC_Lib * pLib, void * pNtk );
/*=== sclSize.c =============================================================*/
extern void Abc_SclSizingPerform( SC_Lib * pLib, void * pNtk );
ABC_NAMESPACE_HEADER_END ABC_NAMESPACE_HEADER_END
......
...@@ -592,36 +592,45 @@ static void Abc_SclWriteSurfaceText( FILE * s, SC_Surface * p ) ...@@ -592,36 +592,45 @@ static void Abc_SclWriteSurfaceText( FILE * s, SC_Surface * p )
float Entry; float Entry;
int i, k; int i, k;
fprintf( s, "Surface:\n" ); fprintf( s, " index_1(\"" );
fprintf( s, "%d", Vec_FltSize(p->vIndex0) );
fprintf( s, "\n" );
Vec_FltForEachEntry( p->vIndex0, Entry, i ) Vec_FltForEachEntry( p->vIndex0, Entry, i )
fprintf( s, "%f ", Entry ); fprintf( s, "%f%s", Entry, i == Vec_FltSize(p->vIndex0)-1 ? "":", " );
fprintf( s, "\n" ); fprintf( s, "\");\n" );
fprintf( s, "%d", Vec_FltSize(p->vIndex1) ); fprintf( s, " index_2(\"" );
fprintf( s, "\n" );
Vec_FltForEachEntry( p->vIndex1, Entry, i ) Vec_FltForEachEntry( p->vIndex1, Entry, i )
fprintf( s, "%f ", Entry ); fprintf( s, "%f%s", Entry, i == Vec_FltSize(p->vIndex1)-1 ? "":", " );
fprintf( s, "\n" ); fprintf( s, "\");\n" );
fprintf( s, " values (\"" );
Vec_PtrForEachEntry( Vec_Flt_t *, p->vData, vVec, i ) Vec_PtrForEachEntry( Vec_Flt_t *, p->vData, vVec, i )
{ {
Vec_FltForEachEntry( vVec, Entry, k ) Vec_FltForEachEntry( vVec, Entry, k )
fprintf( s, "%f ", Entry ); fprintf( s, "%f%s", Entry, i == Vec_PtrSize(p->vData)-1 && k == Vec_FltSize(vVec)-1 ? "\");":", " );
if ( i == Vec_PtrSize(p->vData)-1 )
fprintf( s, "\n" ); fprintf( s, "\n" );
else
{
fprintf( s, "\\\n" );
fprintf( s, " " );
} }
}
/*
fprintf( s, " approximations: \n" );
fprintf( s, " " );
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
fprintf( s, "%f ", p->approx[0][i] ); fprintf( s, "%f ", p->approx[0][i] );
fprintf( s, "\n" ); fprintf( s, "\n" );
fprintf( s, " " );
for ( i = 0; i < 4; i++ ) for ( i = 0; i < 4; i++ )
fprintf( s, "%f ", p->approx[1][i] ); fprintf( s, "%f ", p->approx[1][i] );
fprintf( s, "\n" ); fprintf( s, "\n" );
fprintf( s, " " );
for ( i = 0; i < 6; i++ ) for ( i = 0; i < 6; i++ )
fprintf( s, "%f ", p->approx[2][i] ); fprintf( s, "%f ", p->approx[2][i] );
fprintf( s, "\n" ); fprintf( s, "\n" );
fprintf( s, " \n" );
*/
} }
static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p ) static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p )
{ {
...@@ -633,71 +642,47 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p ) ...@@ -633,71 +642,47 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p )
int i, j, k; int i, j, k;
// fprintf( s, "%d", ABC_SCL_CUR_VERSION ); // fprintf( s, "%d", ABC_SCL_CUR_VERSION );
fprintf( s, "Liberty:\n" ); fprintf( s, "library(%s) {\n\n", p->lib_name );
if ( p->default_wire_load && strlen(p->default_wire_load) )
// Write non-composite fields: fprintf( s, " default_wire_load : \"%s\";\n", p->default_wire_load );
fprintf( s, "%s", p->lib_name ); if ( p->default_wire_load_sel && strlen(p->default_wire_load_sel) )
fprintf( s, "\n" ); fprintf( s, " default_wire_load_selection : \"%s\";\n", p->default_wire_load_sel );
fprintf( s, "%s", p->default_wire_load ); if ( p->default_max_out_slew != -1 )
fprintf( s, "\n" ); fprintf( s, " default_max_transition : %f;\n", p->default_max_out_slew );
fprintf( s, "%s", p->default_wire_load_sel ); if ( p->unit_time == 9 )
fprintf( s, "\n" ); fprintf( s, " time_unit : \"1ns\";\n" );
fprintf( s, "%f", p->default_max_out_slew ); else if ( p->unit_time == 10 )
fprintf( s, "\n" ); fprintf( s, " time_unit : \"100ps\";\n" );
else if ( p->unit_time == 11 )
assert( p->unit_time >= 0 ); fprintf( s, " time_unit : \"10ps\";\n" );
assert( p->unit_cap_snd >= 0 ); else if ( p->unit_time == 12 )
fprintf( s, "%d", p->unit_time ); fprintf( s, " time_unit : \"1ps\";\n" );
fprintf( s, "\n" ); else assert( 0 );
fprintf( s, "%f", p->unit_cap_fst ); fprintf( s, " capacitive_load_unit(%.1f,%s);\n", p->unit_cap_fst, p->unit_cap_snd == 12 ? "pf" : "ff" );
fprintf( s, "\n" );
fprintf( s, "%d", p->unit_cap_snd );
fprintf( s, "\n" ); fprintf( s, "\n" );
// Write 'wire_load' vector: // Write 'wire_load' vector:
fprintf( s, "\n" );
fprintf( s, "%d", Vec_PtrSize(p->vWireLoads) );
fprintf( s, "\n" );
Vec_PtrForEachEntry( SC_WireLoad *, p->vWireLoads, pWL, i ) Vec_PtrForEachEntry( SC_WireLoad *, p->vWireLoads, pWL, i )
{ {
fprintf( s, "WireLoad:\n" ); fprintf( s, " wire_load(\"%s\") {\n", pWL->name );
fprintf( s, "%s ", pWL->name ); fprintf( s, " capacitance : %f;\n", pWL->cap );
fprintf( s, "%f ", pWL->res ); fprintf( s, " resistance : %f;\n", pWL->res );
fprintf( s, "%f", pWL->cap );
fprintf( s, "\n" );
fprintf( s, "%d", Vec_IntSize(pWL->vFanout) );
fprintf( s, "\n" );
for ( j = 0; j < Vec_IntSize(pWL->vFanout); j++ ) for ( j = 0; j < Vec_IntSize(pWL->vFanout); j++ )
{ fprintf( s, " fanout_length( %d, %f );\n", Vec_IntEntry(pWL->vFanout, j), Vec_FltEntry(pWL->vLen, j) );
fprintf( s, "%d ", Vec_IntEntry(pWL->vFanout, j) ); fprintf( s, " }\n\n" );
fprintf( s, "%f ", Vec_FltEntry(pWL->vLen, j) );
}
fprintf( s, "\n" );
} }
fprintf( s, "\n" );
// Write 'wire_load_sel' vector: // Write 'wire_load_sel' vector:
fprintf( s, "%d", Vec_PtrSize(p->vWireLoadSels) );
fprintf( s, "\n" );
Vec_PtrForEachEntry( SC_WireLoadSel *, p->vWireLoadSels, pWLS, i ) Vec_PtrForEachEntry( SC_WireLoadSel *, p->vWireLoadSels, pWLS, i )
{ {
fprintf( s, "WireLoadSel:\n" ); fprintf( s, " wire_load_selection(\"%s\") {\n", pWLS->name );
fprintf( s, "%s", pWLS->name );
fprintf( s, "\n" );
fprintf( s, "%d", Vec_FltSize(pWLS->vAreaFrom) );
fprintf( s, "\n" );
for ( j = 0; j < Vec_FltSize(pWLS->vAreaFrom); j++) for ( j = 0; j < Vec_FltSize(pWLS->vAreaFrom); j++)
{ fprintf( s, " wire_load_from_area( %f, %f, \"%s\" );\n",
fprintf( s, "%f", Vec_FltEntry(pWLS->vAreaFrom, j) ); Vec_FltEntry(pWLS->vAreaFrom, j),
fprintf( s, " " ); Vec_FltEntry(pWLS->vAreaTo, j),
fprintf( s, "%f", Vec_FltEntry(pWLS->vAreaTo, j) ); (char *)Vec_PtrEntry(pWLS->vWireLoadModel, j) );
fprintf( s, " " ); fprintf( s, " }\n\n" );
fprintf( s, "%s", (char *)Vec_PtrEntry(pWLS->vWireLoadModel, j) );
fprintf( s, "\n" );
}
} }
fprintf( s, "\n" );
// Write 'cells' vector: // Write 'cells' vector:
n_valid_cells = 0; n_valid_cells = 0;
...@@ -705,32 +690,25 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p ) ...@@ -705,32 +690,25 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p )
if ( !(pCell->seq || pCell->unsupp) ) if ( !(pCell->seq || pCell->unsupp) )
n_valid_cells++; n_valid_cells++;
fprintf( s, "%d", n_valid_cells );
fprintf( s, "\n" );
Vec_PtrForEachEntry( SC_Cell *, p->vCells, pCell, i ) Vec_PtrForEachEntry( SC_Cell *, p->vCells, pCell, i )
{ {
if ( pCell->seq || pCell->unsupp ) if ( pCell->seq || pCell->unsupp )
continue; continue;
fprintf( s, "\nCell:\n" );
fprintf( s, "%s ", pCell->name );
fprintf( s, "%f ", pCell->area );
fprintf( s, "%d", pCell->drive_strength );
fprintf( s, " " );
// Write 'pins': (sorted at this point; first inputs, then outputs)
fprintf( s, "%d ", pCell->n_inputs);
fprintf( s, "%d", pCell->n_outputs);
fprintf( s, "\n" ); fprintf( s, "\n" );
fprintf( s, " cell(%s) {\n", pCell->name );
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 );
Vec_PtrForEachEntryStop( SC_Pin *, pCell->vPins, pPin, j, pCell->n_inputs ) Vec_PtrForEachEntryStop( SC_Pin *, pCell->vPins, pPin, j, pCell->n_inputs )
{ {
assert(pPin->dir == sc_dir_Input); assert(pPin->dir == sc_dir_Input);
fprintf( s, "Pin:\n" ); fprintf( s, " pin(%s) {\n", pPin->name );
fprintf( s, "%s ", pPin->name ); fprintf( s, " direction : %s;\n", "input" );
fprintf( s, "%f ", pPin->rise_cap ); fprintf( s, " fall_capacitance : %f;\n", pPin->fall_cap );
fprintf( s, "%f", pPin->fall_cap ); fprintf( s, " rise_capacitance : %f;\n", pPin->rise_cap );
fprintf( s, "\n" ); fprintf( s, " }\n" );
} }
Vec_PtrForEachEntryStart( SC_Pin *, pCell->vPins, pPin, j, pCell->n_inputs ) Vec_PtrForEachEntryStart( SC_Pin *, pCell->vPins, pPin, j, pCell->n_inputs )
...@@ -738,50 +716,57 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p ) ...@@ -738,50 +716,57 @@ static void Abc_SclWriteLibraryText( FILE * s, SC_Lib * p )
SC_Timings * pRTime; SC_Timings * pRTime;
// word uWord; // word uWord;
assert(pPin->dir == sc_dir_Output); assert(pPin->dir == sc_dir_Output);
fprintf( s, " pin(%s) {\n", pPin->name );
fprintf( s, "Pin:\n" ); fprintf( s, " direction : %s;\n", "output" );
fprintf( s, "%s ", pPin->name ); fprintf( s, " max_capacitance : %f;\n", pPin->max_out_cap );
fprintf( s, "%f ", pPin->max_out_cap ); fprintf( s, " max_transition : %f;\n", pPin->max_out_slew );
fprintf( s, "%f", pPin->max_out_slew ); fprintf( s, " function : \"%s\";\n", pPin->func_text ? pPin->func_text : "?" );
fprintf( s, "\n" ); fprintf( s, " /* truth table = " );
/*
// write function
assert( Vec_WrdSize(pPin->vFunc) == Abc_Truth6WordNum(pCell->n_inputs) );
fprintf( s, "%d", pCell->n_inputs );
Vec_WrdForEachEntry( pPin->vFunc, uWord, k ) // -- 'size = 1u << (n_vars - 6)'
Vec_StrPutW( s, uWord ); // -- 64-bit number, written uncompressed (low-byte first)
*/
Extra_PrintHex( s, (unsigned *)Vec_WrdArray(pPin->vFunc), pCell->n_inputs ); Extra_PrintHex( s, (unsigned *)Vec_WrdArray(pPin->vFunc), pCell->n_inputs );
fprintf( s, "\n" ); fprintf( s, " */\n" );
// Write 'rtiming': (pin-to-pin timing tables for this particular output) // Write 'rtiming': (pin-to-pin timing tables for this particular output)
assert( Vec_PtrSize(pPin->vRTimings) == pCell->n_inputs ); assert( Vec_PtrSize(pPin->vRTimings) == pCell->n_inputs );
Vec_PtrForEachEntry( SC_Timings *, pPin->vRTimings, pRTime, k ) Vec_PtrForEachEntry( SC_Timings *, pPin->vRTimings, pRTime, k )
{ {
fprintf( s, "%s ", pRTime->name );
fprintf( s, "%d", Vec_PtrSize(pRTime->vTimings) );
fprintf( s, "\n" );
// -- NOTE! After post-processing, the size of the 'rtiming[k]' vector is either
// 0 or 1 (in static timing, we have merged all tables to get the worst case).
// The case with size 0 should only occur for multi-output gates.
if ( Vec_PtrSize(pRTime->vTimings) == 1 ) if ( Vec_PtrSize(pRTime->vTimings) == 1 )
{ {
SC_Timing * pTime = (SC_Timing *)Vec_PtrEntry( pRTime->vTimings, 0 ); SC_Timing * pTime = (SC_Timing *)Vec_PtrEntry( pRTime->vTimings, 0 );
// -- NOTE! We don't need to save 'related_pin' string because we have sorted fprintf( s, " timing() {\n" );
// the elements on input pins. fprintf( s, " related_pin : \"%s\"\n", pRTime->name );
fprintf( s, "%d", (int)pTime->tsense); if ( pTime->tsense == sc_ts_Pos )
fprintf( s, "\n" ); fprintf( s, " timing_sense : positive_unate;\n" );
else if ( pTime->tsense == sc_ts_Neg )
fprintf( s, " timing_sense : negative_unate;\n" );
else if ( pTime->tsense == sc_ts_Non )
fprintf( s, " timing_sense : non_unate;\n" );
else assert( 0 );
fprintf( s, " cell_rise() {\n" );
Abc_SclWriteSurfaceText( s, pTime->pCellRise ); Abc_SclWriteSurfaceText( s, pTime->pCellRise );
fprintf( s, " }\n" );
fprintf( s, " cell_fall() {\n" );
Abc_SclWriteSurfaceText( s, pTime->pCellFall ); Abc_SclWriteSurfaceText( s, pTime->pCellFall );
fprintf( s, " }\n" );
fprintf( s, " rise_transition() {\n" );
Abc_SclWriteSurfaceText( s, pTime->pRiseTrans ); Abc_SclWriteSurfaceText( s, pTime->pRiseTrans );
fprintf( s, " }\n" );
fprintf( s, " fall_transition() {\n" );
Abc_SclWriteSurfaceText( s, pTime->pFallTrans ); Abc_SclWriteSurfaceText( s, pTime->pFallTrans );
fprintf( s, " }\n" );
fprintf( s, " }\n" );
} }
else else
assert( Vec_PtrSize(pRTime->vTimings) == 0 ); assert( Vec_PtrSize(pRTime->vTimings) == 0 );
} }
fprintf( s, " }\n" );
} }
fprintf( s, "\n" ); fprintf( s, " }\n" );
} }
fprintf( s, "}\n\n" );
} }
void Abc_SclWriteText( char * pFileName, SC_Lib * p ) void Abc_SclWriteText( char * pFileName, SC_Lib * p )
{ {
......
...@@ -29,6 +29,7 @@ ABC_NAMESPACE_IMPL_START ...@@ -29,6 +29,7 @@ ABC_NAMESPACE_IMPL_START
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis []
...@@ -40,6 +41,9 @@ ABC_NAMESPACE_IMPL_START ...@@ -40,6 +41,9 @@ ABC_NAMESPACE_IMPL_START
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_SclSizingPerform( SC_Lib * pLib, void * pNtk )
{
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -82,6 +82,7 @@ void Abc_SclManFindGates( SC_Man * p ) ...@@ -82,6 +82,7 @@ void Abc_SclManFindGates( SC_Man * p )
gateId = Abc_SclCellFind( p->pLib, pName ); gateId = Abc_SclCellFind( p->pLib, pName );
assert( gateId >= 0 ); assert( gateId >= 0 );
Vec_IntWriteEntry( p->vGates, i, gateId ); Vec_IntWriteEntry( p->vGates, i, gateId );
//printf( "Found gate %s\n", pName );
} }
} }
SC_Man * Abc_SclManAlloc( SC_Lib * pLib, Abc_Ntk_t * pNtk ) SC_Man * Abc_SclManAlloc( SC_Lib * pLib, Abc_Ntk_t * pNtk )
...@@ -133,9 +134,10 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes ) ...@@ -133,9 +134,10 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes )
{ {
Vec_Flt_t * vCaps = NULL; Vec_Flt_t * vCaps = NULL;
SC_WireLoad * pWL = NULL; SC_WireLoad * pWL = NULL;
int i, Entry, EntryPrev, EntryMax; int i, Entry, EntryMax;
float EntryPrev, EntryCur;
p->pWireLoadUsed = NULL; p->pWireLoadUsed = NULL;
if ( p->pLib->default_wire_load_sel ) if ( p->pLib->default_wire_load_sel && strlen(p->pLib->default_wire_load_sel) )
{ {
float Area; float Area;
SC_WireLoadSel * pWLS = NULL; SC_WireLoadSel * pWLS = NULL;
...@@ -157,7 +159,7 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes ) ...@@ -157,7 +159,7 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes )
if ( i == Vec_FltSize(pWLS->vAreaFrom) ) if ( i == Vec_FltSize(pWLS->vAreaFrom) )
p->pWireLoadUsed = (char *)Vec_PtrEntryLast(pWLS->vWireLoadModel); p->pWireLoadUsed = (char *)Vec_PtrEntryLast(pWLS->vWireLoadModel);
} }
else if ( p->pLib->default_wire_load ) else if ( p->pLib->default_wire_load && strlen(p->pLib->default_wire_load) )
p->pWireLoadUsed = p->pLib->default_wire_load; p->pWireLoadUsed = p->pLib->default_wire_load;
else else
{ {
...@@ -184,10 +186,10 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes ) ...@@ -184,10 +186,10 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes )
Vec_FltWriteEntry( vCaps, Entry, Vec_FltEntry(pWL->vLen, i) * pWL->cap ); Vec_FltWriteEntry( vCaps, Entry, Vec_FltEntry(pWL->vLen, i) * pWL->cap );
// reformat // reformat
EntryPrev = 0; EntryPrev = 0;
Vec_FltForEachEntry( vCaps, Entry, i ) Vec_FltForEachEntry( vCaps, EntryCur, i )
{ {
if ( Entry ) if ( EntryCur )
EntryPrev = Entry; EntryPrev = EntryCur;
else else
Vec_FltWriteEntry( vCaps, i, EntryPrev ); Vec_FltWriteEntry( vCaps, i, EntryPrev );
} }
...@@ -205,6 +207,97 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes ) ...@@ -205,6 +207,97 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_SclComputeLoad( SC_Man * p, Vec_Ptr_t * vNodes, Vec_Flt_t * vWireCaps )
{
Abc_Obj_t * pObj, * pFanin;
int i, k;
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Cell * pCell = Abc_SclObjCell( p, pObj );
Abc_ObjForEachFanin( pObj, pFanin, k )
{
SC_Pin * pPin = SC_CellPin( pCell, k );
SC_Pair * pLoad = Abc_SclObjLoad( p, pFanin );
pLoad->rise += pPin->rise_cap;
pLoad->fall += pPin->fall_cap;
}
}
if ( vWireCaps )
{
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
k = Abc_MinInt( Vec_FltSize(vWireCaps)-1, Abc_ObjFanoutNum(pObj) );
pLoad->rise += Vec_FltEntry(vWireCaps, k);
pLoad->fall += Vec_FltEntry(vWireCaps, k);
}
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Obj_t * Abc_SclFindMostCritical( SC_Man * p, int * pfRise, Vec_Ptr_t * vNodes )
{
Abc_Obj_t * pObj, * pPivot = NULL;
float fMaxArr = 0;
int i;
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Pair * pArr = Abc_SclObjArr( p, pObj );
if ( fMaxArr < pArr->rise ) fMaxArr = pArr->rise, *pfRise = 1, pPivot = pObj;
if ( fMaxArr < pArr->fall ) fMaxArr = pArr->fall, *pfRise = 0, pPivot = pObj;
}
assert( pPivot != NULL );
return pPivot;
}
void Abc_SclTimeNtkPrint( SC_Man * p, Vec_Ptr_t * vNodes )
{
/*
int fRise = 0;
Abc_Obj_t * pPivot = Abc_SclFindMostCritical( p, &fRise, vNodes );
printf( "Critical delay: ObjId = %d. ", Abc_ObjId(pPivot) );
printf( "Rise = %f. ", Abc_SclObjArr(p, pPivot)->rise );
printf( "Fall = %f. ", Abc_SclObjArr(p, pPivot)->fall );
printf( "\n" );
*/
Abc_Obj_t * pObj;
int i;
printf( "WireLoad model = \"%s\".\n", p->pWireLoadUsed );
printf( "Area = %f.\n", Abc_SclTotalArea( p, vNodes ) );
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
printf( "Node %6d : ", Abc_ObjId(pObj) );
printf( "TimeR = %f. ", Abc_SclObjArr(p, pObj)->rise );
printf( "RimeF = %f. ", Abc_SclObjArr(p, pObj)->fall );
printf( "SlewR = %f. ", Abc_SclObjSlew(p, pObj)->rise );
printf( "SlewF = %f. ", Abc_SclObjSlew(p, pObj)->fall );
printf( "LoadR = %f. ", Abc_SclObjLoad(p, pObj)->rise );
printf( "LoadF = %f. ", Abc_SclObjLoad(p, pObj)->fall );
printf( "\n" );
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline float Abc_SclLookup( SC_Surface * p, float slew, float load ) static inline float Abc_SclLookup( SC_Surface * p, float slew, float load )
{ {
float * pIndex0, * pIndex1, * pDataS, * pDataS1; float * pIndex0, * pIndex1, * pDataS, * pDataS1;
...@@ -238,51 +331,25 @@ static inline float Abc_SclLookup( SC_Surface * p, float slew, float load ) ...@@ -238,51 +331,25 @@ static inline float Abc_SclLookup( SC_Surface * p, float slew, float load )
} }
void Abc_SclTimeGate( SC_Man * p, SC_Timing * pTime, Abc_Obj_t * pObj, Abc_Obj_t * pFanin ) void Abc_SclTimeGate( SC_Man * p, SC_Timing * pTime, Abc_Obj_t * pObj, Abc_Obj_t * pFanin )
{ {
SC_Pair * pArrIn = Abc_SclObjLoad( p, pFanin ); SC_Pair * pArrIn = Abc_SclObjArr ( p, pFanin );
SC_Pair * pSlewIn = Abc_SclObjLoad( p, pFanin ); SC_Pair * pSlewIn = Abc_SclObjSlew( p, pFanin );
SC_Pair * pLoad = Abc_SclObjLoad( p, pObj ); SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
SC_Pair * pArrOut = Abc_SclObjLoad( p, pObj ); // modified SC_Pair * pArrOut = Abc_SclObjArr ( p, pObj ); // modified
SC_Pair * pSlewOut = Abc_SclObjLoad( p, pObj ); // modified SC_Pair * pSlewOut = Abc_SclObjSlew( p, pObj ); // modified
if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non) if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
{ {
pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->rise + Abc_SclLookup(pTime->pCellRise, pSlewIn->rise, pLoad->rise) ); pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->rise + Abc_SclLookup(pTime->pCellRise, pSlewIn->rise, pLoad->rise) );
pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->fall + Abc_SclLookup(pTime->pCellFall, pSlewIn->fall, pLoad->fall) ); pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->fall + Abc_SclLookup(pTime->pCellFall, pSlewIn->fall, pLoad->fall) );
pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Abc_SclLookup(pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) ); pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Abc_SclLookup(pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) );
pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Abc_SclLookup(pTime->pFallTrans, pSlewIn->fall, pLoad->fall) ); pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Abc_SclLookup(pTime->pFallTrans, pSlewIn->fall, pLoad->fall) );
} }
if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non) if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
{ {
pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->fall + Abc_SclLookup(pTime->pCellRise, pSlewIn->fall, pLoad->rise) ); pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->fall + Abc_SclLookup(pTime->pCellRise, pSlewIn->fall, pLoad->rise) );
pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->rise + Abc_SclLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) ); pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->rise + Abc_SclLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Abc_SclLookup(pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) ); pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Abc_SclLookup(pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) );
pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Abc_SclLookup(pTime->pFallTrans, pSlewIn->rise, pLoad->fall) ); pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Abc_SclLookup(pTime->pFallTrans, pSlewIn->rise, pLoad->fall) );
}
}
void Abc_SclComputeLoad( SC_Man * p, Vec_Ptr_t * vNodes, Vec_Flt_t * vWireCaps )
{
Abc_Obj_t * pObj, * pFanin;
int i, k;
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Cell * pCell = Abc_SclObjCell( p, pObj );
Abc_ObjForEachFanin( pObj, pFanin, k )
{
SC_Pin * pPin = SC_CellPin( pCell, k );
SC_Pair * pLoad = Abc_SclObjLoad( p, pFanin );
pLoad->rise += pPin->rise_cap;
pLoad->fall += pPin->fall_cap;
}
}
if ( vWireCaps )
{
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
k = Abc_MinInt( Vec_FltSize(vWireCaps)-1, Abc_ObjFanoutNum(pObj) );
pLoad->rise += Vec_FltEntry(vWireCaps, k);
pLoad->fall += Vec_FltEntry(vWireCaps, k);
}
} }
} }
void Abc_SclTimeNtk( SC_Man * p ) void Abc_SclTimeNtk( SC_Man * p )
...@@ -313,6 +380,8 @@ void Abc_SclTimeNtk( SC_Man * p ) ...@@ -313,6 +380,8 @@ void Abc_SclTimeNtk( SC_Man * p )
Abc_SclTimeGate( p, pTime, pObj, Abc_ObjFanin(pObj, k) ); Abc_SclTimeGate( p, pTime, pObj, Abc_ObjFanin(pObj, k) );
} }
} }
Abc_SclTimeNtkPrint( p, vNodes );
Vec_FltFree( vWireCaps );
Vec_PtrFree( vNodes ); Vec_PtrFree( vNodes );
} }
...@@ -327,27 +396,11 @@ void Abc_SclTimeNtk( SC_Man * p ) ...@@ -327,27 +396,11 @@ void Abc_SclTimeNtk( SC_Man * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_SclTimeNtkPrint( SC_Man * p )
{
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_SclTimePerform( SC_Lib * pLib, void * pNtk ) void Abc_SclTimePerform( SC_Lib * pLib, void * pNtk )
{ {
SC_Man * p; SC_Man * p;
p = Abc_SclManAlloc( pLib, (Abc_Ntk_t *)pNtk ); p = Abc_SclManAlloc( pLib, (Abc_Ntk_t *)pNtk );
Abc_SclTimeNtk( p ); Abc_SclTimeNtk( p );
Abc_SclTimeNtkPrint( p );
Abc_SclManFree( p ); Abc_SclManFree( p );
} }
......
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