Commit 39fe23f0 by Alan Mishchenko

Integrated new fast semi-canonical form for Boolean functions up to 16 inputs.

parent 7a6cf9f4
...@@ -1619,8 +1619,8 @@ s_pMan->timeBuild += clock() - timeBuild; ...@@ -1619,8 +1619,8 @@ s_pMan->timeBuild += clock() - timeBuild;
timeInsert = clock(); timeInsert = clock();
Abc_NtkRecInsertToLookUpTable2(s_pMan, ppSpot, pPO, nLeaves, pTruth, s_pMan->fTrim); Abc_NtkRecInsertToLookUpTable2(s_pMan, ppSpot, pPO, nLeaves, pTruth, s_pMan->fTrim);
s_pMan->timeInsert += clock() - timeInsert; s_pMan->timeInsert += clock() - timeInsert;
// if (pIfMan->pPars->fDelayOpt) // if (pIfMan->pPars->fDelayOpt)
// Abc_NtkRecAddSOPB(pIfMan, pCut, pTruth, pCanonPerm, uCanonPhase ); // Abc_NtkRecAddSOPB(pIfMan, pCut, pTruth, pCanonPerm, uCanonPhase );
return 1; return 1;
} }
......
...@@ -24,7 +24,7 @@ static word SFmask[5][4] = { ...@@ -24,7 +24,7 @@ static word SFmask[5][4] = {
{0xC0C0C0C0C0C0C0C0,0x3030303030303030,0x0C0C0C0C0C0C0C0C,0x0303030303030303}, {0xC0C0C0C0C0C0C0C0,0x3030303030303030,0x0C0C0C0C0C0C0C0C,0x0303030303030303},
{0xF000F000F000F000,0x0F000F000F000F00,0x00F000F000F000F0,0x000F000F000F000F}, {0xF000F000F000F000,0x0F000F000F000F00,0x00F000F000F000F0,0x000F000F000F000F},
{0xFF000000FF000000,0x00FF000000FF0000,0x0000FF000000FF00,0x000000FF000000FF}, {0xFF000000FF000000,0x00FF000000FF0000,0x0000FF000000FF00,0x000000FF000000FF},
{0xFFFF000000000000,0x0000FFFF00000000,0x00000000FFFF0000,0x000000000000FFFF} {0xFFFF000000000000,0x0000FFFF00000000,0x00000000FFFF0000,0x000000000000FFFF}
}; };
...@@ -44,7 +44,7 @@ inline void arrangeQuoters_superFast_lessThen5(word* pInOut, int start, int iQ, ...@@ -44,7 +44,7 @@ inline void arrangeQuoters_superFast_lessThen5(word* pInOut, int start, int iQ,
int i; int i;
int blockSize = 1<<iVar; int blockSize = 1<<iVar;
for(i=start;i>=0;i--) for(i=start;i>=0;i--)
{ {
pInOut[i] = (pInOut[i] & SFmask[iVar][iQ])<<(iQ*blockSize) | pInOut[i] = (pInOut[i] & SFmask[iVar][iQ])<<(iQ*blockSize) |
(((pInOut[i] & SFmask[iVar][jQ])<<(jQ*blockSize))>>blockSize) | (((pInOut[i] & SFmask[iVar][jQ])<<(jQ*blockSize))>>blockSize) |
(((pInOut[i] & SFmask[iVar][kQ])<<(kQ*blockSize))>>2*blockSize) | (((pInOut[i] & SFmask[iVar][kQ])<<(kQ*blockSize))>>2*blockSize) |
...@@ -174,15 +174,15 @@ inline int minTemp3_fast(word* pInOut, int iVar, int start, int finish, int iQ, ...@@ -174,15 +174,15 @@ inline int minTemp3_fast(word* pInOut, int iVar, int start, int finish, int iQ,
inline void minimalSwapAndFlipIVar_superFast_lessThen5(word* pInOut, int iVar, int nWords, char * pCanonPerm, unsigned* pCanonPhase) inline void minimalSwapAndFlipIVar_superFast_lessThen5(word* pInOut, int iVar, int nWords, char * pCanonPerm, unsigned* pCanonPhase)
{ {
int min1, min2, DifStart0, DifStart1, DifStartMin; int min1, min2, DifStart0, DifStart1, DifStartMin;
int M[2]; int M[2];
int blockSize = 1<<iVar; int blockSize = 1<<iVar;
int shiftSize = blockSize*4; // int shiftSize = blockSize*4;
M[0] = minTemp0_fast(pInOut, iVar, nWords, &DifStart0); // 0, 3 M[0] = minTemp0_fast(pInOut, iVar, nWords, &DifStart0); // 0, 3
M[1] = minTemp1_fast(pInOut, iVar, nWords, &DifStart1); // 1, 2 M[1] = minTemp1_fast(pInOut, iVar, nWords, &DifStart1); // 1, 2
min1 = minTemp2_fast(pInOut, iVar, M[0], M[1], nWords, &DifStartMin); min1 = minTemp2_fast(pInOut, iVar, M[0], M[1], nWords, &DifStartMin);
if(DifStart0 != DifStart1) if(DifStart0 != DifStart1)
{ {
if( DifStartMin>=DifStart1 && DifStartMin>=DifStart0 ) if( DifStartMin>=DifStart1 && DifStartMin>=DifStart0 )
arrangeQuoters_superFast_lessThen5(pInOut, DifStartMin/100, M[min1], M[(min1+1)%2], 3 - M[(min1+1)%2], 3 - M[min1], iVar, nWords, pCanonPerm, pCanonPhase); arrangeQuoters_superFast_lessThen5(pInOut, DifStartMin/100, M[min1], M[(min1+1)%2], 3 - M[(min1+1)%2], 3 - M[min1], iVar, nWords, pCanonPerm, pCanonPhase);
else if( DifStart0 > DifStart1) else if( DifStart0 > DifStart1)
...@@ -213,12 +213,12 @@ inline void arrangeQuoters_superFast_iVar5(unsigned* pInOut, unsigned* temp, int ...@@ -213,12 +213,12 @@ inline void arrangeQuoters_superFast_iVar5(unsigned* pInOut, unsigned* temp, int
int i,blockSize,shiftSize; int i,blockSize,shiftSize;
unsigned* tempPtr = temp+start; unsigned* tempPtr = temp+start;
if(iQ == 0 && jQ == 1) if(iQ == 0 && jQ == 1)
return; return;
blockSize = sizeof(unsigned); blockSize = sizeof(unsigned);
shiftSize = 4; shiftSize = 4;
for(i=start-1;i>0;i-=shiftSize) for(i=start-1;i>0;i-=shiftSize)
{ {
tempPtr -= 1; tempPtr -= 1;
memcpy(tempPtr, pInOut+i-iQ, blockSize); memcpy(tempPtr, pInOut+i-iQ, blockSize);
tempPtr -= 1; tempPtr -= 1;
memcpy(tempPtr, pInOut+i-jQ, blockSize); memcpy(tempPtr, pInOut+i-jQ, blockSize);
...@@ -227,7 +227,7 @@ inline void arrangeQuoters_superFast_iVar5(unsigned* pInOut, unsigned* temp, int ...@@ -227,7 +227,7 @@ inline void arrangeQuoters_superFast_iVar5(unsigned* pInOut, unsigned* temp, int
tempPtr -= 1; tempPtr -= 1;
memcpy(tempPtr, pInOut+i-lQ, blockSize); memcpy(tempPtr, pInOut+i-lQ, blockSize);
} }
memcpy(pInOut, temp, start*sizeof(unsigned)); memcpy(pInOut, temp, start*sizeof(unsigned));
updataInfo(iQ, jQ, 5, pCanonPerm, pCanonPhase); updataInfo(iQ, jQ, 5, pCanonPerm, pCanonPhase);
} }
...@@ -237,7 +237,7 @@ inline void arrangeQuoters_superFast_iVar5(unsigned* pInOut, unsigned* temp, int ...@@ -237,7 +237,7 @@ inline void arrangeQuoters_superFast_iVar5(unsigned* pInOut, unsigned* temp, int
inline int minTemp0_fast_iVar5(unsigned* pInOut, int nWords, int* pDifStart) inline int minTemp0_fast_iVar5(unsigned* pInOut, int nWords, int* pDifStart)
{ {
int i, temp; int i, temp;
for(i=(nWords)*2 - 1; i>=0; i-=4) for(i=(nWords)*2 - 1; i>=0; i-=4)
{ {
temp = CompareWords(pInOut[i],pInOut[i-3]); temp = CompareWords(pInOut[i],pInOut[i-3]);
if(temp == 0) if(temp == 0)
...@@ -262,7 +262,7 @@ inline int minTemp0_fast_iVar5(unsigned* pInOut, int nWords, int* pDifStart) ...@@ -262,7 +262,7 @@ inline int minTemp0_fast_iVar5(unsigned* pInOut, int nWords, int* pDifStart)
inline int minTemp1_fast_iVar5(unsigned* pInOut, int nWords, int* pDifStart) inline int minTemp1_fast_iVar5(unsigned* pInOut, int nWords, int* pDifStart)
{ {
int i, temp; int i, temp;
for(i=(nWords)*2 - 2; i>=0; i-=4) for(i=(nWords)*2 - 2; i>=0; i-=4)
{ {
temp = CompareWords(pInOut[i],pInOut[i-1]); temp = CompareWords(pInOut[i],pInOut[i-1]);
if(temp == 0) if(temp == 0)
...@@ -287,7 +287,7 @@ inline int minTemp1_fast_iVar5(unsigned* pInOut, int nWords, int* pDifStart) ...@@ -287,7 +287,7 @@ inline int minTemp1_fast_iVar5(unsigned* pInOut, int nWords, int* pDifStart)
inline int minTemp2_fast_iVar5(unsigned* pInOut, int iQ, int jQ, int nWords, int* pDifStart) inline int minTemp2_fast_iVar5(unsigned* pInOut, int iQ, int jQ, int nWords, int* pDifStart)
{ {
int i, temp; int i, temp;
for(i=(nWords)*2 - 1; i>=0; i-=4) for(i=(nWords)*2 - 1; i>=0; i-=4)
{ {
temp = CompareWords(pInOut[i-iQ],pInOut[i-jQ]); temp = CompareWords(pInOut[i-iQ],pInOut[i-jQ]);
if(temp == 0) if(temp == 0)
...@@ -311,7 +311,7 @@ inline int minTemp2_fast_iVar5(unsigned* pInOut, int iQ, int jQ, int nWords, int ...@@ -311,7 +311,7 @@ inline int minTemp2_fast_iVar5(unsigned* pInOut, int iQ, int jQ, int nWords, int
inline int minTemp3_fast_iVar5(unsigned* pInOut, int start, int finish, int iQ, int jQ, int* pDifStart) inline int minTemp3_fast_iVar5(unsigned* pInOut, int start, int finish, int iQ, int jQ, int* pDifStart)
{ {
int i, temp; int i, temp;
for(i=start-1; i>=finish; i-=4) for(i=start-1; i>=finish; i-=4)
{ {
temp = CompareWords(pInOut[i-iQ],pInOut[i-jQ]); temp = CompareWords(pInOut[i-iQ],pInOut[i-jQ]);
if(temp == 0) if(temp == 0)
...@@ -342,7 +342,7 @@ inline void minimalSwapAndFlipIVar_superFast_iVar5(unsigned* pInOut, int nWords, ...@@ -342,7 +342,7 @@ inline void minimalSwapAndFlipIVar_superFast_iVar5(unsigned* pInOut, int nWords,
M[1] = minTemp1_fast_iVar5(pInOut, nWords, &DifStart1); // 1, 2 M[1] = minTemp1_fast_iVar5(pInOut, nWords, &DifStart1); // 1, 2
min1 = minTemp2_fast_iVar5(pInOut, M[0], M[1], nWords, &DifStartMin); min1 = minTemp2_fast_iVar5(pInOut, M[0], M[1], nWords, &DifStartMin);
if(DifStart0 != DifStart1) if(DifStart0 != DifStart1)
{ {
if( DifStartMin>=DifStart1 && DifStartMin>=DifStart0 ) if( DifStartMin>=DifStart1 && DifStartMin>=DifStart0 )
arrangeQuoters_superFast_iVar5(pInOut, temp, DifStartMin, M[min1], M[(min1+1)%2], 3 - M[(min1+1)%2], 3 - M[min1], pCanonPerm, pCanonPhase); arrangeQuoters_superFast_iVar5(pInOut, temp, DifStartMin, M[min1], M[(min1+1)%2], 3 - M[(min1+1)%2], 3 - M[min1], pCanonPerm, pCanonPhase);
else if( DifStart0 > DifStart1) else if( DifStart0 > DifStart1)
...@@ -379,17 +379,17 @@ inline void arrangeQuoters_superFast_moreThen5(word* pInOut, word* temp, int sta ...@@ -379,17 +379,17 @@ inline void arrangeQuoters_superFast_moreThen5(word* pInOut, word* temp, int sta
blockSize = wordBlock*sizeof(word); blockSize = wordBlock*sizeof(word);
shiftSize = wordBlock*4; shiftSize = wordBlock*4;
for(i=start-wordBlock;i>0;i-=shiftSize) for(i=start-wordBlock;i>0;i-=shiftSize)
{ {
tempPtr -= wordBlock; tempPtr -= wordBlock;
memcpy(tempPtr, pInOut+i-iQ*wordBlock, blockSize); memcpy(tempPtr, pInOut+i-iQ*wordBlock, blockSize);
tempPtr -= wordBlock; tempPtr -= wordBlock;
memcpy(tempPtr, pInOut+i-jQ*wordBlock, blockSize); memcpy(tempPtr, pInOut+i-jQ*wordBlock, blockSize);
tempPtr -= wordBlock; tempPtr -= wordBlock;
memcpy(tempPtr, pInOut+i-kQ*wordBlock, blockSize); memcpy(tempPtr, pInOut+i-kQ*wordBlock, blockSize);
tempPtr -= wordBlock; tempPtr -= wordBlock;
memcpy(tempPtr, pInOut+i-lQ*wordBlock, blockSize); memcpy(tempPtr, pInOut+i-lQ*wordBlock, blockSize);
} }
memcpy(pInOut, temp, start*sizeof(word)); memcpy(pInOut, temp, start*sizeof(word));
updataInfo(iQ, jQ, iVar, pCanonPerm, pCanonPhase); updataInfo(iQ, jQ, iVar, pCanonPerm, pCanonPhase);
} }
...@@ -513,13 +513,13 @@ inline void minimalSwapAndFlipIVar_superFast_moreThen5(word* pInOut, int iVar, i ...@@ -513,13 +513,13 @@ inline void minimalSwapAndFlipIVar_superFast_moreThen5(word* pInOut, int iVar, i
int M[2]; int M[2];
word temp[1024]; word temp[1024];
int blockSize = 1<<(iVar-6); int blockSize = 1<<(iVar-6);
int shiftSize = blockSize*4; // int shiftSize = blockSize*4;
M[0] = minTemp0_fast_moreThen5(pInOut, iVar, nWords, &DifStart0); // 0, 3 M[0] = minTemp0_fast_moreThen5(pInOut, iVar, nWords, &DifStart0); // 0, 3
M[1] = minTemp1_fast_moreThen5(pInOut, iVar, nWords, &DifStart1); // 1, 2 M[1] = minTemp1_fast_moreThen5(pInOut, iVar, nWords, &DifStart1); // 1, 2
min1 = minTemp2_fast_moreThen5(pInOut, iVar, M[0], M[1], nWords, &DifStartMin); min1 = minTemp2_fast_moreThen5(pInOut, iVar, M[0], M[1], nWords, &DifStartMin);
if(DifStart0 != DifStart1) if(DifStart0 != DifStart1)
{ {
if( DifStartMin>=DifStart1 && DifStartMin>=DifStart0 ) if( DifStartMin>=DifStart1 && DifStartMin>=DifStart0 )
arrangeQuoters_superFast_moreThen5(pInOut, temp, DifStartMin, M[min1], M[(min1+1)%2], 3 - M[(min1+1)%2], 3 - M[min1], iVar, pCanonPerm, pCanonPhase); arrangeQuoters_superFast_moreThen5(pInOut, temp, DifStartMin, M[min1], M[(min1+1)%2], 3 - M[(min1+1)%2], 3 - M[min1], iVar, pCanonPerm, pCanonPhase);
else if( DifStart0 > DifStart1) else if( DifStart0 > DifStart1)
...@@ -549,7 +549,7 @@ inline void minimalInitialFlip_fast_16Vars(word* pInOut, int nVars, unsigned* p ...@@ -549,7 +549,7 @@ inline void minimalInitialFlip_fast_16Vars(word* pInOut, int nVars, unsigned* p
if( (pInOut[Kit_TruthWordNum_64bit( nVars ) -1]>>63) & oneWord ) if( (pInOut[Kit_TruthWordNum_64bit( nVars ) -1]>>63) & oneWord )
{ {
Kit_TruthNot_64bit( pInOut, nVars ); Kit_TruthNot_64bit( pInOut, nVars );
(* pCanonPhase) ^=(1<<nVars); (* pCanonPhase) ^=(1<<nVars);
} }
} }
...@@ -559,7 +559,7 @@ inline void minimalInitialFlip_fast_16Vars(word* pInOut, int nVars, unsigned* p ...@@ -559,7 +559,7 @@ inline void minimalInitialFlip_fast_16Vars(word* pInOut, int nVars, unsigned* p
inline int minimalSwapAndFlipIVar_superFast_all(word* pInOut, int nVars, int nWords, int * pStore, char * pCanonPerm, unsigned* pCanonPhase) inline int minimalSwapAndFlipIVar_superFast_all(word* pInOut, int nVars, int nWords, int * pStore, char * pCanonPerm, unsigned* pCanonPhase)
{ {
int i; int i;
word pDuplicate[1024]; word pDuplicate[1024];
int bitInfoTemp = pStore[0]; int bitInfoTemp = pStore[0];
memcpy(pDuplicate,pInOut,nWords*sizeof(word)); memcpy(pDuplicate,pInOut,nWords*sizeof(word));
for(i=0;i<5;i++) for(i=0;i<5;i++)
...@@ -602,21 +602,21 @@ inline void luckyCanonicizerS_F_first_16Vars(word* pInOut, int nVars, int nWord ...@@ -602,21 +602,21 @@ inline void luckyCanonicizerS_F_first_16Vars(word* pInOut, int nVars, int nWord
inline void luckyCanonicizer_final_fast_16Vars(word* pInOut, int nVars, int nWords, int * pStore, char * pCanonPerm, unsigned* pCanonPhase) inline void luckyCanonicizer_final_fast_16Vars(word* pInOut, int nVars, int nWords, int * pStore, char * pCanonPerm, unsigned* pCanonPhase)
{ {
// word pDuplicateLocal[1024]={0}; // word pDuplicateLocal[1024]={0};
// memcpy(pDuplicateLocal,pInOut,nWords*sizeof(word)); // memcpy(pDuplicateLocal,pInOut,nWords*sizeof(word));
assert( nVars <= 16 ); assert( nVars <= 16 );
assert( nVars > 6 ); assert( nVars > 6 );
(* pCanonPhase) = Kit_TruthSemiCanonicize_Yasha1( pInOut, nVars, pCanonPerm, pStore ); (* pCanonPhase) = Kit_TruthSemiCanonicize_Yasha1( pInOut, nVars, pCanonPerm, pStore );
luckyCanonicizerS_F_first_16Vars(pInOut, nVars, nWords, pStore, pCanonPerm, pCanonPhase ); luckyCanonicizerS_F_first_16Vars(pInOut, nVars, nWords, pStore, pCanonPerm, pCanonPhase );
// memcpy(pDuplicate,pInOut,nWords*sizeof(word)); // memcpy(pDuplicate,pInOut,nWords*sizeof(word));
// assert(!luckyCheck(pDuplicate, pDuplicateLocal, nVars, pCanonPerm, * pCanonPhase)); // assert(!luckyCheck(pDuplicate, pDuplicateLocal, nVars, pCanonPerm, * pCanonPhase));
} }
// top-level procedure calling two special cases (nVars <= 6 and nVars <= 16) // top-level procedure calling two special cases (nVars <= 6 and nVars <= 16)
int luckyCanonicizer_final_fast( word * pInOut, int nVars, char * pCanonPerm ) int luckyCanonicizer_final_fast( word * pInOut, int nVars, char * pCanonPerm )
{ {
int pStore[16]; int pStore[16];
int uCanonPhase = 0; unsigned uCanonPhase = 0;
int nWords = (nVars <= 6) ? 1 : (1 << (nVars - 6)); int nWords = (nVars <= 6) ? 1 : (1 << (nVars - 6));
if ( nVars <= 6 ) if ( nVars <= 6 )
pInOut[0] = luckyCanonicizer_final_fast_6Vars( pInOut[0], pStore, pCanonPerm, &uCanonPhase ); pInOut[0] = luckyCanonicizer_final_fast_6Vars( pInOut[0], pStore, pCanonPerm, &uCanonPhase );
......
...@@ -89,7 +89,7 @@ inline word Abc_allFlip(word x, unsigned* pCanonPhase) ...@@ -89,7 +89,7 @@ inline word Abc_allFlip(word x, unsigned* pCanonPhase)
} }
inline unsigned adjustInfoAfterSwap(char* pCanonPerm, unsigned uCanonPhase, int iVar, unsigned info) inline unsigned adjustInfoAfterSwap(char* pCanonPerm, unsigned uCanonPhase, int iVar, unsigned info)
{ {
if(info<4) if(info<4)
return (uCanonPhase ^= (info << iVar)); return (uCanonPhase ^= (info << iVar));
else else
...@@ -104,7 +104,7 @@ inline unsigned adjustInfoAfterSwap(char* pCanonPerm, unsigned uCanonPhase, int ...@@ -104,7 +104,7 @@ inline unsigned adjustInfoAfterSwap(char* pCanonPerm, unsigned uCanonPhase, int
uCanonPhase ^= (1 << iVar); uCanonPhase ^= (1 << iVar);
uCanonPhase ^= (1 << (iVar+1)); uCanonPhase ^= (1 << (iVar+1));
} }
return uCanonPhase; return uCanonPhase;
} }
...@@ -207,8 +207,8 @@ inline word Extra_Truth6MinimumRoundMany( word t, int* pStore, char* pCanonPerm, ...@@ -207,8 +207,8 @@ inline word Extra_Truth6MinimumRoundMany( word t, int* pStore, char* pCanonPerm,
tMin0 = tMin; tMin0 = tMin;
for ( i = 0; i < 5; i++ ) for ( i = 0; i < 5; i++ )
{ {
if(bitInfoTemp == pStore[i+1]) if(bitInfoTemp == pStore[i+1])
tMin = Extra_Truth6MinimumRoundOne( tMin, i, pCanonPerm, pCanonPhase ); tMin = Extra_Truth6MinimumRoundOne( tMin, i, pCanonPerm, pCanonPhase );
else else
bitInfoTemp = pStore[i+1]; bitInfoTemp = pStore[i+1];
} }
...@@ -220,9 +220,9 @@ inline word Extra_Truth6MinimumRoundMany( word t, int* pStore, char* pCanonPerm, ...@@ -220,9 +220,9 @@ inline word Extra_Truth6MinimumRoundMany( word t, int* pStore, char* pCanonPerm,
inline word luckyCanonicizer_final_fast_6Vars(word InOut, int* pStore, char* pCanonPerm, unsigned* pCanonPhase ) inline word luckyCanonicizer_final_fast_6Vars(word InOut, int* pStore, char* pCanonPerm, unsigned* pCanonPhase )
{ {
// word temp, duplicat = InOut; // word temp, duplicat = InOut;
(* pCanonPhase) = Kit_TruthSemiCanonicize_Yasha1( &InOut, 6, pCanonPerm, pStore); (* pCanonPhase) = Kit_TruthSemiCanonicize_Yasha1( &InOut, 6, pCanonPerm, pStore);
// InOut = Extra_Truth6MinimumRoundMany(InOut, pStore, pCanonPhase, pCanonPerm ); // InOut = Extra_Truth6MinimumRoundMany(InOut, pStore, pCanonPhase, pCanonPerm );
// temp = InOut; // temp = InOut;
// assert(!luckyCheck(&temp, &duplicat, 6, pCanonPerm, * pCanonPhase)); // assert(!luckyCheck(&temp, &duplicat, 6, pCanonPerm, * pCanonPhase));
// return(InOut); // return(InOut);
......
...@@ -78,7 +78,7 @@ typedef struct ...@@ -78,7 +78,7 @@ typedef struct
int totalSwaps; int totalSwaps;
int* flipArray; int* flipArray;
int flipCtr; int flipCtr;
int totalFlips; int totalFlips;
}permInfo; }permInfo;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
static word mask0[6] = { 0x5555555555555555,0x3333333333333333, 0x0F0F0F0F0F0F0F0F,0x00FF00FF00FF00FF,0x0000FFFF0000FFFF, 0x00000000FFFFFFFF}; static word mask0[6] = { 0x5555555555555555,0x3333333333333333, 0x0F0F0F0F0F0F0F0F,0x00FF00FF00FF00FF,0x0000FFFF0000FFFF, 0x00000000FFFFFFFF};
/* /*
static word mask1[6] = { 0xAAAAAAAAAAAAAAAA,0xCCCCCCCCCCCCCCCC, 0xF0F0F0F0F0F0F0F0,0xFF00FF00FF00FF00,0xFFFF0000FFFF0000, 0xFFFFFFFF00000000 }; static word mask1[6] = { 0xAAAAAAAAAAAAAAAA,0xCCCCCCCCCCCCCCCC, 0xF0F0F0F0F0F0F0F0,0xFF00FF00FF00FF00,0xFFFF0000FFFF0000, 0xFFFFFFFF00000000 };
static word mask[6][2] = { static word mask[6][2] = {
...@@ -55,7 +55,7 @@ inline int Kit_TruthCountOnes_64bit( word* pIn, int nVars ) ...@@ -55,7 +55,7 @@ inline int Kit_TruthCountOnes_64bit( word* pIn, int nVars )
} }
inline void Kit_TruthCountOnesInCofs_64bit( word * pTruth, int nVars, int * pStore ) inline void Kit_TruthCountOnesInCofs_64bit( word * pTruth, int nVars, int * pStore )
{ {
int nWords = Kit_TruthWordNum_64bit( nVars ); int nWords = Kit_TruthWordNum_64bit( nVars );
int i, k, Counter; int i, k, Counter;
memset( pStore, 0, sizeof(int) * nVars ); memset( pStore, 0, sizeof(int) * nVars );
...@@ -72,7 +72,7 @@ inline void Kit_TruthCountOnesInCofs_64bit( word * pTruth, int nVars, int * pSto ...@@ -72,7 +72,7 @@ inline void Kit_TruthCountOnesInCofs_64bit( word * pTruth, int nVars, int * pSto
if ( nVars > 4 ) if ( nVars > 4 )
pStore[4] = Kit_WordCountOnes_64bit( pTruth[0] & 0x0000FFFF0000FFFF ); pStore[4] = Kit_WordCountOnes_64bit( pTruth[0] & 0x0000FFFF0000FFFF );
if ( nVars > 5 ) if ( nVars > 5 )
pStore[5] = Kit_WordCountOnes_64bit( pTruth[0] & 0x00000000FFFFFFFF ); pStore[5] = Kit_WordCountOnes_64bit( pTruth[0] & 0x00000000FFFFFFFF );
return; return;
} }
// nVars > 6 // nVars > 6
...@@ -114,13 +114,13 @@ inline void Kit_TruthChangePhase_64bit( word * pInOut, int nVars, int iVar ) ...@@ -114,13 +114,13 @@ inline void Kit_TruthChangePhase_64bit( word * pInOut, int nVars, int iVar )
Step = (1 << (iVar - 6)); Step = (1 << (iVar - 6));
SizeOfBlock = sizeof(word)*Step; SizeOfBlock = sizeof(word)*Step;
for ( i = 0; i < nWords; i += 2*Step ) for ( i = 0; i < nWords; i += 2*Step )
{ {
memcpy(Temp,pInOut,SizeOfBlock); memcpy(Temp,pInOut,SizeOfBlock);
memcpy(pInOut,pInOut+Step,SizeOfBlock); memcpy(pInOut,pInOut+Step,SizeOfBlock);
memcpy(pInOut+Step,Temp,SizeOfBlock); memcpy(pInOut+Step,Temp,SizeOfBlock);
// Temp = pInOut[i]; // Temp = pInOut[i];
// pInOut[i] = pInOut[Step+i]; // pInOut[i] = pInOut[Step+i];
// pInOut[Step+i] = Temp; // pInOut[Step+i] = Temp;
pInOut += 2*Step; pInOut += 2*Step;
} }
} }
...@@ -164,7 +164,7 @@ inline void Kit_TruthSwapAdjacentVars_64bit( word * pInOut, int nVars, int iVar ...@@ -164,7 +164,7 @@ inline void Kit_TruthSwapAdjacentVars_64bit( word * pInOut, int nVars, int iVar
SizeOfBlock = sizeof(word)*Step; SizeOfBlock = sizeof(word)*Step;
pInOut += 2*Step; pInOut += 2*Step;
for(i=2*Step; i<nWords; i+=4*Step) for(i=2*Step; i<nWords; i+=4*Step)
{ {
memcpy(temp,pInOut-Step,SizeOfBlock); memcpy(temp,pInOut-Step,SizeOfBlock);
memcpy(pInOut-Step,pInOut,SizeOfBlock); memcpy(pInOut-Step,pInOut,SizeOfBlock);
memcpy(pInOut,temp,SizeOfBlock); memcpy(pInOut,temp,SizeOfBlock);
...@@ -236,7 +236,7 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha( word* pInOut, int nVars, char * ...@@ -236,7 +236,7 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha( word* pInOut, int nVars, char *
uCanonPhase ^= (1 << (i+1)); uCanonPhase ^= (1 << (i+1));
} }
Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i ); Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i );
} }
} while ( fChange ); } while ( fChange );
return uCanonPhase; return uCanonPhase;
...@@ -250,8 +250,8 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char * ...@@ -250,8 +250,8 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char *
assert( nVars <= 16 ); assert( nVars <= 16 );
nOnes = Kit_TruthCountOnes_64bit(pInOut, nVars); nOnes = Kit_TruthCountOnes_64bit(pInOut, nVars);
// if ( (nOnes == nWords * 32) ) // if ( (nOnes == nWords * 32) )
// return 999999; // return 999999;
if ( (nOnes > nWords * 32) ) if ( (nOnes > nWords * 32) )
{ {
...@@ -266,8 +266,8 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char * ...@@ -266,8 +266,8 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char *
// canonicize phase // canonicize phase
for ( i = 0; i < nVars; i++ ) for ( i = 0; i < nVars; i++ )
{ {
// if ( pStore[i] == nOnes-pStore[i]) // if ( pStore[i] == nOnes-pStore[i])
// return 999999; // return 999999;
if ( pStore[i] >= nOnes-pStore[i]) if ( pStore[i] >= nOnes-pStore[i])
continue; continue;
uCanonPhase |= (1 << i); uCanonPhase |= (1 << i);
...@@ -298,7 +298,7 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char * ...@@ -298,7 +298,7 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char *
uCanonPhase ^= (1 << (i+1)); uCanonPhase ^= (1 << (i+1));
} }
Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i ); Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i );
} }
} while ( fChange ); } while ( fChange );
return uCanonPhase; return uCanonPhase;
...@@ -311,19 +311,19 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char * ...@@ -311,19 +311,19 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char *
// int pStore[16]; // int pStore[16];
// int nWords = Kit_TruthWordNum_64bit( nVars ); // int nWords = Kit_TruthWordNum_64bit( nVars );
// int i, Temp, fChange, nOnes; // int i, Temp, fChange, nOnes;
// assert( nVars <= 16 ); // assert( nVars <= 16 );
// //
// nOnes = Kit_TruthCountOnes_64bit(pInOut, nVars); // nOnes = Kit_TruthCountOnes_64bit(pInOut, nVars);
// //
// if ( (nOnes > nWords * 32) ) // if ( (nOnes > nWords * 32) )
// { // {
// Kit_TruthNot_64bit( pInOut, nVars ); // Kit_TruthNot_64bit( pInOut, nVars );
// nOnes = nWords*64 - nOnes; // nOnes = nWords*64 - nOnes;
// } // }
// //
// // collect the minterm counts // // collect the minterm counts
// Kit_TruthCountOnesInCofs_64bit( pInOut, nVars, pStore ); // Kit_TruthCountOnesInCofs_64bit( pInOut, nVars, pStore );
// //
// // canonicize phase // // canonicize phase
// for ( i = 0; i < nVars; i++ ) // for ( i = 0; i < nVars; i++ )
// { // {
...@@ -332,19 +332,19 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char * ...@@ -332,19 +332,19 @@ inline unsigned Kit_TruthSemiCanonicize_Yasha1( word* pInOut, int nVars, char *
// pStore[i] = nOnes-pStore[i]; // pStore[i] = nOnes-pStore[i];
// Kit_TruthChangePhase_64bit( pInOut, nVars, i ); // Kit_TruthChangePhase_64bit( pInOut, nVars, i );
// } // }
// //
// do { // do {
// fChange = 0; // fChange = 0;
// for ( i = 0; i < nVars-1; i++ ) // for ( i = 0; i < nVars-1; i++ )
// { // {
// if ( pStore[i] <= pStore[i+1] ) // if ( pStore[i] <= pStore[i+1] )
// continue; // continue;
// fChange = 1; // fChange = 1;
// //
// Temp = pStore[i]; // Temp = pStore[i];
// pStore[i] = pStore[i+1]; // pStore[i] = pStore[i+1];
// pStore[i+1] = Temp; // pStore[i+1] = Temp;
// //
// Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i ); // Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i );
// } // }
// } while ( fChange ); // } while ( fChange );
...@@ -389,7 +389,7 @@ inline void Kit_TruthSemiCanonicize_Yasha_simple( word* pInOut, int nVars, int ...@@ -389,7 +389,7 @@ inline void Kit_TruthSemiCanonicize_Yasha_simple( word* pInOut, int nVars, int
pStore[i] = pStore[i+1]; pStore[i] = pStore[i+1];
pStore[i+1] = Temp; pStore[i+1] = Temp;
Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i ); Kit_TruthSwapAdjacentVars_64bit( pInOut, nVars, i );
} }
} while ( fChange ); } while ( fChange );
} }
......
...@@ -24,7 +24,7 @@ void swap_ij_case1( word* f,int totalVars, int i, int j) ...@@ -24,7 +24,7 @@ void swap_ij_case1( word* f,int totalVars, int i, int j)
{ {
int e,wordsNumber,n,shift; int e,wordsNumber,n,shift;
word maskArray[45]= word maskArray[45]=
{ 0x9999999999999999, 0x2222222222222222, 0x4444444444444444 ,0xA5A5A5A5A5A5A5A5, 0x0A0A0A0A0A0A0A0A, 0x5050505050505050, { 0x9999999999999999, 0x2222222222222222, 0x4444444444444444 ,0xA5A5A5A5A5A5A5A5, 0x0A0A0A0A0A0A0A0A, 0x5050505050505050,
0xAA55AA55AA55AA55, 0x00AA00AA00AA00AA, 0x5500550055005500 ,0xAAAA5555AAAA5555, 0x0000AAAA0000AAAA, 0x5555000055550000 , 0xAA55AA55AA55AA55, 0x00AA00AA00AA00AA, 0x5500550055005500 ,0xAAAA5555AAAA5555, 0x0000AAAA0000AAAA, 0x5555000055550000 ,
0xAAAAAAAA55555555, 0x00000000AAAAAAAA, 0x5555555500000000 ,0xC3C3C3C3C3C3C3C3, 0x0C0C0C0C0C0C0C0C, 0x3030303030303030 , 0xAAAAAAAA55555555, 0x00000000AAAAAAAA, 0x5555555500000000 ,0xC3C3C3C3C3C3C3C3, 0x0C0C0C0C0C0C0C0C, 0x3030303030303030 ,
0xCC33CC33CC33CC33, 0x00CC00CC00CC00CC, 0x3300330033003300 ,0xCCCC3333CCCC3333, 0x0000CCCC0000CCCC, 0x3333000033330000 , 0xCC33CC33CC33CC33, 0x00CC00CC00CC00CC, 0x3300330033003300 ,0xCCCC3333CCCC3333, 0x0000CCCC0000CCCC, 0x3333000033330000 ,
...@@ -51,7 +51,7 @@ void swap_ij_case2( word* f,int totalVars, int i, int j) ...@@ -51,7 +51,7 @@ void swap_ij_case2( word* f,int totalVars, int i, int j)
word temp; word temp;
int x,y,wj; int x,y,wj;
int WORDS_IN_TT = Kit_TruthWordNum_64bit(totalVars); int WORDS_IN_TT = Kit_TruthWordNum_64bit(totalVars);
// int forShift = ((Word)1)<<i; // int forShift = ((Word)1)<<i;
int forShift = (1<<i); int forShift = (1<<i);
wj = 1 << (j - 6); wj = 1 << (j - 6);
x = 0; x = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment