ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sfmTim.c File Reference
#include "sfmInt.h"
Include dependency graph for sfmTim.c:

Go to the source code of this file.

Classes

struct  Sfm_Tim_t_
 DECLARATIONS ///. More...
 

Functions

void Sfm_TimNodeRequired (Sfm_Tim_t *p, Abc_Obj_t *pNode)
 
void Sfm_TimCriticalPath_int (Sfm_Tim_t *p, Abc_Obj_t *pObj, Vec_Int_t *vPath, int SlackMax)
 
int Sfm_TimCriticalPath (Sfm_Tim_t *p, int Window)
 
int Sfm_TimTrace (Sfm_Tim_t *p)
 
Sfm_Tim_tSfm_TimStart (Mio_Library_t *pLib, Scl_Con_t *pExt, Abc_Ntk_t *pNtk, int DeltaCrit)
 
void Sfm_TimStop (Sfm_Tim_t *p)
 
int Sfm_TimReadNtkDelay (Sfm_Tim_t *p)
 
int Sfm_TimReadObjDelay (Sfm_Tim_t *p, int iObj)
 
void Sfm_TimTest (Abc_Ntk_t *pNtk)
 
void Sfm_TimUpdateTiming (Sfm_Tim_t *p, Vec_Int_t *vTimeNodes)
 
int Sfm_TimSortArrayByArrival (Sfm_Tim_t *p, Vec_Int_t *vNodes, int iPivot)
 
int Sfm_TimPriorityNodes (Sfm_Tim_t *p, Vec_Int_t *vCands, int Window)
 
int Sfm_TimNodeIsNonCritical (Sfm_Tim_t *p, Abc_Obj_t *pPivot, 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)
 

Function Documentation

◆ Sfm_TimCriticalPath()

int Sfm_TimCriticalPath ( Sfm_Tim_t * p,
int Window )

Definition at line 172 of file sfmTim.c.

173{
174 int i, SlackMax = p->Delay * Window / 100;
175 Abc_Obj_t * pObj, * pNext;
176 Vec_IntClear( &p->vPath );
177 Abc_NtkIncrementTravId( p->pNtk );
178 Abc_NtkForEachCo( p->pNtk, pObj, i )
179 {
180 pNext = Abc_ObjFanin0(pObj);
181 if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) == 0 )
182 continue;
183 assert( Abc_ObjIsNode(pNext) );
184 if ( Sfm_TimSlack(p, pNext) <= SlackMax )
185 Sfm_TimCriticalPath_int( p, pNext, &p->vPath, SlackMax );
186 }
187 return Vec_IntSize(&p->vPath);
188}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
Cube * p
Definition exorList.c:222
void Sfm_TimCriticalPath_int(Sfm_Tim_t *p, Abc_Obj_t *pObj, Vec_Int_t *vPath, int SlackMax)
Definition sfmTim.c:154
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_TimCriticalPath_int()

void Sfm_TimCriticalPath_int ( Sfm_Tim_t * p,
Abc_Obj_t * pObj,
Vec_Int_t * vPath,
int SlackMax )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 154 of file sfmTim.c.

155{
156 Abc_Obj_t * pNext; int i;
157 if ( Abc_NodeIsTravIdCurrent( pObj ) )
158 return;
159 Abc_NodeSetTravIdCurrent( pObj );
160 assert( Abc_ObjIsNode(pObj) );
161 Abc_ObjForEachFanin( pObj, pNext, i )
162 {
163 if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) == 0 )
164 continue;
165 assert( Abc_ObjIsNode(pNext) );
166 if ( Sfm_TimSlack(p, pNext) <= SlackMax )
167 Sfm_TimCriticalPath_int( p, pNext, vPath, SlackMax );
168 }
169 if ( Abc_ObjFaninNum(pObj) > 0 )
170 Vec_IntPush( vPath, Abc_ObjId(pObj) );
171}
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_TimEvalRemapping()

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 )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 428 of file sfmTim.c.

429{
430 int TimeOut[2][2];
431 int * pTimesIn1[6], * pTimesIn2[6];
432 int i, nFanins1, nFanins2;
433 // process the first gate
434 nFanins1 = Mio_GateReadPinNum( pGate1 );
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]);
440 // process the second gate
441 nFanins2 = Mio_GateReadPinNum( pGate2 );
442 for ( i = 0; i < nFanins2; i++ )
443 if ( (int)pFans2[i] == 16 )
444 pTimesIn2[i] = TimeOut[0];
445 else
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]);
449}
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
Definition mioApi.c:177
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_TimNodeIsNonCritical()

