31#define IF_MAX_CUBES 70
48static inline int If_CutMaxCubeSize(
Vec_Int_t * vCover,
int nVars )
50 int i, k, Entry, Literal, Count, CountMax = 0;
54 for ( k = 0; k < nVars; k++ )
56 Literal = (3 & (Entry >> (k << 1)));
57 if ( Literal == 1 || Literal == 2 )
60 CountMax = Abc_MaxInt( CountMax, Count );
66 char * pPerm = If_CutPerm( pCut );
68 static double GateDelays[20] = { 1.00, 1.00, 2.00, 2.58, 3.00, 3.32, 3.58, 3.81, 4.00, 4.17, 4.32, 4.46, 4.58, 4.70, 4.81, 4.91, 5.00, 5.09, 5.17, 5.25 };
71 int i, nLitMax, Delay, DelayMax;
77 return (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, 0))->Delay;
78 vCover = Vec_WecEntry(
p->vTtIsops[pCut->
nLeaves], Abc_Lit2Var(If_CutTruthLit(pCut)) );
79 if ( Vec_IntSize(vCover) == 0 )
83 if ( Vec_IntSize(vCover) >
p->pPars->nGateSize )
86 assert( If_CutLeaveNum(pCut) >= 0 && If_CutLeaveNum(pCut) <= 16 );
88 nLitMax = If_CutMaxCubeSize( vCover, If_CutLeaveNum(pCut) );
89 if ( Vec_IntSize(vCover) < 2 )
91 pCut->
Cost = Vec_IntSize(vCover);
92 Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + 0.5);
95 DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pPerm[i] = (
char)Delay) );
99 pCut->
Cost = Vec_IntSize(vCover) + 1;
100 Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + GateDelays[nLitMax] + 0.5);
103 DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pPerm[i] = (
char)Delay) );
125 int i, k, Entry, Literal, Delay = 0;
133 for ( k = 0; k < nSuppAll; k++ )
135 Literal = 3 & (Entry >> (k << 1));
136 if ( Literal == 1 || Literal == 2 )
137 Delay = If_LogCounterPinDelays( pCounterAnd, &nCounterAnd, pPinDelsAnd, pTimes[k], pFaninRes[k], nSuppAll, 0 );
138 else if ( Literal != 0 )
141 assert( nCounterAnd > 0 );
142 ResAnd = If_LogPinDelaysMulti( pPinDelsAnd, nCounterAnd, nSuppAll, 0 );
143 Delay = If_LogCounterPinDelays( pCounterOr, &nCounterOr, pPinDelsOr, Delay, ResAnd, nSuppAll, 0 );
146 *pRes = If_LogPinDelaysMulti( pPinDelsOr, nCounterOr, nSuppAll, 0 );
153 for ( i = 0; i < nSuppAll; i++ )
154 FaninRes[i] = If_CutPinDelayInit(i);
156 If_CutPinDelayTranslate( Res, nSuppAll, pPerm );
166 return (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, 0))->Delay;
172 vCover = Vec_WecEntry(
p->vTtIsops[pCut->
nLeaves], Abc_Lit2Var(If_CutTruthLit(pCut)) );
173 if ( Vec_IntSize(vCover) == 0 )
175 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
176 pTimes[i] = (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, i))->Delay;
196 int i, k, Entry, Literal, nLits, Delay = 0, iRes = 0;
202 nCounterAnd = nLits = 0;
203 for ( k = 0; k < nSuppAll; k++ )
205 Literal = 3 & (Entry >> (k << 1));
207 nLits++, Delay = If_LogCounterAddAig( pCounterAnd, &nCounterAnd, pFaninLitsAnd, pTimes[k], vAig ? Abc_LitNot(pFaninLits[k]) : -1, vAig, nSuppAll, 0, 0 );
208 else if ( Literal == 2 )
209 nLits++, Delay = If_LogCounterAddAig( pCounterAnd, &nCounterAnd, pFaninLitsAnd, pTimes[k], vAig ? pFaninLits[k] : -1, vAig, nSuppAll, 0, 0 );
210 else if ( Literal != 0 )
213 assert( nCounterAnd > 0 );
216 iRes = If_LogCreateAndXorMulti( vAig, pFaninLitsAnd, nCounterAnd, nSuppAll, 0 );
218 *pArea += nLits == 1 ? 0 : nLits - 1;
219 Delay = If_LogCounterAddAig( pCounterOr, &nCounterOr, pFaninLitsOr, Delay, vAig ? Abc_LitNot(iRes) : -1, vAig, nSuppAll, 0, 0 );
224 *piRes = Abc_LitNot( If_LogCreateAndXorMulti( vAig, pFaninLitsOr, nCounterOr, nSuppAll, 0 ) );
225 if ( ((vCover->nCap >> 16) & 1) )
226 *piRes = Abc_LitNot( *piRes );
229 *pArea += Vec_IntSize(vCover) == 1 ? 0 : Vec_IntSize(vCover) - 1;
235 int iRes = 0, Res, k;
237 for ( k = 0; k < nLeaves; k++ )
238 pFaninLits[k] = Abc_Var2Lit(k, 0);
242 assert( vAig == NULL || Abc_Lit2Var(iRes) == nLeaves + Abc_Lit2Var(Vec_IntSize(vAig)) - 1 );
244 Vec_IntPush( vAig, Abc_LitIsCompl(iRes) ^ fCompl );
245 assert( vAig == NULL || (Vec_IntSize(vAig) & 1) );
252 Vec_IntClear( vAig );
255 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 0 );
257 Vec_IntPush( vAig, Abc_LitIsCompl(If_CutTruthLit(pCut)) );
263 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 1 );
265 Vec_IntPush( vAig, 0 );
267 Vec_IntPush( vAig, Abc_LitIsCompl(If_CutTruthLit(pCut)) );
269 return (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, 0))->Delay;
274 Vec_Int_t * vCover = Vec_WecEntry(
p->vTtIsops[pCut->
nLeaves], Abc_Lit2Var(If_CutTruthLit(pCut)) );
277 if ( vCover == NULL )
279 assert( Vec_IntSize(vCover) > 0 );
280 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
281 pTimes[i] = (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, i))->Delay;
286 int Max = 0, Two = 0;
287 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
288 Max = Abc_MaxInt( Max, pTimes[i] );
289 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
290 if ( pTimes[i] != Max )
291 Two = Abc_MaxInt( Two, pTimes[i] );
292 if ( Two + 2 < Max && Max + 3 < Delay )
294 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
295 printf(
"%3d ", pTimes[i] );
296 for ( ; i <
p->pPars->nLutSize; i++ )
298 printf(
"-> %3d ", Delay );
304 vIsop.nCap = vIsop.nSize = Abc_Tt6Esop( *If_CutTruthW(
p, pCut), pCut->
nLeaves, pIsop );
305 vIsop.pArray = pIsop;
306 printf(
"ESOP (%d -> %d)\n", Vec_IntSize(vCover), vIsop.nSize );
334 return (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, 0))->Delay;
338 char * pCutPerm = If_CutDsdPerm(
p, pCut );
339 int LutSize =
p->pPars->pLutStruct[0] -
'0';
340 int i, Delay, DelayMax = -1;
342 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
344 if ( If_CutLeaveNum(pCut) > LutSize && ((pCut->
uMaskFunc >> (i << 1)) & 1) )
345 pPerm[Abc_Lit2Var((
int)pCutPerm[i])] = 2;
347 pPerm[Abc_Lit2Var((
int)pCutPerm[i])] = 1;
349 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
351 Delay = (int)If_ObjCutBest(If_CutLeaf(
p, pCut, i))->Delay;
352 DelayMax = Abc_MaxInt( DelayMax, Delay + (
int)pPerm[i] );
376 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 0 );
381 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 1 );
382 return (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, 0))->Delay;
386 char * pCutPerm = If_CutDsdPerm(
p, pCut );
387 int LutSize =
p->pPars->pLutStruct[0] -
'0';
389 int DelayMax = -1, nLeafMax = 0;
390 unsigned uLeafMask = 0;
391 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
393 pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(
p, pCut, Abc_Lit2Var((
int)pCutPerm[i])))->Delay;
394 if ( DelayMax < pTimes[i] )
395 DelayMax = pTimes[i], nLeafMax = 1, uLeafMask = (1 << (i << 1));
396 else if ( DelayMax == pTimes[i] )
397 nLeafMax++, uLeafMask |= (1 << (i << 1));
399 if ( If_CutLeaveNum(pCut) <= LutSize )
402 if ( nLeafMax <= LutSize - 1 )
422 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 0 );
427 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 1 );
428 return (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, 0))->Delay;
431 int LutSize =
p->pPars->nLutDecSize;
433 int DelayMax = -1, nLeafMax = 0;
434 unsigned uLeafMask = 0;
435 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
437 leaf_delay = If_ObjCutBest(If_CutLeaf(
p, pCut, i))->Delay;
439 if ( DelayMax < leaf_delay )
441 DelayMax = leaf_delay;
443 uLeafMask = (1 << i);
445 else if ( DelayMax == leaf_delay )
448 uLeafMask |= (1 << i);
451 if ( If_CutLeaveNum(pCut) <= LutSize )
453 pCut->
decDelay = ( 1 << LutSize ) - 1;
458 int use_late_arrival = 0;
466 use_late_arrival = DelayMax + 2 >= If_ObjCutBest(pObj)->Delay;
471 use_late_arrival = DelayMax + 2 > pObj->
Required +
p->fEpsilon;
476 if ( nLeafMax == LutSize )
478 if ( use_late_arrival )
492 word *pTruth = If_CutTruthW(
p, pCut );
493 int val =
acd_evaluate( pTruth, pCut->
nLeaves, LutSize, &uLeafMask, &cost, !use_late_arrival );
505 return DelayMax + val;
515 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 0 );
520 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 1 );
521 return (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, 0))->Delay;
524 int LutSize =
p->pPars->nLutDecSize;
526 int DelayMax = -1, nLeafMax = 0;
527 unsigned uLeafMask = 0;
528 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
530 leaf_delay = If_ObjCutBest(If_CutLeaf(
p, pCut, i))->Delay;
532 if ( DelayMax < leaf_delay )
534 DelayMax = leaf_delay;
536 uLeafMask = (1 << i);
538 else if ( DelayMax == leaf_delay )
541 uLeafMask |= (1 << i);
544 if ( If_CutLeaveNum(pCut) <= LutSize )
546 pCut->
decDelay = ( 1 << LutSize ) - 1;
551 int use_late_arrival = 0;
559 use_late_arrival = DelayMax + 2 >= If_ObjCutBest(pObj)->Delay;
564 use_late_arrival = DelayMax + 2 > pObj->
Required +
p->fEpsilon;
569 if ( nLeafMax == LutSize && use_late_arrival )
576 if ( !use_late_arrival )
582 word *pTruth = If_CutTruthW(
p, pCut );
583 int val =
acd2_evaluate( pTruth, pCut->
nLeaves, LutSize, &uLeafMask, &cost, !use_late_arrival );
594 return DelayMax + val;
603 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 0 );
608 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 1 );
609 return (
int)If_ObjCutBest(If_CutLeaf(
p, pCut, 0))->Delay;
615 for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
617 leaf_delay = If_ObjCutBest(If_CutLeaf(
p, pCut, i))->Delay;
618 leaf_delay += ( ( pCut->
decDelay >> i ) & 1 ) == 0 ? 2 : 1;
619 DelayMax = Abc_MaxInt( leaf_delay, DelayMax );
629 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 0 );
634 assert( Abc_Lit2Var(If_CutTruthLit(pCut)) == 1 );
638 return ( ( pCut->
decDelay >> i ) & 1 ) == 0 ? 2 : 1;
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START int acd_evaluate(word *pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival)
int acd2_evaluate(word *pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
float If_LutDecPinRequired(If_Man_t *p, If_Cut_t *pCut, int i, float required)
int If_CutLutBalancePinDelays(If_Man_t *p, If_Cut_t *pCut, char *pPerm)
#define IF_MAX_CUBES
DECLARATIONS ///.
int If_CutLutBalanceEval(If_Man_t *p, If_Cut_t *pCut)
int If_CutDelaySop(If_Man_t *p, If_Cut_t *pCut)
int If_CutSopBalancePinDelaysIntInt(Vec_Int_t *vCover, int *pTimes, int nSuppAll, char *pPerm)
int If_LutDecReEval(If_Man_t *p, If_Cut_t *pCut)
int If_CutSopBalanceEvalIntInt(Vec_Int_t *vCover, int nLeaves, int *pTimes, Vec_Int_t *vAig, int fCompl, int *pArea)
int If_Lut2DecEval(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj, int optDelay, int fFirst)
int If_CutSopBalanceEvalInt(Vec_Int_t *vCover, int *pTimes, int *pFaninLits, Vec_Int_t *vAig, int *piRes, int nSuppAll, int *pArea)
int If_CutSopBalancePinDelays(If_Man_t *p, If_Cut_t *pCut, char *pPerm)
int If_CutSopBalanceEval(If_Man_t *p, If_Cut_t *pCut, Vec_Int_t *vAig)
int If_CutSopBalancePinDelaysInt(Vec_Int_t *vCover, int *pTimes, word *pFaninRes, int nSuppAll, word *pRes)
int If_LutDecEval(If_Man_t *p, If_Cut_t *pCut, If_Obj_t *pObj, int optDelay, int fFirst)
unsigned If_DsdManCheckXY(If_DsdMan_t *p, int iDsd, int LutSize, int fDerive, unsigned uMaskNot, int fHighEffort, int fVerbose)
struct If_Cut_t_ If_Cut_t
#define If_CutForEachLeaf(p, pCut, pLeaf, i)
#define IF_MAX_FUNC_LUTSIZE
struct If_Man_t_ If_Man_t
BASIC TYPES ///.
struct If_Obj_t_ If_Obj_t
unsigned __int64 word
DECLARATIONS ///.
void Kit_TruthIsopPrintCover(Vec_Int_t *vCover, int nVars, int fCompl)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.