47 int nMintsL = (1 << nLutSize);
48 int nMintsF = (1 << (2 * nLutSize - 1));
49 int nVars = 2 * nMintsL + nMintsF;
52 int m,iVarM = 2 * nMintsL;
55 for ( m = 0; m < nMintsF; m++ )
58 iVarP1 + 2 * (m / nMintsL) + 1,
59 iVarP1 + 2 * (m / nMintsL),
65 int nMintsL = (1 << nLutSize);
66 int nMintsF = (1 << (3 * nLutSize - 2));
67 int nVars = 3 * nMintsL + nMintsF;
70 int iVarP2 = 2 * nMintsL;
71 int m,iVarM = 3 * nMintsL;
74 for ( m = 0; m < nMintsF; m++ )
77 iVarP1 + (m >> nLutSize) % nMintsL,
78 iVarP2 + 4 * (m >> (2 * nLutSize)) + 0,
79 iVarP2 + 4 * (m >> (2 * nLutSize)) + 1,
80 iVarP2 + 4 * (m >> (2 * nLutSize)) + 2,
81 iVarP2 + 4 * (m >> (2 * nLutSize)) + 3,
104 int m, v, nMints = (1 << k);
107 for ( m = 0; m < nMints; m++ )
109 if ( !((t >> m) & 1) )
112 for ( v = 0; v < k; v++ )
113 c &= ((m >> v) & 1) ? f[v] : ~f[v];
123 for ( i = 0; i < nSSet; i++ )
125 for ( i = 0; i < nBSet; i++ )
131 for ( i = 0; i < nSSet; i++ )
133 for ( i = 0; i < nFSet; i++ )
156 int nMintsL = (1 << nLutSize);
157 int nMintsF = (1 << (2 * nLutSize - 1));
158 int v, Value, m, mNew, nMintsFNew, nMintsLNew;
162 assert( nBSet + nSSet + nFSet == nVars );
164 assert( nSSet + nBSet <= nLutSize );
165 assert( nLutSize + nSSet + nFSet <= 2*nLutSize - 1 );
166 nMintsFNew = (1 << (nLutSize + nSSet + nFSet));
169 for ( m = 0; m < (1 << nVars); m++ )
171 mNew = iBSet = iSSet = iFSet = 0;
172 for ( v = 0; v < nVars; v++ )
174 Value = ((uSet >> (v << 1)) & 3);
177 if ( ((m >> v) & 1) )
178 mNew |= 1 << (nLutSize + nSSet + iFSet), pFSet[iFSet] = v;
181 else if ( Value == 1 )
183 if ( ((m >> v) & 1) )
184 mNew |= 1 << (nSSet + iBSet), pBSet[iBSet] = v;
187 else if ( Value == 3 )
189 if ( ((m >> v) & 1) )
192 mNew |= 1 << (nLutSize + iSSet);
197 else assert( Value == 0 );
199 assert( iBSet == nBSet && iFSet == nFSet );
217 if ( pTBound && pTFree )
220 assert( nSSet + nBSet <= nLutSize );
222 nMintsLNew = (1 << (nSSet + nBSet));
223 for ( m = 0; m < nMintsLNew; m++ )
228 assert( nSSet + nFSet + 1 <= nLutSize );
230 nMintsLNew = (1 << (1 + nSSet + nFSet));
231 for ( m = 0; m < nMintsLNew; m++ )
235 if ( nVars != 6 || nLutSize != 4 )
238 Res =
If_ManSat6Truth( *pTBound, *pTFree, pBSet, nBSet, pSSet, nSSet, pFSet, nFSet );
239 if ( pTruth[0] != Res )
245 printf(
"Verification failed!\n" );
265 int nTotal = 2 * nLutSize - 1;
266 int nShared = nTotal - nVars;
268 assert( nLutSize >= 2 && nLutSize <= 6 );
269 assert( nLutSize < nVars && nVars <= nTotal );
270 assert( nShared >= 0 && nShared < nLutSize - 1 );
274 for ( i[0] = 0; i[0] < nVars; i[0]++ )
275 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
277 uSet = (1 << (2*i[0])) | (1 << (2*i[1]));
278 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet, NULL, NULL, vLits) )
282 else if ( nLutSize == 3 )
284 for ( i[0] = 0; i[0] < nVars; i[0]++ )
285 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
286 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
288 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2]));
289 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet, NULL, NULL, vLits) )
294 for ( i[0] = 0; i[0] < nVars; i[0]++ )
295 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
296 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
298 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2]));
299 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
300 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])), NULL, NULL, vLits) )
301 return uSet | (3 << (2*i[s[0]]));
304 else if ( nLutSize == 4 )
306 for ( i[0] = 0; i[0] < nVars; i[0]++ )
307 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
308 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
309 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
311 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3]));
312 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet, NULL, NULL, vLits) )
317 for ( i[0] = 0; i[0] < nVars; i[0]++ )
318 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
319 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
320 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
322 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3]));
323 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
324 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])), NULL, NULL, vLits) )
325 return uSet | (3 << (2*i[s[0]]));
329 for ( i[0] = 0; i[0] < nVars; i[0]++ )
330 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
331 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
332 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
334 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3]));
336 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
337 for ( s[1] = s[0]+1; s[1] < nLutSize; s[1]++ )
338 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]])), NULL, NULL, vLits) )
339 return uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]]));
343 else if ( nLutSize == 5 )
345 for ( i[0] = 0; i[0] < nVars; i[0]++ )
346 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
347 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
348 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
349 for ( i[4] = i[3]+1; i[4] < nVars; i[4]++ )
351 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3])) | (1 << (2*i[4]));
352 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet, NULL, NULL, vLits) )
357 for ( i[0] = 0; i[0] < nVars; i[0]++ )
358 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
359 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
360 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
361 for ( i[4] = i[3]+1; i[4] < nVars; i[4]++ )
363 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3])) | (1 << (2*i[4]));
364 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
365 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])), NULL, NULL, vLits) )
366 return uSet | (3 << (2*i[s[0]]));
370 for ( i[0] = 0; i[0] < nVars; i[0]++ )
371 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
372 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
373 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
374 for ( i[4] = i[3]+1; i[4] < nVars; i[4]++ )
376 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3])) | (1 << (2*i[4]));
377 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
378 for ( s[1] = s[0]+1; s[1] < nLutSize; s[1]++ )
379 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]])), NULL, NULL, vLits) )
380 return uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]]));
384 for ( i[0] = 0; i[0] < nVars; i[0]++ )
385 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
386 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
387 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
388 for ( i[4] = i[3]+1; i[4] < nVars; i[4]++ )
390 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3])) | (1 << (2*i[4]));
391 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
392 for ( s[1] = s[0]+1; s[1] < nLutSize; s[1]++ )
393 for ( s[2] = s[1]+1; s[2] < nLutSize; s[2]++ )
394 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]])) | (3 << (2*i[s[2]])), NULL, NULL, vLits) )
395 return uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]])) | (3 << (2*i[s[2]]));
398 else if ( nLutSize == 6 )
400 for ( i[0] = 0; i[0] < nVars; i[0]++ )
401 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
402 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
403 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
404 for ( i[4] = i[3]+1; i[4] < nVars; i[4]++ )
405 for ( i[5] = i[4]+1; i[5] < nVars; i[5]++ )
407 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3])) | (1 << (2*i[4])) | (1 << (2*i[5]));
408 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet, NULL, NULL, vLits) )
413 for ( i[0] = 0; i[0] < nVars; i[0]++ )
414 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
415 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
416 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
417 for ( i[4] = i[3]+1; i[4] < nVars; i[4]++ )
418 for ( i[5] = i[4]+1; i[5] < nVars; i[5]++ )
420 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3])) | (1 << (2*i[4])) | (1 << (2*i[5]));
421 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
422 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])), NULL, NULL, vLits) )
423 return uSet | (3 << (2*i[s[0]]));
427 for ( i[0] = 0; i[0] < nVars; i[0]++ )
428 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
429 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
430 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
431 for ( i[4] = i[3]+1; i[4] < nVars; i[4]++ )
432 for ( i[5] = i[4]+1; i[5] < nVars; i[5]++ )
434 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3])) | (1 << (2*i[4])) | (1 << (2*i[5]));
435 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
436 for ( s[1] = s[0]+1; s[1] < nLutSize; s[1]++ )
437 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]])), NULL, NULL, vLits) )
438 return uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]]));
442 for ( i[0] = 0; i[0] < nVars; i[0]++ )
443 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
444 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
445 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
446 for ( i[4] = i[3]+1; i[4] < nVars; i[4]++ )
447 for ( i[5] = i[4]+1; i[5] < nVars; i[5]++ )
449 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3])) | (1 << (2*i[4])) | (1 << (2*i[5]));
450 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
451 for ( s[1] = s[0]+1; s[1] < nLutSize; s[1]++ )
452 for ( s[2] = s[1]+1; s[2] < nLutSize; s[2]++ )
453 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]])) | (3 << (2*i[s[2]])), NULL, NULL, vLits) )
454 return uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]])) | (3 << (2*i[s[2]]));
458 for ( i[0] = 0; i[0] < nVars; i[0]++ )
459 for ( i[1] = i[0]+1; i[1] < nVars; i[1]++ )
460 for ( i[2] = i[1]+1; i[2] < nVars; i[2]++ )
461 for ( i[3] = i[2]+1; i[3] < nVars; i[3]++ )
462 for ( i[4] = i[3]+1; i[4] < nVars; i[4]++ )
463 for ( i[5] = i[4]+1; i[5] < nVars; i[5]++ )
465 uSet = (1 << (2*i[0])) | (1 << (2*i[1])) | (1 << (2*i[2])) | (1 << (2*i[3])) | (1 << (2*i[4])) | (1 << (2*i[5]));
466 for ( s[0] = 0; s[0] < nLutSize; s[0]++ )
467 for ( s[1] = s[0]+1; s[1] < nLutSize; s[1]++ )
468 for ( s[2] = s[1]+1; s[2] < nLutSize; s[2]++ )
469 for ( s[3] = s[1]+1; s[3] < nLutSize; s[3]++ )
470 if (
If_ManSatCheckXY(pSat, nLutSize, pTruth, nVars, uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]])) | (3 << (2*i[s[2]])) | (3 << (2*i[s[3]])), NULL, NULL, vLits) )
471 return uSet | (3 << (2*i[s[0]])) | (3 << (2*i[s[1]])) | (3 << (2*i[s[2]])) | (3 << (2*i[s[3]]));
501 char * pDsd =
"0123456789ABCDEF{abcdef}";
507 unsigned uSet = (1 << 0) | (3 << 2) | (1 << 4) | (1 << 6);
508 int RetValue =
If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
528 char * pDsd =
"0123456789ABCDEF{abcdef}";
533 unsigned uSet = (1 << 0) | (3 << 2) | (1 << 4) | (1 << 6);
static int * Vec_IntArray(Vec_Int_t *p)
void If_ManSatUnbuild(void *p)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static int sat_solver_add_mux(sat_solver *pSat, int iVarC, int iVarT, int iVarE, int iVarZ)
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
ABC_NAMESPACE_IMPL_START void * If_ManSatBuildXY(int nLutSize)
DECLARATIONS ///.
void sat_solver_delete(sat_solver *s)
static int Abc_Var2Lit(int Var, int fCompl)
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
static void Abc_TtSetBit(word *p, int i)
word * Dau_DsdToTruth(char *p, int nVars)
static int Abc_TtGetBit(word *p, int i)
MACRO DEFINITIONS ///.
static int sat_solver_var_value(sat_solver *s, int v)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
word If_ManSat6Truth(word uBound, word uFree, int *pBSet, int nBSet, int *pSSet, int nSSet, int *pFSet, int nFSet)
void sat_solver_setnvars(sat_solver *s, int n)
static int Vec_IntEntry(Vec_Int_t *p, int i)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
static word Abc_Tt6Stretch(word t, int nVars)
#define IF_MAX_FUNC_LUTSIZE
int If_ManSatCheckXY(void *pSat, int nLutSize, word *pTruth, int nVars, unsigned uSet, word *pTBound, word *pTFree, Vec_Int_t *vLits)
#define ABC_NAMESPACE_IMPL_START
void Dau_DecPrintSet(unsigned set, int nVars, int fNewLine)
void Dau_DecSortSet(unsigned set, int nVars, int *pnUnique, int *pnShared, int *pnFree)
sat_solver * sat_solver_new(void)
static int Vec_IntSize(Vec_Int_t *p)
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
unsigned If_ManSatCheckXYall(void *pSat, int nLutSize, word *pTruth, int nVars, Vec_Int_t *vLits)
void * If_ManSatBuildXYZ(int nLutSize)
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static int sat_solver_add_mux41(sat_solver *pSat, int iVarC0, int iVarC1, int iVarD0, int iVarD1, int iVarD2, int iVarD3, int iVarZ)
unsigned If_ManSatCheckXYall_int(void *pSat, int nLutSize, word *pTruth, int nVars, Vec_Int_t *vLits)
static word If_ManSat6ComposeLut4(int t, word f[4], int k)
int nTotal
DECLARATIONS ///.