int Sfm_TimNodeIsNonCritical ( Sfm_Tim_t * p,
Abc_Obj_t * pPivot,
Abc_Obj_t * pNode )

Function*************************************************************

Synopsis [Returns 1 if node is relatively non-critical compared to the pivot.]

Description []

SideEffects []

SeeAlso []

Definition at line 412 of file sfmTim.c.

413{
414 return Sfm_TimArrMax(p, pNode) + p->DeltaCrit <= Sfm_TimArrMax(p, pPivot);
415}

◆ Sfm_TimNodeRequired()

void Sfm_TimNodeRequired ( Sfm_Tim_t * p,
Abc_Obj_t * pNode )

Definition at line 132 of file sfmTim.c.

133{
134 int i, iFanin, * pTimesIn[6];
135 int * pTimeOut = Sfm_TimReq(p, pNode);
136 assert( Abc_ObjFaninNum(pNode) <= 6 );
137 Abc_ObjForEachFaninId( pNode, iFanin, i )
138 pTimesIn[i] = Sfm_TimReqId( p, iFanin );
139 Sfm_TimGateRequired( p, (Mio_Gate_t *)pNode->pData, pTimesIn, pTimeOut );
140}
#define Abc_ObjForEachFaninId(pObj, iFanin, i)
Definition abc.h:531
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
void * pData
Definition abc.h:145
Here is the caller graph for this function:

◆ Sfm_TimPriorityNodes()

int Sfm_TimPriorityNodes ( Sfm_Tim_t * p,
Vec_Int_t * vCands,
int Window )

Function*************************************************************

Synopsis [Priority of nodes to try remapping for delay.]

Description []

SideEffects []

SeeAlso []

Definition at line 374 of file sfmTim.c.

375{
376 Vec_Int_t * vLevel;
377 Abc_Obj_t * pObj;
378 int i, k;
379 assert( Window >= 0 && Window <= 100 );
380 // collect critical path
381 Sfm_TimCriticalPath( p, Window );
382 // add nodes to the levelized structure
383 Sfm_TimUpdateClean( p );
384 Abc_NtkForEachObjVec( &p->vPath, p->pNtk, pObj, i )
385 {
386 assert( pObj->fMarkC == 0 );
387 pObj->fMarkC = 1;
388 Vec_WecPush( &p->vLevels, Abc_ObjLevel(pObj), Abc_ObjId(pObj) );
389 }
390 // prioritize nodes by expected gain
391 Vec_WecSort( &p->vLevels, 0 );
392 Vec_IntClear( vCands );
393 Vec_WecForEachLevel( &p->vLevels, vLevel, i )
394 Abc_NtkForEachObjVec( vLevel, p->pNtk, pObj, k )
395 if ( !pObj->fMarkA )
396 Vec_IntPush( vCands, Abc_ObjId(pObj) );
397// printf( "Path = %5d Cand = %5d\n", Vec_IntSize(&p->vPath) );
398 return Vec_IntSize(vCands) > 0;
399}
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
Definition abc.h:455
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
int Sfm_TimCriticalPath(Sfm_Tim_t *p, int Window)
Definition sfmTim.c:172
unsigned fMarkC
Definition abc.h:136
unsigned fMarkA
Definition abc.h:134
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_TimReadNtkDelay()

int Sfm_TimReadNtkDelay ( Sfm_Tim_t * p)

Definition at line 251 of file sfmTim.c.

252{
253 return p->Delay;
254}

◆ Sfm_TimReadObjDelay()

int Sfm_TimReadObjDelay ( Sfm_Tim_t * p,
int iObj )

Definition at line 255 of file sfmTim.c.

256{
257 return Sfm_TimArrMaxId(p, iObj);
258}

◆ Sfm_TimSortArrayByArrival()

int Sfm_TimSortArrayByArrival ( Sfm_Tim_t * p,
Vec_Int_t * vNodes,
int iPivot )

Function*************************************************************

Synopsis [Sort an array of nodes using their max arrival times.]

Description [Returns the number of new divisor nodes.]

SideEffects []

SeeAlso []

Definition at line 336 of file sfmTim.c.

