52 if ( Gia_ObjIsCi(pObj) )
54 assert( Gia_ObjIsAnd(pObj) );
55 iFanin = Gia_ObjFaninId0p(
p, pObj);
56 Vec_IntPush( vNodes, iFanin );
57 if ( !Gia_ObjRefDecId(
p, iFanin) && (Vec_IntSize(vNodes) > Limit || !
Gia_ObjCheckMffc_rec(
p, Gia_ObjFanin0(pObj), Limit, vNodes)) )
59 iFanin = Gia_ObjFaninId1p(
p, pObj);
60 Vec_IntPush( vNodes, iFanin );
61 if ( !Gia_ObjRefDecId(
p, iFanin) && (Vec_IntSize(vNodes) > Limit || !
Gia_ObjCheckMffc_rec(
p, Gia_ObjFanin1(pObj), Limit, vNodes)) )
63 if ( !Gia_ObjIsMux(
p, pObj) )
65 iFanin = Gia_ObjFaninId2p(
p, pObj);
66 Vec_IntPush( vNodes, iFanin );
67 if ( !Gia_ObjRefDecId(
p, iFanin) && (Vec_IntSize(vNodes) > Limit || !
Gia_ObjCheckMffc_rec(
p, Gia_ObjFanin2(
p, pObj), Limit, vNodes)) )
73 int RetValue, iObj, i;
74 Vec_IntClear( vNodes );
78 Vec_IntClear( vLeaves );
79 Vec_IntClear( vInners );
80 Vec_IntSort( vNodes, 0 );
82 if ( Gia_ObjRefNumId(
p, iObj) > 0 || Gia_ObjIsCi(Gia_ManObj(
p, iObj)) )
84 if ( !Vec_IntSize(vLeaves) || Vec_IntEntryLast(vLeaves) != iObj )
85 Vec_IntPush( vLeaves, iObj );
89 if ( !Vec_IntSize(vInners) || Vec_IntEntryLast(vInners) != iObj )
90 Vec_IntPush( vInners, iObj );
92 Vec_IntPush( vInners, Gia_ObjId(
p, pRoot) );
95 Gia_ObjRefIncId(
p, iObj );
102 Vec_Int_t * vNodes, * vLeaves, * vInners, * vMffc;
105 vNodes = Vec_IntAlloc( 2 * LimitMax );
106 vLeaves = Vec_IntAlloc( 2 * LimitMax );
107 vInners = Vec_IntAlloc( 2 * LimitMax );
108 vMffcs = Vec_WecAlloc( 1000 );
112 if ( !Gia_ObjRefNum(
p, pObj) )
116 if ( Vec_IntSize(vInners) < LimitMin )
118 if ( Vec_IntSize(vLeaves) > SuppMax )
122 vMffc = Vec_WecPushLevel( vMffcs );
123 Vec_IntGrow( vMffc, Vec_IntSize(vLeaves) + Vec_IntSize(vInners) + 20 );
124 Vec_IntPush( vMffc, i );
125 Vec_IntPush( vMffc, Vec_IntSize(vLeaves) );
126 Vec_IntPush( vMffc, Vec_IntSize(vInners) );
127 Vec_IntAppend( vMffc, vLeaves );
130 Vec_IntPush( vMffc, 1000 * Vec_IntSize(vInners) / Vec_IntSize(vLeaves) );
132 Vec_IntFree( vNodes );
133 Vec_IntFree( vLeaves );
134 Vec_IntFree( vInners );
136 Vec_WecSortByLastInt( vMffcs, 1 );
140 iPivot = RatioBest * Vec_WecSize(vMffcs) / 100;
142 Vec_IntErase( vMffc );
143 assert( iPivot <= Vec_WecSize(vMffcs) );
144 Vec_WecShrink( vMffcs, iPivot );
163 int i, nDivs, nDivsAll = 0, nDivs0 = 0;
166 nDivs = Vec_IntSize(vMffc) - 3 - Vec_IntEntry(vMffc, 1) - Vec_IntEntry(vMffc, 2);
167 nDivs0 += (nDivs == 0);
171 printf(
"%6d : ", Vec_IntEntry(vMffc, 0) );
172 printf(
"Leaf =%3d ", Vec_IntEntry(vMffc, 1) );
173 printf(
"Mffc =%4d ", Vec_IntEntry(vMffc, 2) );
174 printf(
"Divs =%4d ", nDivs );
177 printf(
"Collected %d (%.1f %%) MFFCs and %d (%.1f %%) have no divisors (div ave for others is %.2f).\n",
178 Vec_WecSize(vMffcs), 100.0 * Vec_WecSize(vMffcs) / Gia_ManAndNum(
p),
179 nDivs0, 100.0 * nDivs0 / Gia_ManAndNum(
p),
180 1.0*nDivsAll/Abc_MaxInt(1, Vec_WecSize(vMffcs) - nDivs0) );
181 printf(
"Using %.2f MB for MFFCs and %.2f MB for pivots. ",
182 Vec_WecMemory(vMffcs)/(1<<20), Vec_WecMemory(vPivots)/(1<<20) );
199 Vec_Int_t * vMffc, * vPivot, * vPivot0, * vPivot1;
202 int i, k, iObj, iPivot, iMffc;
205 vMap = Vec_IntStartFull( Gia_ManObjNum(
p) );
206 vPivots = Vec_WecStart( Gia_ManObjNum(
p) );
209 assert( Vec_IntSize(vMffc) == 3 + Vec_IntEntry(vMffc, 1) );
210 iPivot = Vec_IntEntry( vMffc, 0 );
211 Vec_IntWriteEntry( vMap, iPivot, i );
215 vPivot = Vec_WecEntry( vPivots, iObj );
216 if ( Vec_IntSize(vPivot) == 0 )
217 Vec_IntGrow(vPivot, 4);
218 Vec_IntPush( vPivot, iPivot );
222 Vec_IntSort( vPivot, 0 );
224 vCommon = Vec_IntAlloc( 100 );
225 vCommon2 = Vec_IntAlloc( 100 );
230 vPivot0 = Vec_WecEntry( vPivots, Gia_ObjFaninId0(pObj, i) );
231 vPivot1 = Vec_WecEntry( vPivots, Gia_ObjFaninId1(pObj, i) );
232 Vec_IntTwoFindCommon( vPivot0, vPivot1, vCommon );
233 if ( Gia_ObjIsMuxId(
p, i) )
235 vPivot = Vec_WecEntry( vPivots, Gia_ObjFaninId2(
p, i) );
236 Vec_IntTwoFindCommon( vPivot, vCommon, vCommon2 );
239 if ( Vec_IntSize(vCommon) == 0 )
242 vPivot = Vec_WecEntry( vPivots, i );
243 Vec_IntTwoMerge2( vPivot, vCommon, vCommon2 );
248 iMffc = Vec_IntEntry( vMap, iObj );
250 vMffc = Vec_WecEntry( vMffcs, iMffc );
251 Vec_IntPush( vMffc, i );
255 Vec_IntFree( vCommon );
256 Vec_IntFree( vCommon2 );
259 Vec_WecFree( vPivots );
269 Vec_WecFree( vMffcs );
270Abc_PrintTime( 1,
"Time", Abc_Clock() - clkStart );
318 p->vUnateLits[0] = Vec_IntAlloc( 100 );
319 p->vUnateLits[1] = Vec_IntAlloc( 100 );
320 p->vNotUnateVars[0] = Vec_IntAlloc( 100 );
321 p->vNotUnateVars[1] = Vec_IntAlloc( 100 );
322 p->vUnatePairs[0] = Vec_IntAlloc( 100 );
323 p->vUnatePairs[1] = Vec_IntAlloc( 100 );
324 p->vUnateLitsW[0] = Vec_IntAlloc( 100 );
325 p->vUnateLitsW[1] = Vec_IntAlloc( 100 );
326 p->vUnatePairsW[0] = Vec_IntAlloc( 100 );
327 p->vUnatePairsW[1] = Vec_IntAlloc( 100 );
328 p->vSorter = Vec_WecAlloc(
nWords*64 );
329 p->vBinateVars = Vec_IntAlloc( 100 );
330 p->vGates = Vec_IntAlloc( 100 );
331 p->vDivs = Vec_PtrAlloc( 100 );
336 p->vSims = Vec_WrdAlloc( 100 );
343 p->nDivsMax = nDivsMax;
344 p->iChoice = iChoice;
345 p->fUseXor = fUseXor;
347 p->fVerbose = fVerbose;
348 p->fVeryVerbose = fVeryVerbose;
349 Abc_TtCopy(
p->pSets[0], (
word *)Vec_PtrEntry(vDivs, 0),
nWords, 0 );
350 Abc_TtCopy(
p->pSets[1], (
word *)Vec_PtrEntry(vDivs, 1),
nWords, 0 );
351 Vec_PtrClear(
p->vDivs );
352 Vec_PtrAppend(
p->vDivs, vDivs );
353 Vec_IntClear(
p->vGates );
354 Vec_IntClear(
p->vUnateLits[0] );
355 Vec_IntClear(
p->vUnateLits[1] );
356 Vec_IntClear(
p->vNotUnateVars[0] );
357 Vec_IntClear(
p->vNotUnateVars[1] );
358 Vec_IntClear(
p->vUnatePairs[0] );
359 Vec_IntClear(
p->vUnatePairs[1] );
360 Vec_IntClear(
p->vUnateLitsW[0] );
361 Vec_IntClear(
p->vUnateLitsW[1] );
362 Vec_IntClear(
p->vUnatePairsW[0] );
363 Vec_IntClear(
p->vUnatePairsW[1] );
364 Vec_IntClear(
p->vBinateVars );
368 Vec_IntFree(
p->vUnateLits[0] );
369 Vec_IntFree(
p->vUnateLits[1] );
370 Vec_IntFree(
p->vNotUnateVars[0] );
371 Vec_IntFree(
p->vNotUnateVars[1] );
372 Vec_IntFree(
p->vUnatePairs[0] );
373 Vec_IntFree(
p->vUnatePairs[1] );
374 Vec_IntFree(
p->vUnateLitsW[0] );
375 Vec_IntFree(
p->vUnateLitsW[1] );
376 Vec_IntFree(
p->vUnatePairsW[0] );
377 Vec_IntFree(
p->vUnatePairsW[1] );
378 Vec_IntFree(
p->vBinateVars );
379 Vec_IntFree(
p->vGates );
380 Vec_WrdFree(
p->vSims );
381 Vec_PtrFree(
p->vDivs );
382 Vec_WecFree(
p->vSorter );
404 int iLit0 = Vec_IntEntry( vRes, 2*Node + 0 );
405 int iLit1 = Vec_IntEntry( vRes, 2*Node + 1 );
407 if ( iLit0 > iLit1 && Abc_LitIsCompl(fCompl) )
414 printf(
" %c ", iLit0 > iLit1 ?
'^' : (fCompl ?
'|' :
'&') );
420 if ( Abc_Lit2Var(iLit) < nVars )
423 printf(
"%s%c", Abc_LitIsCompl(iLit) ?
"~":
"",
'a' + Abc_Lit2Var(iLit)-2 );
425 printf(
"%si%d", Abc_LitIsCompl(iLit) ?
"~":
"", Abc_Lit2Var(iLit)-2 );
433 if ( Vec_IntSize(vRes) == 0 )
434 return printf(
"none" );
435 assert( Vec_IntSize(vRes) % 2 == 1 );
436 iTopLit = Vec_IntEntryLast(vRes);
438 return printf(
"const0" );
440 return printf(
"const1" );
458 int nVars = Vec_PtrSize(
p->vDivs);
459 int iTopLit, RetValue;
461 if ( Vec_IntSize(
p->vGates) == 0 )
463 iTopLit = Vec_IntEntryLast(
p->vGates);
467 if ( pFunc ) Abc_TtClear( pFunc,
p->nWords );
468 return Abc_TtIsConst0(
p->pSets[1],
p->nWords );
472 if ( pFunc ) Abc_TtFill( pFunc,
p->nWords );
473 return Abc_TtIsConst0(
p->pSets[0],
p->nWords );
475 if ( Abc_Lit2Var(iTopLit) < nVars )
477 assert( Vec_IntSize(
p->vGates) == 1 );
478 pDivRes = (
word *)Vec_PtrEntry(
p->vDivs, Abc_Lit2Var(iTopLit) );
483 assert( Vec_IntSize(
p->vGates) > 1 );
484 assert( Vec_IntSize(
p->vGates) % 2 == 1 );
485 assert( Abc_Lit2Var(iTopLit)-nVars == Vec_IntSize(
p->vGates)/2-1 );
486 Vec_WrdFill(
p->vSims,
p->nWords * Vec_IntSize(
p->vGates)/2, 0 );
489 int iVar0 = Abc_Lit2Var(iLit0);
490 int iVar1 = Abc_Lit2Var(iLit1);
491 word * pDiv0 = iVar0 < nVars ? (
word *)Vec_PtrEntry(
p->vDivs, iVar0) : Vec_WrdEntryP(
p->vSims,
p->nWords*(iVar0 - nVars));
492 word * pDiv1 = iVar1 < nVars ? (
word *)Vec_PtrEntry(
p->vDivs, iVar1) : Vec_WrdEntryP(
p->vSims,
p->nWords*(iVar1 - nVars));
493 word * pDiv = Vec_WrdEntryP(
p->vSims,
p->nWords*i/2);
495 Abc_TtAndCompl( pDiv, pDiv0, Abc_LitIsCompl(iLit0), pDiv1, Abc_LitIsCompl(iLit1),
p->nWords );
496 else if ( iVar0 > iVar1 )
498 assert( !Abc_LitIsCompl(iLit0) );
499 assert( !Abc_LitIsCompl(iLit1) );
500 Abc_TtXor( pDiv, pDiv0, pDiv1,
p->nWords, 0 );
504 pDivRes = Vec_WrdEntryP(
p->vSims,
p->nWords*(Vec_IntSize(
p->vGates)/2-1) );
506 if ( Abc_LitIsCompl(iTopLit) )
507 RetValue = !Abc_TtIntersectOne(
p->pSets[1], 0, pDivRes, 0,
p->nWords) && !Abc_TtIntersectOne(
p->pSets[0], 0, pDivRes, 1,
p->nWords);
509 RetValue = !Abc_TtIntersectOne(
p->pSets[0], 0, pDivRes, 0,
p->nWords) && !Abc_TtIntersectOne(
p->pSets[1], 0, pDivRes, 1,
p->nWords);
510 if ( pFunc ) Abc_TtCopy( pFunc, pDivRes,
p->nWords, Abc_LitIsCompl(iTopLit) );
527 int i, iLit0, iLit1, iLitRes, iTopLit = Vec_IntEntryLast( vGates );
528 assert( Vec_IntSize(vUsed) == nVars );
529 assert( Vec_IntSize(vGates) > 1 );
530 assert( Vec_IntSize(vGates) % 2 == 1 );
531 assert( Abc_Lit2Var(iTopLit)-nVars == Vec_IntSize(vGates)/2-1 );
532 Vec_IntClear( vCopy );
535 int iVar0 = Abc_Lit2Var(iLit0);
536 int iVar1 = Abc_Lit2Var(iLit1);
537 int iRes0 = iVar0 < nVars ? Vec_IntEntry(vUsed, iVar0) : Vec_IntEntry(vCopy, iVar0 - nVars);
538 int iRes1 = iVar1 < nVars ? Vec_IntEntry(vUsed, iVar1) : Vec_IntEntry(vCopy, iVar1 - nVars);
542 iLitRes =
Gia_ManHashAnd( pNew, Abc_LitNotCond(iRes0, Abc_LitIsCompl(iLit0)), Abc_LitNotCond(iRes1, Abc_LitIsCompl(iLit1)) );
544 iLitRes = Gia_ManAppendAnd( pNew, Abc_LitNotCond(iRes0, Abc_LitIsCompl(iLit0)), Abc_LitNotCond(iRes1, Abc_LitIsCompl(iLit1)) );
546 else if ( iVar0 > iVar1 )
548 assert( !Abc_LitIsCompl(iLit0) );
549 assert( !Abc_LitIsCompl(iLit1) );
551 iLitRes =
Gia_ManHashXor( pNew, Abc_LitNotCond(iRes0, Abc_LitIsCompl(iLit0)), Abc_LitNotCond(iRes1, Abc_LitIsCompl(iLit1)) );
553 iLitRes = Gia_ManAppendXor( pNew, Abc_LitNotCond(iRes0, Abc_LitIsCompl(iLit0)), Abc_LitNotCond(iRes1, Abc_LitIsCompl(iLit1)) );
556 Vec_IntPush( vCopy, iLitRes );
558 assert( Vec_IntSize(vCopy) == Vec_IntSize(vGates)/2 );
559 iLitRes = Vec_IntEntry( vCopy, Vec_IntSize(vGates)/2-1 );
566 Vec_Int_t * vUsed = Vec_IntStartFull( nDivs );
568 pNew->
pName = Abc_UtilStrsav(
"resub" );
571 assert( Vec_IntSize(vGates) % 2 == 1 );
574 int iVar = Abc_Lit2Var(iLit);
575 if ( iVar > 0 && iVar < nDivs && Vec_IntEntry(vUsed, iVar) == -1 )
576 Vec_IntWriteEntry( vUsed, iVar, Gia_ManAppendCi(pNew) );
581 int iLitRes, iTopLit = Vec_IntEntryLast( vGates );
582 if ( Abc_Lit2Var(iTopLit) == 0 )
584 else if ( Abc_Lit2Var(iTopLit) < nDivs )
585 iLitRes = Vec_IntEntry( vUsed, Abc_Lit2Var(iTopLit) );
588 Gia_ManAppendCo( pNew, Abc_LitNotCond( iLitRes, Abc_LitIsCompl(iTopLit) ) );
590 Vec_IntFree( vCopy );
591 Vec_IntFree( vUsed );
596 Vec_Int_t * vGates;
int i, k, iVar, iLit;
599 Vec_Wec_t * vUseds = Vec_WecStart( Vec_WecSize(vDivs) );
600 Vec_Int_t * vMap = Vec_IntStartFull( nObjs );
602 pNew->
pName = Abc_UtilStrsav(
"resub" );
603 assert( Vec_WecSize(vFuncs) == Vec_WecSize(vDivs) );
606 Vec_Int_t * vDiv = Vec_WecEntry( vDivs, i );
607 assert( Vec_IntSize(vGates) % 2 == 1 );
610 int iVar = Abc_Lit2Var(iLit);
611 if ( iVar > 0 && iVar < Vec_IntSize(vDiv) && Vec_IntEntry(vMap, Vec_IntEntry(vDiv, iVar)) == -1 )
612 Vec_IntWriteEntry( vMap, Vec_IntPushReturn(vSupp, Vec_IntEntry(vDiv, iVar)), 0 );
615 Vec_IntSort( vSupp, 0 );
617 Vec_IntWriteEntry( vMap, iVar, Gia_ManAppendCi(pNew) );
620 Vec_Int_t * vDiv = Vec_WecEntry( vDivs, i );
621 Vec_Int_t * vUsed = Vec_WecEntry( vUseds, i );
622 Vec_IntFill( vUsed, Vec_IntSize(vDiv), -1 );
625 int iVar = Abc_Lit2Var(iLit);
626 if ( iVar > 0 && iVar < Vec_IntSize(vDiv) )
628 assert( Vec_IntEntry(vMap, Vec_IntEntry(vDiv, iVar)) > 0 );
629 Vec_IntWriteEntry( vUsed, iVar, Vec_IntEntry(vMap, Vec_IntEntry(vDiv, iVar)) );
635 Vec_Int_t * vDiv = Vec_WecEntry( vDivs, i );
636 Vec_Int_t * vUsed = Vec_WecEntry( vUseds, i );
637 int iLitRes, iTopLit = Vec_IntEntryLast( vGates );
638 if ( Abc_Lit2Var(iTopLit) == 0 )
640 else if ( Abc_Lit2Var(iTopLit) < Vec_IntSize(vDiv) )
641 iLitRes = Vec_IntEntry( vUsed, Abc_Lit2Var(iTopLit) );
644 Gia_ManAppendCo( pNew, Abc_LitNotCond( iLitRes, Abc_LitIsCompl(iTopLit) ) );
647 Vec_IntFree( vCopy );
648 Vec_WecFree( vUseds );
652 Vec_IntFree( vSupp );
657 Vec_Int_t * vRes = Vec_IntAlloc( 2*Gia_ManAndNum(
p) + 1 );
659 int iRoot = Gia_ObjFaninId0p(
p, pRoot) - 1;
660 int nVars = Gia_ManCiNum(
p);
661 assert( Gia_ManCoNum(
p) == 1 );
663 Vec_IntPush( vRes, Gia_ObjFaninC0(pRoot) );
664 else if ( iRoot < nVars )
665 Vec_IntPush( vRes, 4 + Abc_Var2Lit(iRoot, Gia_ObjFaninC0(pRoot)) );
670 assert( Gia_ObjId(
p, pObj) == i+1 );
673 int iLit0 = Abc_Var2Lit( Gia_ObjFaninId0(pObj, i) - 1, Gia_ObjFaninC0(pObj) );
674 int iLit1 = Abc_Var2Lit( Gia_ObjFaninId1(pObj, i) - 1, Gia_ObjFaninC1(pObj) );
676 iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1;
677 Vec_IntPushTwo( vRes, 4 + iLit0, 4 + iLit1 );
680 assert( pLast == Gia_ObjFanin0(pRoot) );
681 Vec_IntPush( vRes, 4 + Abc_Var2Lit(iRoot, Gia_ObjFaninC0(pRoot)) );
683 assert( Vec_IntSize(vRes) == 2*Gia_ManAndNum(
p) + 1 );
705 int nVars = Gia_ManObjNum(
p);
706 int k, iLit, Index = Vec_IntFind( vObjs, iObj );
707 Vec_Int_t * vGates = Vec_WecEntry( vFuncs, Index );
708 assert( Gia_ObjIsCo(pObj) || Gia_ObjIsAnd(pObj) );
710 if ( Abc_Lit2Var(iLit) < nVars )
713 else if ( Gia_ObjIsCo(pObj) )
715 else if ( Gia_ObjIsAnd(pObj) )
720 else assert( Gia_ObjIsCi(pObj) );
721 if ( !Gia_ObjIsCi(pObj) )
722 Vec_IntPush( vNodes, iObj );
727 Vec_Int_t * vNodes = Vec_IntAlloc( Gia_ManObjNum(
p) );
736 int i, nVars = Gia_ManObjNum(
p);
737 Vec_Int_t * vUsed = Vec_IntStartFull( nVars );
738 Vec_Int_t * vNodes, * vCopy = Vec_IntAlloc(100);
744 Gia_ManConst0(
p)->Value = 0;
746 pObj->
Value = Gia_ManAppendCi( pNew );
750 if ( Gia_ObjIsCo(pObj) )
751 pObj->
Value = Gia_ObjFanin0Copy(pObj);
752 else if ( Gia_ObjIsAnd(pObj) )
758 int k, iLit, Index = Vec_IntFind( vObjs, Gia_ObjId(
p, pObj) );
759 Vec_Int_t * vGates = Vec_WecEntry( vFuncs, Index );
760 int iLitRes, iTopLit = Vec_IntEntryLast( vGates );
761 if ( Abc_Lit2Var(iTopLit) == 0 )
763 else if ( Abc_Lit2Var(iTopLit) < nVars )
764 iLitRes = Gia_ManObj(
p, Abc_Lit2Var(iTopLit))->Value;
768 Vec_IntWriteEntry( vUsed, Abc_Lit2Var(iLit), Gia_ManObj(
p, Abc_Lit2Var(iLit))->Value );
771 Vec_IntWriteEntry( vUsed, Abc_Lit2Var(iLit), -1 );
773 pObj->
Value = Abc_LitNotCond( iLitRes, Abc_LitIsCompl(iTopLit) );
776 Gia_ManAppendCo( pNew, pObj->
Value );
782 Vec_IntFree( vNodes );
783 Vec_IntFree( vUsed );
784 Vec_IntFree( vCopy );
800static inline int Gia_ManFindFirstCommonLit(
Vec_Int_t * vArr1,
Vec_Int_t * vArr2,
int fVerbose )
802 int * pBeg1 = vArr1->pArray;
803 int * pBeg2 = vArr2->pArray;
804 int * pEnd1 = vArr1->pArray + vArr1->nSize;
805 int * pEnd2 = vArr2->pArray + vArr2->nSize;
806 int * pStart1 = vArr1->pArray;
807 int * pStart2 = vArr2->pArray;
809 while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
811 if ( Abc_Lit2Var(*pBeg1) == Abc_Lit2Var(*pBeg2) )
813 if ( *pBeg1 != *pBeg2 )
819 else if ( *pBeg1 < *pBeg2 )
820 *pStart1++ = *pBeg1++;
822 *pStart2++ = *pBeg2++;
824 while ( pBeg1 < pEnd1 )
825 *pStart1++ = *pBeg1++;
826 while ( pBeg2 < pEnd2 )
827 *pStart2++ = *pBeg2++;
828 Vec_IntShrink( vArr1, pStart1 - vArr1->pArray );
829 Vec_IntShrink( vArr2, pStart2 - vArr2->pArray );
837 Vec_IntClear( vUnateLits );
838 Vec_IntClear( vNotUnateVars );
840 if ( !Abc_TtIntersectOne( pOff, 0, pDiv, 0,
nWords ) )
841 Vec_IntPush( vUnateLits, Abc_Var2Lit(i, 0) );
842 else if ( !Abc_TtIntersectOne( pOff, 0, pDiv, 1,
nWords ) )
843 Vec_IntPush( vUnateLits, Abc_Var2Lit(i, 1) );
845 Vec_IntPush( vNotUnateVars, i );
850 if ( fVerbose ) printf(
" " );
851 for ( n = 0; n < 2; n++ )
854 if ( fVerbose ) printf(
"U%d =%4d ", n, Vec_IntSize(vUnateLits[n]) );
856 return Gia_ManFindFirstCommonLit( vUnateLits[0], vUnateLits[1], fVerbose );
859static inline int Gia_ManDivCover(
word * pOff,
word * pOn,
word * pDivA,
int ComplA,
word * pDivB,
int ComplB,
int nWords )
863 return !Abc_TtIntersectTwo( pOn, 0, pDivA, !ComplA, pDivB, !ComplB,
nWords );
867 int i, k, iDiv0_, iDiv1_, Cover0, Cover1;
876 int iDiv0 = Abc_MinInt( iDiv0_, iDiv1_ );
877 int iDiv1 = Abc_MaxInt( iDiv0_, iDiv1_ );
878 word * pDiv0 = (
word *)Vec_PtrEntry(vDivs, Abc_Lit2Var(iDiv0));
879 word * pDiv1 = (
word *)Vec_PtrEntry(vDivs, Abc_Lit2Var(iDiv1));
880 if ( Cover0 + Cover1 <
nTotal )
883 if ( Gia_ManDivCover(pOff, pOn, pDiv1, Abc_LitIsCompl(iDiv1), pDiv0, Abc_LitIsCompl(iDiv0),
nWords) )
884 return Abc_Var2Lit((Abc_LitNot(iDiv1) << 15) | Abc_LitNot(iDiv0), 1);
892 if ( fVerbose ) printf(
" " );
893 for ( n = 0; n < 2; n++ )
897 if ( fVerbose ) printf(
"UU%d =%5d ", n, nPairs );
899 return Abc_LitNotCond(iLit, n);
906 int i, k, iDiv0_, iDiv1_;
907 int Limit2 = Vec_IntSize(vBinate);
911 int iDiv0 = Abc_MinInt( iDiv0_, iDiv1_ );
912 int iDiv1 = Abc_MaxInt( iDiv0_, iDiv1_ );
913 word * pDiv0 = (
word *)Vec_PtrEntry(vDivs, iDiv0);
914 word * pDiv1 = (
word *)Vec_PtrEntry(vDivs, iDiv1);
915 if ( !Abc_TtIntersectXor( pOff, 0, pDiv0, pDiv1, 0,
nWords ) )
916 Vec_IntPush( vUnatePairs, Abc_Var2Lit((Abc_Var2Lit(iDiv0, 0) << 15) | Abc_Var2Lit(iDiv1, 0), 0) );
917 else if ( !Abc_TtIntersectXor( pOff, 0, pDiv0, pDiv1, 1,
nWords ) )
918 Vec_IntPush( vUnatePairs, Abc_Var2Lit((Abc_Var2Lit(iDiv0, 0) << 15) | Abc_Var2Lit(iDiv1, 0), 1) );
924 if ( fVerbose ) printf(
" " );
925 for ( n = 0; n < 2; n++ )
927 Vec_IntClear( vUnatePairs[n] );
929 if ( fVerbose ) printf(
"UX%d =%5d ", n, Vec_IntSize(vUnatePairs[n]) );
931 return Gia_ManFindFirstCommonLit( vUnatePairs[0], vUnatePairs[1], fVerbose );
936 int n, i, k, iDiv0_, iDiv1_;
937 int Limit2 = Vec_IntSize(vBinate);
941 int iDiv0 = Abc_MinInt( iDiv0_, iDiv1_ );
942 int iDiv1 = Abc_MaxInt( iDiv0_, iDiv1_ );
943 word * pDiv0 = (
word *)Vec_PtrEntry(vDivs, iDiv0);
944 word * pDiv1 = (
word *)Vec_PtrEntry(vDivs, iDiv1);
945 for ( n = 0; n < 4; n++ )
947 int iLit0 = Abc_Var2Lit( iDiv0, n&1 );
948 int iLit1 = Abc_Var2Lit( iDiv1, n>>1 );
950 if ( !Abc_TtIntersectTwo( pOff, 0, pDiv1, n>>1, pDiv0, n&1,
nWords ) && Abc_TtIntersectTwo( pOn, 0, pDiv1, n>>1, pDiv0, n&1,
nWords ) )
951 Vec_IntPush( vUnatePairs, Abc_Var2Lit((iLit1 << 15) | iLit0, 0) );
958 if ( fVerbose ) printf(
" " );
959 for ( n = 0; n < 2; n++ )
961 int nBefore = Vec_IntSize(vUnatePairs[n]);
963 if ( fVerbose ) printf(
"UP%d =%5d ", n, Vec_IntSize(vUnatePairs[n])-nBefore );
965 RetValue = Gia_ManFindFirstCommonLit( vUnatePairs[0], vUnatePairs[1], fVerbose );
971 int fComp = Abc_LitIsCompl(iDiv);
972 int iDiv0 = Abc_Lit2Var(iDiv) & 0x7FFF;
973 int iDiv1 = Abc_Lit2Var(iDiv) >> 15;
974 word * pDiv0 = (
word *)Vec_PtrEntry(vDivs, Abc_Lit2Var(iDiv0));
975 word * pDiv1 = (
word *)Vec_PtrEntry(vDivs, Abc_Lit2Var(iDiv1));
979 Abc_TtAndCompl( pRes, pDiv0, Abc_LitIsCompl(iDiv0), pDiv1, Abc_LitIsCompl(iDiv1),
nWords );
983 assert( !Abc_LitIsCompl(iDiv0) );
984 assert( !Abc_LitIsCompl(iDiv1) );
985 Abc_TtXor( pRes, pDiv0, pDiv1,
nWords, 0 );
990 int i, k, iDiv0, iDiv1, Cover0, Cover1;
994 word * pDiv0 = (
word *)Vec_PtrEntry(vDivs, Abc_Lit2Var(iDiv0));
999 int fComp1 = Abc_LitIsCompl(iDiv1);
1000 if ( Cover0 + Cover1 <
nTotal )
1003 if ( Gia_ManDivCover(pOff, pOn, pDiv0, Abc_LitIsCompl(iDiv0), pDivTemp, fComp1,
nWords) )
1004 return Abc_Var2Lit((Abc_Var2Lit(k, 1) << 15) | Abc_LitNot(iDiv0), 1);
1012 for ( n = 0; n < 2; n++ )
1014 iLit =
Gia_ManFindDivGateInt( pSets[n], pSets[!n], vDivs,
nWords, vUnateLits[n], vUnatePairs[n], vUnateLitsW[n], vUnatePairsW[n], pDivTemp );
1016 return Abc_LitNotCond( iLit, n );
1023 int i, k, iDiv0, iDiv1, Cover0, Cover1;
1027 int fCompA = Abc_LitIsCompl(iDiv0);
1033 int fCompB = Abc_LitIsCompl(iDiv1);
1034 if ( Cover0 + Cover1 <
nTotal )
1037 if ( Gia_ManDivCover(pOff, pOn, pDivTempA, fCompA, pDivTempB, fCompB,
nWords) )
1038 return Abc_Var2Lit((Abc_Var2Lit(i, 1) << 15) | Abc_Var2Lit(k, 1), 1);
1046 for ( n = 0; n < 2; n++ )
1050 return Abc_LitNotCond( iLit, n );
1059 Vec_WecInit( vSorter,
nWords*64 );
1062 word * pDiv = (
word *)Vec_PtrEntry(vDivs, Abc_Lit2Var(iLit));
1064 Vec_WecPush( vSorter, Abc_TtCountOnesVecMask(pDiv, pOn,
nWords, Abc_LitIsCompl(iLit)), iLit );
1066 Vec_IntClear( vUnateLits );
1067 Vec_IntClear( vUnateLitsW );
1071 Vec_IntPush( vUnateLits, iLit );
1072 Vec_IntPush( vUnateLitsW, k );
1075 Vec_WecClear( vSorter );
1080 for ( n = 0; n < 2; n++ )
1088 Vec_WecInit( vSorter,
nWords*64 );
1091 int fComp = Abc_LitIsCompl(iPair);
1092 int iLit0 = Abc_Lit2Var(iPair) & 0x7FFF;
1093 int iLit1 = Abc_Lit2Var(iPair) >> 15;
1094 word * pDiv0 = (
word *)Vec_PtrEntry( vDivs, Abc_Lit2Var(iLit0) );
1095 word * pDiv1 = (
word *)Vec_PtrEntry( vDivs, Abc_Lit2Var(iLit1) );
1096 if ( iLit0 < iLit1 )
1100 Vec_WecPush( vSorter, Abc_TtCountOnesVecMask2(pDiv0, pDiv1, Abc_LitIsCompl(iLit0), Abc_LitIsCompl(iLit1), pOn,
nWords), iPair );
1104 assert( !Abc_LitIsCompl(iLit0) );
1105 assert( !Abc_LitIsCompl(iLit1) );
1107 Vec_WecPush( vSorter, Abc_TtCountOnesVecXorMask(pDiv0, pDiv1, fComp, pOn,
nWords), iPair );
1110 Vec_IntClear( vUnatePairs );
1111 Vec_IntClear( vUnatePairsW );
1115 Vec_IntPush( vUnatePairs, iPair );
1116 Vec_IntPush( vUnatePairsW, k );
1119 Vec_WecClear( vSorter );
1125 for ( n = 0; n < 2; n++ )
1132 int nMints[2] = { Abc_TtCountOnesVec(pSets[0],
nWords), Abc_TtCountOnesVec(pSets[1],
nWords) };
1133 word * pBig = nMints[0] > nMints[1] ? pSets[0] : pSets[1];
1134 word * pSmo = nMints[0] > nMints[1] ? pSets[1] : pSets[0];
1135 int Big = Abc_MaxInt( nMints[0], nMints[1] );
1136 int Smo = Abc_MinInt( nMints[0], nMints[1] );
1137 int i, k, iDiv, Gain;
1139 Vec_WecInit( vSorter,
nWords*64 );
1142 word * pDiv = (
word *)Vec_PtrEntry( vDivs, iDiv );
1143 int nInter[2] = { Abc_TtCountOnesVecMask(pBig, pDiv,
nWords, 0), Abc_TtCountOnesVecMask(pSmo, pDiv,
nWords, 0) };
1144 if ( nInter[0] < Big/2 )
1146 nInter[0] = Big - nInter[0];
1147 nInter[1] = Smo - nInter[1];
1149 assert( nInter[0] >= Big/2 );
1150 Gain = Abc_MaxInt( 0, nInter[0] - Big/2 + Smo/2 - nInter[1] );
1151 Vec_WecPush( vSorter, Gain, iDiv );
1154 Vec_IntClear( vBinateVars );
1157 Vec_IntPush( vBinateVars, iDiv );
1158 Vec_WecClear( vSorter );
1160 if ( Vec_IntSize(vBinateVars) > 2000 )
1161 Vec_IntShrink( vBinateVars, 2000 );
1177 int nMintsAll = Abc_TtCountOnesVec(
p->pSets[0],
p->nWords) + Abc_TtCountOnesVec(
p->pSets[1],
p->nWords);
1178 int i, iDiv, iLitBest = -1, CostBest = -1;
1184 word * pDiv = (
word *)Vec_PtrEntry(
p->vDivs, iDiv);
1185 int nMints0 = Abc_TtCountOnesVecMask( pDiv,
p->pSets[0],
p->nWords, 0 );
1186 int nMints1 = Abc_TtCountOnesVecMask( pDiv,
p->pSets[1],
p->nWords, 0 );
1187 if ( CostBest < nMints0 + nMints1 )
1189 CostBest = nMints0 + nMints1;
1190 iLitBest = Abc_Var2Lit( iDiv, 0 );
1192 if ( CostBest < nMintsAll - nMints0 - nMints1 )
1194 CostBest = nMintsAll - nMints0 - nMints1;
1195 iLitBest = Abc_Var2Lit( iDiv, 1 );
1202 int iNode = Vec_PtrSize(
p->vDivs) + Vec_IntSize(
p->vGates)/2;
1203 int fFlip = (Type == 2) ^ (iLit0 > iLit1);
1204 int iFan0 = fFlip ? iLit1 : iLit0;
1205 int iFan1 = fFlip ? iLit0 : iLit1;
1206 assert( iLit0 != iLit1 );
1211 Vec_IntPushTwo(
p->vGates, Abc_LitNotCond(iFan0, Type==1), Abc_LitNotCond(iFan1, Type==1) );
1212 return Abc_Var2Lit( iNode, Type==1 );
1217 int iDivBest, iResLit0, iResLit1, nNodes;
1218 word * pDiv, * pCopy[2];
1224 if ( iDivBest == -1 )
1228 Abc_TtCopy( pCopy[0],
p->pSets[0],
p->nWords, 0 );
1229 Abc_TtCopy( pCopy[1],
p->pSets[1],
p->nWords, 0 );
1230 pDiv = (
word *)Vec_PtrEntry(
p->vDivs, Abc_Lit2Var(iDivBest) );
1231 Abc_TtAndSharp(
p->pSets[0], pCopy[0], pDiv,
p->nWords, !Abc_LitIsCompl(iDivBest) );
1232 Abc_TtAndSharp(
p->pSets[1], pCopy[1], pDiv,
p->nWords, !Abc_LitIsCompl(iDivBest) );
1233 nNodes = Vec_IntSize(
p->vGates)/2;
1236 if ( iResLit0 == -1 )
1238 if ( iResLit0 == -1 )
1244 Abc_TtAndSharp(
p->pSets[0], pCopy[0], pDiv,
p->nWords, Abc_LitIsCompl(iDivBest) );
1245 Abc_TtAndSharp(
p->pSets[1], pCopy[1], pDiv,
p->nWords, Abc_LitIsCompl(iDivBest) );
1248 nNodes = Vec_IntSize(
p->vGates)/2 - nNodes;
1249 if ( nLimit-nNodes < 3 )
1253 if ( iResLit1 == -1 )
1255 if ( iResLit1 == -1 )
1278 int TopOneW[2] = {0}, TopTwoW[2] = {0}, Max1, Max2, iResLit, nVars = Vec_PtrSize(
p->vDivs);
1281 int nMints[2] = { Abc_TtCountOnesVec(
p->pSets[0],
p->nWords), Abc_TtCountOnesVec(
p->pSets[1],
p->nWords) };
1284 printf(
"0=%5d (%5.2f %%) ", nMints[0], 100.0*nMints[0]/(64*
p->nWords) );
1285 printf(
"1=%5d (%5.2f %%) ", nMints[1], 100.0*nMints[1]/(64*
p->nWords) );
1287 if ( Abc_TtIsConst0(
p->pSets[1],
p->nWords ) )
1289 if ( Abc_TtIsConst0(
p->pSets[0],
p->nWords ) )
1300 int iNode = nVars + Vec_IntSize(
p->vGates)/2;
1301 int fComp = Abc_LitIsCompl(iResLit);
1302 int iDiv0 = Abc_Lit2Var(iResLit) & 0x7FFF;
1303 int iDiv1 = Abc_Lit2Var(iResLit) >> 15;
1305 Vec_IntPushTwo(
p->vGates, iDiv0, iDiv1 );
1306 return Abc_Var2Lit( iNode, fComp );
1308 Vec_IntTwoFindCommon(
p->vNotUnateVars[0],
p->vNotUnateVars[1],
p->vBinateVars );
1311 if ( Vec_IntSize(
p->vBinateVars) >
p->nDivsMax )
1312 Vec_IntShrink(
p->vBinateVars,
p->nDivsMax );
1313 if (
p->fVerbose ) printf(
" B = %3d", Vec_IntSize(
p->vBinateVars) );
1317 iResLit =
Gia_ManFindXor(
p->pSets,
p->vDivs,
p->nWords,
p->vBinateVars,
p->vUnatePairs,
p->fVerbose );
1320 int iNode = nVars + Vec_IntSize(
p->vGates)/2;
1321 int fComp = Abc_LitIsCompl(iResLit);
1322 int iDiv0 = Abc_Lit2Var(iResLit) & 0x7FFF;
1323 int iDiv1 = Abc_Lit2Var(iResLit) >> 15;
1324 assert( !Abc_LitIsCompl(iDiv0) );
1325 assert( !Abc_LitIsCompl(iDiv1) );
1327 Vec_IntPushTwo(
p->vGates, iDiv0, iDiv1 );
1328 return Abc_Var2Lit( iNode, fComp );
1335 iResLit =
Gia_ManFindDivGate(
p->pSets,
p->vDivs,
p->nWords,
p->vUnateLits,
p->vUnatePairs,
p->vUnateLitsW,
p->vUnatePairsW,
p->pDivA );
1338 int iNode = nVars + Vec_IntSize(
p->vGates)/2;
1340 int fComp = Abc_LitIsCompl(iResLit);
1341 int iDiv0 = Abc_Lit2Var(iResLit) & 0x7FFF;
1342 int iDiv1 = Abc_Lit2Var(iResLit) >> 15;
1344 int Div1 = Vec_IntEntry(
p->vUnatePairs[!fComp], Abc_Lit2Var(iDiv1) );
1345 int fComp1 = Abc_LitIsCompl(Div1) ^ Abc_LitIsCompl(iDiv1);
1346 int iDiv10 = Abc_Lit2Var(Div1) & 0x7FFF;
1347 int iDiv11 = Abc_Lit2Var(Div1) >> 15;
1349 Vec_IntPushTwo(
p->vGates, iDiv10, iDiv11 );
1350 Vec_IntPushTwo(
p->vGates, iDiv0, Abc_Var2Lit(iNode, fComp1) );
1351 return Abc_Var2Lit( iNode+1, fComp );
1360 int iNode = nVars + Vec_IntSize(
p->vGates)/2;
1362 int fComp = Abc_LitIsCompl(iResLit);
1363 int iDiv0 = Abc_Lit2Var(iResLit) & 0x7FFF;
1364 int iDiv1 = Abc_Lit2Var(iResLit) >> 15;
1366 int Div0 = Vec_IntEntry(
p->vUnatePairs[!fComp], Abc_Lit2Var(iDiv0) );
1367 int fComp0 = Abc_LitIsCompl(Div0) ^ Abc_LitIsCompl(iDiv0);
1368 int iDiv00 = Abc_Lit2Var(Div0) & 0x7FFF;
1369 int iDiv01 = Abc_Lit2Var(Div0) >> 15;
1371 int Div1 = Vec_IntEntry(
p->vUnatePairs[!fComp], Abc_Lit2Var(iDiv1) );
1372 int fComp1 = Abc_LitIsCompl(Div1) ^ Abc_LitIsCompl(iDiv1);
1373 int iDiv10 = Abc_Lit2Var(Div1) & 0x7FFF;
1374 int iDiv11 = Abc_Lit2Var(Div1) >> 15;
1376 Vec_IntPushTwo(
p->vGates, iDiv00, iDiv01 );
1377 Vec_IntPushTwo(
p->vGates, iDiv10, iDiv11 );
1378 Vec_IntPushTwo(
p->vGates, Abc_Var2Lit(iNode, fComp0), Abc_Var2Lit(iNode+1, fComp1) );
1379 return Abc_Var2Lit( iNode+2, fComp );
1384 if ( Vec_IntSize(
p->vUnateLits[0]) + Vec_IntSize(
p->vUnateLits[1]) + Vec_IntSize(
p->vUnatePairs[0]) + Vec_IntSize(
p->vUnatePairs[1]) == 0 )
1387 TopOneW[0] = Vec_IntSize(
p->vUnateLitsW[0]) ? Vec_IntEntry(
p->vUnateLitsW[0], 0) : 0;
1388 TopOneW[1] = Vec_IntSize(
p->vUnateLitsW[1]) ? Vec_IntEntry(
p->vUnateLitsW[1], 0) : 0;
1390 TopTwoW[0] = Vec_IntSize(
p->vUnatePairsW[0]) ? Vec_IntEntry(
p->vUnatePairsW[0], 0) : 0;
1391 TopTwoW[1] = Vec_IntSize(
p->vUnatePairsW[1]) ? Vec_IntEntry(
p->vUnatePairsW[1], 0) : 0;
1393 Max1 = Abc_MaxInt(TopOneW[0], TopOneW[1]);
1394 Max2 = Abc_MaxInt(TopTwoW[0], TopTwoW[1]);
1395 if ( Abc_MaxInt(Max1, Max2) == 0 )
1398 if ( Max1 > Max2/2 )
1400 if ( nLimit >= 2 && (Max1 == TopOneW[0] || Max1 == TopOneW[1]) )
1402 int fUseOr = Max1 == TopOneW[0];
1403 int iDiv = Vec_IntEntry(
p->vUnateLits[!fUseOr], 0 );
1404 int fComp = Abc_LitIsCompl(iDiv);
1405 word * pDiv = (
word *)Vec_PtrEntry(
p->vDivs, Abc_Lit2Var(iDiv) );
1406 Abc_TtAndSharp(
p->pSets[fUseOr],
p->pSets[fUseOr], pDiv,
p->nWords, !fComp );
1412 int iNode = nVars + Vec_IntSize(
p->vGates)/2;
1413 if ( iDiv < iResLit )
1414 Vec_IntPushTwo(
p->vGates, Abc_LitNot(iDiv), Abc_LitNotCond(iResLit, fUseOr) );
1416 Vec_IntPushTwo(
p->vGates, Abc_LitNotCond(iResLit, fUseOr), Abc_LitNot(iDiv) );
1417 return Abc_Var2Lit( iNode, fUseOr );
1447 if ( nLimit >= 3 && (Max2 == TopTwoW[0] || Max2 == TopTwoW[1]) )
1449 int fUseOr = Max2 == TopTwoW[0];
1450 int iDiv = Vec_IntEntry(
p->vUnatePairs[!fUseOr], 0 );
1451 int fComp = Abc_LitIsCompl(iDiv);
1453 Abc_TtAndSharp(
p->pSets[fUseOr],
p->pSets[fUseOr],
p->pDivA,
p->nWords, !fComp );
1459 int iNode = nVars + Vec_IntSize(
p->vGates)/2;
1460 int iDiv0 = Abc_Lit2Var(iDiv) & 0x7FFF;
1461 int iDiv1 = Abc_Lit2Var(iDiv) >> 15;
1462 Vec_IntPushTwo(
p->vGates, iDiv0, iDiv1 );
1463 Vec_IntPushTwo(
p->vGates, Abc_LitNotCond(iResLit, fUseOr), Abc_Var2Lit(iNode, !fComp) );
1464 return Abc_Var2Lit( iNode+1, fUseOr );
1494 Gia_ResbInit(
p, vDivs,
nWords, nLimit, nDivsMax, iChoice, fUseXor, fDebug, fVerbose, fVerbose );
1497 Vec_IntPush(
p->vGates, Res );
1499 Vec_IntClear(
p->vGates );
1515 printf(
"Verification FAILED.\n" );
1517 else if ( fDebug && fVerbose )
1518 printf(
"Verification succeeded." );
1521 vRes = Vec_IntDup(
p->vGates );
1541 if ( s_pResbMan != NULL )
1550 Vec_Ptr_t Divs = { nDivs, nDivs, ppDivs };
1551 assert( s_pResbMan != NULL );
1555 int nGates = Vec_IntSize(s_pResbMan->vGates)/2;
1558 printf(
" Gain = %2d Gates = %2d __________ F = ", nLimit+1-nGates, nGates );
1568 printf(
"Verification FAILED.\n" );
1573 *ppArray = Vec_IntArray(s_pResbMan->vGates);
1574 assert( Vec_IntSize(s_pResbMan->vGates)/2 <= nLimit );
1575 return Vec_IntSize(s_pResbMan->vGates);
1583 for ( d = 0; d < nDivs; d++ )
1584 for ( w = 0; w <
nWords; w++ )
1585 Vec_WrdPush( vSims, pDivs[d][w] );
1586 Vec_WrdDumpHex( pFileName, vSims,
nWords, 1 );
1587 Vec_WrdFree( vSims );
1602extern void Extra_PrintHex( FILE * pFile,
unsigned * pTruth,
int nVars );
1609 word Divs[6] = { 0, 0,
1617 int i, k, ArraySize, * pArray;
1618 for ( i = 0; i < 6; i++ )
1619 Vec_PtrPush( vDivs, Divs+i );
1621 for ( i = 0; i < (1<<(1<<nVars)); i++ )
1623 word Truth = Abc_Tt6Stretch( i, nVars );
1626 printf(
"%3d : ", i );
1633 ArraySize =
Abc_ResubComputeFunction( (
void **)Vec_PtrArray(vDivs), Vec_PtrSize(vDivs), 1, 16, 50, 0, 0, 1, fVerbose, &pArray );
1636 Vec_IntClear( vRes );
1637 for ( k = 0; k < ArraySize; k++ )
1638 Vec_IntPush( vRes, pArray[k] );
1644 Vec_IntFree( vRes );
1645 Vec_PtrFree( vDivs );
1650 word Divs[6] = { 0, 0,
1659 for ( i = 0; i < 6; i++ )
1660 Vec_PtrPush( vDivs, Divs+i );
1663 word Truth = (Divs[2] | Divs[3]) & (Divs[4] & Divs[5]);
1674 Vec_IntFree( vRes );
1675 Vec_PtrFree( vDivs );
1733 int i, nVars = 3, pVarSet[10] = { 2, 3, 4 };
1734 word * pOff = (
word *)Vec_PtrEntry( vDivs, 0 );
1735 word * pOn = (
word *)Vec_PtrEntry( vDivs, 1 );
1736 Vec_Int_t * vValue = Vec_IntStartFull( 1 << 6 );
1737 printf(
"Verifying resub:\n" );
1738 for ( i = 0; i < 64*
nWords; i++ )
1740 int v, Mint = 0, Value = Abc_TtGetBit(pOn, i);
1741 if ( !Abc_TtGetBit(pOff, i) && !Value )
1743 for ( v = 0; v < nVars; v++ )
1744 if ( Abc_TtGetBit((
word *)Vec_PtrEntry(vDivs, pVarSet[v]), i) )
1746 if ( Vec_IntEntry(vValue, Mint) == -1 )
1747 Vec_IntWriteEntry(vValue, Mint, Value);
1748 else if ( Vec_IntEntry(vValue, Mint) != Value )
1749 printf(
"Mismatch in pattern %d\n", i );
1751 printf(
"Finished verifying resub.\n" );
1752 Vec_IntFree( vValue );
1756 int i, nDivs = Vec_WrdSize(vSims)/
nWords;
1757 Vec_Ptr_t * vDivs = Vec_PtrAlloc( nDivs );
1758 for ( i = 0; i < nDivs; i++ )
1759 Vec_PtrPush( vDivs, Vec_WrdEntryP(vSims,
nWords*i) );
1766Gia_Man_t *
Gia_ManResub1(
char * pFileName,
int nNodes,
int nSupp,
int nDivs,
int iChoice,
int fUseXor,
int fVerbose,
int fVeryVerbose )
1774 if ( Vec_PtrSize(vDivs) >= (1<<14) )
1776 printf(
"Reducing all divs from %d to %d.\n", Vec_PtrSize(vDivs), (1<<14)-1 );
1777 Vec_PtrShrink( vDivs, (1<<14)-1 );
1779 assert( Vec_PtrSize(vDivs) < (1<<14) );
1781 if ( Vec_IntSize(
p->vGates) )
1784 Vec_IntAppend( Vec_WecEntry(vGates, 0),
p->vGates );
1786 Vec_WecFree( vGates );
1789 printf(
"Decomposition did not succeed.\n" );
1791 Vec_PtrFree( vDivs );
1792 Vec_WrdFree( vSims );
1809 int i, iFan, Count = 1;
1810 if ( Gia_ObjIsTravIdCurrentId(
p, iObj) )
1812 Gia_ObjSetTravIdCurrentId(
p, iObj);
1813 if ( vNodes && Gia_ObjIsCo(Gia_ManObj(
p, iObj)) )
1814 Vec_IntPush( vNodes, iObj );
1815 if ( vPos && Gia_ObjIsCo(Gia_ManObj(
p, iObj)) )
1816 Vec_IntPush( vPos, iObj );
1827 Vec_IntClear( *pvNodes );
1829 *pvNodes = Vec_IntAlloc( 100 );
1834 Vec_IntClear( *pvPos );
1836 *pvPos = Vec_IntAlloc( 100 );
1839 for ( i = 0; i < nObjs; i++ )
1840 Count +=
Gia_ManUnivTfo_rec(
p, pObjs[i], pvNodes ? *pvNodes : NULL, pvPos ? *pvPos : NULL );
1842 Vec_IntSort( *pvNodes, 0 );
1844 Vec_IntSort( *pvPos, 0 );
1867 abctime clk, clkResub = 0, clkStart = Abc_Clock();
1868 Vec_Ptr_t * vvSims = Vec_PtrAlloc( 100 );
1870 word * pSets[2], * pFunc;
1873 assert( Gia_ManCiNum(
p) < 16 );
1874 Vec_WrdFreeP( &
p->vSimsPi );
1875 p->vSimsPi = Vec_WrdStartTruthTables( Gia_ManCiNum(
p) );
1876 nWords = Vec_WrdSize(
p->vSimsPi) / Gia_ManCiNum(
p);
1888 int * pArray, nArray, nTfo, iObj = Gia_ObjId(
p, pObj);
1889 int Level = Gia_ObjLevel(
p, pObj);
1891 pFunc = Vec_WrdEntryP( vSims,
nWords*iObj );
1892 Abc_TtCopy( pSets[0], pFunc,
nWords, 1 );
1893 Abc_TtCopy( pSets[1], pFunc,
nWords, 0 );
1894 Vec_PtrClear( vvSims );
1895 Vec_PtrPushTwo( vvSims, pSets[0], pSets[1] );
1898 Vec_PtrPush( vvSims, Vec_WrdEntryP(vSims,
nWords*Gia_ObjId(
p, pObj2)) );
1900 if ( !Gia_ObjIsTravIdCurrent(
p, pObj2) && !Gia_ObjIsTravIdPrevious(
p, pObj2) && Gia_ObjLevel(
p, pObj2) <= Level )
1901 Vec_PtrPush( vvSims, Vec_WrdEntryP(vSims,
nWords*Gia_ObjId(
p, pObj2)) );
1903 printf(
"%3d : Lev = %2d Mffc = %2d Divs = %3d Tfo = %3d\n", iObj, Level, nMffc, Vec_PtrSize(vvSims)-2, nTfo );
1905 nArray =
Abc_ResubComputeFunction( (
void **)Vec_PtrArray(vvSims), Vec_PtrSize(vvSims),
nWords, Abc_MinInt(nMffc-1, nLimit), nDivsMax, iChoice, fUseXor, fDebug, fVerbose, &pArray );
1906 clkResub += Abc_Clock() - clk;
1907 vGates.nSize = vGates.nCap = nArray;
1908 vGates.pArray = pArray;
1909 assert( nMffc > Vec_IntSize(&vGates)/2 );
1910 if ( Vec_IntSize(&vGates) > 0 )
1911 nTotal += nMffc - Vec_IntSize(&vGates)/2;
1912 nNonDec += Vec_IntSize(&vGates) == 0;
1914 printf(
"Total nodes = %5d. Non-realizable = %5d. Gain = %6d. ", Gia_ManAndNum(
p), nNonDec,
nTotal );
1915 Abc_PrintTime( 1,
"Time", Abc_Clock() - clkStart );
1916 Abc_PrintTime( 1,
"Pure resub time", clkResub );
1919 Vec_PtrFree( vvSims );
1920 Vec_WrdFree( vSims );
1939 int i, k = 0, nFuncs = Vec_WrdSize(vFuncs) /
nWords / 2;
1941 for ( i = 0; i < nFuncs; i++ )
1943 word * pFunc0 = Vec_WrdEntryP(vFuncs, (2*i+0)*
nWords);
1944 word * pFunc1 = Vec_WrdEntryP(vFuncs, (2*i+1)*
nWords);
1945 if ( Abc_TtIsConst0(pFunc0,
nWords) || Abc_TtIsConst0(pFunc1,
nWords) )
1947 if ( k < i ) Abc_TtCopy( Vec_WrdEntryP(vFuncs, (2*k+0)*
nWords), pFunc0,
nWords, 0 );
1948 if ( k < i ) Abc_TtCopy( Vec_WrdEntryP(vFuncs, (2*k+1)*
nWords), pFunc1,
nWords, 0 );
1951 Vec_WrdShrink( vFuncs, 2*k*
nWords );
1956 int i, nFuncs = Vec_WrdSize(vFuncs) /
nWords / 2;
1958 Vec_IntClear( vCounts );
1959 for ( i = 0; i < 2*nFuncs; i++ )
1960 Vec_IntPush( vCounts, Abc_TtCountOnesVec(Vec_WrdEntryP(vFuncs, i*
nWords),
nWords) );
1964 int i, Res = 0, nFuncs = Vec_WrdSize(vFuncs) /
nWords / 2;
1966 assert( Vec_IntSize(vCounts) *
nWords == Vec_WrdSize(vFuncs) );
1967 for ( i = 0; i < nFuncs; i++ )
1969 int Total[2] = { Vec_IntEntry(vCounts, 2*i+0), Vec_IntEntry(vCounts, 2*i+1) };
1970 int This[2] = { Abc_TtCountOnesVecMask(Vec_WrdEntryP(vFuncs, (2*i+0)*
nWords), pMask,
nWords, 0),
1971 Abc_TtCountOnesVecMask(Vec_WrdEntryP(vFuncs, (2*i+1)*
nWords), pMask,
nWords, 0) };
1972 assert( Total[0] >= This[0] && Total[1] >= This[1] );
1973 Res += This[0] * This[1] + (Total[0] - This[0]) * (Total[1] - This[1]);
1979 int i, Ent1, Ent2, Res = 0;
1986 int i, iStop = Vec_WrdSize(vFuncs);
word Data;
1987 int nFuncs = Vec_WrdSize(vFuncs) /
nWords / 2;
1990 Vec_WrdPush( vFuncs, Data );
1991 for ( i = 0; i < nFuncs; i++ )
1993 word * pFunc0n = Vec_WrdEntryP(vFuncs, (2*i+0)*
nWords);
1994 word * pFunc1n = Vec_WrdEntryP(vFuncs, (2*i+1)*
nWords);
1995 word * pFunc0p = Vec_WrdEntryP(vFuncs, (2*i+0)*
nWords + iStop);
1996 word * pFunc1p = Vec_WrdEntryP(vFuncs, (2*i+1)*
nWords + iStop);
1997 Abc_TtAnd( pFunc0p, pFunc0n, pMask,
nWords, 0 );
1998 Abc_TtAnd( pFunc1p, pFunc1n, pMask,
nWords, 0 );
1999 Abc_TtSharp( pFunc0n, pFunc0n, pMask,
nWords );
2000 Abc_TtSharp( pFunc1n, pFunc1n, pMask,
nWords );
2005 int i, k, iObj, CostBestPrev, nFuncs = Vec_WrdSize(vFuncs) /
nWords;
2007 Vec_Int_t * vCounts = Vec_IntAlloc( nFuncs * 2 );
2008 Vec_Wrd_t * vFSims = Vec_WrdDup( vFuncs );
2011 assert( Vec_IntSize(vObjs) <= Gia_ManCandNum(
p) );
2014 assert( Vec_IntSize(vCounts) *
nWords == Vec_WrdSize(vFSims) );
2017 printf(
"Processing %d functions and %d objects with cost %d\n", nFuncs, Vec_IntSize(vObjs), CostBestPrev );
2018 for ( i = 0; nFuncs > 0; i++ )
2023 if ( Vec_IntFind(vRes, iObj) >= 0 )
2026 if ( CountBest > CountThis )
2028 CountBest = CountThis;
2031 if ( !k ) Count0 = CountThis;
2033 if ( Count0 < CostBestPrev )
2036 iObjBest = Vec_IntEntry(vObjs, 0);
2042 Vec_IntPush( vRes, iObjBest );
2043 CostBestPrev = CountBest;
2045 printf(
"Iter %2d : Funcs = %6d. Object %6d. Cost %6d.\n", i, nFuncs, iObjBest, CountBest );
2047 Vec_IntFree( vCounts );
2048 Vec_WrdFree( vFSims );
2065 int i, k, iLit, Counter = 1;
2066 Vec_Int_t * vUsed = Vec_IntStartFull( nDivs );
2068 Vec_IntWriteEntry( vUsed, 0, 0 );
2069 assert( Vec_IntSize(vRes) % 2 == 1 );
2070 Vec_IntSort( vRes2, 0 );
2073 int iVar = Abc_Lit2Var(iLit);
2074 if ( iVar > 0 && iVar < nDivs && Vec_IntEntry(vUsed, iVar) == -1 ) {
2075 Vec_IntWriteEntry( vUsed, iVar, Counter++ );
2076 Vec_IntPush( vSupp, iVar-2 );
2079 Vec_IntFree( vRes2 );
2080 for ( i = nDivs; i < nDivs + nNodes; i++ )
2081 Vec_IntPush( vUsed, Counter++ );
2087 Vec_Int_t * vResNew = Vec_IntAlloc( Vec_IntSize(vRes) );
2089 Vec_IntPush( vResNew, Abc_Lit2LitV(Vec_IntArray(vUsed), iLit) );
2094 FILE * pFile = fopen( pFileName,
"ab" );
2095 if ( pFile == NULL ) {
2096 printf(
"Cannot open file \"%s\" for writing.\n", pFileName );
2099 Vec_Int_t * vSupp = Vec_IntAlloc( 100 );
2104 fprintf( pFile,
"\n.s" );
2106 fprintf( pFile,
" %d", Temp );
2107 fprintf( pFile,
"\n.a" );
2109 fprintf( pFile,
" %d", Temp );
2110 fprintf( pFile,
"\n" );
2113 Vec_IntFree( vUsed );
2114 Vec_IntFree( vSupp );
2115 Vec_IntFree( vResN );
2121 if (
p == NULL )
return NULL;
2123 Vec_Ptr_t * vDivs = Vec_PtrAlloc( 2+
p->nIns );
2125 Vec_PtrPush( vDivs, Vec_WrdEntryP(
p->vSimsOut, 0*
p->nSimWords) );
2126 Vec_PtrPush( vDivs, Vec_WrdEntryP(
p->vSimsOut, 1*
p->nSimWords) );
2127 int i, k, ArraySize, * pArray;
2128 for ( i = 0; i <
p->nIns; i++ )
2129 Vec_PtrPush( vDivs, Vec_WrdEntryP(
p->vSimsIn, i*
p->nSimWords) );
2132 printf(
"The problem has %d divisors and %d outputs.\n",
p->nIns,
p->nOuts );
2133 ArraySize =
Abc_ResubComputeFunction( (
void **)Vec_PtrArray(vDivs), Vec_PtrSize(vDivs),
p->nSimWords, nLimit, nDivMax, 0, 0, 1, fVerbose, &pArray );
2134 for ( k = 0; k < ArraySize; k++ )
2135 Vec_IntPush( vRes, pArray[k] );
2139 Vec_IntAppend( Vec_WecEntry(vGates, 0), vRes );
2141 Vec_WecFree( vGates );
2143 printf(
"The solution has %d inputs and %d nodes.\n", Gia_ManCiNum(pNew), Gia_ManAndNum(pNew) );
2145 if ( fWriteSol && ArraySize )
2148 Vec_IntFree( vRes );
2149 Vec_PtrFree( vDivs );
#define ABC_SWAP(Type, a, b)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_CALLOC(type, num)
#define ABC_CONST(number)
PARAMETERS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
int nTotal
DECLARATIONS ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Vec_Wec_t * Gia_ManComputeMffcs(Gia_Man_t *p, int LimitMin, int LimitMax, int SuppMax, int RatioBest)
int Gia_ManDeriveSimpleCost(Vec_Int_t *vCounts)
Vec_Int_t * Gia_ManToGates(Gia_Man_t *p)
void Gia_ManDeriveCounts(Vec_Wrd_t *vFuncs, int nWords, Vec_Int_t *vCounts)
int Gia_ObjCheckMffc(Gia_Man_t *p, Gia_Obj_t *pRoot, int Limit, Vec_Int_t *vNodes, Vec_Int_t *vLeaves, Vec_Int_t *vInners)
Gia_ResbMan_t * Gia_ResbAlloc(int nWords)
int Gia_ManDeriveCost(Vec_Wrd_t *vFuncs, int nWords, word *pMask, Vec_Int_t *vCounts)
void Abc_ResubPrepareManager(int nWords)
Vec_Int_t * Gia_ManResubRemapSolution(Vec_Int_t *vRes, Vec_Int_t *vUsed)
void Gia_ManDeriveDivPair(int iDiv, Vec_Ptr_t *vDivs, int nWords, word *pRes)
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
Vec_Int_t * Gia_ManDeriveSubset(Gia_Man_t *p, Vec_Wrd_t *vFuncs, Vec_Int_t *vObjs, Vec_Wrd_t *vSims, int nWords, int fVerbose)
int Gia_ManResubPerform_rec(Gia_ResbMan_t *p, int nLimit, int Depth)
int Gia_ManFindTwoUnate(word *pSets[2], Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnateLits[2], Vec_Int_t *vUnateLitsW[2], int fVerbose)
void Gia_ManPrintDivStats(Gia_Man_t *p, Vec_Wec_t *vMffcs, Vec_Wec_t *vPivots)
Vec_Int_t * Gia_ManResubOne(Vec_Ptr_t *vDivs, int nWords, int nLimit, int nDivsMax, int iChoice, int fUseXor, int fDebug, int fVerbose, word *pFunc, int Depth)
int Gia_ManResubVerify(Gia_ResbMan_t *p, word *pFunc)
ABC_NAMESPACE_IMPL_START int Gia_ObjCheckMffc_rec(Gia_Man_t *p, Gia_Obj_t *pObj, int Limit, Vec_Int_t *vNodes)
DECLARATIONS ///.
void Gia_ManSortUnates(word *pSets[2], Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnateLits[2], Vec_Int_t *vUnateLitsW[2], Vec_Wec_t *vSorter)
int Gia_ManFindGateGateInt(word *pOff, word *pOn, Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnatePairs, Vec_Int_t *vUnatePairsW, word *pDivTempA, word *pDivTempB)
void Gia_ResbInit(Gia_ResbMan_t *p, Vec_Ptr_t *vDivs, int nWords, int nLimit, int nDivsMax, int iChoice, int fUseXor, int fDebug, int fVerbose, int fVeryVerbose)
void Gia_ManResubRecordSolution(char *pFileName, Vec_Int_t *vRes, int nDivs)
void Gia_ManResubPrintNode(Vec_Int_t *vRes, int nVars, int Node, int fCompl)
int Gia_ManResubFindBestBinate(Gia_ResbMan_t *p)
void Gia_ManDeriveNext(Vec_Wrd_t *vFuncs, int nWords, word *pMask)
int Gia_ManDeriveShrink(Vec_Wrd_t *vFuncs, int nWords)
void Gia_ManResubPair(Vec_Wrd_t *vOn, Vec_Wrd_t *vOff, int nWords, int nIns)
void Gia_ManFindOneUnateInt(word *pOff, word *pOn, Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnateLits, Vec_Int_t *vNotUnateVars)
void Gia_ManInsertOrder_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vObjs, Vec_Wec_t *vFuncs, Vec_Int_t *vNodes)
int Gia_ManFindOneUnate(word *pSets[2], Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnateLits[2], Vec_Int_t *vNotUnateVars[2], int fVerbose)
int Gia_ManResubPerformMux_rec(Gia_ResbMan_t *p, int nLimit, int Depth)
int Gia_ManFindDivGateInt(word *pOff, word *pOn, Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnateLits, Vec_Int_t *vUnatePairs, Vec_Int_t *vUnateLitsW, Vec_Int_t *vUnatePairsW, word *pDivTemp)
Vec_Ptr_t * Gia_ManDeriveDivs(Vec_Wrd_t *vSims, int nWords)
Gia_Man_t * Gia_ManInsertFromGates(Gia_Man_t *p, Vec_Int_t *vObjs, Vec_Wec_t *vFuncs)
void Gia_ManResubTest(Gia_Man_t *p)
int Gia_ManFindDivGate(word *pSets[2], Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnateLits[2], Vec_Int_t *vUnatePairs[2], Vec_Int_t *vUnateLitsW[2], Vec_Int_t *vUnatePairsW[2], word *pDivTemp)
Gia_Man_t * Gia_ManResubUnateOne(char *pFileName, int nLimit, int nDivMax, int fWriteSol, int fVerbose)
void Gia_ManSortPairs(word *pSets[2], Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnateLits[2], Vec_Int_t *vUnateLitsW[2], Vec_Wec_t *vSorter)
void Dau_DsdPrintFromTruth2(word *pTruth, int nVarsInit)
void Gia_ManAddDivisors(Gia_Man_t *p, Vec_Wec_t *vMffcs)
void Gia_ManResubTest3_()
Vec_Int_t * Gia_ManInsertOrder(Gia_Man_t *p, Vec_Int_t *vObjs, Vec_Wec_t *vFuncs)
int Gia_ManUnivTfo(Gia_Man_t *p, int *pObjs, int nObjs, Vec_Int_t **pvNodes, Vec_Int_t **pvPos)
void Gia_ManSortBinate(word *pSets[2], Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vBinateVars, Vec_Wec_t *vSorter)
int Gia_ManResubAddNode(Gia_ResbMan_t *p, int iLit0, int iLit1, int Type)
void Gia_ManFindUnatePairsInt(word *pOff, word *pOn, Vec_Int_t *vBinate, Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnatePairs)
void Gia_ManFindXorInt(word *pOff, word *pOn, Vec_Int_t *vBinate, Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnatePairs)
void Gia_ManResubPrintLit(Vec_Int_t *vRes, int nVars, int iLit)
Gia_Man_t * Gia_ManConstructFromGates2(Vec_Wec_t *vFuncs, Vec_Wec_t *vDivs, int nObjs, Vec_Int_t **pvSupp)
Gia_Man_t * Gia_ManConstructFromGates(Vec_Wec_t *vFuncs, int nDivs)
struct Gia_ResbMan_t_ Gia_ResbMan_t
Gia_Man_t * Gia_ManResub1(char *pFileName, int nNodes, int nSupp, int nDivs, int iChoice, int fUseXor, int fVerbose, int fVeryVerbose)
int Gia_ManFindXor(word *pSets[2], Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vBinateVars, Vec_Int_t *vUnatePairs[2], int fVerbose)
void Gia_ManSortUnatesInt(word *pOff, word *pOn, Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnateLits, Vec_Int_t *vUnateLitsW, Vec_Wec_t *vSorter)
int Gia_ManConstructFromMap(Gia_Man_t *pNew, Vec_Int_t *vGates, int nVars, Vec_Int_t *vUsed, Vec_Int_t *vCopy, int fHash)
int Abc_ResubComputeFunction(void **ppDivs, int nDivs, int nWords, int nLimit, int nDivsMax, int iChoice, int fUseXor, int fDebug, int fVerbose, int **ppArray)
void Gia_ManSortPairsInt(word *pOff, word *pOn, Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnatePairs, Vec_Int_t *vUnatePairsW, Vec_Wec_t *vSorter)
void Gia_ManFindUnatePairs(word *pSets[2], Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vBinateVars, Vec_Int_t *vUnatePairs[2], int fVerbose)
void Gia_ManResubPerform(Gia_ResbMan_t *p, Vec_Ptr_t *vDivs, int nWords, int nLimit, int nDivsMax, int iChoice, int fUseXor, int fDebug, int fVerbose, int Depth)
Gia_Man_t * Gia_ManResub2(Gia_Man_t *pGia, int nNodes, int nSupp, int nDivs, int iChoice, int fUseXor, int fVerbose, int fVeryVerbose)
int Gia_ManResubPrint(Vec_Int_t *vRes, int nVars)
void Abc_ResubDumpProblem(char *pFileName, void **ppDivs, int nDivs, int nWords)
Vec_Int_t * Gia_ManResubFindUsed(Vec_Int_t *vRes, int nDivs, int nNodes, Vec_Int_t *vSupp)
void Gia_ResbFree(Gia_ResbMan_t *p)
int Gia_ManUnivTfo_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vNodes, Vec_Int_t *vPos)
int Gia_ManFindTwoUnateInt(word *pOff, word *pOn, Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnateLits, Vec_Int_t *vUnateLitsW, int *pnPairs)
void Gia_ManTryResub(Gia_Man_t *p)
void Gia_ManCheckResub(Vec_Ptr_t *vDivs, int nWords)
int Gia_ManFindGateGate(word *pSets[2], Vec_Ptr_t *vDivs, int nWords, Vec_Int_t *vUnatePairs[2], Vec_Int_t *vUnatePairsW[2], word *pDivTempA, word *pDivTempB)
void Gia_ManStop(Gia_Man_t *p)
Gia_Man_t * Gia_ManDupMuxes(Gia_Man_t *p, int Limit)
void Gia_ManStaticFanoutStart(Gia_Man_t *p)
void Gia_ManHashStart(Gia_Man_t *p)
void Gia_ManStaticFanoutStop(Gia_Man_t *p)
#define Gia_ManForEachAnd(p, pObj, i)
#define Gia_ManForEachCoId(p, Id, i)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
struct Gia_Man_t_ Gia_Man_t
Vec_Wrd_t * Gia_ManSimPatSim(Gia_Man_t *p)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
void Gia_ManCreateRefs(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManIncrementTravId(Gia_Man_t *p)
#define Gia_ObjForEachFanoutStaticId(p, Id, FanId, i)
#define Gia_ManForEachCo(p, pObj, i)
#define Gia_ManForEachCi(p, pObj, i)
void Gia_ManHashStop(Gia_Man_t *p)
int Gia_ManLevelNum(Gia_Man_t *p)
int Gia_NodeMffcSizeMark(Gia_Man_t *p, Gia_Obj_t *pNode)
typedefABC_NAMESPACE_HEADER_START struct Abc_RData_t_ Abc_RData_t
INCLUDES ///.
unsigned __int64 word
DECLARATIONS ///.
Vec_Int_t * vNotUnateVars[2]
Vec_Int_t * vUnateLitsW[2]
Vec_Int_t * vUnateLits[2]
Vec_Int_t * vUnatePairsW[2]
Vec_Int_t * vUnatePairs[2]
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_IntForEachEntryTwoStart(vVec1, vVec2, Entry1, Entry2, i, Start)
#define Vec_IntForEachEntryStop(vVec, Entry, i, Stop)
#define Vec_IntForEachEntryTwo(vVec1, vVec2, Entry1, Entry2, i)
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
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 ///.
#define Vec_WecForEachLevelReverse(vGlob, vVec, i)
#define Vec_WecForEachLevelStart(vGlob, vVec, i, LevelStart)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
#define Vec_WrdForEachEntryStop(vVec, Entry, i, Stop)