48static inline int * Sfm_TimArrId(
Sfm_Tim_t *
p,
int Id ) {
return Vec_IntEntryP( &
p->vTimArrs, Abc_Var2Lit(Id, 0) ); }
49static inline int * Sfm_TimReqId(
Sfm_Tim_t *
p,
int Id ) {
return Vec_IntEntryP( &
p->vTimReqs, Abc_Var2Lit(Id, 0) ); }
51static inline int * Sfm_TimArr(
Sfm_Tim_t *
p,
Abc_Obj_t * pNode ) {
return Vec_IntEntryP( &
p->vTimArrs, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
52static inline int * Sfm_TimReq(
Sfm_Tim_t *
p,
Abc_Obj_t * pNode ) {
return Vec_IntEntryP( &
p->vTimReqs, Abc_Var2Lit(Abc_ObjId(pNode), 0) ); }
54static inline int Sfm_TimArrMaxId(
Sfm_Tim_t *
p,
int Id ) {
int * a = Sfm_TimArrId(
p, Id);
return Abc_MaxInt(a[0], a[1]); }
56static inline int Sfm_TimArrMax(
Sfm_Tim_t *
p,
Abc_Obj_t * pNode ) {
int * a = Sfm_TimArr(
p, pNode);
return Abc_MaxInt(a[0], a[1]); }
57static inline void Sfm_TimSetReq(
Sfm_Tim_t *
p,
Abc_Obj_t * pNode,
int t ) {
int * r = Sfm_TimReq(
p, pNode); r[0] = r[1] = t; }
58static inline int Sfm_TimSlack(
Sfm_Tim_t *
p,
Abc_Obj_t * pNode ) {
int * r = Sfm_TimReq(
p, pNode), * a = Sfm_TimArr(
p, pNode);
return Abc_MinInt(r[0]-a[0], r[1]-a[1]); }
75static inline void Sfm_TimEdgeArrival(
Sfm_Tim_t *
p,
Mio_Pin_t * pPin,
int * pTimeIn,
int * pTimeOut )
82 pTimeOut[0] = Abc_MaxInt( pTimeOut[0], pTimeIn[0] + tDelayBlockRise );
83 pTimeOut[1] = Abc_MaxInt( pTimeOut[1], pTimeIn[1] + tDelayBlockFall );
87 pTimeOut[0] = Abc_MaxInt( pTimeOut[0], pTimeIn[1] + tDelayBlockRise );
88 pTimeOut[1] = Abc_MaxInt( pTimeOut[1], pTimeIn[0] + tDelayBlockFall );
91static inline void Sfm_TimGateArrival(
Sfm_Tim_t *
p,
Mio_Gate_t * pGate,
int ** pTimesIn,
int * pTimeOut )
94 pTimeOut[0] = pTimeOut[1] = 0;
96 Sfm_TimEdgeArrival(
p, pPin, pTimesIn[i++], pTimeOut );
101 int i, iFanin, * pTimesIn[6];
102 int * pTimeOut = Sfm_TimArr(
p, pNode);
103 assert( Abc_ObjFaninNum(pNode) <= 6 );
105 pTimesIn[i] = Sfm_TimArrId(
p, iFanin );
109static inline void Sfm_TimEdgeRequired(
Sfm_Tim_t *
p,
Mio_Pin_t * pPin,
int * pTimeIn,
int * pTimeOut )
116 pTimeIn[0] = Abc_MinInt( pTimeIn[0], pTimeOut[0] - tDelayBlockRise );
117 pTimeIn[1] = Abc_MinInt( pTimeIn[1], pTimeOut[1] - tDelayBlockFall );
121 pTimeIn[0] = Abc_MinInt( pTimeIn[0], pTimeOut[1] - tDelayBlockRise );
122 pTimeIn[1] = Abc_MinInt( pTimeIn[1], pTimeOut[0] - tDelayBlockFall );
125static inline void Sfm_TimGateRequired(
Sfm_Tim_t *
p,
Mio_Gate_t * pGate,
int ** pTimesIn,
int * pTimeOut )
129 Sfm_TimEdgeRequired(
p, pPin, pTimesIn[i++], pTimeOut );
134 int i, iFanin, * pTimesIn[6];
135 int * pTimeOut = Sfm_TimReq(
p, pNode);
136 assert( Abc_ObjFaninNum(pNode) <= 6 );
138 pTimesIn[i] = Sfm_TimReqId(
p, iFanin );
157 if ( Abc_NodeIsTravIdCurrent( pObj ) )
159 Abc_NodeSetTravIdCurrent( pObj );
160 assert( Abc_ObjIsNode(pObj) );
163 if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) == 0 )
165 assert( Abc_ObjIsNode(pNext) );
166 if ( Sfm_TimSlack(
p, pNext) <= SlackMax )
169 if ( Abc_ObjFaninNum(pObj) > 0 )
170 Vec_IntPush( vPath, Abc_ObjId(pObj) );
174 int i, SlackMax =
p->Delay * Window / 100;
176 Vec_IntClear( &
p->vPath );
177 Abc_NtkIncrementTravId(
p->pNtk );
180 pNext = Abc_ObjFanin0(pObj);
181 if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) == 0 )
183 assert( Abc_ObjIsNode(pNext) );
184 if ( Sfm_TimSlack(
p, pNext) <= SlackMax )
187 return Vec_IntSize(&
p->vPath);
206 Sfm_TimNodeArrival(
p, pObj );
208 Delay = Abc_MaxInt( Delay, Sfm_TimArrMax(
p, Abc_ObjFanin0(pObj)) );
209 Vec_IntFill( &
p->vTimReqs, 2*Abc_NtkObjNumMax(
p->pNtk),
ABC_INFINITY );
211 Sfm_TimSetReq(
p, Abc_ObjFanin0(pObj), Delay );
214 Vec_PtrFree( vNodes );
235 Vec_IntFill( &
p->vTimArrs, 3*Abc_NtkObjNumMax(pNtk), 0 );
236 Vec_IntFill( &
p->vTimReqs, 3*Abc_NtkObjNumMax(pNtk), 0 );
238 assert( DeltaCrit > 0 && DeltaCrit < Scl_Flt2Int(1000.0) );
239 p->DeltaCrit = DeltaCrit;
244 Vec_IntErase( &
p->vTimArrs );
245 Vec_IntErase( &
p->vTimReqs );
246 Vec_WecErase( &
p->vLevels );
247 Vec_IntErase( &
p->vPath );
248 Vec_WrdErase( &
p->vSortData );
257 return Sfm_TimArrMaxId(
p, iObj);
275 printf(
"Max delay = %.2f. Path = %d (%d).\n", Scl_Int2Flt(
p->Delay),
Sfm_TimCriticalPath(
p, 1), Abc_NtkNodeNum(
p->pNtk) );
290static inline void Sfm_TimUpdateClean(
Sfm_Tim_t *
p )
302 Vec_IntClear( vLevel );
319 assert( Vec_IntSize(vTimeNodes) > 0 && Vec_IntSize(vTimeNodes) <= 2 );
320 Vec_IntFillExtra( &
p->vTimArrs, 2*Abc_NtkObjNumMax(
p->pNtk), 0 );
321 Vec_IntFillExtra( &
p->vTimReqs, 2*Abc_NtkObjNumMax(
p->pNtk), 0 );
339 int i, Id, Time, nDivNew = -1;
343 Vec_WrdClear( &
p->vSortData );
346 Time = Sfm_TimArrMaxId(
p, Id );
351 Abc_QuickSort3( Vec_WrdArray(&
p->vSortData), Vec_WrdSize(&
p->vSortData), 0 );
353 Vec_IntClear( vNodes );
356 Vec_IntPush( vNodes, (
int)(Entry >> 32) );
357 if ( nDivNew == -1 && ((
int)Entry) +
p->DeltaCrit > MaxDelay )
379 assert( Window >= 0 && Window <= 100 );
383 Sfm_TimUpdateClean(
p );
388 Vec_WecPush( &
p->vLevels, Abc_ObjLevel(pObj), Abc_ObjId(pObj) );
391 Vec_WecSort( &
p->vLevels, 0 );
392 Vec_IntClear( vCands );
396 Vec_IntPush( vCands, Abc_ObjId(pObj) );
398 return Vec_IntSize(vCands) > 0;
414 return Sfm_TimArrMax(
p, pNode) +
p->DeltaCrit <= Sfm_TimArrMax(
p, pPivot);
431 int * pTimesIn1[6], * pTimesIn2[6];
432 int i, nFanins1, nFanins2;
435 for ( i = 0; i < nFanins1; i++ )
436 pTimesIn1[i] = Sfm_TimArrId(
p, Vec_IntEntry(vMap, Vec_IntEntry(vFanins, (
int)pFans1[i])) );
437 Sfm_TimGateArrival(
p, pGate1, pTimesIn1, TimeOut[0] );
438 if ( pGate2 == NULL )
439 return Abc_MaxInt(TimeOut[0][0], TimeOut[0][1]);
442 for ( i = 0; i < nFanins2; i++ )
443 if ( (
int)pFans2[i] == 16 )
444 pTimesIn2[i] = TimeOut[0];
446 pTimesIn2[i] = Sfm_TimArrId(
p, Vec_IntEntry(vMap, Vec_IntEntry(vFanins, (
int)pFans2[i])) );
447 Sfm_TimGateArrival(
p, pGate2, pTimesIn2, TimeOut[1] );
448 return Abc_MaxInt(TimeOut[1][0], TimeOut[1][1]);
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
struct Abc_Ntk_t_ Abc_Ntk_t
#define Abc_ObjForEachFaninId(pObj, iFanin, i)
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
void Abc_QuickSort3(word *pData, int nSize, int fDecrease)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
unsigned __int64 word
DECLARATIONS ///.
double Mio_PinReadDelayBlockFall(Mio_Pin_t *pPin)
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
Mio_PinPhase_t
INCLUDES ///.
struct Mio_LibraryStruct_t_ Mio_Library_t
Mio_PinPhase_t Mio_PinReadPhase(Mio_Pin_t *pPin)
struct Mio_PinStruct_t_ Mio_Pin_t
double Mio_PinReadDelayBlockRise(Mio_Pin_t *pPin)
#define Mio_GateForEachPin(Gate, Pin)
struct Mio_GateStruct_t_ Mio_Gate_t
typedefABC_NAMESPACE_HEADER_START struct Scl_Con_t_ Scl_Con_t
DECLARATIONS ///.
struct Sfm_Tim_t_ Sfm_Tim_t
int Sfm_TimSortArrayByArrival(Sfm_Tim_t *p, Vec_Int_t *vNodes, int iPivot)
int Sfm_TimCriticalPath(Sfm_Tim_t *p, int Window)
int Sfm_TimTrace(Sfm_Tim_t *p)
void Sfm_TimTest(Abc_Ntk_t *pNtk)
Sfm_Tim_t * Sfm_TimStart(Mio_Library_t *pLib, Scl_Con_t *pExt, Abc_Ntk_t *pNtk, int DeltaCrit)
void Sfm_TimCriticalPath_int(Sfm_Tim_t *p, Abc_Obj_t *pObj, Vec_Int_t *vPath, int SlackMax)
int Sfm_TimReadObjDelay(Sfm_Tim_t *p, int iObj)
int Sfm_TimNodeIsNonCritical(Sfm_Tim_t *p, Abc_Obj_t *pPivot, Abc_Obj_t *pNode)
int Sfm_TimReadNtkDelay(Sfm_Tim_t *p)
void Sfm_TimUpdateTiming(Sfm_Tim_t *p, Vec_Int_t *vTimeNodes)
void Sfm_TimStop(Sfm_Tim_t *p)
void Sfm_TimNodeRequired(Sfm_Tim_t *p, Abc_Obj_t *pNode)
int Sfm_TimEvalRemapping(Sfm_Tim_t *p, Vec_Int_t *vFanins, Vec_Int_t *vMap, Mio_Gate_t *pGate1, char *pFans1, Mio_Gate_t *pGate2, char *pFans2)
int Sfm_TimPriorityNodes(Sfm_Tim_t *p, Vec_Int_t *vCands, int Window)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.