337{
338 word Entry;
339 int i, Id, Time, nDivNew = -1;
340 int MaxDelay = ABC_INFINITY/2+Sfm_TimArrMaxId(p, iPivot);
341 assert( p->DeltaCrit > 0 );
342 // collect nodes
343 Vec_WrdClear( &p->vSortData );
344 Vec_IntForEachEntry( vNodes, Id, i )
345 {
346 Time = Sfm_TimArrMaxId( p, Id );
347 assert( -ABC_INFINITY/2 < Time && Time < ABC_INFINITY/2 );
348 Vec_WrdPush( &p->vSortData, ((word)Id << 32) | (ABC_INFINITY/2+Time) );
349 }
350 // sort nodes by delay
351 Abc_QuickSort3( Vec_WrdArray(&p->vSortData), Vec_WrdSize(&p->vSortData), 0 );
352 // collect sorted nodes and find place where divisors end
353 Vec_IntClear( vNodes );
354 Vec_WrdForEachEntry( &p->vSortData, Entry, i )
355 {
356 Vec_IntPush( vNodes, (int)(Entry >> 32) );
357 if ( nDivNew == -1 && ((int)Entry) + p->DeltaCrit > MaxDelay )
358 nDivNew = i;
359 }
360 return nDivNew;
361}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
void Abc_QuickSort3(word *pData, int nSize, int fDecrease)
Definition utilSort.c:884
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecWrd.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_TimStart()

Sfm_Tim_t * Sfm_TimStart ( Mio_Library_t * pLib,
Scl_Con_t * pExt,
Abc_Ntk_t * pNtk,
int DeltaCrit )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file sfmTim.c.

230{
232 p->pLib = pLib;
233 p->pExt = pExt;
234 p->pNtk = pNtk;
235 Vec_IntFill( &p->vTimArrs, 3*Abc_NtkObjNumMax(pNtk), 0 );
236 Vec_IntFill( &p->vTimReqs, 3*Abc_NtkObjNumMax(pNtk), 0 );
237 p->Delay = Sfm_TimTrace( p );
238 assert( DeltaCrit > 0 && DeltaCrit < Scl_Flt2Int(1000.0) );
239 p->DeltaCrit = DeltaCrit;
240 return p;
241}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
struct Sfm_Tim_t_ Sfm_Tim_t
Definition sfmInt.h:68
int Sfm_TimTrace(Sfm_Tim_t *p)
Definition sfmTim.c:201
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_TimStop()

void Sfm_TimStop ( Sfm_Tim_t * p)

Definition at line 242 of file sfmTim.c.

243{
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 );
249 ABC_FREE( p );
250}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Sfm_TimTest()

void Sfm_TimTest ( Abc_Ntk_t * pNtk)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 271 of file sfmTim.c.

272{
273 Mio_Library_t * pLib = (Mio_Library_t *)pNtk->pManFunc;
274 Sfm_Tim_t * p = Sfm_TimStart( pLib, NULL, pNtk, 100 );
275 printf( "Max delay = %.2f. Path = %d (%d).\n", Scl_Int2Flt(p->Delay), Sfm_TimCriticalPath(p, 1), Abc_NtkNodeNum(p->pNtk) );
276 Sfm_TimStop( p );
277}
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
Sfm_Tim_t * Sfm_TimStart(Mio_Library_t *pLib, Scl_Con_t *pExt, Abc_Ntk_t *pNtk, int DeltaCrit)
Definition sfmTim.c:229
void Sfm_TimStop(Sfm_Tim_t *p)
Definition sfmTim.c:242
void * pManFunc
Definition abc.h:191
Here is the call graph for this function:

◆ Sfm_TimTrace()

int Sfm_TimTrace ( Sfm_Tim_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 201 of file sfmTim.c.

202{
203 Abc_Obj_t * pObj; int i, Delay = 0;
204 Vec_Ptr_t * vNodes = Abc_NtkDfs( p->pNtk, 1 );
205 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
206 Sfm_TimNodeArrival( p, pObj );
207 Abc_NtkForEachCo( p->pNtk, pObj, i )
208 Delay = Abc_MaxInt( Delay, Sfm_TimArrMax(p, Abc_ObjFanin0(pObj)) );
209 Vec_IntFill( &p->vTimReqs, 2*Abc_NtkObjNumMax(p->pNtk), ABC_INFINITY );
210 Abc_NtkForEachCo( p->pNtk, pObj, i )
211 Sfm_TimSetReq( p, Abc_ObjFanin0(pObj), Delay );
212 Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pObj, i )
213 Sfm_TimNodeRequired( p, pObj );
214 Vec_PtrFree( vNodes );
215 return Delay;
216}
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition abcDfs.c:82
void Sfm_TimNodeRequired(Sfm_Tim_t *p, Abc_Obj_t *pNode)
Definition sfmTim.c:132
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition vecPtr.h:63
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sfm_TimUpdateTiming()

void Sfm_TimUpdateTiming ( Sfm_Tim_t * p,
Vec_Int_t * vTimeNodes )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file sfmTim.c.

318{
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 );
322 p->Delay = Sfm_TimTrace( p );
323}
Here is the call graph for this function:
Here is the caller graph for this function: