49 for ( i = 0; i < pCut->
nLeaves; i++ )
50 printf(
" %d", pCut->
pLeaves[i] );
69 printf(
"Cuts for node %d:\n", pObj->
Id );
86static inline int Dar_WordCountOnes(
unsigned uWord )
88 uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
89 uWord = (uWord & 0x33333333) + ((uWord>>2) & 0x33333333);
90 uWord = (uWord & 0x0F0F0F0F) + ((uWord>>4) & 0x0F0F0F0F);
91 uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
92 return (uWord & 0x0000FFFF) + (uWord>>16);
118 Value += pLeaf->
nRefs;
119 nOnes += (pLeaf->
nRefs == 1);
149 if ( pCut->
fUsed == 0 )
153 if ( pCutMax == NULL || pCutMax->
Value > pCut->
Value )
156 if ( pCutMax == NULL )
162 if ( pCutMax == NULL || pCutMax->
Value > pCut->
Value )
166 if ( pCutMax == NULL )
170 if ( pCutMax == NULL || pCutMax->
Value > pCut->
Value )
174 assert( pCutMax != NULL );
194 for ( i = 0; i < (int)pDom->
nLeaves; i++ )
196 for ( k = 0; k < (int)pCut->
nLeaves; k++ )
233 if ( Dar_CutCheckDominance( pCut, pTemp ) )
245 if ( Dar_CutCheckDominance( pTemp, pCut ) )
277 for ( i = 0; i < (int)pC0->
nLeaves; i++ )
280 for ( i = 0; i < (int)pC0->
nLeaves; i++ )
291 for ( i = 0; i < (int)pC1->
nLeaves; i++ )
293 for ( k = (
int)pC0->
nLeaves - 1; k >= 0; k-- )
299 for ( i = 0; i < (int)pC0->
nLeaves; i++ )
307 for ( c = 0; c < 4; c++ )
365 if ( !Dar_CutMergeOrdered( pCut, pCut1, pCut0 ) )
370 if ( !Dar_CutMergeOrdered( pCut, pCut0, pCut1 ) )
394 for ( i = k = 0; i < (int)pCut->
nLeaves; i++ )
396 if ( k == (
int)pCut1->
nLeaves )
418static inline unsigned Dar_CutTruthSwapAdjacentVars(
unsigned uTruth,
int iVar )
420 assert( iVar >= 0 && iVar <= 2 );
422 return (uTruth & 0x99999999) | ((uTruth & 0x22222222) << 1) | ((uTruth & 0x44444444) >> 1);
424 return (uTruth & 0xC3C3C3C3) | ((uTruth & 0x0C0C0C0C) << 2) | ((uTruth & 0x30303030) >> 2);
426 return (uTruth & 0xF00FF00F) | ((uTruth & 0x00F000F0) << 4) | ((uTruth & 0x0F000F00) >> 4);
442static inline unsigned Dar_CutTruthSwapPolarity(
unsigned uTruth,
int iVar )
444 assert( iVar >= 0 && iVar <= 3 );
446 return ((uTruth & 0xAAAA) >> 1) | ((uTruth & 0x5555) << 1);
448 return ((uTruth & 0xCCCC) >> 2) | ((uTruth & 0x3333) << 2);
450 return ((uTruth & 0xF0F0) >> 4) | ((uTruth & 0x0F0F) << 4);
452 return ((uTruth & 0xFF00) >> 8) | ((uTruth & 0x00FF) << 8);
470static inline unsigned Dar_CutTruthStretch(
unsigned uTruth,
int nVars,
unsigned Phase )
472 int i, k,
Var = nVars - 1;
473 for ( i = 3; i >= 0; i-- )
474 if ( Phase & (1 << i) )
476 for ( k =
Var; k < i; k++ )
477 uTruth = Dar_CutTruthSwapAdjacentVars( uTruth, k );
497static inline unsigned Dar_CutTruthShrink(
unsigned uTruth,
int nVars,
unsigned Phase )
500 for ( i = 0; i < 4; i++ )
501 if ( Phase & (1 << i) )
503 for ( k = i-1; k >=
Var; k-- )
504 uTruth = Dar_CutTruthSwapAdjacentVars( uTruth, k );
523 int i, Temp, fChange, Counter = 0;
525 for ( i = 0; i < 4; i++ )
527 if ( pVars[i] == -1 )
528 pVars[i] = 0x3FFFFFFF;
530 if ( Abc_LitIsCompl(pVars[i]) )
532 pVars[i] = Abc_LitNot( pVars[i] );
533 uTruth = Dar_CutTruthSwapPolarity( uTruth, i );
540 for ( i = 0; i < 3; i++ )
542 if ( pVars[i] <= pVars[i+1] )
548 pVars[i] = pVars[i+1];
551 uTruth = Dar_CutTruthSwapAdjacentVars( uTruth, i );
556 for ( i = 0; i < 4; i++ )
558 if ( pVars[i] == 0x3FFFFFFF )
582 unsigned uTruth0 = fCompl0 ? ~pCut0->uTruth : pCut0->
uTruth;
583 unsigned uTruth1 = fCompl1 ? ~pCut1->uTruth : pCut1->
uTruth;
584 uTruth0 = Dar_CutTruthStretch( uTruth0, pCut0->
nLeaves, Dar_CutTruthPhase(pCut, pCut0) );
585 uTruth1 = Dar_CutTruthStretch( uTruth1, pCut1->
nLeaves, Dar_CutTruthPhase(pCut, pCut1) );
586 return uTruth0 & uTruth1;
600static inline int Dar_CutSuppMinimize(
Dar_Cut_t * pCut )
602 unsigned uMasks[4][2] = {
608 unsigned uPhase = 0, uTruth = 0xFFFF & pCut->
uTruth;
613 for ( i = 0; i < (int)pCut->
nLeaves; i++ )
614 if ( (uTruth & uMasks[i][0]) == ((uTruth & uMasks[i][1]) >> (1 << i)) )
618 if ( nLeaves == (
int)pCut->
nLeaves )
621 uTruth = Dar_CutTruthShrink( uTruth, pCut->
nLeaves, uPhase );
622 pCut->
uTruth = 0xFFFF & uTruth;
625 for ( i = k = 0; i < (int)pCut->
nLeaves; i++ )
627 if ( !(uPhase & (1 << i)) )
650 if (
p->pMemCuts == NULL )
672 assert( Dar_ObjCuts(pObj) == NULL );
673 pObj->
nCuts =
p->pPars->nCutsMax;
677 Dar_ObjSetCuts( pObj, pCutSet );
680 Vec_PtrPush(
p->vCutNodes, pObj );
684 if ( Aig_ObjIsConst1(pObj) )
694 pCut->
uSign = Aig_ObjCutSign( pObj->
Id );
697 pCut->
Value = Dar_CutFindValue(
p, pCut );
718 Dar_ObjSetCuts( Aig_ManConst1(
p->pAig), NULL );
720 if ( !Aig_ObjIsNone(pObj) )
721 Dar_ObjSetCuts( pObj, NULL );
722 Vec_PtrClear(
p->vCutNodes );
742 Aig_Obj_t * pFaninR0 = Aig_Regular(pFanin0);
743 Aig_Obj_t * pFaninR1 = Aig_Regular(pFanin1);
744 Dar_Cut_t * pCutSet, * pCut0, * pCut1, * pCut;
747 assert( !Aig_IsComplement(pObj) );
748 assert( Aig_ObjIsNode(pObj) );
749 assert( Dar_ObjCuts(pObj) == NULL );
750 assert( Dar_ObjCuts(pFaninR0) != NULL );
751 assert( Dar_ObjCuts(pFaninR1) != NULL );
761 if ( Dar_WordCountOnes(pCut0->
uSign | pCut1->
uSign) > 4 )
764 pCut = Dar_CutFindFree(
p, pObj );
766 if ( !Dar_CutMerge( pCut, pCut0, pCut1 ) )
773 if ( Dar_CutFilter( pObj, pCut ) )
779 pCut->
uTruth = 0xFFFF & Dar_CutTruth( pCut, pCut0, pCut1, Aig_IsComplement(pFanin0), Aig_IsComplement(pFanin1) );
782 if ( !fSkipTtMin && Dar_CutSuppMinimize( pCut ) )
784 int RetValue = Dar_CutFilter( pObj, pCut );
789 pCut->
Value = Dar_CutFindValue(
p, pCut );
791 if ( pCut->
Value == 0 )
801 p->nCutsUsed += pCut->
fUsed;
820 if ( Dar_ObjCuts(pObj) )
821 return Dar_ObjCuts(pObj);
822 if ( Aig_ObjIsCi(pObj) )
824 if ( Aig_ObjIsBuf(pObj) )
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
int Aig_MmFixedReadMemUsage(Aig_MmFixed_t *p)
char * Aig_MmFixedEntryFetch(Aig_MmFixed_t *p)
struct Aig_Obj_t_ Aig_Obj_t
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
void Aig_MmFixedRestart(Aig_MmFixed_t *p)
Aig_Obj_t * Aig_ObjReal_rec(Aig_Obj_t *pObj)
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
ABC_NAMESPACE_IMPL_START void Dar_CutPrint(Dar_Cut_t *pCut)
DECLARATIONS ///.
Dar_Cut_t * Dar_ObjComputeCuts(Dar_Man_t *p, Aig_Obj_t *pObj, int fSkipTtMin)
Dar_Cut_t * Dar_ObjPrepareCuts(Dar_Man_t *p, Aig_Obj_t *pObj)
void Dar_ManCutsRestart(Dar_Man_t *p, Aig_Obj_t *pRoot)
FUNCTION DECLARATIONS ///.
Dar_Cut_t * Dar_ObjComputeCuts_rec(Dar_Man_t *p, Aig_Obj_t *pObj)
void Dar_ObjCutPrint(Aig_Man_t *p, Aig_Obj_t *pObj)
unsigned Dar_CutSortVars(unsigned uTruth, int *pVars)
void Dar_ManCutsFree(Dar_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Dar_Man_t_ Dar_Man_t
INCLUDES ///.
struct Dar_Cut_t_ Dar_Cut_t
#define Dar_CutForEachLeaf(p, pCut, pLeaf, i)
#define Dar_ObjForEachCutAll(pObj, pCut, i)
MACRO DEFINITIONS ///.
#define Dar_ObjForEachCut(pObj, pCut, i)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.