mirror of https://github.com/YosysHQ/abc.git
Added command 'print_gs' to print gate sizes in the mapping.
This commit is contained in:
parent
e63c603e92
commit
8c0e0d7143
|
|
@ -31,6 +31,7 @@ ABC_NAMESPACE_IMPL_START
|
|||
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_CommandPrint ( 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 );
|
||||
static int Scl_CommandBuffer ( Abc_Frame_t * pAbc, int argc, char **argv );
|
||||
static int Scl_CommandGsize ( Abc_Frame_t * pAbc, int argc, char **argv );
|
||||
|
|
@ -52,12 +53,13 @@ static int Scl_CommandGsize ( Abc_Frame_t * pAbc, int argc, char **argv );
|
|||
***********************************************************************/
|
||||
void Scl_Init( Abc_Frame_t * pAbc )
|
||||
{
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "read_scl", Scl_CommandRead, 0 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "write_scl", Scl_CommandWrite, 0 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "print_scl", Scl_CommandPrint, 0 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "buffer", Scl_CommandBuffer, 1 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "gsize", Scl_CommandGsize, 1 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "read_scl", Scl_CommandRead, 0 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "write_scl", Scl_CommandWrite, 0 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "print_scl", Scl_CommandPrint, 0 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "print_gs", Scl_CommandPrintGS, 0 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "buffer", Scl_CommandBuffer, 1 );
|
||||
Cmd_CommandAdd( pAbc, "SCL mapping", "gsize", Scl_CommandGsize, 1 );
|
||||
}
|
||||
void Scl_End( Abc_Frame_t * pAbc )
|
||||
{
|
||||
|
|
@ -218,6 +220,59 @@ usage:
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Scl_CommandPrintGS( 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;
|
||||
}
|
||||
|
||||
// save current library
|
||||
Abc_SclPrintGateSizes( pAbc->pLibScl, Abc_FrameReadNtk(pAbc) );
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
fprintf( pAbc->Err, "usage: print_gs [-h]\n" );
|
||||
fprintf( pAbc->Err, "\t prints gate sizes in the current mapping\n" );
|
||||
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
|
|
@ -423,6 +423,7 @@ extern void Abc_SclLinkCells( SC_Lib * p );
|
|||
extern void Abc_SclPrintCells( SC_Lib * p );
|
||||
extern Vec_Int_t * Abc_SclManFindGates( SC_Lib * pLib, Abc_Ntk_t * p );
|
||||
extern void Abc_SclManSetGates( SC_Lib * pLib, Abc_Ntk_t * p, Vec_Int_t * vGates );
|
||||
extern void Abc_SclPrintGateSizes( SC_Lib * pLib, Abc_Ntk_t * p );
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ Vec_Int_t * Abc_SclCollectTfo( Abc_Ntk_t * p, Abc_Obj_t * pObj, Vec_Int_t * vPiv
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
SC_Cell * Abc_SclObjResiable( SC_Man * p, Abc_Obj_t * pObj, int fUpsize )
|
||||
static inline SC_Cell * Abc_SclObjResiable( SC_Man * p, Abc_Obj_t * pObj, int fUpsize )
|
||||
{
|
||||
SC_Cell * pOld = Abc_SclObjCell( p, pObj );
|
||||
if ( fUpsize )
|
||||
|
|
@ -353,6 +353,37 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int nCone, int fUpsize,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Begin by upsizing gates will many fanouts.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Abc_SclManUpsize( SC_Man * p )
|
||||
{
|
||||
SC_Cell * pOld, * pNew;
|
||||
Abc_Obj_t * pObj;
|
||||
int i;
|
||||
Abc_NtkForEachNode1( p->pNtk, pObj, i )
|
||||
{
|
||||
if ( Abc_ObjFanoutNum(pObj) <= 2 )
|
||||
continue;
|
||||
// find new gate
|
||||
pOld = Abc_SclObjCell( p, pObj );
|
||||
pNew = Abc_SclObjResiable( p, pObj, 1 );
|
||||
if ( pNew == NULL )
|
||||
continue;
|
||||
Vec_IntWriteEntry( p->vGates, Abc_ObjId(pObj), Abc_SclCellFind(p->pLib, pNew->pName) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
|
|||
|
|
@ -262,6 +262,7 @@ SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk )
|
|||
SC_Man * p = Abc_SclManAlloc( pLib, pNtk );
|
||||
assert( p->vGates == NULL );
|
||||
p->vGates = Abc_SclManFindGates( pLib, pNtk );
|
||||
// Abc_SclManUpsize( p );
|
||||
Abc_SclComputeLoad( p );
|
||||
Abc_SclTimeNtk( p );
|
||||
p->SumArea = p->SumArea0 = Abc_SclGetTotalArea( p );
|
||||
|
|
|
|||
|
|
@ -221,6 +221,52 @@ void Abc_SclManSetGates( SC_Lib * pLib, Abc_Ntk_t * p, Vec_Int_t * vGates )
|
|||
}
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Reports percentage of gates of each size.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
#define ABC_SCL_MAX_SIZE 64
|
||||
void Abc_SclManPrintGateSizes( SC_Lib * pLib, Abc_Ntk_t * p, Vec_Int_t * vGates )
|
||||
{
|
||||
Abc_Obj_t * pObj;
|
||||
int i, nGates = 0, Counters[ABC_SCL_MAX_SIZE] = {0};
|
||||
double TotArea = 0, Areas[ABC_SCL_MAX_SIZE] = {0};
|
||||
Abc_NtkForEachNode1( p, pObj, i )
|
||||
{
|
||||
SC_Cell * pCell = SC_LibCell( pLib, Vec_IntEntry(vGates, Abc_ObjId(pObj)) );
|
||||
assert( pCell->Order < ABC_SCL_MAX_SIZE );
|
||||
Counters[pCell->Order]++;
|
||||
Areas[pCell->Order] += pCell->area;
|
||||
TotArea += pCell->area;
|
||||
nGates++;
|
||||
}
|
||||
printf( "Total gates = %d. Total area = %.1f\n", nGates, TotArea );
|
||||
for ( i = 0; i < ABC_SCL_MAX_SIZE; i++ )
|
||||
{
|
||||
if ( Counters[i] == 0 )
|
||||
continue;
|
||||
printf( "Cell size = %d. ", i );
|
||||
printf( "Count = %6d ", Counters[i] );
|
||||
printf( "(%5.1f %%) ", 100.0 * Counters[i] / nGates );
|
||||
printf( "Area = %12.1f ", Areas[i] );
|
||||
printf( "(%5.1f %%) ", 100.0 * Areas[i] / TotArea );
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
void Abc_SclPrintGateSizes( SC_Lib * pLib, Abc_Ntk_t * p )
|
||||
{
|
||||
Vec_Int_t * vGates;
|
||||
vGates = Abc_SclManFindGates( pLib, p );
|
||||
Abc_SclManPrintGateSizes( pLib, p, vGates );
|
||||
Vec_IntFree( vGates );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
|
|
|
|||
Loading…
Reference in New Issue