27static unsigned int s_256Primes[
ISO_MASK+1] =
29 0x984b6ad9,0x18a6eed3,0x950353e2,0x6222f6eb,0xdfbedd47,0xef0f9023,0xac932a26,0x590eaf55,
30 0x97d0a034,0xdc36cd2e,0x22736b37,0xdc9066b0,0x2eb2f98b,0x5d9c7baf,0x85747c9e,0x8aca1055,
31 0x50d66b74,0x2f01ae9e,0xa1a80123,0x3e1ce2dc,0xebedbc57,0x4e68bc34,0x855ee0cf,0x17275120,
32 0x2ae7f2df,0xf71039eb,0x7c283eec,0x70cd1137,0x7cf651f3,0xa87bfa7a,0x14d87f02,0xe82e197d,
33 0x8d8a5ebe,0x1e6a15dc,0x197d49db,0x5bab9c89,0x4b55dea7,0x55dede49,0x9a6a8080,0xe5e51035,
34 0xe148d658,0x8a17eb3b,0xe22e4b38,0xe5be2a9a,0xbe938cbb,0x3b981069,0x7f9c0c8e,0xf756df10,
35 0x8fa783f7,0x252062ce,0x3dc46b4b,0xf70f6432,0x3f378276,0x44b137a1,0x2bf74b77,0x04892ed6,
36 0xfd318de1,0xd58c235e,0x94c6d25b,0x7aa5f218,0x35c9e921,0x5732fbbb,0x06026481,0xf584a44f,
37 0x946e1b5f,0x8463d5b2,0x4ebca7b2,0x54887b15,0x08d1e804,0x5b22067d,0x794580f6,0xb351ea43,
38 0xbce555b9,0x19ae2194,0xd32f1396,0x6fc1a7f1,0x1fd8a867,0x3a89fdb0,0xea49c61c,0x25f8a879,
39 0xde1e6437,0x7c74afca,0x8ba63e50,0xb1572074,0xe4655092,0xdb6f8b1c,0xc2955f3c,0x327f85ba,
40 0x60a17021,0x95bd261d,0xdea94f28,0x04528b65,0xbe0109cc,0x26dd5688,0x6ab2729d,0xc4f029ce,
41 0xacf7a0be,0x4c912f55,0x34c06e65,0x4fbb938e,0x1533fb5f,0x03da06bd,0x48262889,0xc2523d7d,
42 0x28a71d57,0x89f9713a,0xf574c551,0x7a99deb5,0x52834d91,0x5a6f4484,0xc67ba946,0x13ae698f,
43 0x3e390f34,0x34fc9593,0x894c7932,0x6cf414a3,0xdb7928ab,0x13a3b8a3,0x4b381c1d,0xa10b54cb,
44 0x55359d9d,0x35a3422a,0x58d1b551,0x0fd4de20,0x199eb3f4,0x167e09e2,0x3ee6a956,0x5371a7fa,
45 0xd424efda,0x74f521c5,0xcb899ff6,0x4a42e4f4,0x747917b6,0x4b08df0b,0x090c7a39,0x11e909e4,
46 0x258e2e32,0xd9fad92d,0x48fe5f69,0x0545cde6,0x55937b37,0x9b4ae4e4,0x1332b40e,0xc3792351,
47 0xaff982ef,0x4dba132a,0x38b81ef1,0x28e641bf,0x227208c1,0xec4bbe37,0xc4e1821c,0x512c9d09,
48 0xdaef1257,0xb63e7784,0x043e04d7,0x9c2cea47,0x45a0e59a,0x281315ca,0x849f0aac,0xa4071ed3,
49 0x0ef707b3,0xfe8dac02,0x12173864,0x471f6d46,0x24a53c0a,0x35ab9265,0xbbf77406,0xa2144e79,
50 0xb39a884a,0x0baf5b6d,0xcccee3dd,0x12c77584,0x2907325b,0xfd1adcd2,0xd16ee972,0x345ad6c1,
51 0x315ebe66,0xc7ad2b8d,0x99e82c8d,0xe52da8c8,0xba50f1d3,0x66689cd8,0x2e8e9138,0x43e15e74,
52 0xf1ced14d,0x188ec52a,0xe0ef3cbb,0xa958aedc,0x4107a1bc,0x5a9e7a3e,0x3bde939f,0xb5b28d5a,
53 0x596fe848,0xe85ad00c,0x0b6b3aae,0x44503086,0x25b5695c,0xc0c31dcd,0x5ee617f0,0x74d40c3a,
54 0xd2cb2b9f,0x1e19f5fa,0x81e24faf,0xa01ed68f,0xcee172fc,0x7fdf2e4d,0x002f4774,0x664f82dd,
55 0xc569c39a,0xa2d4dcbe,0xaadea306,0xa4c947bf,0xa413e4e3,0x81fb5486,0x8a404970,0x752c980c,
56 0x98d1d881,0x5c932c1e,0xeee65dfb,0x37592cdd,0x0fd4e65b,0xad1d383f,0x62a1452f,0x8872f68d,
57 0xb58c919b,0x345c8ee3,0xb583a6d6,0x43d72cb3,0x77aaa0aa,0xeb508242,0xf2db64f8,0x86294328,
58 0x82211731,0x1239a9d5,0x673ba5de,0xaf4af007,0x44203b19,0x2399d955,0xa175cd12,0x595928a7,
59 0x6918928b,0xde3126bb,0x6c99835c,0x63ba1fa2,0xdebbdff0,0x3d02e541,0xd6f7aac6,0xe80b4cd0,
60 0xd0fa29f1,0x804cac5e,0x2c226798,0x462f624c,0xad05b377,0x22924fcd,0xfbea205c,0x1b47586d
93static inline unsigned Gia_IsoGetValue(
Gia_IsoMan_t *
p,
int i ) {
return (
unsigned)(
p->pStoreW[i]); }
94static inline unsigned Gia_IsoGetItem(
Gia_IsoMan_t *
p,
int i ) {
return (
unsigned)(
p->pStoreW[i] >> 32); }
96static inline void Gia_IsoSetValue(
Gia_IsoMan_t *
p,
int i,
unsigned v ) { ((
unsigned *)(
p->pStoreW + i))[0] = v; }
97static inline void Gia_IsoSetItem(
Gia_IsoMan_t *
p,
int i,
unsigned v ) { ((
unsigned *)(
p->pStoreW + i))[1] = v; }
119 p->nObjs = Gia_ManObjNum( pGia );
121 p->nEntries =
p->nObjs;
127 p->vClasses = Vec_IntAlloc(
p->nObjs/4 );
128 p->vClasses2 = Vec_IntAlloc(
p->nObjs/4 );
134 Vec_IntFree(
p->vClasses );
135 Vec_IntFree(
p->vClasses2 );
148 pObj->
Value =
p->pUniques[i];
166 int i, k, iBegin, nSize;
167 printf(
"The total of %d classes:\n", Vec_IntSize(
p->vClasses)/2 );
170 printf(
"%5d : (%3d,%3d) ", i/2, iBegin, nSize );
174 for ( k = 0; k < nSize; k++ )
175 printf(
" %3d,%08x", Gia_IsoGetItem(
p, iBegin+k), Gia_IsoGetValue(
p, iBegin+k) );
183 printf(
"Iter %4d : ", Iter );
184 printf(
"Entries =%8d. ",
p->nEntries );
186 printf(
"Uniques =%8d. ",
p->nUniques );
187 printf(
"Singles =%8d. ",
p->nSingles );
188 printf(
"%9.2f sec", (
float)(Time)/(
float)(CLOCKS_PER_SEC) );
207 int * pLevBegins, * pLevSizes;
208 int i, iObj, MaxLev = 0;
212 p->pLevels[Gia_ObjId(
p->pGia, pObj)] = 0;
214 p->pLevels[i] = 1 + Abc_MaxInt(
p->pLevels[Gia_ObjFaninId0(pObj, i)],
p->pLevels[Gia_ObjFaninId1(pObj, i)] );
217 iObj = Gia_ObjId(
p->pGia, pObj);
218 p->pLevels[iObj] = 1 +
p->pLevels[Gia_ObjFaninId0(pObj, iObj)];
219 MaxLev = Abc_MaxInt( MaxLev,
p->pLevels[Gia_ObjId(
p->pGia, pObj)] );
224 for ( i = 1; i <
p->nObjs; i++ )
225 pLevSizes[
p->pLevels[i]]++;
227 Vec_IntClear(
p->vClasses );
228 Vec_IntPush(
p->vClasses, 0 );
229 Vec_IntPush(
p->vClasses, 1 );
233 for ( i = 0; i <= MaxLev; i++ )
235 assert( pLevSizes[i] > 0 );
236 Vec_IntPush(
p->vClasses, pLevBegins[i] );
237 Vec_IntPush(
p->vClasses, pLevSizes[i] );
238 pLevBegins[i+1] = pLevBegins[i] + pLevSizes[i];
240 assert( pLevBegins[MaxLev+1] ==
p->nObjs );
242 for ( i = 1; i <
p->nObjs; i++ )
243 Gia_IsoSetItem(
p, pLevBegins[
p->pLevels[i]]++, i );
267 int i, iBegin, nSize;
269 Vec_IntClear(
p->vClasses2 );
274 assert(
p->pUniques[Gia_IsoGetItem(
p, iBegin)] == 0 );
275 p->pUniques[Gia_IsoGetItem(
p, iBegin)] =
p->nUniques++;
280 Vec_IntPush(
p->vClasses2, iBegin );
281 Vec_IntPush(
p->vClasses2, nSize );
285 p->nEntries -=
p->nSingles;
302 int i, k, fSameValue, iBegin, iBeginOld, nSize, nSizeNew;
308 Vec_IntClear(
p->vClasses2 );
313 pObj0 = Gia_ManObj(
p->pGia, Gia_IsoGetItem(
p,iBegin) );
314 for ( k = 0; k < nSize; k++ )
316 pObj = Gia_ManObj(
p->pGia, Gia_IsoGetItem(
p,iBegin+k) );
317 Gia_IsoSetValue(
p, iBegin+k, pObj->
Value );
323 Vec_IntPush(
p->vClasses2, iBegin );
324 Vec_IntPush(
p->vClasses2, nSize );
331 p->timeSort += Abc_Clock() - clk;
334 pObj0 = Gia_ManObj(
p->pGia, Gia_IsoGetItem(
p,iBegin) );
335 for ( k = 1; k < nSize; k++ )
337 pObj = Gia_ManObj(
p->pGia, Gia_IsoGetItem(
p,iBegin+k) );
340 nSizeNew = iBegin + k - iBeginOld;
343 assert(
p->pUniques[Gia_IsoGetItem(
p, iBeginOld)] == 0 );
344 p->pUniques[Gia_IsoGetItem(
p, iBeginOld)] =
p->nUniques++;
349 Vec_IntPush(
p->vClasses2, iBeginOld );
350 Vec_IntPush(
p->vClasses2, nSizeNew );
352 iBeginOld = iBegin + k;
356 nSizeNew = iBegin + k - iBeginOld;
359 assert(
p->pUniques[Gia_IsoGetItem(
p, iBeginOld)] == 0 );
360 p->pUniques[Gia_IsoGetItem(
p, iBeginOld)] =
p->nUniques++;
365 Vec_IntPush(
p->vClasses2, iBeginOld );
366 Vec_IntPush(
p->vClasses2, nSizeNew );
371 p->nEntries -=
p->nSingles;
391 int i, k, iBegin, nSize;
393 vGroups = Vec_PtrAlloc( 1000 );
395 if (
p->pUniques[Gia_ObjId(
p->pGia, pObj)] > 0 )
397 vLevel = Vec_IntAlloc( 1 );
398 Vec_IntPush( vLevel, i );
399 Vec_PtrPush( vGroups, vLevel );
405 for ( k = 0; k < nSize; k++ )
407 pObj = Gia_ManObj(
p->pGia, Gia_IsoGetItem(
p,iBegin+k) );
408 if ( Gia_ObjIsPo(
p->pGia, pObj) )
413 vLevel = Vec_IntAlloc( 8 );
414 for ( k = 0; k < nSize; k++ )
416 pObj = Gia_ManObj(
p->pGia, Gia_IsoGetItem(
p,iBegin+k) );
417 if ( Gia_ObjIsPo(
p->pGia, pObj) )
418 Vec_IntPush( vLevel, Gia_ObjCioId(pObj) );
420 Vec_PtrPush( vGroups, vLevel );
424 Vec_IntSort( vLevel, 0 );
425 Vec_VecSortByFirstInt( (
Vec_Vec_t *)vGroups, 0 );
442static inline unsigned Gia_IsoUpdateValue(
int Value,
int fCompl )
444 return (Value+1) * s_256Primes[Abc_Var2Lit(Value, fCompl) &
ISO_MASK];
446static inline unsigned Gia_IsoUpdate(
Gia_IsoMan_t *
p,
int Iter,
int iObj,
int fCompl )
448 if ( Iter == 0 )
return Gia_IsoUpdateValue(
p->pLevels[iObj], fCompl );
449 if (
p->pUniques[iObj] > 0 )
return Gia_IsoUpdateValue(
p->pUniques[iObj], fCompl );
458 Gia_ManConst0(
p->pGia)->Value += s_256Primes[
ISO_MASK];
467 pObj->
Value += Gia_ObjFanin0(pObj)->Value + Gia_IsoUpdate(
p, Iter, Gia_ObjFaninId0(pObj, i), Gia_ObjFaninC0(pObj));
468 pObj->
Value += Gia_ObjFanin1(pObj)->Value + Gia_IsoUpdate(
p, Iter, Gia_ObjFaninId1(pObj, i), Gia_ObjFaninC1(pObj));
473 iObj = Gia_ObjId(
p->pGia, pObj);
474 pObj->
Value += Gia_ObjFanin0(pObj)->Value + Gia_IsoUpdate(
p, Iter, Gia_ObjFaninId0(pObj, iObj), Gia_ObjFaninC0(pObj));
487 iObj = Gia_ObjId(
p->pGia, pObj);
488 Gia_ObjFanin0(pObj)->Value += pObj->
Value + Gia_IsoUpdate(
p, Iter, iObj, Gia_ObjFaninC0(pObj));
493 Gia_ObjFanin0(pObj)->Value += pObj->
Value + Gia_IsoUpdate(
p, Iter, i, Gia_ObjFaninC0(pObj));
494 Gia_ObjFanin1(pObj)->Value += pObj->
Value + Gia_IsoUpdate(
p, Iter, i, Gia_ObjFaninC1(pObj));
514 int i, iBegin = -1, nSize = -1;
516 assert( Vec_IntSize(
p->vClasses) > 0 );
526 assert(
p->pUniques[Gia_IsoGetItem(
p, iBegin)] == 0 );
527 p->pUniques[Gia_IsoGetItem(
p, iBegin)] =
p->nUniques++;
531 assert(
p->pUniques[Gia_IsoGetItem(
p, iBegin+1)] == 0 );
532 p->pUniques[Gia_IsoGetItem(
p, iBegin+1)] =
p->nUniques++;
538 assert(
p->pUniques[Gia_IsoGetItem(
p, iBegin)] == 0 );
539 p->pUniques[Gia_IsoGetItem(
p, iBegin)] =
p->nUniques++;
544 for ( ; i < Vec_IntSize(
p->vClasses) - 2; i += 2 )
546 p->vClasses->pArray[i+0] =
p->vClasses->pArray[i+2];
547 p->vClasses->pArray[i+1] =
p->vClasses->pArray[i+3];
549 Vec_IntShrink(
p->vClasses, Vec_IntSize(
p->vClasses) - 2 );
551 printf(
"Broke ties in class %d of size %d at level %d.\n", i/2, nSize,
p->pLevels[Gia_IsoGetItem(
p, iBegin)] );
558 assert( Vec_IntSize(
p->vClasses) > 0 );
559 iBegin = Vec_IntEntry(
p->vClasses, Vec_IntSize(
p->vClasses) - 2 );
560 nSize = Vec_IntEntry(
p->vClasses, Vec_IntSize(
p->vClasses) - 1 );
561 Vec_IntShrink(
p->vClasses, Vec_IntSize(
p->vClasses) - 2 );
567 assert(
p->pUniques[Gia_IsoGetItem(
p, iBegin)] == 0 );
568 p->pUniques[Gia_IsoGetItem(
p, iBegin)] =
p->nUniques++;
572 assert(
p->pUniques[Gia_IsoGetItem(
p, iBegin+1)] == 0 );
573 p->pUniques[Gia_IsoGetItem(
p, iBegin+1)] =
p->nUniques++;
579 assert(
p->pUniques[Gia_IsoGetItem(
p, iBegin)] == 0 );
580 p->pUniques[Gia_IsoGetItem(
p, iBegin)] =
p->nUniques++;
584 printf(
"Broke ties in last class of size %d at level %d.\n", nSize,
p->pLevels[Gia_IsoGetItem(
p, iBegin)] );
589 int i, k, iBegin0, iBegin, nSize, Shrink;
591 assert( Vec_IntSize(
p->vClasses) > 0 );
592 iBegin0 = Vec_IntEntry(
p->vClasses, Vec_IntSize(
p->vClasses) - 2 );
593 for ( i = Vec_IntSize(
p->vClasses) - 2; i >= 0; i -= 2 )
595 iBegin = Vec_IntEntry(
p->vClasses, i );
596 if (
p->pLevels[Gia_IsoGetItem(
p, iBegin)] !=
p->pLevels[Gia_IsoGetItem(
p, iBegin0)] )
602 for ( Shrink = i; i < Vec_IntSize(
p->vClasses); i += 2 )
604 iBegin = Vec_IntEntry(
p->vClasses, i );
605 nSize = Vec_IntEntry(
p->vClasses, i + 1 );
606 for ( k = 0; k < nSize; k++ )
608 assert(
p->pUniques[Gia_IsoGetItem(
p, iBegin+k)] == 0 );
609 p->pUniques[Gia_IsoGetItem(
p, iBegin+k)] =
p->nUniques++;
615 printf(
"Broke ties in class of size %d at level %d.\n", nSize,
p->pLevels[Gia_IsoGetItem(
p, iBegin)] );
617 Vec_IntShrink(
p->vClasses, Shrink );
634 int i, k, iBegin, nSize, Counter = 0;
640 for ( k = 0; k < nSize; k++ )
642 pObj = Gia_ManObj(
p->pGia, Gia_IsoGetItem(
p, iBegin+k) );
643 if ( Gia_ObjIsAnd(pObj) )
645 Gia_ObjSetTravIdCurrent(
p->pGia, Gia_ObjFanin0(pObj) );
646 Gia_ObjSetTravIdCurrent(
p->pGia, Gia_ObjFanin1(pObj) );
648 else if ( Gia_ObjIsRo(
p->pGia, pObj) )
649 Gia_ObjSetTravIdCurrent(
p->pGia, Gia_ObjFanin0(Gia_ObjRoToRi(
p->pGia, pObj)) );
657 for ( k = 0; k < nSize; k++ )
659 pObj = Gia_ManObj(
p->pGia, Gia_IsoGetItem(
p, iBegin+k) );
660 if ( !Gia_ObjIsTravIdCurrent(
p->pGia, pObj) )
662 printf(
"%5d : ", ++Counter );
663 printf(
"Obj %6d : Level = %4d. iBegin = %4d. Size = %4d.\n",
664 Gia_ObjId(
p->pGia, pObj),
p->pLevels[Gia_ObjId(
p->pGia, pObj)], iBegin, nSize );
684 Gia_Obj_t * pObj, * pObjC, * pObj1, * pObj0;
691 if ( Gia_Regular(pObj0) == Gia_Regular(pObj1) )
694 Gia_Regular(pObj)->Value += s_256Primes[233];
695 Gia_Regular(pObjC)->Value += s_256Primes[234];
696 Gia_Regular(pObj0)->Value += s_256Primes[234];
701 Gia_Regular(pObj)->Value += s_256Primes[235];
702 Gia_Regular(pObjC)->Value += s_256Primes[236];
703 Gia_Regular(pObj0)->Value += s_256Primes[237];
704 Gia_Regular(pObj1)->Value += s_256Primes[237];
722 int nIterMax = 10000;
726 int fRefined, fRefinedAll;
728 abctime clk = Abc_Clock(), clkTotal = Abc_Clock();
729 assert( Gia_ManCiNum(pGia) > 0 );
730 assert( Gia_ManPoNum(pGia) > 0 );
736 p->timeStart = Abc_Clock() - clk;
745 for ( c = 0; i < nIterMax && c < nFixedPoint+1; i++, c = fRefined ? 0 : c+1 )
748 clk = Abc_Clock(); fRefined =
Gia_IsoSort(
p );
p->timeRefine += Abc_Clock() - clk;
755 while ( Vec_IntSize(
p->vClasses) > 0 )
757 for ( fRefinedAll = 1; i < nIterMax && fRefinedAll; )
760 for ( c = 0; i < nIterMax && c < nFixedPoint+1; i++, c = fRefined ? 0 : c+1 )
763 clk = Abc_Clock(); fRefined =
Gia_IsoSort(
p );
p->timeRefine += Abc_Clock() - clk;
766 fRefinedAll |= fRefined;
768 for ( c = 0; i < nIterMax && c < nFixedPoint+1; i++, c = fRefined ? 0 : c+1 )
771 clk = Abc_Clock(); fRefined =
Gia_IsoSort(
p );
p->timeRefine += Abc_Clock() - clk;
774 fRefinedAll |= fRefined;
783 while ( Vec_IntSize(
p->vClasses) > 0 )
786 for ( fRefinedAll = 1; i < nIterMax && fRefinedAll; )
789 for ( c = 0; i < nIterMax && c < nFixedPoint; i++, c = fRefined ? 0 : c+1 )
792 clk = Abc_Clock(); fRefined =
Gia_IsoSort(
p );
p->timeRefine += Abc_Clock() - clk;
795 fRefinedAll |= fRefined;
797 for ( c = 0; i < nIterMax && c < nFixedPoint; i++, c = fRefined ? 0 : c+1 )
800 clk = Abc_Clock(); fRefined =
Gia_IsoSort(
p );
p->timeRefine += Abc_Clock() - clk;
803 fRefinedAll |= fRefined;
816 p->timeTotal = Abc_Clock() - clkTotal;
817 p->timeOther =
p->timeTotal -
p->timeStart -
p->timeSim -
p->timeRefine;
818 ABC_PRTP(
"Start ",
p->timeStart,
p->timeTotal );
819 ABC_PRTP(
"Simulate ",
p->timeSim,
p->timeTotal );
820 ABC_PRTP(
"Refine ",
p->timeRefine-
p->timeSort,
p->timeTotal );
821 ABC_PRTP(
"Sort ",
p->timeSort,
p->timeTotal );
822 ABC_PRTP(
"Other ",
p->timeOther,
p->timeTotal );
823 ABC_PRTP(
"TOTAL ",
p->timeTotal,
p->timeTotal );
826 if ( Gia_ManPoNum(
p->pGia) > 1 )
857 if ( Gia_ObjIsTravIdCurrent(
p, pObj) )
859 Gia_ObjSetTravIdCurrent(
p, pObj);
860 assert( Gia_ObjIsAnd(pObj) );
861 if ( !Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) || !Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) )
868 assert( Gia_ObjFanin0(pObj)->Value != Gia_ObjFanin1(pObj)->Value );
869 if ( Gia_ObjFanin0(pObj)->Value < Gia_ObjFanin1(pObj)->Value )
880 Vec_IntPush( vAnds, Gia_ObjId(
p, pObj) );
888 vTemp = Vec_PtrAlloc( 1000 );
889 Vec_IntClear( vCis );
890 Vec_IntClear( vAnds );
891 Vec_IntClear( vCos );
894 Vec_PtrClear( vTemp );
896 Vec_PtrPush( vTemp, pObj );
900 Vec_IntPush( vCis, Gia_ObjId(
p, pObj) );
904 *pvPiPerm = Vec_IntAlloc( Gia_ManPiNum(
p) );
906 Vec_IntPush( *pvPiPerm, Gia_ObjCioId(pObj) );
910 if ( Gia_ManPoNum(
p) == 1 )
911 Vec_IntPush( vCos, Gia_ObjId(
p, Gia_ManPo(
p, 0)) );
914 Vec_PtrClear( vTemp );
917 pObj->
Value = Abc_Var2Lit( Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj) );
918 Vec_PtrPush( vTemp, pObj );
922 Vec_IntPush( vCos, Gia_ObjId(
p, pObj) );
926 Vec_PtrClear( vTemp );
928 Vec_PtrPush( vTemp, pObj );
933 Vec_IntPush( vCis, Gia_ObjId(
p, pObj) );
934 Vec_IntPush( vCos, Gia_ObjId(
p, Gia_ObjRoToRi(
p, pObj)) );
936 Vec_PtrFree( vTemp );
940 Gia_ObjSetTravIdCurrent(
p, Gia_ManConst0(
p) );
942 Gia_ObjSetTravIdCurrent(
p, pObj );
963 if ( Gia_ManCiNum(
p) == 0 )
965 assert( Gia_ManPoNum(
p) == 1 );
966 assert( Gia_ManObjNum(
p) == 2 );
974 vCis = Vec_IntAlloc( Gia_ManCiNum(
p) );
975 vAnds = Vec_IntAlloc( Gia_ManAndNum(
p) );
976 vCos = Vec_IntAlloc( Gia_ManCoNum(
p) );
982 Vec_IntFree( vAnds );
1007 assert( Gia_ManPoNum(pPart) == 1 );
1008 if ( Gia_ManCiNum(pPart) == 0 )
1010 assert( Gia_ManPoNum(pPart) == 1 );
1011 assert( Gia_ManObjNum(pPart) == 2 );
1015 *pvPiPerm = Vec_IntAlloc( 0 );
1022 vCis = Vec_IntAlloc( Gia_ManCiNum(pPart) );
1023 vAnds = Vec_IntAlloc( Gia_ManAndNum(pPart) );
1024 vCos = Vec_IntAlloc( Gia_ManCoNum(pPart) );
1031 Vec_IntFree( vCis );
1032 Vec_IntFree( vAnds );
1033 Vec_IntFree( vCos );
1052 int i, nClasses = 0;
1056 if ( Vec_IntSize(vClass) < 2 )
1059 (*pnUsed) += Vec_IntSize(vClass);
1078 Vec_Ptr_t * vEquivs, * vEquivs2, * vStrings;
1079 Vec_Int_t * vRemain, * vLevel, * vLevel2;
1081 int i, k, s, sStart, iPo, Counter;
1082 int nClasses, nUsedPos;
1085 *pvPosEquivs = NULL;
1087 *pvPiPerms = Vec_PtrStart( Gia_ManPoNum(pInit) );
1091 assert( (Gia_ManPoNum(pInit) & 1) == 0 );
1092 if ( Gia_ManPoNum(pInit) == 2 )
1100 if ( Gia_ManPoNum(pInit) == 1 )
1107 if ( vEquivs == NULL )
1114 printf(
"Reduced %d outputs to %d candidate classes (%d outputs are in %d non-trivial classes). ",
1115 Gia_ManPoNum(
p), Vec_PtrSize(vEquivs), nUsedPos, nClasses );
1116 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1125 vEquivs2 = Vec_PtrAlloc( 100 );
1128 if ( Vec_IntSize(vLevel) < 2 )
1130 Vec_PtrPush( vEquivs2, Vec_IntDup(vLevel) );
1131 for ( k = 0; k < Vec_IntSize(vLevel); k++ )
1132 if ( ++Counter % 100 == 0 )
1133 printf(
"%6d finished...\r", Counter );
1139 iPo = Vec_IntEntry(vLevel, 0);
1140 printf(
"%6d %6d %6d : ", i, Vec_IntSize(vLevel), iPo );
1146 sStart = Vec_PtrSize( vEquivs2 );
1147 vStrings = Vec_PtrAlloc( 100 );
1150 if ( ++Counter % 100 == 0 )
1151 printf(
"%6d finished...\r", Counter );
1152 assert( pvPiPerms == NULL || Vec_PtrArray(*pvPiPerms)[iPo] == NULL );
1160 if ( Vec_StrCompareVec(vStr, vStr2) == 0 )
1162 if ( s == Vec_PtrSize(vStrings) )
1164 Vec_PtrPush( vStrings, vStr );
1165 Vec_PtrPush( vEquivs2, Vec_IntAlloc(8) );
1168 Vec_StrFree( vStr );
1170 vLevel2 = (
Vec_Int_t *)Vec_PtrEntry( vEquivs2, sStart + s );
1171 Vec_IntPush( vLevel2, iPo );
1177 assert( Counter == Gia_ManPoNum(
p) );
1178 Vec_VecSortByFirstInt( (
Vec_Vec_t *)vEquivs2, 0 );
1183 vRemain = Vec_IntAlloc( 100 );
1185 Vec_IntPush( vRemain, Vec_IntEntry(vLevel, 0) );
1189 Vec_Int_t * vTemp = Vec_IntAlloc( Vec_IntSize(vRemain) );
1194 Vec_IntPush( vTemp, 2*Entry );
1195 Vec_IntPush( vTemp, 2*Entry+1 );
1198 Vec_IntFree( vRemain );
1206 pPart =
Gia_ManDupCones(
p, Vec_IntArray(vRemain), Vec_IntSize(vRemain), 0 );
1207 Vec_IntFree( vRemain );
1211 printf(
"Reduced %d outputs to %d equivalence classes (%d outputs are in %d non-trivial classes). ",
1212 Gia_ManPoNum(
p), Vec_PtrSize(vEquivs), nUsedPos, nClasses );
1214 printf(
"Reduced %d dual outputs to %d dual outputs. ", Gia_ManPoNum(
p)/2, Gia_ManPoNum(pPart)/2 );
1215 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1218 printf(
"Nontrivial classes:\n" );
1219 Vec_VecPrintInt( (
Vec_Vec_t *)vEquivs, 1 );
1222 *pvPosEquivs = vEquivs;
1246 printf(
"Reduced %d outputs to %d. ", Gia_ManPoNum(
p), vEquivs ? Vec_PtrSize(vEquivs) : 1 );
1247 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1248 if ( fVerbose && vEquivs && Gia_ManPoNum(
p) != Vec_PtrSize(vEquivs) )
1250 printf(
"Nontrivial classes:\n" );
1271 vPerm = Vec_IntStartNatural( nPis );
1272 pArray = Vec_IntArray( vPerm );
1273 for ( i = 0; i < nPis; i++ )
1275 int iNew = rand() % nPis;
1276 ABC_SWAP(
int, pArray[i], pArray[iNew] );
1287 assert( Gia_ManPoNum(
p) == 1 );
1288 assert( Gia_ManRegNum(
p) > 0 );
1291 printf(
"Considering random permutation of the primary inputs of the AIG:\n" );
1292 Vec_IntPrint( vPiPerm );
1303 vPerm0 = (
Vec_Int_t *)Vec_PtrEntry( vPisPerm, 0 );
1304 vPerm1 = (
Vec_Int_t *)Vec_PtrEntry( vPisPerm, 1 );
1310 printf(
"CEX for the init AIG is valid.\n" );
1312 printf(
"CEX for the init AIG is not valid.\n" );
1314 printf(
"CEX for the perm AIG is valid.\n" );
1316 printf(
"CEX for the perm AIG is not valid.\n" );
1321 Vec_IntFree( vPiPerm );
#define ABC_SWAP(Type, a, b)
#define ABC_PRTP(a, t, T)
void Abc_QuickSort3(word *pData, int nSize, int fDecrease)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
int Gia_IsoSort(Gia_IsoMan_t *p)
void Gia_ManFindCaninicalOrder(Gia_Man_t *p, Vec_Int_t *vCis, Vec_Int_t *vAnds, Vec_Int_t *vCos, Vec_Int_t **pvPiPerm)
void Gia_IsoAssignOneClass2(Gia_IsoMan_t *p)
void Gia_IsoRecognizeMuxes(Gia_Man_t *pGia)
Vec_Ptr_t * Gia_IsoDeriveEquivPos(Gia_Man_t *pGia, int fForward, int fVerbose)
void Gia_IsoTest(Gia_Man_t *p, Abc_Cex_t *pCex, int fVerbose)
void Gia_IsoAssignUnique(Gia_IsoMan_t *p)
void Gia_IsoTestOld(Gia_Man_t *p, int fVerbose)
Vec_Int_t * Gia_IsoTestGenPerm(int nPis)
void Gia_IsoPrintClasses(Gia_IsoMan_t *p)
void Gia_IsoSimulate(Gia_IsoMan_t *p, int Iter)
void Gia_IsoReportTopmost(Gia_IsoMan_t *p)
void Gia_IsoManStop(Gia_IsoMan_t *p)
Vec_Ptr_t * Gia_IsoCollectCosClasses(Gia_IsoMan_t *p, int fVerbose)
void Gia_ManFindCaninicalOrder_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vAnds)
Vec_Str_t * Gia_ManIsoFindString(Gia_Man_t *p, int iPo, int fVerbose, Vec_Int_t **pvPiPerm)
void Gia_IsoManTransferUnique(Gia_IsoMan_t *p)
Gia_Man_t * Gia_ManIsoReduce(Gia_Man_t *pInit, Vec_Ptr_t **pvPosEquivs, Vec_Ptr_t **pvPiPerms, int fEstimate, int fDualOut, int fVerbose, int fVeryVerbose)
struct Gia_IsoMan_t_ Gia_IsoMan_t
DECLARATIONS ///.
void Gia_IsoAssignOneClass3(Gia_IsoMan_t *p)
void Gia_IsoSimulateBack(Gia_IsoMan_t *p, int Iter)
Gia_IsoMan_t * Gia_IsoManStart(Gia_Man_t *pGia)
FUNCTION DEFINITIONS ///.
void Gia_IsoPrepare(Gia_IsoMan_t *p)
void Gia_IsoAssignOneClass(Gia_IsoMan_t *p, int fVerbose)
int Vec_IntCountNonTrivial(Vec_Ptr_t *vEquivs, int *pnUsed)
Gia_Man_t * Gia_ManIsoCanonicize(Gia_Man_t *p, int fVerbose)
void Gia_IsoPrint(Gia_IsoMan_t *p, int Iter, abctime Time)
int Gia_ObjCompareByValue(Gia_Obj_t **pp1, Gia_Obj_t **pp2)
void Gia_ManStop(Gia_Man_t *p)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
#define Gia_ManForEachRo(p, pObj, i)
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
#define Gia_ManForEachPo(p, pObj, i)
#define Gia_ManForEachAnd(p, pObj, i)
Vec_Str_t * Gia_AigerWriteIntoMemoryStr(Gia_Man_t *p)
Gia_Man_t * Gia_ManTransformMiter(Gia_Man_t *p)
#define Gia_ManForEachAndReverse(p, pObj, i)
#define Gia_ManForEachPi(p, pObj, i)
struct Gia_Obj_t_ Gia_Obj_t
Gia_Man_t * Gia_ManDupPerm(Gia_Man_t *p, Vec_Int_t *vPiPerm)
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManDupFromVecs(Gia_Man_t *p, Vec_Int_t *vCis, Vec_Int_t *vAnds, Vec_Int_t *vCos, int nRegs)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
void Gia_ManCleanValue(Gia_Man_t *p)
Gia_Man_t * Gia_ManSeqStructSweep(Gia_Man_t *p, int fConst, int fEquiv, int fVerbose)
int Gia_ManVerifyCex(Gia_Man_t *pAig, Abc_Cex_t *p, int fDualOut)
DECLARATIONS ///.
void Gia_ManIncrementTravId(Gia_Man_t *p)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
#define Gia_ManForEachCo(p, pObj, i)
#define Gia_ManForEachCi(p, pObj, i)
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Gia_Man_t * Gia_ManDupAppendNew(Gia_Man_t *pOne, Gia_Man_t *pTwo)
Vec_Str_t * Gia_AigerWriteIntoMemoryStrPart(Gia_Man_t *p, Vec_Int_t *vCis, Vec_Int_t *vAnds, Vec_Int_t *vCos, int nRegs)
unsigned __int64 word
DECLARATIONS ///.
void Abc_CexFree(Abc_Cex_t *p)
Abc_Cex_t * Abc_CexPermuteTwo(Abc_Cex_t *p, Vec_Int_t *vPermOld, Vec_Int_t *vPermNew)
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
#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 ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.