55 unsigned char * pnLitsDiff;
60 int nCubes, nBitsMax, nSum;
61 int CutOffNum = -1, CutOffQuant = -1;
62 int iPair, iQuant, k, c;
67 assert( nPairsMax < nPairsTotal );
70 pnLitsDiff =
ABC_FALLOC(
unsigned char, nPairsTotal );
74 for ( c = 0; c < vCovers->nSize; c++ )
75 if ( (pSopCover = (
char *)vCovers->pArray[c]) )
82 iPair += nCubes * (nCubes - 1) / 2;
83 if ( nBitsMax < nFanins )
86 assert( iPair == nPairsTotal );
89 pnPairCounters =
ABC_FALLOC(
int, 2 * nBitsMax );
90 memset( pnPairCounters, 0,
sizeof(
int) * 2 * nBitsMax );
92 for ( k = 0; k < nPairsTotal; k++ )
93 pnPairCounters[ pnLitsDiff[k] ]++;
96 if ( pnPairCounters[0] != 0 )
100 printf(
"The SOPs of the nodes contain duplicated cubes. Run \"bdd; sop\" before \"fx\".\n" );
103 if ( pnPairCounters[1] != 0 )
107 printf(
"The SOPs of the nodes are not SCC-free. Run \"bdd; sop\" before \"fx\".\n" );
110 assert( pnPairCounters[0] == 0 );
111 assert( pnPairCounters[1] == 0 );
113 for ( k = 0; k < 2 * nBitsMax; k++ )
115 nSum += pnPairCounters[k];
116 if ( nSum >= nPairsMax )
119 CutOffQuant = pnPairCounters[k] - (nSum - nPairsMax);
128 for ( k = 0; k < nPairsTotal; k++ )
129 if ( pnLitsDiff[k] > CutOffNum )
131 else if ( pnLitsDiff[k] == CutOffNum )
133 if ( iQuant++ >= CutOffQuant )
140 assert( iPair == nPairsMax );
144 for ( c = 0; c < vCovers->nSize; c++ )
145 if ( (pSopCover = (
char *)vCovers->pArray[c]) )
148 pVar = p->ppVars[2*c+1];
150 pCubeFirst = pVar->
pFirst;
152 pCubeLast = pCubeFirst;
153 for ( k = 0; k < pVar->
nCubes; k++ )
154 pCubeLast = pCubeLast->
pNext;
155 assert( pCubeLast == NULL || pCubeLast->
pVar != pVar );
158 for ( pCube1 = pCubeFirst; pCube1 != pCubeLast; pCube1 = pCube1->
pNext )
159 for ( pCube2 = pCube1->
pNext; pCube2 != pCubeLast; pCube2 = pCube2->
pNext )
160 if ( pnLitsDiff[iPair++] )
165 assert( iPair == nPairsTotal );
190 char * pCube1, * pCube2;
191 int nOnes, nCubePairs, nFanins, v;
197 if ( pCube1 == pCube2 )
200 for ( v = 0; v < nFanins; v++ )
201 nOnes += (pCube1[v] != pCube2[v]);
202 pDiffs[nCubePairs++] = nOnes;
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
void Fxu_MatrixAddDivisor(Fxu_Matrix *p, Fxu_Cube *pCube1, Fxu_Cube *pCube2)
#define Abc_SopForEachCube(pSop, nFanins, pCube)
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
int Fxu_PreprocessCubePairs(Fxu_Matrix *p, Vec_Ptr_t *vCovers, int nPairsTotal, int nPairsMax)
FUNCTION DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_START
ABC_DLL int Abc_SopGetVarNum(char *pSop)
typedefABC_NAMESPACE_HEADER_START struct FxuMatrix Fxu_Matrix
INCLUDES ///.
static ABC_NAMESPACE_IMPL_START int Fxu_CountPairDiffs(char *pCover, unsigned char pDiffs[])
DECLARATIONS ///.
#define ABC_FALLOC(type, num)