51 nOffset = Aig_ManObjNumMax(
p->pManAig);
52 vResult = Vec_IntStart( nOffset );
55 assert( Aig_ObjIsNode(pObj) );
56 pCut = Cnf_ObjBestCut( pObj );
58 Vec_IntWriteEntry( vResult, Aig_ObjId(pObj), nOffset );
59 Vec_IntPush( vResult, *Cnf_CutTruth(pCut) );
60 for ( k = 0; k < pCut->
nFanins; k++ )
61 Vec_IntPush( vResult, pCut->
pFanins[k] );
63 Vec_IntPush( vResult, -1 );
201 int fChangeVariableOrder = 0;
206 int OutVar, PoVar, pVars[32], * pLits, ** pClas;
208 int i, k, nLiterals, nClauses,
Cube, Number;
211 nLiterals = 1 + Aig_ManCoNum(
p->pManAig ) + 3 * nOutputs;
212 nClauses = 1 + Aig_ManCoNum(
p->pManAig ) + nOutputs;
215 assert( Aig_ObjIsNode(pObj) );
216 pCut = Cnf_ObjBestCut( pObj );
221 uTruth = 0xFFFF & *Cnf_CutTruth(pCut);
223 assert(
p->pSopSizes[uTruth] >= 0 );
224 nClauses +=
p->pSopSizes[uTruth];
229 nClauses += Vec_IntSize(pCut->
vIsop[1]);
234 uTruth = 0xFFFF & ~*Cnf_CutTruth(pCut);
236 assert(
p->pSopSizes[uTruth] >= 0 );
237 nClauses +=
p->pSopSizes[uTruth];
242 nClauses += Vec_IntSize(pCut->
vIsop[0]);
250 pCnf->
pMan =
p->pManAig;
259 for ( i = 0; i < Aig_ManObjNumMax(
p->pManAig); i++ )
262 if ( !fChangeVariableOrder )
268 if ( Aig_ManRegNum(
p->pManAig) == 0 )
270 assert( nOutputs == Aig_ManCoNum(
p->pManAig) );
276 assert( nOutputs == Aig_ManRegNum(
p->pManAig) );
287 pCnf->
pVarNums[Aig_ManConst1(
p->pManAig)->Id] = Number++;
288 pCnf->
nVars = Number;
293 Number = Aig_ManObjNumMax(
p->pManAig) + 1;
294 pCnf->
nVars = Number + 1;
297 if ( Aig_ManRegNum(
p->pManAig) == 0 )
299 assert( nOutputs == Aig_ManCoNum(
p->pManAig) );
305 assert( nOutputs == Aig_ManRegNum(
p->pManAig) );
316 pCnf->
pVarNums[Aig_ManConst1(
p->pManAig)->Id] = Number--;
321 vSopTemp = Vec_IntAlloc( 1 << 16 );
326 pCut = Cnf_ObjBestCut( pObj );
330 for ( k = 0; k < (int)pCut->
nFanins; k++ )
333 assert( pVars[k] <= Aig_ManObjNumMax(
p->pManAig) );
339 uTruth = 0xFFFF & *Cnf_CutTruth(pCut);
344 vCover = pCut->
vIsop[1];
348 *pLits++ = 2 * OutVar;
355 uTruth = 0xFFFF & ~*Cnf_CutTruth(pCut);
360 vCover = pCut->
vIsop[0];
364 *pLits++ = 2 * OutVar + 1;
368 Vec_IntFree( vSopTemp );
371 OutVar = pCnf->
pVarNums[ Aig_ManConst1(
p->pManAig)->Id ];
372 assert( OutVar <= Aig_ManObjNumMax(
p->pManAig) );
374 *pLits++ = 2 * OutVar;
379 OutVar = pCnf->
pVarNums[ Aig_ObjFanin0(pObj)->Id ];
380 if ( i < Aig_ManCoNum(
p->pManAig) - nOutputs )
383 *pLits++ = 2 * OutVar + Aig_ObjFaninC0(pObj);
390 *pLits++ = 2 * PoVar;
391 *pLits++ = 2 * OutVar + !Aig_ObjFaninC0(pObj);
394 *pLits++ = 2 * PoVar + 1;
395 *pLits++ = 2 * OutVar + Aig_ObjFaninC0(pObj);
425 int OutVar, PoVar, pVars[32], * pLits, ** pClas;
427 int i, k, nLiterals, nClauses,
Cube;
430 nLiterals = 1 + 4 * Aig_ManCoNum(
p->pManAig );
431 nClauses = 1 + 2 * Aig_ManCoNum(
p->pManAig );
434 assert( Aig_ObjIsNode(pObj) );
435 pCut = Cnf_ObjBestCut( pObj );
439 uTruth = 0xFFFF & *Cnf_CutTruth(pCut);
441 assert(
p->pSopSizes[uTruth] >= 0 );
442 nClauses +=
p->pSopSizes[uTruth];
447 nClauses += Vec_IntSize(pCut->
vIsop[1]);
452 uTruth = 0xFFFF & ~*Cnf_CutTruth(pCut);
454 assert(
p->pSopSizes[uTruth] >= 0 );
455 nClauses +=
p->pSopSizes[uTruth];
460 nClauses += Vec_IntSize(pCut->
vIsop[0]);
466 pCnf->
pMan =
p->pManAig;
475 for ( i = 0; i < Aig_ManObjNumMax(
p->pManAig); i++ )
477 pCnf->
nVars = Aig_ManObjNumMax(
p->pManAig);
484 vSopTemp = Vec_IntAlloc( 1 << 16 );
494 pCut = Cnf_ObjBestCut( pObj );
497 for ( k = 0; k < (int)pCut->
nFanins; k++ )
500 assert( pVars[k] <= Aig_ManObjNumMax(
p->pManAig) );
506 uTruth = 0xFFFF & *Cnf_CutTruth(pCut);
511 vCover = pCut->
vIsop[1];
515 *pLits++ = 2 * OutVar;
523 uTruth = 0xFFFF & ~*Cnf_CutTruth(pCut);
528 vCover = pCut->
vIsop[0];
532 *pLits++ = 2 * OutVar + 1;
537 Vec_IntFree( vSopTemp );
546 OutVar = Aig_ObjFanin0(pObj)->Id;
550 *pLits++ = 2 * PoVar;
551 *pLits++ = 2 * OutVar + !Aig_ObjFaninC0(pObj);
554 *pLits++ = 2 * PoVar + 1;
555 *pLits++ = 2 * OutVar + Aig_ObjFaninC0(pObj);
560 pCnf->
pObj2Count[Aig_ManConst1(
p->pManAig)->Id] = 1;
562 OutVar = Aig_ManConst1(
p->pManAig)->Id;
564 *pLits++ = 2 * OutVar;
591 int OutVar, PoVar, pVars[32], * pLits, ** pClas;
592 int i, nLiterals, nClauses, Number;
595 nLiterals = 1 + 7 * Aig_ManNodeNum(
p) + Aig_ManCoNum(
p ) + 3 * nOutputs;
596 nClauses = 1 + 3 * Aig_ManNodeNum(
p) + Aig_ManCoNum(
p ) + nOutputs;
611 for ( i = 0; i < Aig_ManObjNumMax(
p); i++ )
629 pCnf->
pVarNums[Aig_ManConst1(
p)->Id] = Number++;
630 pCnf->
nVars = Number;
644 pVars[0] = pCnf->
pVarNums[ Aig_ObjFanin0(pObj)->Id ];
645 pVars[1] = pCnf->
pVarNums[ Aig_ObjFanin1(pObj)->Id ];
649 *pLits++ = 2 * OutVar;
650 *pLits++ = 2 * pVars[0] + !Aig_ObjFaninC0(pObj);
651 *pLits++ = 2 * pVars[1] + !Aig_ObjFaninC1(pObj);
654 *pLits++ = 2 * OutVar + 1;
655 *pLits++ = 2 * pVars[0] + Aig_ObjFaninC0(pObj);
657 *pLits++ = 2 * OutVar + 1;
658 *pLits++ = 2 * pVars[1] + Aig_ObjFaninC1(pObj);
662 OutVar = pCnf->
pVarNums[ Aig_ManConst1(
p)->Id ];
663 assert( OutVar <= Aig_ManObjNumMax(
p) );
665 *pLits++ = 2 * OutVar;
670 OutVar = pCnf->
pVarNums[ Aig_ObjFanin0(pObj)->Id ];
671 if ( i < Aig_ManCoNum(
p) - nOutputs )
674 *pLits++ = 2 * OutVar + Aig_ObjFaninC0(pObj);
681 *pLits++ = 2 * PoVar;
682 *pLits++ = 2 * OutVar + !Aig_ObjFaninC0(pObj);
685 *pLits++ = 2 * PoVar + 1;
686 *pLits++ = 2 * OutVar + Aig_ObjFaninC0(pObj);
713 int OutVar, PoVar, pVars[32], * pLits, ** pClas;
714 int i, nLiterals, nClauses, Number;
717 nLiterals = 1 + 7 * Aig_ManNodeNum(
p) + 5 * Aig_ManCoNum(
p);
718 nClauses = 1 + 3 * Aig_ManNodeNum(
p) + 3 * Aig_ManCoNum(
p);
733 for ( i = 0; i < Aig_ManObjNumMax(
p); i++ )
745 pCnf->
pVarNums[Aig_ManConst1(
p)->Id] = Number++;
746 pCnf->
nVars = Number;
753 pVars[0] = pCnf->
pVarNums[ Aig_ObjFanin0(pObj)->Id ];
754 pVars[1] = pCnf->
pVarNums[ Aig_ObjFanin1(pObj)->Id ];
758 *pLits++ = 2 * OutVar;
759 *pLits++ = 2 * pVars[0] + !Aig_ObjFaninC0(pObj);
760 *pLits++ = 2 * pVars[1] + !Aig_ObjFaninC1(pObj);
763 *pLits++ = 2 * OutVar + 1;
764 *pLits++ = 2 * pVars[0] + Aig_ObjFaninC0(pObj);
766 *pLits++ = 2 * OutVar + 1;
767 *pLits++ = 2 * pVars[1] + Aig_ObjFaninC1(pObj);
771 OutVar = pCnf->
pVarNums[ Aig_ManConst1(
p)->Id ];
772 assert( OutVar <= Aig_ManObjNumMax(
p) );
774 *pLits++ = 2 * OutVar;
779 OutVar = pCnf->
pVarNums[ Aig_ObjFanin0(pObj)->Id ];
783 *pLits++ = 2 * PoVar;
784 *pLits++ = 2 * OutVar + !Aig_ObjFaninC0(pObj);
787 *pLits++ = 2 * PoVar + 1;
788 *pLits++ = 2 * OutVar + Aig_ObjFaninC0(pObj);
791 *pLits++ = 2 * PoVar + 1;