30static int Abc_NtkRetimeMinDelayTry(
Abc_Ntk_t * pNtk,
int nDelayLim,
int fForward,
int fInitial,
int nIterLimit,
int * pIterBest,
int fVerbose );
31static int Abc_NtkRetimeTiming(
Abc_Ntk_t * pNtk,
int fForward,
Vec_Ptr_t * vCritical );
32static int Abc_NtkRetimeTiming_rec(
Abc_Obj_t * pObj,
int fForward );
52 int IterBest, DelayBest;
53 int IterBest2, DelayBest2;
55 DelayBest = Abc_NtkRetimeMinDelayTry( pNtkCopy, nDelayLim, fForward, 0, nIterLimit, &IterBest, fVerbose );
59 DelayBest2 = Abc_NtkRetimeMinDelayTry( pNtk, nDelayLim, fForward, 1, IterBest, &IterBest2, fVerbose );
60 assert( DelayBest == DelayBest2 );
61 assert( IterBest == IterBest2 );
76int Abc_NtkRetimeMinDelayTry(
Abc_Ntk_t * pNtk,
int nDelayLim,
int fForward,
int fInitial,
int nIterLimit,
int * pIterBest,
int fVerbose )
82 int i, k, IterBest, DelayCur, DelayBest;
99 if ( fVerbose && !fInitial )
100 printf(
"Performing analysis:\n" );
102 DelayBest =
ABC_INFINITY; IterBest = 0; LatchesBest = Abc_NtkLatchNum(pNtk);
103 vCritical = Vec_PtrAlloc( 100 );
107 DelayCur = Abc_NtkRetimeTiming( pNtk, fForward, vCritical );
109 DelayStart = DelayCur;
111 if ( DelayBest > DelayCur )
113if ( fVerbose && !fInitial )
114 printf(
"%s Iter = %3d. Delay = %3d. Latches = %5d. Delta = %6.2f. Ratio = %4.2f %%\n",
115 fForward ?
"Fwd":
"Bwd", i, DelayCur, Abc_NtkLatchNum(pNtk),
116 1.0*(Abc_NtkLatchNum(pNtk)-LatchesBest)/(DelayBest-DelayCur),
117 100.0*(Abc_NtkLatchNum(pNtk)-LatchesBest)/Abc_NtkLatchNum(pNtk)/(DelayBest-DelayCur) );
119 DelayBest = DelayCur;
121 LatchesBest = Abc_NtkLatchNum(pNtk);
124 if ( i == nIterLimit )
127 if ( i - IterBest > 20 )
130 if ( nDelayLim > 0 && DelayCur <= nDelayLim )
140 Vec_PtrFree( vCritical );
150 Vec_IntFree( vValues );
153 if ( fVerbose && !fInitial )
154 printf(
"%s : Starting delay = %3d. Final delay = %3d. IterBest = %2d (out of %2d).\n",
155 fForward?
"Forward " :
"Backward", DelayStart, DelayBest, IterBest, nIterLimit );
156 *pIterBest = (nIterLimit == 1) ? 1 : IterBest;
176 int i, k, LevelCur, LevelMax = 0;
178 Abc_NtkIncrementTravId(pNtk);
179 vLatches = Vec_PtrAlloc( Abc_NtkLatchNum(pNtk) );
182 if ( Abc_ObjIsLatch(pObj) )
183 Vec_PtrPush( vLatches, pObj );
184 if ( Abc_ObjIsNode(pObj) )
187 Abc_NodeSetTravIdCurrent( pObj );
196 LevelCur = Abc_NtkRetimeTiming_rec( pNext, fForward );
197 if ( LevelMax < LevelCur )
205 LevelCur = Abc_NtkRetimeTiming_rec( pNext, fForward );
206 if ( LevelMax < LevelCur )
215 LevelCur = Abc_NtkRetimeTiming_rec( Abc_ObjFanin0(pObj), fForward );
216 if ( LevelMax < LevelCur )
221 LevelCur = Abc_NtkRetimeTiming_rec( Abc_ObjFanin0(pObj), fForward );
222 if ( LevelMax < LevelCur )
227 Vec_PtrClear( vCritical );
228 Abc_NtkIncrementTravId(pNtk);
235 if ( Abc_NodeIsTravIdCurrent(pNext) )
237 if ( LevelMax != (
int)pNext->
Level )
240 Vec_PtrPush( vCritical, pNext );
241 Abc_NodeSetTravIdCurrent( pNext );
251 if ( Abc_NodeIsTravIdCurrent(pNext) )
253 if ( LevelMax != (
int)pNext->
Level )
256 Vec_PtrPush( vCritical, pNext );
257 Abc_NodeSetTravIdCurrent( pNext );
261 Vec_PtrFree( vLatches );
277int Abc_NtkRetimeTiming_rec(
Abc_Obj_t * pObj,
int fForward )
280 int i, LevelCur, LevelMax = 0;
282 if ( Abc_NodeIsTravIdCurrent(pObj) )
284 Abc_NodeSetTravIdCurrent(pObj);
290 LevelCur = Abc_NtkRetimeTiming_rec( pNext, fForward );
291 if ( LevelMax < LevelCur )
299 LevelCur = Abc_NtkRetimeTiming_rec( pNext, fForward );
300 if ( LevelMax < LevelCur )
305 pObj->
Level = LevelMax + 1;
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachPo(pNtk, pPo, i)
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
struct Abc_Ntk_t_ Abc_Ntk_t
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
int Abc_NtkRetimeMinDelay(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkCopy, int nDelayLim, int nIterLimit, int fForward, int fVerbose)
FUNCTION DEFINITIONS ///.
void Abc_NtkRetimeNode(Abc_Obj_t *pObj, int fForward, int fInitial)
void Abc_NtkRetimeShareLatches(Abc_Ntk_t *pNtk, int fInitial)
int Abc_NtkRetimeNodeIsEnabled(Abc_Obj_t *pObj, int fForward)
Abc_Ntk_t * Abc_NtkRetimeBackwardInitialStart(Abc_Ntk_t *pNtk)
void Abc_NtkRetimeTranferToCopy(Abc_Ntk_t *pNtk)
Vec_Int_t * Abc_NtkRetimeCollectLatchValues(Abc_Ntk_t *pNtk)
void Abc_NtkRetimeBackwardInitialFinish(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew, Vec_Int_t *vValuesOld, int fVerbose)
void Abc_NtkRetimeTranferFromCopy(Abc_Ntk_t *pNtk)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.