diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-08-31 09:26:26 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-08-31 09:26:26 -0700 |
commit | 8c0e0d7143961f2f575478ca815438817587a90f (patch) | |
tree | faaceda1d9a40c8ae90ad2d4ad58bca76181fe85 | |
parent | e63c603e926d85040503d6a6caf73419d1837bae (diff) | |
download | abc-8c0e0d7143961f2f575478ca815438817587a90f.tar.gz abc-8c0e0d7143961f2f575478ca815438817587a90f.tar.bz2 abc-8c0e0d7143961f2f575478ca815438817587a90f.zip |
Added command 'print_gs' to print gate sizes in the mapping.
-rw-r--r-- | src/map/scl/scl.c | 67 | ||||
-rw-r--r-- | src/map/scl/sclInt.h | 1 | ||||
-rw-r--r-- | src/map/scl/sclSize.c | 33 | ||||
-rw-r--r-- | src/map/scl/sclTime.c | 1 | ||||
-rw-r--r-- | src/map/scl/sclUtil.c | 46 |
5 files changed, 141 insertions, 7 deletions
diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c index a730322c..61288ccf 100644 --- a/src/map/scl/scl.c +++ b/src/map/scl/scl.c @@ -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 ) { @@ -229,6 +231,59 @@ usage: 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 [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ int Scl_CommandStime( Abc_Frame_t * pAbc, int argc, char **argv ) { int c; diff --git a/src/map/scl/sclInt.h b/src/map/scl/sclInt.h index baf1d146..da2569ba 100644 --- a/src/map/scl/sclInt.h +++ b/src/map/scl/sclInt.h @@ -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 ); diff --git a/src/map/scl/sclSize.c b/src/map/scl/sclSize.c index 3baeb2c2..4be4fd5b 100644 --- a/src/map/scl/sclSize.c +++ b/src/map/scl/sclSize.c @@ -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 [] diff --git a/src/map/scl/sclTime.c b/src/map/scl/sclTime.c index bdad7f7c..5556ec55 100644 --- a/src/map/scl/sclTime.c +++ b/src/map/scl/sclTime.c @@ -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 ); diff --git a/src/map/scl/sclUtil.c b/src/map/scl/sclUtil.c index 2ae0ddca..b0fdda05 100644 --- a/src/map/scl/sclUtil.c +++ b/src/map/scl/sclUtil.c @@ -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 /// |