FUNCTION DEFINITIONS ///.
Description [This procedure takes the matrix with variables and cubes allocated (p), the original covers of the nodes (i-sets) and their number (ppCovers,nCovers). The maximum number of pairs to compute and the total number of pairs in existence. This procedure adds to the storage of divisors exactly the given number of pairs (nPairsMax) while taking first those pairs that have the smallest number of literals in their cube-free form.]
54{
55 unsigned char * pnLitsDiff;
56 int * pnPairCounters;
60 int nCubes, nBitsMax, nSum;
61 int CutOffNum = -1, CutOffQuant = -1;
62 int iPair, iQuant, k, c;
63
64 char * pSopCover;
65 int nFanins;
66
67 assert( nPairsMax < nPairsTotal );
68
69
70 pnLitsDiff =
ABC_FALLOC(
unsigned char, nPairsTotal );
71
72 iPair = 0;
73 nBitsMax = -1;
74 for ( c = 0; c < vCovers->nSize; c++ )
75 if ( (pSopCover = (char *)vCovers->pArray[c]) )
76 {
78
79 Fxu_CountPairDiffs( pSopCover, pnLitsDiff + iPair );
80
82 iPair += nCubes * (nCubes - 1) / 2;
83 if ( nBitsMax < nFanins )
84 nBitsMax = nFanins;
85 }
86 assert( iPair == nPairsTotal );
87 if ( nBitsMax == -1 )
88 nBitsMax = 0;
89
90
91 pnPairCounters =
ABC_CALLOC(
int, 2 * nBitsMax );
92
93 for ( k = 0; k < nPairsTotal; k++ )
94 pnPairCounters[ pnLitsDiff[k] ]++;
95
96
97 if ( pnPairCounters[0] != 0 )
98 {
101 printf( "The SOPs of the nodes contain duplicated cubes. Run \"bdd; sop\" before \"fx\".\n" );
102 return 0;
103 }
104 if ( pnPairCounters[1] != 0 )
105 {
108 printf( "The SOPs of the nodes are not SCC-free. Run \"bdd; sop\" before \"fx\".\n" );
109 return 0;
110 }
111 assert( pnPairCounters[0] == 0 );
112 assert( pnPairCounters[1] == 0 );
113 nSum = 0;
114 for ( k = 0; k < 2 * nBitsMax; k++ )
115 {
116 nSum += pnPairCounters[k];
117 if ( nSum >= nPairsMax )
118 {
119 CutOffNum = k;
120 CutOffQuant = pnPairCounters[k] - (nSum - nPairsMax);
121 break;
122 }
123 }
125
126
127 iQuant = 0;
128 iPair = 0;
129 for ( k = 0; k < nPairsTotal; k++ )
130 if ( pnLitsDiff[k] > CutOffNum )
131 pnLitsDiff[k] = 0;
132 else if ( pnLitsDiff[k] == CutOffNum )
133 {
134 if ( iQuant++ >= CutOffQuant )
135 pnLitsDiff[k] = 0;
136 else
137 iPair++;
138 }
139 else
140 iPair++;
141 assert( iPair == nPairsMax );
142
143
144 iPair = 0;
145 for ( c = 0; c < vCovers->nSize; c++ )
146 if ( (pSopCover = (char *)vCovers->pArray[c]) )
147 {
148
149 pVar =
p->ppVars[2*c+1];
150
151 pCubeFirst = pVar->
pFirst;
152
153 pCubeLast = pCubeFirst;
154 for ( k = 0; k < pVar->
nCubes; k++ )
155 pCubeLast = pCubeLast->
pNext;
156 assert( pCubeLast == NULL || pCubeLast->
pVar != pVar );
157
158
159 for ( pCube1 = pCubeFirst; pCube1 != pCubeLast; pCube1 = pCube1->
pNext )
160 for ( pCube2 = pCube1->
pNext; pCube2 != pCubeLast; pCube2 = pCube2->
pNext )
161 if ( pnLitsDiff[iPair++] )
162 {
164 }
165 }
166 assert( iPair == nPairsTotal );
168
169 return 1;
170}
ABC_DLL int Abc_SopGetVarNum(char *pSop)
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
#define ABC_FALLOC(type, num)
#define ABC_CALLOC(type, num)
void Fxu_MatrixAddDivisor(Fxu_Matrix *p, Fxu_Cube *pCube1, Fxu_Cube *pCube2)