34 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
35 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
36 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
37 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
38 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
39 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
40 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
41 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
80 S[0] = (z & 0xffff) | ((z & 0xffff) << 16);
85 printf(
" %d", (
int)((z >> 16) & 7) );
86 printf(
" %d", (
int)((z >> 20) & 7) );
87 printf(
" %d", (
int)((z >> 24) & 7) );
88 printf(
" %d", (
int)((z >> 28) & 7) );
90 S[0] = ((z >> 32) & 0xffff) | (((z >> 32) & 0xffff) << 16);
95 printf(
" %d", (
int)((z >> 48) & 7) );
96 printf(
" %d", (
int)((z >> 52) & 7) );
97 printf(
" %d", (
int)((z >> 56) & 7) );
98 printf(
" %d", (
int)((z >> 60) & 7) );
107 for ( m = 0; m < 16; m++ )
109 if ( !((t >> m) & 1) )
112 for ( v = 0; v < 4; v++ )
113 c &= ((m >> v) & 1) ? f[v] : ~f[v];
123 for ( i = 0; i < 4; i++ )
125 v = (z >> (16+(i<<2))) & 7;
132 for ( i = 0; i < 4; i++ )
134 v = (z >> (48+(i<<2))) & 7;
137 f[i] = (v == 7) ? q :
Truth6[v];
151 printf(
"Verification failed!\n" );
160 for ( m = 0; m < 16; m++ )
162 if ( !((t >> m) & 1) )
164 c[0] = c[1] = ~(
word)0;
165 for ( v = 0; v < 4; v++ )
167 c[0] &= ((m >> v) & 1) ? f[v][0] : ~f[v][0];
168 c[1] &= ((m >> v) & 1) ? f[v][1] : ~f[v][1];
179 for ( i = 0; i < 4; i++ )
181 v = (z >> (16+(i<<2))) & 7;
188 for ( i = 0; i < 3; i++ )
190 v = (z >> (48+(i<<2))) & 7;
195 if ( r[0] != t[0] || r[1] != t[1] )
200 printf(
"Verification failed!\n" );
209 for ( i = 0; i < 16; i++ )
210 Mask |= (1 << ((t >> (i<<2)) & 15));
216 unsigned char * pTruth = (
unsigned char *)t;
218 for ( i = 1; i < 16; i++ )
220 if ( pTruth[i] == pTruth[0] )
224 else if ( pTruth[i] != pTruth[iCof2] )
235 return (t &
PMasks[v][0]) | ((t &
PMasks[v][1]) << (1 << v)) | ((t &
PMasks[v][2]) >> (1 << v));
239 int iPlace0, iPlace1;
240 assert( Var2Pla[v] >= p );
241 while ( Var2Pla[v] != p )
243 iPlace0 = Var2Pla[v]-1;
244 iPlace1 = Var2Pla[v];
246 Var2Pla[Pla2Var[iPlace0]]++;
247 Var2Pla[Pla2Var[iPlace1]]--;
248 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
249 Pla2Var[iPlace1] ^= Pla2Var[iPlace0];
250 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
252 assert( Pla2Var[p] == v );
261 unsigned Temp = (t[0] >> 32);
262 t[0] = (t[0] & 0xFFFFFFFF) | ((t[1] & 0xFFFFFFFF) << 32);
263 t[1] ^= (t[1] & 0xFFFFFFFF) ^ Temp;
272 int iPlace0, iPlace1;
273 assert( Var2Pla[v] >= p );
274 while ( Var2Pla[v] != p )
276 iPlace0 = Var2Pla[v]-1;
277 iPlace1 = Var2Pla[v];
279 Var2Pla[Pla2Var[iPlace0]]++;
280 Var2Pla[Pla2Var[iPlace1]]--;
281 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
282 Pla2Var[iPlace1] ^= Pla2Var[iPlace0];
283 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
285 assert( Pla2Var[p] == v );
294 for ( i = 1; i < 16; i++ )
295 if ( *pCof0 != ((t >> (i<<2)) & 15) )
297 *pCof1 = ((t >> (i<<2)) & 15);
304 unsigned char * pTruth = (
unsigned char *)t;
308 for ( i = 1; i < 16; i++ )
309 if ( *pCof0 != pTruth[i] )
320 assert( iVar >= 0 && iVar < 6 );
322 return (t &
Truth6[iVar]) | ((t &
Truth6[iVar]) >> (1<<iVar));
324 return (t &~
Truth6[iVar]) | ((t &~
Truth6[iVar]) << (1<<iVar));
330 for ( i = 0; i < 4; i++ )
331 z |= (((
word)Pla2Var[i+2]) << (16 + 4*i));
332 z |= ((
word)((Cof1 << 4) | Cof0) << 32);
333 z |= ((
word)((Cof1 << 4) | Cof0) << 40);
334 for ( i = 0; i < 2; i++ )
335 z |= (((
word)Pla2Var[i]) << (48 + 4*i));
336 z |= (((
word)7) << (48 + 4*i++));
343 int Cof0[2], Cof1[2];
344 int Truth0, Truth1, i;
345 int Pla2Var[6], Var2Pla[6];
346 assert( s >= 2 && s <= 5 );
347 for ( i = 0; i < 6; i++ )
349 Pla2Var[i] = Pla2Var0[i];
350 Var2Pla[i] = Var2Pla0[i];
352 for ( i = s; i < 5; i++ )
355 Var2Pla[Pla2Var[i]]++;
356 Var2Pla[Pla2Var[i+1]]--;
357 Pla2Var[i] ^= Pla2Var[i+1];
358 Pla2Var[i+1] ^= Pla2Var[i];
359 Pla2Var[i] ^= Pla2Var[i+1];
367 z = ((Truth1 & 0xFF) << 8) | (Truth0 & 0xFF);
368 for ( i = 0; i < 4; i++ )
369 z |= (((
word)Pla2Var[i+2]) << (16 + 4*i));
370 z |= ((
word)((Cof0[1] << 4) | Cof0[0]) << 32);
371 z |= ((
word)((Cof1[1] << 4) | Cof1[0]) << 40);
372 for ( i = 0; i < 2; i++ )
373 z |= (((
word)Pla2Var[i]) << (48 + 4*i));
374 z |= (((
word)7) << (48 + 4*i++));
375 z |= (((
word)Pla2Var[5]) << (48 + 4*i++));
383 for ( i = 0; i < 4; i++ )
384 z |= (((
word)Pla2Var[i+3]) << (16 + 4*i));
385 z |= ((
word)((Cof1 << 8) | Cof0) << 32);
386 for ( i = 0; i < 3; i++ )
387 z |= (((
word)Pla2Var[i]) << (48 + 4*i));
388 z |= (((
word)7) << (48 + 4*i));
399 return (t &
ABC_CONST(0x00000000FFFFFFFF)) + (t>>32);
407 assert( v >= 0 && v < 7 );
410 return ((t[0] &
Truth6[v]) >> (1<<v)) != (t[0] & ~
Truth6[v])
411 || ((t[1] &
Truth6[v]) >> (1<<v)) != (t[1] & ~
Truth6[v]);
417 for ( i = 0; i < 6; i++ )
418 assert( Pla2Var[Var2Pla[i]] == i );
423 int i, v, u, x, Count, Pla2Var[6], Var2Pla[6];
425 for ( i = 0; i < 6; i++ )
428 Pla2Var[i] = Var2Pla[i] = i;
432 for ( v = 0; v < 6; v++ )
433 for ( u = v+1; u < 6; u++, i++ )
443 if ( !r && (Count == 3 || Count == 4) )
445 for ( x = 0; x < 4; x++ )
462 word t[2] = {t0[0], t0[1]};
463 int i, v, u, y, Pla2Var[7], Var2Pla[7];
465 for ( i = 0; i < 7; i++ )
473 Pla2Var[i] = Var2Pla[i] = i;
476 for ( v = 0; v < 7; v++ )
477 for ( u = v+1; u < 7; u++ )
478 for ( y = u+1; y < 7; y++ )
496 return (Supp & (Supp+1)) == 0;
502 for ( i = 0; i < nVarsAll; i++ )
503 if ( Phase & (1 << i) )
505 for ( k = i-1; k >=
Var; k-- )
514 int v, iVar = 0, uSupp = 0;
516 for ( v = 0; v < nVarsAll; v++ )
521 pSupp[iVar] = pSupp[v];
535 for ( i = 0; i < nVarsAll; i++ )
536 if ( Phase & (1 << i) )
538 for ( k = i-1; k >=
Var; k-- )
546 int v, iVar = 0, uSupp = 0;
548 for ( v = 0; v < nVarsAll; v++ )
553 pSupp[iVar] = pSupp[v];
569 for ( v = 0; v < 6; v++ )
577 for ( v = 0; v < 6; v++ )
587 assert( iVar >= 0 && iVar < 7 );
599 r[0] = (t[0] &
Truth6[iVar]) | ((t[0] &
Truth6[iVar]) >> (1<<iVar));
600 r[1] = (t[1] &
Truth6[iVar]) | ((t[1] &
Truth6[iVar]) >> (1<<iVar));
604 r[0] = (t[0] &~
Truth6[iVar]) | ((t[0] &~
Truth6[iVar]) << (1<<iVar));
605 r[1] = (t[1] &~
Truth6[iVar]) | ((t[1] &~
Truth6[iVar]) << (1<<iVar));
613 for ( v = 0; v < 7; v++ )
617 if ( c0[0] != c1[0] || c0[1] != c1[1] )
626 for ( v = 0; v < 7; v++ )
639 int v, vBest = -1, Count0, Count1, CountBest = 1000;
640 for ( v = 0; v < 6; v++ )
644 if ( Count0 < 5 && Count1 < 5 && CountBest > Count0 + Count1 )
646 CountBest = Count0 + Count1;
657 int v, vBest = -1, Count0, Count1, CountBest = 1000;
658 for ( v = 0; v < 7; v++ )
664 if ( Count0 < 5 && Count1 < 5 && CountBest > Count0 + Count1 )
666 CountBest = Count0 + Count1;
668 c0r[0] = c0[0]; c0r[1] = c0[1];
669 c1r[0] = c1[0]; c1r[1] = c1[1];
692 assert( x >= 0 && x < 4 );
693 assert( y >= 0 && y < 4 );
694 for ( m = 0; m < 4; m++ )
696 for ( Mask = i = 0; i < 16; i++ )
697 if ( ((i >> x) & 1) == ((m >> 0) & 1) && ((i >> y) & 1) == ((m >> 1) & 1) )
698 Mask |= (1 << ((t >> (i<<1)) & 3));
711 word C2[4], D2[4] = {0}, C1[2], D1[2], C, D, z;
712 int v, zz1 = -1, zz2 = -1;
714 for ( v = 0; v < 4; v++ )
715 if ( v != x && v != y )
717 for ( v = 1; v < 4; v++ )
718 if ( v != x && v != y && v != zz1 )
720 assert( zz1 != -1 && zz2 != -1 );
722 for ( m = 0; m < 4; m++ )
725 for ( Mask = i = 0; i < 16; i++ )
726 if ( ((i >> x) & 1) == ((m >> 0) & 1) && ((i >> y) & 1) == ((m >> 1) & 1) )
727 Mask |= (1 << ((t >> (i<<1)) & 3));
740 for ( Mask = i = 0; i < 16; i++ )
741 if ( ((i >> x) & 1) == ((m >> 0) & 1) && ((i >> y) & 1) == ((m >> 1) & 1) )
742 if ( Bit1 == ((t >> (i<<1)) & 3) )
743 D2[m] |= (((
word)1) << ( (((i >> zz2) & 1) << 1) | ((i >> zz1) & 1) ));
767 if ( fHas2 && fHas3 )
770 z |= (((
word)Pla2Var[zz1+1]) << (16 + 4*0));
771 z |= (((
word)Pla2Var[zz2+1]) << (16 + 4*1));
772 z |= (((
word)Pla2Var[x+1]) << (16 + 4*2));
773 z |= (((
word)Pla2Var[y+1]) << (16 + 4*3));
775 else if ( fHas2 && !fHas3 )
778 z |= (((
word)Pla2Var[zz1+1]) << (16 + 4*0));
779 z |= (((
word)Pla2Var[zz2+1]) << (16 + 4*1));
780 z |= (((
word)Pla2Var[x+1]) << (16 + 4*2));
781 z |= (((
word)6) << (16 + 4*3));
783 else if ( !fHas2 && fHas3 )
787 z |= (((
word)Pla2Var[zz1+1]) << (16 + 4*0));
788 z |= (((
word)Pla2Var[zz2+1]) << (16 + 4*1));
789 z |= (((
word)Pla2Var[y+1]) << (16 + 4*2));
790 z |= (((
word)6) << (16 + 4*3));
795 z |= (((
word)Pla2Var[zz1+1]) << (16 + 4*0));
796 z |= (((
word)Pla2Var[zz2+1]) << (16 + 4*1));
797 z |= (((
word)6) << (16 + 4*2));
798 z |= (((
word)6) << (16 + 4*3));
804 if ( fHas2 && fHas3 )
806 z |= ((C & 0xFFFF) << 32);
807 z |= (((
word)Pla2Var[0]) << (48 + 4*0));
808 z |= (((
word)7) << (48 + 4*1));
809 z |= (((
word)Pla2Var[x+1]) << (48 + 4*2));
810 z |= (((
word)Pla2Var[y+1]) << (48 + 4*3));
812 else if ( fHas2 && !fHas3 )
814 z |= ((C & 0xFFFF) << 32);
815 z |= (((
word)Pla2Var[0]) << (48 + 4*0));
816 z |= (((
word)7) << (48 + 4*1));
817 z |= (((
word)Pla2Var[x+1]) << (48 + 4*2));
818 z |= (((
word)6) << (48 + 4*3));
820 else if ( !fHas2 && fHas3 )
823 z |= ((C & 0xFFFF) << 32);
824 z |= (((
word)Pla2Var[0]) << (48 + 4*0));
825 z |= (((
word)7) << (48 + 4*1));
826 z |= (((
word)Pla2Var[y+1]) << (48 + 4*2));
827 z |= (((
word)6) << (48 + 4*3));
831 z |= ((C & 0xFFFF) << 32);
832 z |= (((
word)Pla2Var[0]) << (48 + 4*0));
833 z |= (((
word)7) << (48 + 4*1));
834 z |= (((
word)6) << (48 + 4*2));
835 z |= (((
word)6) << (48 + 4*3));
870 int Pla2Var[7], Var2Pla[7];
914 for ( i = 0; i < 7; i++ )
915 Pla2Var[i] = Var2Pla[i] = i;
917 for ( v = 0; v < 5; v++ )
921 for ( i = 0; i < 4; i++ )
922 for ( j = i + 1; j < 4; j++ )
990 z = (
word)(0x17ac & 0xFFFF);
991 z |= (((
word)3) << (16 + 4*0));
992 z |= (((
word)4) << (16 + 4*1));
993 z |= (((
word)1) << (16 + 4*2));
994 z |= (((
word)2) << (16 + 4*3));
996 z |= (((
word)(0x179a & 0xFFFF)) << 32);
997 z |= (((
word)0) << (48 + 4*0));
998 z |= (((
word)7) << (48 + 4*1));
999 z |= (((
word)1) << (48 + 4*2));
1000 z |= (((
word)2) << (48 + 4*3));
1008 t = 0xB0F3B0FFB0F3B0FF;
1050 t[0] = ((
word *)pTruth)[0];
1051 t[1] = ((
word *)pTruth)[1];
1076 for ( v = 0; v < nLeaves; v++ )
1106 t[0] = ((
word *)pTruth)[0];
1107 t[1] = ((
word *)pTruth)[1];
word If_CutPerformDerive07(If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
void If_DecPrintConfig(word z)
FUNCTION DEFINITIONS ///.
static word If_Dec6DeriveNonDisjoint(word t, int s, int Pla2Var0[6], int Var2Pla0[6])
static word If_Dec6MoveTo(word t, int v, int p, int Pla2Var[6], int Var2Pla[6])
int If_CutPerformCheck07(If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
word If_Dec7Perform(word t0[2], int fDerive)
static int If_Dec7CofCount3(word t[2])
int If_Dec6PickBestMux(word t, word Cofs[2])
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
static word If_Dec6Cofactor(word t, int iVar, int fCof1)
static void If_DecVerifyPerm(int Pla2Var[6], int Var2Pla[6])
static int If_Dec6CheckMux(word t)
static word If_Dec6TruthShrink(word uTruth, int nVars, int nVarsAll, unsigned Phase)
static int Abc_Tt6FirstBit(word t)
word If_Dec6Truth(word z)
static word If_Dec6ComposeLut4(int t, word f[4])
static void If_Dec7Cofactor(word t[2], int iVar, int fCof1, word r[2])
static void If_Dec7MoveTo(word t[2], int v, int p, int Pla2Var[7], int Var2Pla[7])
static void If_Dec7TruthShrink(word uTruth[2], int nVars, int nVarsAll, unsigned Phase)
static word If_Dec6SwapAdjacent(word t, int v)
static int If_Dec7HasVar(word t[2], int v)
static int If_Dec6CountOnes(word t)
static void If_Dec7ComposeLut4(int t, word f[4][2], word r[2])
static int If_DecSuppIsMinBase(int Supp)
static int If_Dec7DeriveCount3(word t[2], int *pCof0, int *pCof1)
static word If_Dec6DeriveDisjoint(word t, int Pla2Var[6], int Var2Pla[6])
static int If_Dec6SuppSize(word t)
static int If_Dec6HasVar(word t, int v)
static ABC_NAMESPACE_IMPL_START int BitCount8[256]
DECLARATIONS ///.
word If_Dec6MinimumBase(word uTruth, int *pSupp, int nVarsAll, int *pnVars)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
void If_Dec5PerformTest()
static word Abc_Tt6Stretch(word t, int nVars)
word If_Dec5Perform(word t, int fDerive)
static int Abc_TtHasVar(word *t, int nVars, int iVar)
static word If_Dec7DeriveDisjoint(word t[2], int Pla2Var[7], int Var2Pla[7])
static int If_Dec7SuppSize(word t[2])
#define ABC_NAMESPACE_IMPL_START
void If_Dec6Verify(word t, word z)
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
#define ABC_CONST(number)
PARAMETERS ///.
static int If_Dec6CofCount2(word t)
int If_Dec7PickBestMux(word t[2], word c0r[2], word c1r[2])
word If_Dec6Perform(word t, int fDerive)
static void Abc_TtSwapVars(word *pTruth, int nVars, int iVar, int jVar)
static word If_Dec5CofCount2(word t, int x, int y, int *Pla2Var, word t0, int fDerive)
void If_Dec7MinimumBase(word uTruth[2], int *pSupp, int nVarsAll, int *pnVars)
static void If_Dec7SwapAdjacent(word t[2], int v)
static int If_Dec7CheckMux(word t[2])
static int If_Dec6DeriveCount2(word t, int *pCof0, int *pCof1)
void If_Dec7Verify(word t[2], word z)