diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-03-23 22:29:25 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-03-23 22:29:25 -0700 |
commit | 1c31dbe7861e1b5313dd6de8c34951aeb5e4b35c (patch) | |
tree | 2ff4f77ca361607b302a918b97f747008fb32238 /src/base | |
parent | 0792ab0eb630da4a46b117367f86a6c7a8ab94a0 (diff) | |
download | abc-1c31dbe7861e1b5313dd6de8c34951aeb5e4b35c.tar.gz abc-1c31dbe7861e1b5313dd6de8c34951aeb5e4b35c.tar.bz2 abc-1c31dbe7861e1b5313dd6de8c34951aeb5e4b35c.zip |
Added command 'addbuffs' to create balanced CI/CO paths.
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/abc/abcUtil.c | 57 | ||||
-rw-r--r-- | src/base/abci/abc.c | 66 |
2 files changed, 123 insertions, 0 deletions
diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c index 3651e61a..4bf881bc 100644 --- a/src/base/abc/abcUtil.c +++ b/src/base/abc/abcUtil.c @@ -2001,9 +2001,66 @@ void Abc_NtkPrintCiLevels( Abc_Ntk_t * pNtk ) Abc_NtkForEachCi( pNtk, pObj, i ) printf( "%c=%d ", 'a'+i, pObj->Level ); printf( "\n" ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] +***********************************************************************/ +Abc_Obj_t * Abc_NtkAddBuffsOne( Vec_Ptr_t * vBuffs, Abc_Obj_t * pFanin, int Level, int nLevelMax ) +{ + Abc_Obj_t * pBuffer; + assert( Level - 1 >= Abc_ObjLevel(pFanin) ); + pBuffer = (Abc_Obj_t *)Vec_PtrEntry( vBuffs, Abc_ObjId(pFanin) * nLevelMax + Level ); + if ( pBuffer == NULL ) + { + if ( Level - 1 == Abc_ObjLevel(pFanin) ) + pBuffer = pFanin; + else + pBuffer = Abc_NtkAddBuffsOne( vBuffs, pFanin, Level - 1, nLevelMax ); + pBuffer = Abc_NtkCreateNodeBuf( Abc_ObjNtk(pFanin), pBuffer ); + Vec_PtrWriteEntry( vBuffs, Abc_ObjId(pFanin) * nLevelMax + Level, pBuffer ); + } + return pBuffer; +} +Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtkInit, int fVerbose ) +{ + Vec_Ptr_t * vBuffs; + Abc_Ntk_t * pNtk = Abc_NtkDup( pNtkInit ); + Abc_Obj_t * pObj, * pFanin, * pBuffer; + int i, k, nLevelMax = Abc_NtkLevel( pNtk ); + Abc_NtkForEachCo( pNtk, pObj, i ) + pObj->Level = nLevelMax + 1; + vBuffs = Vec_PtrStart( Abc_NtkObjNumMax(pNtk) * nLevelMax ); + Abc_NtkForEachObj( pNtk, pObj, i ) + { + if ( i == Vec_PtrSize(vBuffs) / nLevelMax ) + break; + if ( !Abc_ObjIsNode(pObj) && !Abc_ObjIsCo(pObj) ) + continue; + Abc_ObjForEachFanin( pObj, pFanin, k ) + { + assert( Abc_ObjLevel(pObj) - 1 >= Abc_ObjLevel(pFanin) ); + if ( Abc_ObjLevel(pObj) - 1 == Abc_ObjLevel(pFanin) ) + continue; + pBuffer = Abc_NtkAddBuffsOne( vBuffs, pFanin, Abc_ObjLevel(pObj) - 1, nLevelMax ); + Abc_ObjPatchFanin( pObj, pFanin, pBuffer ); + } + } + Vec_PtrFree( vBuffs ); + Abc_NtkForEachCo( pNtk, pObj, i ) + pObj->Level = 0; + return pNtk; } + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 3ca2aab2..1fdceb32 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -106,6 +106,7 @@ static int Abc_CommandMfs ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandTrace ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSpeedup ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPowerdown ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAddBuffs ( Abc_Frame_t * pAbc, int argc, char ** argv ); //static int Abc_CommandMerge ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -550,6 +551,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Synthesis", "trace", Abc_CommandTrace, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "speedup", Abc_CommandSpeedup, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "powerdown", Abc_CommandPowerdown, 1 ); + Cmd_CommandAdd( pAbc, "Synthesis", "addbuffs", Abc_CommandAddBuffs, 1 ); // Cmd_CommandAdd( pAbc, "Synthesis", "merge", Abc_CommandMerge, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "rewrite", Abc_CommandRewrite, 1 ); @@ -4526,6 +4528,70 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAddBuffs( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Abc_Ntk_t * Abc_NtkAddBuffs( Abc_Ntk_t * pNtk, int fVerbose ); + Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); + Abc_Ntk_t * pNtkRes; + int c, fVerbose; + + fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + + if ( pNtk == NULL ) + { + Abc_Print( -1, "Empty network.\n" ); + return 1; + } + if ( !Abc_NtkIsLogic(pNtk) ) + { + Abc_Print( -1, "This command can only be applied to a logic network.\n" ); + return 1; + } + + // modify the current network + pNtkRes = Abc_NtkAddBuffs( pNtk, fVerbose ); + if ( pNtkRes == NULL ) + { + Abc_Print( -1, "The command has failed.\n" ); + return 1; + } + // replace the current network + Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); + return 0; + +usage: + Abc_Print( -2, "usage: addbuffs [-vh]\n" ); + Abc_Print( -2, "\t adds buffers to create balanced CI/CO paths\n" ); + Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + #if 0 /**Function************************************************************* |