50 void Abc_GetFirst(
int * pnVars,
int * pnMints,
int * pnFuncs,
unsigned * pVars,
unsigned * pMints,
unsigned * pFuncs )
55 char * pMintStrs[16] = {
76 char * pFuncStrs[8] = {
91 for ( i = 0; i < nMints; i++ )
92 for ( k = 0; k < nVars; k++ )
93 if ( pMintStrs[i][k] ==
'1' )
94 pMints[i] |= (1 << k), pVars[k] |= (1 << i);
96 for ( i = 0; i < nFuncs; i++ )
97 for ( k = 0; k < nMints; k++ )
98 if ( pFuncStrs[i][k] ==
'1' )
99 pFuncs[i] |= (1 << k);
113 void Abc_GetSecond(
int * pnVars,
int * pnMints,
int * pnFuncs,
unsigned * pVars,
unsigned * pMints,
unsigned * pFuncs )
118 char * pMintStrs[32] = {
160 char * pFuncStrs[7] = {
161 "11111110110010001110110010000000",
162 "00000001001101110001001101111111",
163 "10000001001001000001001001001000",
164 "01001000000100101000000100100100",
165 "00100100100000010100100000010010",
166 "00010010010010000010010010000001",
167 "11111111111111111111000000000000"
174 for ( i = 0; i < nMints; i++ )
175 for ( k = 0; k < nVars; k++ )
176 if ( pMintStrs[i][k] ==
'1' )
177 pMints[i] |= (1 << k), pVars[k] |= (1 << i);
179 for ( i = 0; i < nFuncs; i++ )
180 for ( k = 0; k < nMints; k++ )
181 if ( pFuncStrs[i][k] ==
'1' )
182 pFuncs[i] |= (1 << k);
196 void Abc_GetThird(
int * pnVars,
int * pnMints,
int * pnFuncs,
unsigned * pVars,
unsigned * pMints,
unsigned * pFuncs )
201 char * pMintStrs[16] = {
222 char * pFuncStrs[7] = {
236 for ( i = 0; i < nMints; i++ )
237 for ( k = 0; k < nVars; k++ )
238 if ( pMintStrs[i][k] ==
'1' )
239 pMints[i] |= (1 << k), pVars[k] |= (1 << i);
241 for ( i = 0; i < nFuncs; i++ )
242 for ( k = 0; k < nMints; k++ )
243 if ( pFuncStrs[i][k] ==
'1' )
244 pFuncs[i] |= (1 << k);
262 char * pOper = Fan0 < Fan1 ?
"" :
"+";
266 printf(
"%c",
'a'+Fan0 );
273 printf(
"%s", pOper );
275 printf(
"%c",
'a'+Fan1 );
320 unsigned pVars[100] = {0};
321 unsigned pMints[100] = {0};
322 unsigned pFuncs[100] = {0};
324 int FuncDone[100] = {0}, nFuncDone = 0;
325 int GateCount[100] = {0};
326 int i, k, n, a, b, v;
335 Abc_GetSecond( &nVars, &nMints, &nFuncs, pVars, pMints, pFuncs );
339 assert( nMints == 16 || nMints == 32 );
343 for ( k = 0; k < nVars; k++ )
354 GateCount[1] = nVars;
356 for ( n = 0; n < nDecMax && nFuncDone < nFuncs; n++ )
358 for ( a = 0; a <= n; a++ )
359 for ( b = a; b <= n; b++ )
362 printf(
"Trying %d + %d + 1 = %d\n", a, b, n+1 );
363 for ( i = GateCount[a]; i < GateCount[a+1]; i++ )
364 for ( k = GateCount[b]; k < GateCount[b+1]; k++ )
377 for ( v = 0; v < nFuncs; v++ )
378 if ( !FuncDone[v] && Truth == pFuncs[v] )
380 printf(
"Found function %d with %d gates: ", v, n+1 );
396 for ( v = 0; v < nFuncs; v++ )
397 if ( !FuncDone[v] && Truth == pFuncs[v] )
399 printf(
"Found function %d with %d gates: ", v, n+1 );
408 printf(
"Finished %d gates. Truths = %10d. ", n+1,
Vec_IntSize(vTruths) );
429 #define ABC_ENUM_MAX 16
463 if ( p->
pRefs[i]++ == 0 )
468 if ( --p->
pRefs[i] == 0 )
492 for ( i = p->
nVars; i < p->nNodes; i++ )
493 if ( p->
Polar[i] == 4 )
494 printf(
" %c=%c+%c",
'a'+i,
'a'+p->
pFans0[i],
'a'+p->
pFans1[i] );
513 return a == b || a == ~b;
522 word uTruth = pTruths[n];
528 for ( t = 0; t < n; t++ )
535 for ( a = 0; a <= i; a++ )
536 for ( b = a + 1; b <= k; b++ )
538 if ( a == i && b == k )
555 int uTruthI = p->
fCompl0[n] ? ~pTruths[i] : pTruths[i];
556 int uTruthK = p->
fCompl1[n] ? ~pTruths[k] : pTruths[k];
558 for ( t = 0; t < k; t++ )
561 for ( t = 0; t < i; t++ )
580 int high0 = fNew ? iNode1st : p->
pFans1[n-1];
581 int high1 = fNew ? n : iNode1st;
582 int low0 = fNew ? 0 : p->
pFans0[n-1];
583 int c0 = fNew ? 0 : p->
Polar[n-1];
584 int Level = p->
pLevel[high0];
587 for ( k = high0; k < high1; k++ )
589 if ( nRefedFans == 0 && p->
pRefs[k] > 0 )
591 if ( p->
pRefs[k] > 0 )
593 assert( nRefedFans >= 0 );
595 for ( i = (k == high0) ? low0 : 0; i < k; i++ )
597 if ( nRefedFans == 0 && p->
pRefs[i] > 0 )
599 if ( Level == 0 && p->
pRefs[i] == 0 && p->
pRefs[k] == 0 && (i+1 != k || (i > 0 && p->
pRefs[i-1] == 0)) )
606 for ( c = (k == high0 && i == low0 && !fNew) ? c0 + 1 : 0; c < cLim; c++ )
608 if ( p->
pLevel[i] == 0 && p->
pRefs[i] == 0 && (c & 1) == 1 )
610 if ( p->
pLevel[k] == 0 && p->
pRefs[k] == 0 && (c & 2) == 2 )
635 if ( p->
pRefs[k] > 0 )
649 if ( nVars > nGates + 1 )
651 printf(
"The gate count %d is not enough to have functions with %d inputs.\n", nGates, nVars );
654 assert( nVars >= 2 && nVars <= 6 );
663 for ( i = 0; i < nVars; i++ )
669 printf(
"Vars = %d. Gates = %d. Tries = %u. Builds = %u. Finished = %d. ",
static ABC_NAMESPACE_IMPL_START int pTruths[13719]
DECLARATIONS ///.
word pTruths[ABC_ENUM_MAX]
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
#define ABC_SWAP(Type, a, b)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
int fCompl0[ABC_ENUM_MAX]
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Vec_IntEntry(Vec_Int_t *p, int i)
unsigned __int64 word
DECLARATIONS ///.
int fCompl1[ABC_ENUM_MAX]
#define ABC_NAMESPACE_IMPL_END
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define ABC_NAMESPACE_IMPL_START
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
static int Vec_IntSize(Vec_Int_t *p)
#define ABC_CONST(number)
PARAMETERS ///.
#define ABC_CALLOC(type, num)
static void Vec_IntFree(Vec_Int_t *p)