55 i = i - ((i >> 1) & 0x55555555);
56 i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
57 i = ((i + (i >> 4)) & 0x0F0F0F0F);
58 return (i*(0x01010101))>>24;
63 int i, Size = (1 << n);
64 for ( i = 0; i < Size; i++ )
84 word * pLimit, * pEntry1, * pEntry2;
86 int i, k, v, Value,
Counter = 0;
91 for ( v = 0; v < nVarsMin; v++ )
94 for ( k = 0; k < nVars; k++ )
95 if ( ((pMatrix[v] >> k) & 1) && ((Entry >> k) & 1) )
98 EntryNew |= (((
word)1) << v);
105 for ( ; pEntry1 < pLimit; pEntry1++ )
106 for ( pEntry2 = pEntry1 + 1; pEntry2 < pLimit; pEntry2++ )
107 if ( *pEntry1 == *pEntry2 )
110 printf(
"The total of %d pairs fail verification.\n", Counter );
112 printf(
"Verification successful.\n" );
133 word * pEntry2, Value;
134 for ( ; pEntry1 < pLimit; pEntry1++ )
135 for ( pEntry2 = pEntry1 + 1; pEntry2 < pLimit; pEntry2++ )
137 Value = *pEntry1 ^ *pEntry2;
149 int i, k, Size = (1 << nBits), Value;
150 for ( i = 0; i < Size; i++ )
153 for ( k = 1; k <= nOnes; k++ )
176 for ( i = 0; i < nBits; i++ )
177 printf(
"%d", (
int)((uMask >> i) & 1) );
185 for ( b = ((Ent >> nBits) & 1), k = 0; k < nBits; k++ )
186 pCounts[k] += ((Ent >> k) & 1) ^ b;
190 int k, Counts[64] = {0};
192 for ( k = 0; k < nBits; k++ )
193 printf(
"%2d : %6d %6.2f %%\n", k, Counts[k], 100.0 * Counts[k] /
Vec_WrdSize(p) );
197 int k, kBest = 0, Counts[64] = {0};
199 for ( k = 1; k < nBits; k++ )
200 if ( Counts[kBest] < Counts[k] )
202 *pMerit = Counts[kBest];
209 for ( ; pEntry < pLimit; pEntry++ )
210 if ( (*pEntry >> iVar) & 1 )
211 *pEntry ^= (((
word)1) << nBits);
218 if ( ((Ent >> nBits) & 1) == 0 )
225 int Prev = -1, This,
Var;
248 printf(
"%2d : ", i );
267 void Abc_SuppTest(
int nOnes,
int nVars,
int fUseSimple,
int fCheck,
int fVerbose )
276 printf(
"M = %2d N = %2d : ", nOnes, nVars );
284 printf(
"Solution with %d variables found. ", nVarsMin );
307 int nCubes = 0, nVars = -1, iVar;
308 char * pCur, * pToken, * pStart =
"INPUT F-COVER";
311 { printf(
"Cannot open input file (%s).\n", pFileName );
return NULL; }
312 pCur =
strstr( pStr, pStart );
314 { printf(
"Cannot find beginning of cube cover (%s).\n", pStart );
return NULL; }
316 nCubes = atoi( pToken );
317 if ( nCubes < 1 || nCubes > 1000000 )
318 { printf(
"The number of cubes in not in the range [1; 1000000].\n" );
return NULL; }
321 while ( (pToken =
strtok(NULL,
" \t\r\n,")) != NULL )
328 { printf(
"The number of inputs (%d) is too high.\n", iVar );
Vec_WrdFree(vRes);
return NULL; }
331 else if ( nVars != iVar )
332 { printf(
"The number of inputs (%d) does not match declaration (%d).\n", nVars, iVar );
Vec_WrdFree(vRes);
return NULL; }
337 if ( pToken[1] ==
'0' && pToken[0] ==
'1' )
338 uCube |= (((
word)1) << iVar);
339 else if ( pToken[1] !=
'1' || pToken[0] !=
'0' )
340 { printf(
"Strange literal representation (%s) of cube %d.\n", pToken, nCubes );
Vec_WrdFree(vRes);
return NULL; }
345 { printf(
"The number of cubes (%d) does not match declaration (%d).\n",
Vec_WrdSize(vRes), nCubes );
Vec_WrdFree(vRes);
return NULL; }
347 printf(
"Successfully parsed function with %d inputs and %d cubes.\n", nVars, nCubes );
370 for ( ; pEnt < pLimit; pEnt++ )
371 for ( pEnt2 = pEnt+1; pEnt2 < pLimit; pEnt2++ )
372 *pStore++ = *pEnt ^ *pEnt2;
378 printf(
"Successfully generated diff matrix with %10d rows (%6.2f %%). ",
398 i = i - ((i >> 1) & 0x5555555555555555);
399 i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
400 i = ((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F);
401 return (i*(0x0101010101010101))>>56;
405 int v, vBest = -1, dBest = -1;
406 for ( v = 0; v < nVars; v++ )
417 word Entry;
int i, v;
422 if ( ((Entry >> iVar) & 1) == 0 )
425 if ( pCounts[i] == 1 )
427 for ( v = 0; v < nVars; v++ )
428 if ( (Entry >> v) & 1 )
434 else if ( pCounts[i] == 2 )
436 for ( v = 0; v < nVars; v++ )
437 if ( (Entry >> v) & 1 )
445 for ( v = 0; v < nVars; v++ )
454 word Entry;
int i, v, iVar, nVarsNew = nVars;
459 if ( pCounts[i] == 1 )
461 for ( v = 0; v < nVars; v++ )
462 if ( (Entry >> v) & 1 )
465 else if ( pCounts[i] == 2 )
467 for ( v = 0; v < nVars; v++ )
468 if ( (Entry >> v) & 1 )
512 if ( vCubes == NULL )
520 printf(
"Solution with %d variables found. ", nVarsMin );
static int Vec_WecLevelSize(Vec_Wec_t *p, int i)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
static int Abc_InfoHasBit(unsigned *p, int i)
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
static void Abc_InfoXorBit(unsigned *p, int i)
static void Vec_WecFree(Vec_Wec_t *p)
static Vec_Wec_t * Vec_WecStart(int nSize)
static int Vec_WrdCap(Vec_Wrd_t *p)
#define ABC_ALLOC(type, num)
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
static int Vec_WrdSize(Vec_Wrd_t *p)
static void Vec_WrdFreeP(Vec_Wrd_t **p)
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static void Abc_PrintTime(int level, const char *pStr, abctime time)
static void Vec_WrdShrink(Vec_Wrd_t *p, int nSizeNew)
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
static word * Vec_WrdLimit(Vec_Wrd_t *p)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Vec_WrdFree(Vec_Wrd_t *p)
static int Vec_IntRemove(Vec_Int_t *p, int Entry)
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
static word * Vec_WrdArray(Vec_Wrd_t *p)
#define ABC_CALLOC(type, num)
static void Vec_IntClear(Vec_Int_t *p)
static Vec_Wrd_t * Vec_WrdDup(Vec_Wrd_t *pVec)
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
static void Vec_WecPush(Vec_Wec_t *p, int Level, int Entry)