diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-09-12 14:39:50 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-09-12 14:39:50 -0700 |
commit | 9b15f71f2f82dfe5a222fceed135640be8cc5dfb (patch) | |
tree | 4709f96ea03198a1f65bb9e2105d5b7545712411 | |
parent | e3d75484ce558d862f7dfc80de9e88b56360b084 (diff) | |
download | abc-9b15f71f2f82dfe5a222fceed135640be8cc5dfb.tar.gz abc-9b15f71f2f82dfe5a222fceed135640be8cc5dfb.tar.bz2 abc-9b15f71f2f82dfe5a222fceed135640be8cc5dfb.zip |
Added new command 'upsize'.
-rw-r--r-- | src/map/scl/module.make | 1 | ||||
-rw-r--r-- | src/map/scl/scl.c | 89 | ||||
-rw-r--r-- | src/map/scl/sclInt.h | 2 | ||||
-rw-r--r-- | src/map/scl/sclMan.h | 26 | ||||
-rw-r--r-- | src/map/scl/sclSize.c | 38 | ||||
-rw-r--r-- | src/map/scl/sclTime.c | 15 | ||||
-rw-r--r-- | src/map/scl/sclUpsize.c | 114 |
7 files changed, 241 insertions, 44 deletions
diff --git a/src/map/scl/module.make b/src/map/scl/module.make index 72afe653..7ba331de 100644 --- a/src/map/scl/module.make +++ b/src/map/scl/module.make @@ -4,4 +4,5 @@ SRC += src/map/scl/scl.c \ src/map/scl/sclLoad.c \ src/map/scl/sclSize.c \ src/map/scl/sclTime.c \ + src/map/scl/sclUpsize.c \ src/map/scl/sclUtil.c diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c index 337c5a05..35423beb 100644 --- a/src/map/scl/scl.c +++ b/src/map/scl/scl.c @@ -36,6 +36,7 @@ static int Scl_CommandStime ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandTopo ( 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 ); +static int Scl_CommandUpsize ( Abc_Frame_t * pAbc, int argc, char **argv ); //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -62,6 +63,7 @@ void Scl_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "SCL mapping", "topo", Scl_CommandTopo, 1 ); Cmd_CommandAdd( pAbc, "SCL mapping", "buffer", Scl_CommandBuffer, 1 ); Cmd_CommandAdd( pAbc, "SCL mapping", "gsize", Scl_CommandGsize, 1 ); + Cmd_CommandAdd( pAbc, "SCL mapping", "upsize", Scl_CommandUpsize, 1 ); } void Scl_End( Abc_Frame_t * pAbc ) { @@ -621,6 +623,93 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) +{ + Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); + int Degree = 2; + int nRange = 5; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "NWvh" ) ) != EOF ) + { + switch ( c ) + { + case 'N': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" ); + goto usage; + } + Degree = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( Degree < 0 ) + goto usage; + break; + case 'W': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" ); + goto usage; + } + nRange = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nRange < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + 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 ( !Abc_SclCheckNtk(Abc_FrameReadNtk(pAbc), 0) ) + { + fprintf( pAbc->Err, "The current networks is not in a topo order (run \"topo\").\n" ); + return 1; + } + if ( pAbc->pLibScl == NULL ) + { + fprintf( pAbc->Err, "There is no Liberty library available.\n" ); + return 1; + } + + Abc_SclUpsizingPerform( pAbc->pLibScl, pNtk, Degree, nRange, fVerbose ); + return 0; + +usage: + fprintf( pAbc->Err, "usage: upsize [-NW num] [-vh]\n" ); + fprintf( pAbc->Err, "\t selectively increases gate sizes in timing-critical regions\n" ); + fprintf( pAbc->Err, "\t-N <num> : the max fanout count of gates to upsize [default = %d]\n", Degree ); + fprintf( pAbc->Err, "\t-W <num> : delay window (in percents) of near-critical COs [default = %d]\n", nRange ); + fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + fprintf( pAbc->Err, "\t-h : print the command usage\n"); + return 1; +} //////////////////////////////////////////////////////////////////////// /// END OF FILE /// diff --git a/src/map/scl/sclInt.h b/src/map/scl/sclInt.h index c674c82e..40f0a460 100644 --- a/src/map/scl/sclInt.h +++ b/src/map/scl/sclInt.h @@ -435,6 +435,8 @@ extern void Abc_SclSave( char * pFileName, SC_Lib * pScl ); extern void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fShowAll, int fUseWireLoads ); /*=== sclSize.c =============================================================*/ extern void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * p ); +/*=== sclUpsize.c =============================================================*/ +extern void Abc_SclUpsizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int Degree, int nRange, int fVerbose ); /*=== sclUtil.c =============================================================*/ extern void Abc_SclHashCells( SC_Lib * p ); extern int Abc_SclCellFind( SC_Lib * p, char * pName ); diff --git a/src/map/scl/sclMan.h b/src/map/scl/sclMan.h index 228ff8c9..1c6382ba 100644 --- a/src/map/scl/sclMan.h +++ b/src/map/scl/sclMan.h @@ -131,6 +131,11 @@ static inline void Abc_SclManFree( SC_Man * p ) ABC_FREE( p->pSlews2 ); ABC_FREE( p ); } +static inline void Abc_SclManCleanTime( SC_Man * p ) +{ + memset( p->pTimes, 0, sizeof(SC_Pair) * p->nObjs ); + memset( p->pSlews, 0, sizeof(SC_Pair) * p->nObjs ); +} /**Function************************************************************* @@ -206,6 +211,26 @@ static inline float Abc_SclGetMaxDelayNode( SC_Man * p, Abc_Obj_t * pNode ) return fMaxArr; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline SC_Cell * Abc_SclObjResiable( SC_Man * p, Abc_Obj_t * pObj, int fUpsize ) +{ + SC_Cell * pOld = Abc_SclObjCell( p, pObj ); + if ( fUpsize ) + return pOld->pNext->Order > pOld->Order ? pOld->pNext : NULL; + else + return pOld->pPrev->Order < pOld->Order ? pOld->pPrev : NULL; +} + /*=== sclTime.c =============================================================*/ extern Abc_Obj_t * Abc_SclFindCriticalCo( SC_Man * p, int * pfRise ); @@ -213,6 +238,7 @@ extern Abc_Obj_t * Abc_SclFindMostCriticalFanin( SC_Man * p, int * pfRise, Abc_O extern void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll ); extern SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads ); extern void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone ); +extern void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay ); /*=== sclTime.c =============================================================*/ extern void Abc_SclComputeLoad( SC_Man * p ); extern void Abc_SclUpdateLoad( SC_Man * p, Abc_Obj_t * pObj, SC_Cell * pOld, SC_Cell * pNew ); diff --git a/src/map/scl/sclSize.c b/src/map/scl/sclSize.c index 6b6e2778..a5f99191 100644 --- a/src/map/scl/sclSize.c +++ b/src/map/scl/sclSize.c @@ -246,14 +246,6 @@ Vec_Int_t * Abc_SclCollectTfo( Abc_Ntk_t * p, Abc_Obj_t * pObj, Vec_Int_t * vPiv SeeAlso [] ***********************************************************************/ -static inline SC_Cell * Abc_SclObjResiable( SC_Man * p, Abc_Obj_t * pObj, int fUpsize ) -{ - SC_Cell * pOld = Abc_SclObjCell( p, pObj ); - if ( fUpsize ) - return pOld->pNext->Order > pOld->Order ? pOld->pNext : NULL; - else - return pOld->pPrev->Order < pOld->Order ? pOld->pPrev : NULL; -} float Abc_SclSizingGain( SC_Man * p, Abc_Obj_t * pPivot, Vec_Int_t * vPivots, int fUpsize ) { double dGain = 0; @@ -356,36 +348,6 @@ 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 [] Description [] diff --git a/src/map/scl/sclTime.c b/src/map/scl/sclTime.c index 6b5031c1..202cf96b 100644 --- a/src/map/scl/sclTime.c +++ b/src/map/scl/sclTime.c @@ -250,14 +250,20 @@ void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone ) printf( "after (%6.1f ps %6.1f ps)\n", Abc_SclObjTimePs(p, pObj, 1), Abc_SclObjTimePs(p, pObj, 0) ); } } -void Abc_SclTimeNtk( SC_Man * p ) +void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay ) { Abc_Obj_t * pObj; int i; + Abc_SclComputeLoad( p ); + Abc_SclManCleanTime( p ); Abc_NtkForEachNode1( p->pNtk, pObj, i ) Abc_SclTimeGate( p, pObj ); Abc_NtkForEachCo( p->pNtk, pObj, i ) Abc_SclObjDupFanin( p, pObj ); + if ( pArea ) + *pArea = Abc_SclGetTotalArea( p ); + if ( pDelay ) + *pDelay = Abc_SclGetMaxDelay( p ); } /**Function************************************************************* @@ -277,11 +283,8 @@ SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads ) p->fUseWireLoads = fUseWireLoads; 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 ); - p->MaxDelay0 = Abc_SclGetMaxDelay( p ); + Abc_SclTimeNtkRecompute( p, &p->SumArea0, &p->MaxDelay0 ); + p->SumArea = p->SumArea0; return p; } diff --git a/src/map/scl/sclUpsize.c b/src/map/scl/sclUpsize.c new file mode 100644 index 00000000..27631d0a --- /dev/null +++ b/src/map/scl/sclUpsize.c @@ -0,0 +1,114 @@ +/**CFile**************************************************************** + + FileName [sclUpsize.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Standard-cell library representation.] + + Synopsis [Selective increase of gate sizes.] + + Author [Alan Mishchenko, Niklas Een] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - August 24, 2012.] + + Revision [$Id: sclUpsize.c,v 1.0 2012/08/24 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "sclInt.h" +#include "sclMan.h" + +ABC_NAMESPACE_IMPL_START + + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Begin by upsizing gates will many fanouts.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_SclManUpsize( SC_Man * p, int Degree ) +{ + SC_Cell * pOld, * pNew; + Abc_Obj_t * pObj; + int i, Count = 0; + Abc_NtkForEachNode1( p->pNtk, pObj, i ) + { + if ( Abc_ObjFanoutNum(pObj) < Degree ) + 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) ); + Count++; + } + return Count; +} + + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Abc_SclUpsizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int Degree, int nRange, int fVerbose ) +{ + SC_Man * p; + int nUpsizes; + + // prepare the manager; collect init stats + p = Abc_SclManStart( pLib, pNtk, 1 ); + + // perform upsizing + nUpsizes = Abc_SclManUpsize( p, Degree ); + + // recompute timing + Abc_SclTimeNtkRecompute( p, &p->SumArea, &p->MaxDelay ); + + // print cumulative statistics + printf( "Resized: %d. ", nUpsizes ); + printf( "Delay: " ); + printf( "%.2f -> %.2f ps ", SC_LibTimePs(p->pLib, p->MaxDelay0), SC_LibTimePs(p->pLib, p->MaxDelay) ); + printf( "(%+.1f %%). ", 100.0 * (p->MaxDelay - p->MaxDelay0)/ p->MaxDelay0 ); + printf( "Area: " ); + printf( "%.2f -> %.2f ", p->SumArea0, p->SumArea ); + printf( "(%+.1f %%). ", 100.0 * (p->SumArea - p->SumArea0)/ p->SumArea0 ); + Abc_PrintTime( 1, "Time", clock() - p->clkStart ); + + // save the result and quit + Abc_SclManSetGates( pLib, pNtk, p->vGates ); // updates gate pointers + Abc_SclManFree( p ); +} + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + +ABC_NAMESPACE_IMPL_END + |