mirror of https://github.com/YosysHQ/abc.git
Added command 'addbuffs' to create balanced CI/CO paths.
This commit is contained in:
parent
0792ab0eb6
commit
1c31dbe786
|
|
@ -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 ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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*************************************************************
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue