79 #define Ifd_ManForEachNodeWithSupp( p, nVars, pLeaf, i ) \
80 for ( i = Vec_IntEntry(p->vMarks, nVars); (i < Vec_IntEntry(p->vMarks, nVars+1)) && (pLeaf = Ifd_ManObj(p, i)); i++ )
106 (p->
pObjs + 1)->nSupp = 1;
107 (p->
pObjs + 1)->fWay = 1;
124 int i, This, Prev = 0;
127 printf(
"%d(%d:%d) ", i-1, This, This - Prev );
156 char Symb[2][4] = { {
'?',
'(',
'[',
'<'}, {
'?',
')',
']',
'>'} };
161 { printf(
"%c",
'a' + (*pCounter)++ );
return; }
164 printf(
"%c", Symb[0][pDsd->Type] );
167 if ( pDsd->pFans[2] != -1 )
170 printf(
"%c", Symb[1][pDsd->Type] );
176 { printf(
"0" );
return; }
178 { printf(
"1" );
return; }
184 for ( i = 0; i < p->
nObjs; i++ )
186 printf(
"%4d : ", i );
194 for ( i = 0; i < p->
nObjs; i++ )
201 printf(
"ABC_CONST(" );
205 printf(
"\" }, // %4d \n", i );
232 word Fun0, Fun1, Fun2 = 0;
235 return s_Truths6[(*pCounter)++];
240 if ( pDsd->pFans[2] != -1 )
245 if ( pDsd->pFans[2] != -1 )
248 if ( pDsd->Type == 1 )
250 if ( pDsd->Type == 2 )
252 if ( pDsd->Type == 3 )
253 return (Fun2 & Fun1) | (~Fun2 & Fun0);
273 for ( i = 0; i < p->
nObjs; i++ )
296 if ( Truth == 0 || ~Truth == 0 )
305 int i, k, c, RetValue, Literal, Cube, nCubes = 0;
307 for ( c = 0; c < 2; c ++ )
309 Truth = c ? ~Truth :
Truth;
310 RetValue =
Kit_TruthIsop( (
unsigned *)&Truth, nVars, vCover, 0 );
315 for ( k = 0; k < nVars; k++ )
317 Literal = 3 & (Cube >> (k << 1));
320 else if ( Literal == 2 )
322 else if ( Literal != 0 )
359 assert( iDsdC != -1 || iDsd0 >= iDsd1 );
370 assert( iDsdC != -1 || iDsd0 >= iDsd1 );
385 assert( iDsdC != -1 || iDsd0 >= iDsd1 );
398 assert( (
int)pObj->Type == Type );
404 printf(
"The number of nodes is more than %d\n", p->
nObjs );
414 else if ( Type == 2 )
416 else if ( Type == 3 )
420 pObj->pFans[0] = iDsd0;
421 pObj->pFans[1] = iDsd1;
422 pObj->pFans[2] = iDsdC;
441 int i, iLit0, iLit1, iThis, fCompl = 0;
444 if ( iDsd0 == 0 || iDsd1 == 0 )
446 if ( iDsd0 == 1 || iDsd1 == 1 )
447 return (iDsd0 == 1) ? iDsd1 : iDsd0;
449 else if ( Type == 2 )
460 else if ( Type == 3 )
470 assert( iDsd0 > 1 && iDsd1 > 1 && Type >= 1 && Type <= 3 );
515 if ( **p >=
'a' && **p <=
'f' )
517 assert( **p -
'a' >= 0 && **p -
'a' < 6 );
522 char * q = pStr + pMatches[ *p - pStr ];
524 assert( **p ==
'(' && *q ==
')' );
525 for ( (*p)++; *p < q; (*p)++ )
535 char * q = pStr + pMatches[ *p - pStr ];
537 assert( **p ==
'[' && *q ==
']' );
538 for ( (*p)++; *p < q; (*p)++ )
548 int Temp[3], * pTemp = Temp, Res;
549 char * q = pStr + pMatches[ *p - pStr ];
550 assert( **p ==
'<' && *q ==
'>' );
552 for ( (*p)++; *p < q; (*p)++ )
554 assert( pTemp == Temp + 3 );
557 Res =
Ifd_ManOper( pMan, Temp[2], Temp[1], Temp[0], 3 );
563 #define IFM_MAX_STR 100
564 #define IFM_MAX_VAR 16
570 for ( v = 0; p[v]; v++ )
574 if ( p[v] ==
'(' || p[v] ==
'[' || p[v] ==
'<' || p[v] ==
'{' )
575 pNested[nNested++] = v;
576 else if ( p[v] ==
')' || p[v] ==
']' || p[v] ==
'>' || p[v] ==
'}' )
577 pMatches[pNested[--nNested]] = v;
586 if ( *p ==
'0' && *(p+1) == 0 )
588 else if ( *p ==
'1' && *(p+1) == 0 )
637 int v, i, j, k, c0, c1, c2;
638 for ( v = 2; v <= nVars; v++ )
641 for ( i = 1; i < v; i++ )
642 for ( j = 1; j < v; j++ )
648 assert( (
int)pLeaf0->nSupp == i );
649 assert( (
int)pLeaf1->nSupp == j );
655 if ( !pLeaf0->fWay && !pLeaf1->fWay )
662 for ( i = 1; i < v-1; i++ )
663 for ( j = 1; j < v-1; j++ )
664 for ( k = 1; k < v-1; k++ )
665 if ( i + j + k == v )
671 assert( (
int)pLeaf0->nSupp == i );
672 assert( (
int)pLeaf1->nSupp == j );
673 assert( (
int)pLeaf2->nSupp == k );
676 if ( pLeaf2->fWay && c0 < c1 )
679 if ( !pLeaf0->fWay && !pLeaf1->fWay )
709 for ( i = 0; i <
size; i++ )
710 printf(
"%d", perm[i] );
716 int *array, *dir, tmp, tmp2, i,
max;
717 array = (
int*)
malloc(
sizeof(
int) * n);
718 dir = (
int*)
calloc(n,
sizeof(
int));
719 for (i = 0; i < n; i++)
728 i = !dir[
max] ? max - 1 : max + 1;
729 array[
max] = array[i];
734 for (i = 0; i < n; i++)
738 for (i = 0; i < n; i++)
739 if (((!dir[i] && i != 0 && array[i] > array[i-1]) || (dir[i] && i != n-1 && array[i] > array[i+1])) && (array[i] > array[max] || max == n))
751 int pPerm[6] = { 0, 1, 2, 3, 4, 5 };
756 ABC_SWAP(
int, pPerm[Entry], pPerm[Entry+1] );
786 return (t & PMasks[iVar][0]) | ((t & PMasks[iVar][1]) << (1 << iVar)) | ((t & PMasks[iVar][2]) >> (1 << iVar));
800 return ((t & ~Truth6[iVar]) << (1 << iVar)) | ((t & Truth6[iVar]) >> (1 << iVar));
805 int nSwaps = (1 << nVars);
807 word tCur, tTemp1, tTemp2;
809 for ( i = 0; i < 2; i++ )
813 for ( p = 0; p < nPerms; p++ )
816 for ( c = 0; c < nSwaps; c++ )
838 int nSwaps = (1 << nVars);
840 word tCur = t, tTemp1, tTemp2;
844 for ( p = 0; p < nPerms; p++ )
849 for ( c = 0; c < nSwaps; c++ )
853 Config ^= (1 << pComp[c]);
884 int v,
Pos, Neg, Xor;
885 for ( v = 0; v < 6; v++ )
891 pCounts[v] = (Pos << 20) | (Neg << 10) | Xor;
893 pCounts[v] = (Neg << 20) | (Pos << 10) | Xor;
901 int i, v, pCounts[6];
907 printf(
"%5d : ", i );
908 for ( v = 0; v < 6; v++ )
909 printf(
"%2d %2d %2d ", (pCounts[v] >> 20) & 0xFF, (pCounts[v] >> 10) & 0xFF, (pCounts[v] >> 0) & 0xFF );
940 int * pComp, *
pPerm;
942 int i, k, Uniq, Runner,
Counter = 0;
943 assert( nVars >= 3 && nVars <= 6 );
962 if ( Runner == Uniq )
965 assert( (Variant & 1) == 0 );
981 printf(
"Total = %d.\n", Counter );
984 sprintf( pFileName,
"dsdfuncs%d.dat", nVars );
985 pFile = fopen( pFileName,
"wb" );
989 printf(
"File \"%s\" with %d 6-input functions has been written out.\n", pFileName,
Vec_IntSize(vConfgRes) );
999 char * pFileName =
"dsdfuncs6.dat";
1005 pFile = fopen( pFileName,
"rb" );
1007 RetValue = fread(
Vec_IntArray(vConfgRes),
sizeof(
int), size, pFile );
1008 vTruthRes->nSize =
size;
1009 vConfgRes->nSize =
size;
void Ifd_ManDsdPermPrint(int *perm, int size)
static int * Vec_IntArray(Vec_Int_t *p)
static int Ifd_ObjIsAnd(Ifd_Obj_t *p)
int Ifd_ManFindDsd(Ifd_Man_t *pMan, char *p)
void Ifd_ManTruthAll(Ifd_Man_t *p)
static int Ifd_ObjIsXor(Ifd_Obj_t *p)
Vec_Wrd_t * Ifd_ManDsdTruths(int nVars)
static int Ifd_LitNumAnds(Ifd_Man_t *p, int iLit)
static int Abc_PrimeCudd(unsigned int p)
void Ifd_ObjPrint_rec(Ifd_Man_t *p, int iLit, int *pCounter, int DiffType)
void Ifd_ManOperSuper_rec(Ifd_Man_t *p, int iLit, int Type, Vec_Int_t *vObjs)
typedefABC_NAMESPACE_IMPL_START struct Ifd_Obj_t_ Ifd_Obj_t
DECLARATIONS ///.
#define Ifd_ManForEachNodeWithSupp(p, nVars, pLeaf, i)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static void Vec_WrdPush(Vec_Wrd_t *p, word Entry)
static int Ifd_LitSuppSize(Ifd_Man_t *p, int iLit)
static int Ifd_ObjIsMux(Ifd_Obj_t *p)
static int Abc_Var2Lit(int Var, int fCompl)
static void Vec_StrClear(Vec_Str_t *p)
void Ifd_ManHashInsert(Ifd_Man_t *p, int iDsd0, int iDsd1, int iDsdC, int Type, int Res)
void Ifd_ManPrint(Ifd_Man_t *p)
void Ifd_ObjPrint(Ifd_Man_t *p, int iLit)
word Ifd_ObjTruth(Ifd_Man_t *p, int iLit)
static Vec_Str_t * Vec_StrAlloc(int nCap)
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
static int Abc_TtCountOnes(word x)
static abctime Abc_Clock()
static Ifd_Obj_t * Ifd_ManObjFromLit(Ifd_Man_t *p, int iLit)
static word Abc_Tt6Cofactor0(word t, int iVar)
static void Vec_StrPush(Vec_Str_t *p, char Entry)
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 Vec_IntSort(Vec_Int_t *p, int fReverse)
static int Abc_LitNotCond(int Lit, int c)
static Vec_Int_t * Hsh_WrdManHashArray(Vec_Wrd_t *vDataW, int nSize)
#define ABC_SWAP(Type, a, b)
void Ifd_ManStop(Ifd_Man_t *p)
static Hsh_IntMan_t * Hsh_WrdManHashArrayStart(Vec_Wrd_t *vDataW, int nSize)
Vec_Wrd_t * Extra_Truth6AllConfigs2(word t, int *pComp, int *pPerm, int nVars)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
int Ifd_ManOper(Ifd_Man_t *p, int iDsd0, int iDsd1, int iDsdC, int Type)
static int Ifd_ObjId(Ifd_Man_t *p, Ifd_Obj_t *pObj)
static void Vec_IntSelectSort(int *pArray, int nSize)
static int Abc_MinInt(int a, int b)
static int Abc_LitIsCompl(int Lit)
static word Abc_Tt6Cofactor1(word t, int iVar)
int Ifd_ManHashLookup(Ifd_Man_t *p, int iDsd0, int iDsd1, int iDsdC, int Type)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int * Hsh_IntManLookup(Hsh_IntMan_t *p, unsigned *pData)
void Ifd_ManPrint2(Ifd_Man_t *p)
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
int Mpm_ComputeCnfSizeOne(word Truth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vCnf)
static void Vec_StrFree(Vec_Str_t *p)
static word Extra_Truth6SwapAdjacent(word t, int iVar)
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
int Ifd_ManHashFindOrAdd(Ifd_Man_t *p, int iDsd0, int iDsd1, int iDsdC, int Type)
static int Vec_IntEntry(Vec_Int_t *p, int i)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Vec_WrdFree(Vec_Wrd_t *p)
void Mpm_ComputeCnfSizeAll(Ifd_Man_t *p)
Ifd_Man_t * Ifd_ManStart()
FUNCTION DEFINITIONS ///.
static int Vec_IntUniqify(Vec_Int_t *p)
static int Ifd_ObjIsVar(Ifd_Obj_t *p)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
int Ifd_ManFindDsd_rec(Ifd_Man_t *pMan, char *pStr, char **p, int *pMatches)
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
static void Vec_IntFreeP(Vec_Int_t **p)
static void Hsh_IntManStop(Hsh_IntMan_t *p)
static word Extra_Truth6ChangePhase(word t, int iVar)
static Ifd_Obj_t * Ifd_ManObj(Ifd_Man_t *p, int i)
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
static int Hsh_IntManAdd(Hsh_IntMan_t *p, int iData)
static Vec_Wrd_t * Vec_WrdStart(int nSize)
static int Abc_LitNot(int Lit)
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
static int Vec_IntSize(Vec_Int_t *p)
void Ifd_ComputeSignature(word uTruth, int pCounts[6])
static word * Vec_WrdArray(Vec_Wrd_t *p)
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
#define ABC_CONST(number)
PARAMETERS ///.
Vec_Wrd_t * Extra_Truth6AllConfigs(word t, int *pComp, int *pPerm, int nVars)
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
int * Ifd_ManComputeMatches(char *p)
#define ABC_CALLOC(type, num)
static int Abc_Lit2Var(int Lit)
static int Abc_LitRegular(int Lit)
Vec_Int_t * Ifd_ManDsdPermJT(int n)
static void Vec_IntFree(Vec_Int_t *p)
static Hsh_IntMan_t * Hsh_IntManStart(Vec_Int_t *vData, int nSize, int nEntries)
FUNCTION DEFINITIONS ///.
word Ifd_ObjTruth_rec(Ifd_Man_t *p, int iLit, int *pCounter)
static void Vec_IntClear(Vec_Int_t *p)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.