41static inline float Iff_ObjTimeId(
Iff_Man_t *
p,
int iObj ) {
return Vec_FltEntry(
p->vTimes, iObj ); }
42static inline float Iff_ObjTime(
Iff_Man_t *
p,
Gia_Obj_t * pObj ) {
return Iff_ObjTimeId(
p, Gia_ObjId(
p->pGia, pObj) ); }
43static inline void Iff_ObjSetTimeId(
Iff_Man_t *
p,
int iObj,
float Time ) { Vec_FltWriteEntry(
p->vTimes, iObj, Time ); }
44static inline void Iff_ObjSetTime(
Iff_Man_t *
p,
Gia_Obj_t * pObj,
float Time ) { Iff_ObjSetTimeId(
p, Gia_ObjId(
p->pGia, pObj), Time ); }
46static inline int Iff_ObjMatchId(
Iff_Man_t *
p,
int iObj,
int Type ) {
return Vec_IntEntry(
p->vMatch[Type], iObj ); }
47static inline int Iff_ObjMatch(
Iff_Man_t *
p,
Gia_Obj_t * pObj,
int Type ) {
return Iff_ObjMatchId(
p, Gia_ObjId(
p->pGia, pObj), Type ); }
48static inline void Iff_ObjSetMatchId(
Iff_Man_t *
p,
int iObj,
int Type,
int Match ) { Vec_IntWriteEntry(
p->vMatch[Type], iObj, Match ); }
49static inline void Iff_ObjSetMatch(
Iff_Man_t *
p,
Gia_Obj_t * pObj,
int Type,
int Match ) { Iff_ObjSetMatchId(
p, Gia_ObjId(
p->pGia, pObj), Type, Match );}
69 p->vTimes = Vec_FltStartFull( Gia_ManObjNum(pGia) );
70 p->vMatch[2] = Vec_IntStartFull( Gia_ManObjNum(pGia) );
71 p->vMatch[3] = Vec_IntStartFull( Gia_ManObjNum(pGia) );
76 Vec_FltFree(
p->vTimes );
77 Vec_IntFree(
p->vMatch[2] );
78 Vec_IntFree(
p->vMatch[3] );
95 int i, iFanin, Count = 0;
99 if ( iFanin == iFaninSkip2 || iFanin == iFaninSkip3 )
101 if ( Gia_ObjIsTravIdCurrentId( pGia, iFanin ) )
103 Gia_ObjSetTravIdCurrentId( pGia, iFanin );
106 if ( iFaninSkip2 >= 0 )
110 if ( iFanin == iFaninSkip3 )
112 if ( Gia_ObjIsTravIdCurrentId( pGia, iFanin ) )
114 Gia_ObjSetTravIdCurrentId( pGia, iFanin );
118 if ( iFaninSkip3 >= 0 )
122 if ( iFanin == iFaninSkip2 )
124 if ( Gia_ObjIsTravIdCurrentId( pGia, iFanin ) )
126 Gia_ObjSetTravIdCurrentId( pGia, iFanin );
149 if ( iFanin != iFaninSkip2 && iFanin != iFaninSkip3 && DelayMax < Iff_ObjTimeId(
p, iFanin) )
150 DelayMax = Iff_ObjTimeId(
p, iFanin);
151 assert( i == Gia_ObjLutSize(
p->pGia, iObj) );
152 if ( iFaninSkip2 == -1 )
155 if ( iFanin != iFaninSkip3 && DelayMax < Iff_ObjTimeId(
p, iFanin) )
156 DelayMax = Iff_ObjTimeId(
p, iFanin);
157 if ( iFaninSkip3 == -1 )
160 if ( iFanin != iFaninSkip2 && DelayMax < Iff_ObjTimeId(
p, iFanin) )
161 DelayMax = Iff_ObjTimeId(
p, iFanin);
167 int i, iFanin, nSize;
172 if ( Gia_ObjIsCi(Gia_ManObj(
p->pGia, iFanin)) )
176 assert( nSize <= p->pLib->LutMax );
177 This +=
p->pLib->pLutDelays[nSize][0];
178 if ( DelayMin > This )
188 int i, k, iFanin, iFanin2, nSize;
195 if ( iFanin == iFanin2 )
197 if ( Gia_ObjIsCi(Gia_ManObj(
p->pGia, iFanin)) )
199 if ( Gia_ObjIsCi(Gia_ManObj(
p->pGia, iFanin2)) )
203 assert( nSize <= p->pLib->LutMax );
204 This +=
p->pLib->pLutDelays[nSize][0];
205 if ( DelayMin > This )
230 int iObj, iFanin, iFanin1, iFanin2;
231 int CountAll = 0, Count2 = 0, Count3 = 0;
232 float arrTime1, arrTime2, arrTime3, arrMax = -
ABC_INFINITY;
233 assert( nDegree == 2 || nDegree == 3 );
238 p->nLutSize = nLutSize;
239 p->nDegree = nDegree;
241 Iff_ObjSetTimeId(
p, 0, 0 );
245 if ( Gia_ObjIsAnd(pObj) )
247 if ( !Gia_ObjIsLut(pGia, iObj) )
252 arrTime1 +=
p->pLib->pLutDelays[Gia_ObjLutSize(pGia, iObj)][0];
258 Iff_ObjSetTimeId(
p, iObj, arrTime2 );
259 if ( arrTime2 < arrTime1 )
260 Iff_ObjSetMatchId(
p, iObj, 2, iFanin ), Count2++;
262 else if ( nDegree == 3 )
267 Iff_ObjSetTimeId(
p, iObj, arrTime3 );
268 if ( arrTime3 == arrTime1 )
270 if ( arrTime3 == arrTime2 )
271 Iff_ObjSetMatchId(
p, iObj, 2, iFanin ), Count2++;
274 assert( arrTime3 < arrTime2 );
275 Iff_ObjSetMatchId(
p, iObj, 2, iFanin1 );
276 Iff_ObjSetMatchId(
p, iObj, 3, iFanin2 ), Count3++;
281 else if ( Gia_ObjIsCi(pObj) )
284 Iff_ObjSetTime(
p, pObj, arrTime1 );
286 else if ( Gia_ObjIsCo(pObj) )
288 arrTime1 = Iff_ObjTimeId(
p, Gia_ObjFaninId0p(pGia, pObj) );
290 Iff_ObjSetTime(
p, pObj, arrTime1 );
291 arrMax = Abc_MaxFloat( arrMax, arrTime1 );
295 printf(
"Max delay = %.2f. Count1 = %d. Count2 = %d. Count3 = %d.\n",
296 arrMax, CountAll - Count2 - Count3, Count2, Count3 );
313 int i, iFanin, iFaninSkip2, iFaninSkip3;
314 if ( Gia_ObjIsTravIdCurrentId(
p->pGia, iObj ) )
316 Gia_ObjSetTravIdCurrentId(
p->pGia, iObj );
317 assert( Gia_ObjIsLut(
p->pGia, iObj) );
318 iFaninSkip2 = Iff_ObjMatchId(
p, iObj, 2);
319 iFaninSkip3 = Iff_ObjMatchId(
p, iObj, 3);
320 if ( iFaninSkip2 == -1 )
322 assert( iFaninSkip3 == -1 );
325 Vec_IntPush( vPacking, 1 );
326 Vec_IntPush( vPacking, iObj );
328 else if ( iFaninSkip3 == -1 )
330 assert( iFaninSkip2 > 0 );
332 if ( iFanin != iFaninSkip2 )
336 Vec_IntPush( vPacking, 2 );
337 Vec_IntPush( vPacking, iFaninSkip2 );
338 Vec_IntPush( vPacking, iObj );
342 assert( iFaninSkip2 > 0 && iFaninSkip3 > 0 );
344 if ( iFanin != iFaninSkip2 && iFanin != iFaninSkip3 )
347 if ( iFanin != iFaninSkip3 )
350 if ( iFanin != iFaninSkip2 )
352 Vec_IntPush( vPacking, 3 );
353 Vec_IntPush( vPacking, iFaninSkip2 );
354 Vec_IntPush( vPacking, iFaninSkip3 );
355 Vec_IntPush( vPacking, iObj );
357 Vec_IntAddToEntry( vPacking, 0, 1 );
363 vPacking = Vec_IntAlloc( Gia_ManObjNum(
p->pGia) );
364 Vec_IntPush( vPacking, 0 );
367 Gia_ObjSetTravIdCurrentId(
p->pGia, 0 );
369 Gia_ObjSetTravIdCurrent(
p->pGia, pObj );
398 else if ( pLib->
LutMax == 10 )
401 { printf(
"LUT library for packing 4-LUTs should have 7 or 10 inputs.\n" );
return; }
403 else if ( nLutSize <= 6 )
408 else if ( pLib->
LutMax == 16 )
411 { printf(
"LUT library for packing 6-LUTs should have 11 or 16 inputs.\n" );
return; }
415 printf(
"The LUT size is more than 6.\n" );
419 printf(
"Performing %d-clustering with %d-LUTs:\n", nDegree, nLutSize );
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#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 ///.
int Gia_IffObjCount(Gia_Man_t *pGia, int iObj, int iFaninSkip2, int iFaninSkip3)
Iff_Man_t * Gia_ManIffStart(Gia_Man_t *pGia)
FUNCTION DEFINITIONS ///.
void Gia_ManIffSelect_rec(Iff_Man_t *p, int iObj, Vec_Int_t *vPacking)
void Gia_ManIffStop(Iff_Man_t *p)
Iff_Man_t * Gia_ManIffPerform(Gia_Man_t *pGia, If_LibLut_t *pLib, Tim_Man_t *pTime, int nLutSize, int nDegree)
Vec_Int_t * Gia_ManIffSelect(Iff_Man_t *p)
float Gia_IffObjTimeTwo(Iff_Man_t *p, int iObj, int *piFanin, float DelayMin)
float Gia_IffObjTimeThree(Iff_Man_t *p, int iObj, int *piFanin, int *piFanin2, float DelayMin)
typedefABC_NAMESPACE_IMPL_START struct Iff_Man_t_ Iff_Man_t
DECLARATIONS ///.
float Gia_IffObjTimeOne(Iff_Man_t *p, int iObj, int iFaninSkip2, int iFaninSkip3)
void Gia_ManIffTest(Gia_Man_t *pGia, If_LibLut_t *pLib, int fVerbose)
void Gia_ManPrintPackingStats(Gia_Man_t *p)
struct Gia_Obj_t_ Gia_Obj_t
#define Gia_LutForEachFanin(p, i, iFan, k)
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObj1(p, pObj, i)
int Gia_ManLutSizeMax(Gia_Man_t *p)
void Gia_ManIncrementTravId(Gia_Man_t *p)
#define Gia_ManForEachCo(p, pObj, i)
#define Gia_ManForEachCi(p, pObj, i)
struct If_LibLut_t_ If_LibLut_t
void Tim_ManStopP(Tim_Man_t **p)
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
void Tim_ManIncrementTravId(Tim_Man_t *p)
DECLARATIONS ///.
Tim_Man_t * Tim_ManStart(int nCis, int nCos)
DECLARATIONS ///.
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.