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CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC),
ABC_CONST(0xCCCCCCCCCCCCCCCC)},
63 {
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0),
ABC_CONST(0xF0F0F0F0F0F0F0F0)},
64 {
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00),
ABC_CONST(0xFF00FF00FF00FF00)},
65 {
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000),
ABC_CONST(0xFFFF0000FFFF0000)},
66 {
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000),
ABC_CONST(0xFFFFFFFF00000000)},
67 {
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF)},
68 {
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF)},
69 {
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF)},
70 {
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0x0000000000000000),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF),
ABC_CONST(0xFFFFFFFFFFFFFFFF)}
82 return nVars <= 6 ? 1 : 1 << (nVars-6);
87 t = (z & 0xffff) | ((z & 0xffff) << 16);
92 printf(
" %d", (z >> 16) & 7 );
93 printf(
" %d", (z >> 20) & 7 );
94 printf(
" %d", (z >> 24) & 7 );
95 printf(
" %d", (z >> 28) & 7 );
109 for ( w = 0; w <
nWords; w++ )
111 for ( m = 0; m < 16; m++ )
113 if ( !((t >> m) & 1) )
115 for ( w = 0; w <
nWords; w++ )
117 for ( v = 0; v < 4; v++ )
118 for ( w = 0; w <
nWords; w++ )
119 pC[w] &= ((m >> v) & 1) ? pF[v][w] : ~pF[v][w];
120 for ( w = 0; w <
nWords; w++ )
126 word pN[16][16], * pG[4];
130 for ( k = 0; k < nVars; k++ )
131 for ( w = 0; w <
nWords; w++ )
133 for ( i = 0; (z = pZ[i]); i++, k++ )
135 for ( v = 0; v < 4; v++ )
136 pG[v] = pN[ (z >> (16+(v<<2))) & 7 ];
140 for ( w = 0; w <
nWords; w++ )
141 if ( pN[k][w] != pF[w] )
146 printf(
"Verification failed!\n" );
155 int nShift = (1 << (nVars - 3));
156 word Mask = (((
word)1) << nShift) - 1;
157 word iCof0 = pF[0] & Mask;
158 word iCof1 = iCof0, iCof;
160 assert( nVars >= 6 && nVars <= 8 );
163 for ( i = 1; i < 8; i++ )
165 iCof = (pF[(i * nShift) / 64] >> ((i * nShift) & 63)) & Mask;
168 if ( iCof1 == iCof0 )
170 else if ( iCof != iCof1 )
177 int nShift = (1 << (nVars - 3));
178 word Mask = (((
word)1) << nShift) - 1;
179 word iCofs[16], iCof;
183 iCofs[0] = pF[0] & Mask;
184 for ( i = 1; i < 8; i++ )
186 iCof = (pF[(i * nShift) / 64] >> ((i * nShift) & 63)) & Mask;
187 for ( c = 0; c < nCofs; c++ )
188 if ( iCof == iCofs[c] )
191 iCofs[nCofs++] = iCof;
201 for ( w = 0; w <
nWords; w++ )
207 assert( iVar < nVars - 1 );
210 int Shift = (1 << iVar);
211 for ( i = 0; i <
nWords; i++ )
212 pOut[i] = (pIn[i] &
PMasks[iVar][0]) | ((pIn[i] &
PMasks[iVar][1]) << Shift) | ((pIn[i] &
PMasks[iVar][2]) >> Shift);
216 int Step = (1 << (iVar - 6));
217 for ( k = 0; k <
nWords; k += 4*Step )
219 for ( i = 0; i < Step; i++ )
221 for ( i = 0; i < Step; i++ )
222 pOut[Step+i] = pIn[2*Step+i];
223 for ( i = 0; i < Step; i++ )
224 pOut[2*Step+i] = pIn[Step+i];
225 for ( i = 0; i < Step; i++ )
226 pOut[3*Step+i] = pIn[3*Step+i];
233 for ( i = 0; i <
nWords; i += 2 )
235 pOut[i] = (pIn[i] &
ABC_CONST(0x00000000FFFFFFFF)) | ((pIn[i+1] &
ABC_CONST(0x00000000FFFFFFFF)) << 32);
236 pOut[i+1] = (pIn[i+1] &
ABC_CONST(0xFFFFFFFF00000000)) | ((pIn[i] &
ABC_CONST(0xFFFFFFFF00000000)) >> 32);
242 word pG[16], * pIn = pF, * pOut = pG, * pTemp;
243 int iPlace0, iPlace1, Count = 0;
244 assert( Var2Pla[v] <= p );
245 while ( Var2Pla[v] != p )
247 iPlace0 = Var2Pla[v];
248 iPlace1 = Var2Pla[v]+1;
250 pTemp = pIn; pIn = pOut, pOut = pTemp;
251 Var2Pla[Pla2Var[iPlace0]]++;
252 Var2Pla[Pla2Var[iPlace1]]--;
253 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
254 Pla2Var[iPlace1] ^= Pla2Var[iPlace0];
255 Pla2Var[iPlace0] ^= Pla2Var[iPlace1];
260 assert( Pla2Var[p] == v );
306 return (Supp & (Supp+1)) == 0;
314 int i, Shift = (1 << iVar);
315 for ( i = 0; i <
nWords; i++ )
316 if ( (t[i] & ~
Truth6[iVar]) != ((t[i] &
Truth6[iVar]) >> Shift) )
322 int i, k, Step = (1 << (iVar - 6));
323 for ( k = 0; k <
nWords; k += 2*Step )
325 for ( i = 0; i < Step; i++ )
326 if ( t[i] != t[Step+i] )
336 for ( v = 0; v < nVars; v++ )
349 int i, Shift = (1 << iVar);
350 for ( i = 0; i <
nWords; i++ )
352 pCof0[i] = (pF[i] & ~
Truth6[iVar]) | ((pF[i] & ~
Truth6[iVar]) << Shift);
353 pCof1[i] = (pF[i] &
Truth6[iVar]) | ((pF[i] &
Truth6[iVar]) >> Shift);
359 int i, k, Step = (1 << (iVar - 6));
360 for ( k = 0; k <
nWords; k += 2*Step )
362 for ( i = 0; i < Step; i++ )
364 pCof0[i] = pCof0[Step+i] = pF[i];
365 pCof1[i] = pCof1[Step+i] = pF[Step+i];
376 assert( Num16 < (1<<16)-1 );
382 for ( i = 0; i < nVars; i++ )
383 assert( Pla2Var[Var2Pla[i]] == i );
388 word pCof0[16], pCof1[16];
389 int Pla2Var[10], Var2Pla[10], Count[210], Masks[210];
390 int i, i0,i1,i2, v, x;
391 assert( nVars >= 6 && nVars <= 8 );
393 for ( i = 0; i < nVars; i++ )
396 Pla2Var[i] = Var2Pla[i] = i;
412 for ( i0 = 0; i0 < nVars; i0++ )
413 for ( i1 = i0+1; i1 < nVars; i1++ )
414 for ( i2 = i1+1; i2 < nVars; i2++, v++ )
421 Masks[v] = (1 << i0) | (1 << i1) | (1 << i2);
424 if ( Count[v] == 2 || Count[v] > 5 )
426 for ( x = 0; x < 4; x++ )
431 Count[v] = -Count[v];
439 for ( i0 = 0; i0 < v; i0++ )
440 for ( i1 = i0+1; i1 < v; i1++ )
446 if ( Count[i0] == 2 && Count[i1] == 2 )
449 else if ( nVars == 7 )
451 if ( (Count[i0] == 2 && Count[i1] == 2) ||
452 (Count[i0] == 2 && Count[i1] < 0) ||
453 (Count[i0] < 0 && Count[i1] == 2) )
458 if ( (Count[i0] == 2 && Count[i1] == 2) ||
459 (Count[i0] == 2 && Count[i1] < 0) ||
460 (Count[i0] < 0 && Count[i1] == 2) ||
461 (Count[i0] < 0 && Count[i1] < 0) )
483 int nSupp, fDerive = 0;
void If_Dec08PrintConfig(unsigned *pZ)
static void If_Dec08Copy(word *pOut, word *pIn, int nVars)
static void If_Dec08SwapAdjacent(word *pOut, word *pIn, int iVar, int nVars)
static int If_DecSuppIsMinBase(int Supp)
static int If_Dec08CofCount2(word *pF, int nVars)
static ABC_NAMESPACE_IMPL_START int BitCount8[256]
DECLARATIONS ///.
void If_Dec08Cofactors(word *pF, int nVars, int iVar, word *pCof0, word *pCof1)
static void If_Dec08MoveTo(word *pF, int nVars, int v, int p, int Pla2Var[], int Var2Pla[])
static word Truth10[10][16]
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
int If_CutPerformCheck08(If_Man_t *p, unsigned *pTruth, int nVars, int nLeaves, char *pStr)
static int If_Dec08CofCount(word *pF, int nVars)
static int If_Dec08Support(word *t, int nVars)
static void If_DecVerifyPerm(int Pla2Var[10], int Var2Pla[10], int nVars)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
int If_Dec08Perform(word *pF, int nVars, int fDerive)
#define ABC_NAMESPACE_IMPL_START
static int If_Dec08HasVar(word *t, int nVars, int iVar)
#define ABC_CONST(number)
PARAMETERS ///.
static void If_Dec08PrintConfigOne(unsigned z)
static void If_Dec08ComposeLut4(int t, word **pF, word *pR, int nVars)
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
static int If_Dec08WordNum(int nVars)
FUNCTION DEFINITIONS ///.
void If_Dec08Verify(word *pF, int nVars, unsigned *pZ)
static int If_Dec08Count16(int Num16)