47 if ( pRoot != pObj && (pObj->
fMarkA || (fStopCompl && Aig_IsComplement(pObj))) )
49 Vec_PtrPushUnique( vSuper, fStopCompl ? pObj : Aig_Regular(pObj) );
52 assert( Aig_ObjIsNode(pObj) );
78 assert( !Aig_IsComplement(pRoot) );
79 Vec_PtrClear( vSuper );
96 if ( Aig_ObjIsTravIdCurrent(
p, pObj ) )
98 Aig_ObjSetTravIdCurrent(
p, pObj );
99 assert( Aig_ObjIsNode(pObj) );
102 Vec_PtrPush( vNodes, pObj );
122 Aig_ObjSetTravIdCurrent(
p, pObj );
123 Vec_PtrClear( vNodes );
140 static word Truth6[6] = {
152 assert( Vec_PtrSize(vLeaves) <= 6 && Vec_PtrSize(vNodes) > 0 );
153 assert( Vec_PtrSize(vLeaves) + Vec_PtrSize(vNodes) <= 256 );
157 S[pObj->
iData] = Truth6[i];
161 pObj->
iData = Vec_PtrSize(vLeaves) + i;
162 S[pObj->
iData] = (S[Aig_ObjFanin0(pObj)->iData] ^ C[Aig_ObjFaninC0(pObj)]) &
163 (S[Aig_ObjFanin1(pObj)->iData] ^ C[Aig_ObjFaninC1(pObj)]);
165 return S[pObj->
iData];
182 int iSatVar = vMap ? Vec_IntEntry(vMap, Aig_ObjId(pObj)) : Aig_ObjId(pObj);
184 return iSatVar + iSatVar + fCompl;
202 int c, k,
Cube, OutLit, RetValue;
206 Vec_IntClear( vClauses );
208 OutLit = Cnf_ObjGetLit( vMap, pRoot, 0 );
212 assert( pRoot == Vec_PtrEntryLast(vNodes) );
216 if ( Aig_ObjFaninC0(pLeaf) && !Aig_ObjFanin0(pLeaf)->fMarkA )
218 if ( Aig_ObjFaninC1(pLeaf) && !Aig_ObjFanin1(pLeaf)->fMarkA )
221 if ( k == Vec_PtrSize(vNodes) )
225 Vec_IntPush( vClauses, 0 );
226 Vec_IntPush( vClauses, OutLit );
228 Vec_IntPush( vClauses, Cnf_ObjGetLit(vMap, Aig_Regular(pLeaf), !Aig_IsComplement(pLeaf)) );
232 Vec_IntPush( vClauses, 0 );
233 Vec_IntPush( vClauses, OutLit ^ 1 );
234 Vec_IntPush( vClauses, Cnf_ObjGetLit(vMap, Aig_Regular(pLeaf), Aig_IsComplement(pLeaf)) );
238 if ( Vec_PtrSize(vLeaves) > 6 )
239 printf(
"FastCnfGeneration: Internal error!!!\n" );
240 assert( Vec_PtrSize(vLeaves) <= 6 );
243 if ( Truth == 0 || Truth == ~(
word)0 )
245 Vec_IntPush( vClauses, 0 );
246 Vec_IntPush( vClauses, (Truth == 0) ? (OutLit ^ 1) : OutLit );
250 RetValue =
Kit_TruthIsop( (
unsigned *)&Truth, Vec_PtrSize(vLeaves), vCover, 0 );
255 Vec_IntPush( vClauses, 0 );
256 Vec_IntPush( vClauses, OutLit );
257 for ( k = 0; k < Vec_PtrSize(vLeaves); k++,
Cube >>= 2 )
259 if ( (
Cube & 3) == 0 )
262 Vec_IntPush( vClauses, Cnf_ObjGetLit(vMap, (
Aig_Obj_t *)Vec_PtrEntry(vLeaves,k), (
Cube&3)!=1) );
268 RetValue =
Kit_TruthIsop( (
unsigned *)&Truth, Vec_PtrSize(vLeaves), vCover, 0 );
272 Vec_IntPush( vClauses, 0 );
273 Vec_IntPush( vClauses, OutLit ^ 1 );
274 for ( k = 0; k < Vec_PtrSize(vLeaves); k++,
Cube >>= 2 )
276 if ( (
Cube & 3) == 0 )
279 Vec_IntPush( vClauses, Cnf_ObjGetLit(vMap, (
Aig_Obj_t *)Vec_PtrEntry(vLeaves,k), (
Cube&3)!=1) );
301 Aig_Obj_t * pObj, * pTemp, * pObjC, * pObj0, * pObj1;
302 int i, k, nFans, Counter;
304 vLeaves = Vec_PtrAlloc( 100 );
305 vNodes = Vec_PtrAlloc( 100 );
306 vSupps = Vec_IntStart( Aig_ManObjNumMax(
p) );
314 Aig_ObjFanin0(pObj)->fMarkA = 1;
322 pObj0 = Aig_ObjFanin0(pObj);
323 if ( pObj0->
fMarkB || Aig_ObjRefs(pObj0) > 1 )
325 pObj1 = Aig_ObjFanin1(pObj);
326 if ( pObj1->
fMarkB || Aig_ObjRefs(pObj1) > 1 )
334 Aig_ObjFanin0(pObj0)->fMarkA = 1;
335 Aig_ObjFanin1(pObj0)->fMarkA = 1;
336 Aig_ObjFanin0(pObj1)->fMarkA = 1;
337 Aig_ObjFanin1(pObj1)->fMarkA = 1;
344 if ( Aig_ObjRefs(pObj) > 1 )
347 if ( Aig_ObjFaninC0(pObj) && !Aig_ObjFanin0(pObj)->fMarkB )
348 Aig_ObjFanin0(pObj)->fMarkA = 1;
349 if ( Aig_ObjFaninC1(pObj) && !Aig_ObjFanin1(pObj)->fMarkB )
350 Aig_ObjFanin1(pObj)->fMarkA = 1;
363 pObj0 = Aig_Regular(pObj0);
364 pObj1 = Aig_Regular(pObj1);
369 nFans = 1 + (pObj0 == pObj1);
370 if ( !pObj0->
fMarkB && !Aig_ObjIsCi(pObj0) && Aig_ObjRefs(pObj0) == nFans && Vec_IntEntry(vSupps, Aig_ObjId(pObj0)) < 3 )
375 if ( !pObj1->
fMarkB && !Aig_ObjIsCi(pObj1) && Aig_ObjRefs(pObj1) == nFans && Vec_IntEntry(vSupps, Aig_ObjId(pObj1)) < 3 )
384 Vec_IntWriteEntry( vSupps, Aig_ObjId(pObj), Vec_PtrSize(vLeaves) );
385 if ( Vec_PtrSize(vLeaves) >= 6 )
389 pTemp = Aig_Regular(pTemp);
391 if ( pTemp->
fMarkB || Aig_ObjIsCi(pTemp) || Aig_ObjRefs(pTemp) > 1 )
393 assert( Vec_IntEntry(vSupps, Aig_ObjId(pTemp)) > 0 );
394 if ( Vec_PtrSize(vLeaves) - 1 + Vec_IntEntry(vSupps, Aig_ObjId(pTemp)) > 6 )
397 Vec_IntWriteEntry( vSupps, Aig_ObjId(pObj), 6 );
407 Counter += !Aig_ObjFanin0(pObj)->fMarkA;
409 printf(
"PO-driver rule is violated %d times.\n", Counter );
419 if ( Vec_PtrSize(vLeaves) <= 6 )
424 if ( Aig_ObjFaninC0(pTemp) && !Aig_ObjFanin0(pTemp)->fMarkA )
426 if ( Aig_ObjFaninC1(pTemp) && !Aig_ObjFanin1(pTemp)->fMarkA )
431 printf(
"AND-gate rule is violated %d times.\n", Counter );
433 Vec_PtrFree( vLeaves );
434 Vec_PtrFree( vNodes );
435 Vec_IntFree( vSupps );
454 int i, RetValue, nSize = 0;
455 if ( Vec_PtrSize(vLeaves) > 6 )
460 if ( Aig_ObjFaninC0(pObj) && !Aig_ObjFanin0(pObj)->fMarkA )
461 printf(
"Unusual 1!\n" );
462 if ( Aig_ObjFaninC1(pObj) && !Aig_ObjFanin1(pObj)->fMarkA )
463 printf(
"Unusual 2!\n" );
466 assert( !Aig_ObjFaninC0(pObj) || Aig_ObjFanin0(pObj)->fMarkA );
467 assert( !Aig_ObjFaninC1(pObj) || Aig_ObjFanin1(pObj)->fMarkA );
469 return Vec_PtrSize(vLeaves) + 1;
473 RetValue =
Kit_TruthIsop( (
unsigned *)&Truth, Vec_PtrSize(vLeaves), vCover, 0 );
475 nSize += Vec_IntSize(vCover);
479 RetValue =
Kit_TruthIsop( (
unsigned *)&Truth, Vec_PtrSize(vLeaves), vCover, 0 );
481 nSize += Vec_IntSize(vCover);
501 int nVars = 0, nClauses = 0;
504 vLeaves = Vec_PtrAlloc( 100 );
505 vNodes = Vec_PtrAlloc( 100 );
506 vCover = Vec_IntAlloc( 1 << 16 );
517 assert( pObj == Vec_PtrEntryLast(vNodes) );
525 printf(
"Vars = %d Clauses = %d\n", nVars, nClauses );
527 Vec_PtrFree( vLeaves );
528 Vec_PtrFree( vNodes );
529 Vec_IntFree( vCover );
548 Vec_Int_t * vLits, * vClas, * vMap, * vTemp;
552 int i, k, nVars, Entry, OutLit, DriLit;
554 vLits = Vec_IntAlloc( 1 << 16 );
555 vClas = Vec_IntAlloc( 1 << 12 );
556 vMap = Vec_IntStartFull( Aig_ManObjNumMax(
p) );
562 if ( Aig_ManRegNum(
p) == 0 )
564 assert( nOutputs == Aig_ManCoNum(
p) );
566 Vec_IntWriteEntry( vMap, Aig_ObjId(pObj), nVars++ );
570 assert( nOutputs == Aig_ManRegNum(
p) );
572 Vec_IntWriteEntry( vMap, Aig_ObjId(pObj), nVars++ );
578 Vec_IntWriteEntry( vMap, Aig_ObjId(pObj), nVars++ );
581 Vec_IntWriteEntry( vMap, Aig_ObjId(pObj), nVars++ );
582 Vec_IntWriteEntry( vMap, Aig_ObjId(Aig_ManConst1(
p)), nVars++ );
585 vLeaves = Vec_PtrAlloc( 100 );
586 vNodes = Vec_PtrAlloc( 100 );
587 vCover = Vec_IntAlloc( 1 << 16 );
588 vTemp = Vec_IntAlloc( 100 );
597 Vec_IntPush( vClas, Vec_IntSize(vLits) );
599 Vec_IntPush( vLits, Entry );
602 Vec_PtrFree( vLeaves );
603 Vec_PtrFree( vNodes );
604 Vec_IntFree( vCover );
605 Vec_IntFree( vTemp );
610 DriLit = Cnf_ObjGetLit( vMap, Aig_ObjFanin0(pObj), Aig_ObjFaninC0(pObj) );
611 if ( i < Aig_ManCoNum(
p) - nOutputs )
613 Vec_IntPush( vClas, Vec_IntSize(vLits) );
614 Vec_IntPush( vLits, DriLit );
618 OutLit = Cnf_ObjGetLit( vMap, pObj, 0 );
620 Vec_IntPush( vClas, Vec_IntSize(vLits) );
621 Vec_IntPush( vLits, OutLit );
622 Vec_IntPush( vLits, DriLit ^ 1 );
624 Vec_IntPush( vClas, Vec_IntSize(vLits) );
625 Vec_IntPush( vLits, OutLit ^ 1 );
626 Vec_IntPush( vLits, DriLit );
631 OutLit = Cnf_ObjGetLit( vMap, Aig_ManConst1(
p), 0 );
632 Vec_IntPush( vClas, Vec_IntSize(vLits) );
633 Vec_IntPush( vLits, OutLit );
640 pCnf->
nClauses = Vec_IntSize( vClas );
642 pCnf->
pClauses[0] = Vec_IntReleaseArray( vLits );
646 pCnf->
pVarNums = Vec_IntReleaseArray( vMap );
649 Vec_IntFree( vLits );
650 Vec_IntFree( vClas );
#define ABC_ALLOC(type, num)
#define ABC_CALLOC(type, num)
#define ABC_CONST(number)
PARAMETERS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Aig_Obj_t * Aig_ObjRecognizeMux(Aig_Obj_t *pObj, Aig_Obj_t **ppObjT, Aig_Obj_t **ppObjE)
void Aig_ManCleanMarkB(Aig_Man_t *p)
void Aig_ManCleanMarkA(Aig_Man_t *p)
#define Aig_ManForEachNodeReverse(p, pObj, i)
#define Aig_ManForEachObj(p, pObj, i)
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
#define Aig_ManForEachLiSeq(p, pObj, i)
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
struct Aig_Obj_t_ Aig_Obj_t
#define Aig_ManForEachNode(p, pObj, i)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
void Aig_ManCleanMarkAB(Aig_Man_t *p)
#define Aig_ManForEachCo(p, pObj, i)
int Aig_ObjIsMuxType(Aig_Obj_t *pObj)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Cnf_Dat_t * Cnf_DeriveFast(Aig_Man_t *p, int nOutputs)
int Cnf_CountCnfSize(Aig_Man_t *p)
int Cnf_CutCountClauses(Aig_Man_t *p, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vNodes, Vec_Int_t *vCover)
word Cnf_CutDeriveTruth(Aig_Man_t *p, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vNodes)
void Cnf_CollectVolume(Aig_Man_t *p, Aig_Obj_t *pRoot, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vNodes)
void Cnf_ComputeClauses(Aig_Man_t *p, Aig_Obj_t *pRoot, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vNodes, Vec_Int_t *vMap, Vec_Int_t *vCover, Vec_Int_t *vClauses)
void Cnf_CollectVolume_rec(Aig_Man_t *p, Aig_Obj_t *pObj, Vec_Ptr_t *vNodes)
ABC_NAMESPACE_IMPL_START void Cnf_CollectLeaves_rec(Aig_Obj_t *pRoot, Aig_Obj_t *pObj, Vec_Ptr_t *vSuper, int fStopCompl)
DECLARATIONS ///.
void Cnf_CollectLeaves(Aig_Obj_t *pRoot, Vec_Ptr_t *vSuper, int fStopCompl)
Cnf_Dat_t * Cnf_DeriveFastClauses(Aig_Man_t *p, int nOutputs)
void Cnf_DeriveFastMark(Aig_Man_t *p)
struct Cnf_Dat_t_ Cnf_Dat_t
unsigned __int64 word
DECLARATIONS ///.
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.