From faf9c2015a94522bfbaaf6293316bdfb6862f046 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 18 Mar 2014 14:20:03 -0700 Subject: Updating code to support barrier buffers. --- src/base/abc/abc.h | 2 ++ src/base/abc/abcAig.c | 2 ++ src/base/abc/abcDfs.c | 24 ++++++++++++++++++++---- src/base/abc/abcShow.c | 4 ++++ src/base/abci/abcBalance.c | 23 +++++++++++++++++------ 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index 2c371ce6..93e0d02b 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -507,6 +507,8 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At for ( i = 0; (i < Abc_NtkPoNum(pNtk)) && (((pPo) = Abc_NtkPo(pNtk, i)), 1); i++ ) #define Abc_NtkForEachCo( pNtk, pCo, i ) \ for ( i = 0; (i < Abc_NtkCoNum(pNtk)) && (((pCo) = Abc_NtkCo(pNtk, i)), 1); i++ ) +#define Abc_NtkForEachLiPo( pNtk, pCo, i ) \ +for ( i = 0; (i < Abc_NtkCoNum(pNtk)) && (((pCo) = Abc_NtkCo(pNtk, i < pNtk->nBarBufs ? Abc_NtkCoNum(pNtk) - pNtk->nBarBufs + i : i - pNtk->nBarBufs)), 1); i++ ) // fanin and fanouts #define Abc_ObjForEachFanin( pObj, pFanin, i ) \ for ( i = 0; (i < Abc_ObjFaninNum(pObj)) && (((pFanin) = Abc_ObjFanin(pObj, i)), 1); i++ ) diff --git a/src/base/abc/abcAig.c b/src/base/abc/abcAig.c index 7bd44932..d3347a13 100644 --- a/src/base/abc/abcAig.c +++ b/src/base/abc/abcAig.c @@ -294,6 +294,8 @@ int Abc_AigLevel( Abc_Ntk_t * pNtk ) Abc_Obj_t * pNode; int i, LevelsMax; assert( Abc_NtkIsStrash(pNtk) ); + if ( pNtk->nBarBufs ) + return Abc_NtkLevel( pNtk ); // perform the traversal LevelsMax = 0; Abc_NtkForEachCo( pNtk, pNode, i ) diff --git a/src/base/abc/abcDfs.c b/src/base/abc/abcDfs.c index dd8b2644..9a483f18 100644 --- a/src/base/abc/abcDfs.c +++ b/src/base/abc/abcDfs.c @@ -1139,11 +1139,27 @@ int Abc_NtkLevel( Abc_Ntk_t * pNtk ) // perform the traversal LevelsMax = 0; Abc_NtkIncrementTravId( pNtk ); - Abc_NtkForEachNode( pNtk, pNode, i ) + if ( pNtk->nBarBufs == 0 ) { - Abc_NtkLevel_rec( pNode ); - if ( LevelsMax < (int)pNode->Level ) - LevelsMax = (int)pNode->Level; + Abc_NtkForEachNode( pNtk, pNode, i ) + { + Abc_NtkLevel_rec( pNode ); + if ( LevelsMax < (int)pNode->Level ) + LevelsMax = (int)pNode->Level; + } + } + else + { + Abc_NtkForEachLiPo( pNtk, pNode, i ) + { + Abc_Obj_t * pDriver = Abc_ObjFanin0(pNode); + Abc_NtkLevel_rec( pDriver ); + if ( LevelsMax < (int)pDriver->Level ) + LevelsMax = (int)pDriver->Level; + // transfer the delay + if ( i < pNtk->nBarBufs ) + Abc_ObjFanout0(Abc_ObjFanout0(pNode))->Level = pDriver->Level; + } } return LevelsMax; } diff --git a/src/base/abc/abcShow.c b/src/base/abc/abcShow.c index e1baffa1..d209a9ce 100644 --- a/src/base/abc/abcShow.c +++ b/src/base/abc/abcShow.c @@ -185,6 +185,7 @@ void Abc_NtkShow( Abc_Ntk_t * pNtk0, int fGateNames, int fSeq, int fUseReverse ) Abc_Ntk_t * pNtk; Abc_Obj_t * pNode; Vec_Ptr_t * vNodes; + int nBarBufs; char FileNameDot[200]; int i; @@ -215,10 +216,13 @@ void Abc_NtkShow( Abc_Ntk_t * pNtk0, int fGateNames, int fSeq, int fUseReverse ) Abc_NtkForEachObj( pNtk, pNode, i ) Vec_PtrPush( vNodes, pNode ); // write the DOT file + nBarBufs = pNtk->nBarBufs; + pNtk->nBarBufs = 0; if ( fSeq ) Io_WriteDotSeq( pNtk, vNodes, NULL, FileNameDot, fGateNames, fUseReverse ); else Io_WriteDotNtk( pNtk, vNodes, NULL, FileNameDot, fGateNames, fUseReverse ); + pNtk->nBarBufs = nBarBufs; Vec_PtrFree( vNodes ); // visualize the file diff --git a/src/base/abci/abcBalance.c b/src/base/abci/abcBalance.c index 9807997c..552cba7f 100644 --- a/src/base/abci/abcBalance.c +++ b/src/base/abci/abcBalance.c @@ -103,7 +103,7 @@ void Abc_NtkBalancePerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkAig, int fDuplicat { ProgressBar * pProgress; Vec_Vec_t * vStorage; - Abc_Obj_t * pNode, * pDriver; + Abc_Obj_t * pNode; int i; // transfer level Abc_NtkForEachCi( pNtk, pNode, i ) @@ -114,12 +114,23 @@ void Abc_NtkBalancePerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkAig, int fDuplicat vStorage = Vec_VecStart( 10 ); // perform balancing of POs pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) ); - Abc_NtkForEachCo( pNtk, pNode, i ) + if ( pNtk->nBarBufs == 0 ) { - Extra_ProgressBarUpdate( pProgress, i, NULL ); - // strash the driver node - pDriver = Abc_ObjFanin0(pNode); - Abc_NodeBalance_rec( pNtkAig, pDriver, vStorage, 0, fDuplicate, fSelective, fUpdateLevel ); + Abc_NtkForEachCo( pNtk, pNode, i ) + { + Extra_ProgressBarUpdate( pProgress, i, NULL ); + Abc_NodeBalance_rec( pNtkAig, Abc_ObjFanin0(pNode), vStorage, 0, fDuplicate, fSelective, fUpdateLevel ); + } + } + else + { + Abc_NtkForEachLiPo( pNtk, pNode, i ) + { + Extra_ProgressBarUpdate( pProgress, i, NULL ); + Abc_NodeBalance_rec( pNtkAig, Abc_ObjFanin0(pNode), vStorage, 0, fDuplicate, fSelective, fUpdateLevel ); + if ( i < pNtk->nBarBufs ) + Abc_ObjFanout0(Abc_ObjFanout0(pNode))->Level = Abc_ObjFanin0(pNode)->Level; + } } Extra_ProgressBarStop( pProgress ); Vec_VecFree( vStorage ); -- cgit v1.2.3