FUNCTION DEFINITIONS ///.
DECLARATIONS ///.
53{
59 char * pSopCover;
60 char * pSopCube;
61 int * pOrder, nBitsMax;
62 int i, v, c;
63 int nCubesTotal;
64 int nPairsTotal;
65 int nPairsStore;
66 int nCubes;
67 int iCube, iPair;
68 int nFanins;
69
70
71 nCubesTotal = 0;
72 nPairsTotal = 0;
73 nPairsStore = 0;
74 nBitsMax = -1;
75 for ( i = 0; i < pData->nNodesOld; i++ )
76 if ( (pSopCover = (char *)pData->vSops->pArray[i]) )
77 {
80 assert( nFanins > 1 && nCubes > 0 );
81
82 nCubesTotal += nCubes;
83 nPairsTotal += nCubes * (nCubes - 1) / 2;
84 nPairsStore += nCubes * nCubes;
85 if ( nBitsMax < nFanins )
86 nBitsMax = nFanins;
87 }
88 if ( nBitsMax <= 0 )
89 {
90 printf( "The current network does not have SOPs to perform extraction.\n" );
91 return NULL;
92 }
93
94 if ( nPairsStore > 50000000 )
95 {
96 printf( "The problem is too large to be solved by \"fxu\" (%d cubes and %d cube pairs)\n", nCubesTotal, nPairsStore );
97 return NULL;
98 }
99
100
102
104 for ( i = 0; i < 2 * pData->nNodesOld; i++ )
106
107
111 iCube = 0;
112 iPair = 0;
113 for ( i = 0; i < pData->nNodesOld; i++ )
114 if ( (pSopCover = (char *)pData->vSops->pArray[i]) )
115 {
116
118
119 pVar =
p->ppVars[2*i+1];
120
122 if ( nCubes > 0 )
123 {
124 pVar->
ppPairs =
p->pppPairs + iCube;
125 pVar->
ppPairs[0] =
p->ppPairs + iPair;
126 for ( v = 1; v < nCubes; v++ )
128 }
129
130 iCube += nCubes;
131 iPair += nCubes * nCubes;
132 }
133 assert( iCube == nCubesTotal );
134 assert( iPair == nPairsStore );
135
136
137
139
140 for ( i = 0; i < pData->nNodesOld; i++ )
141 if ( (pSopCover = (char *)pData->vSops->pArray[i]) )
142 {
143
144 pVar =
p->ppVars[2*i+1];
145
146
147
148 vFanins = (
Vec_Int_t *)pData->vFanins->pArray[i];
149 s_pLits = vFanins->pArray;
150
152 for ( v = 0; v < nFanins; v++ )
153 pOrder[v] = v;
154
155 qsort( (void *)pOrder, (size_t)nFanins, sizeof(int),(int (*)(const void *, const void *))Fxu_CreateMatrixLitCompare);
156 assert( s_pLits[ pOrder[0] ] < s_pLits[ pOrder[nFanins-1] ] );
157
158 pCubeFirst = NULL;
159 c = 0;
161 {
162
164 Fxu_CreateMatrixAddCube(
p, pCubeNew, pSopCube, vFanins, pOrder );
165 if ( pCubeFirst == NULL )
166 pCubeFirst = pCubeNew;
167 pCubeNew->
pFirst = pCubeFirst;
168 }
169
170 pVar->
pFirst = pCubeFirst;
171
172 if ( nPairsTotal <= pData->nPairsMax )
173 {
174 for ( pCube1 = pCubeFirst; pCube1; pCube1 = pCube1->
pNext )
175 for ( pCube2 = pCube1? pCube1->
pNext: NULL; pCube2; pCube2 = pCube2->
pNext )
177 }
178 }
180
181
182
183
184
185 if ( nPairsTotal > 10000000 )
186 {
187 printf( "The total number of cube pairs of the network is more than 10,000,000.\n" );
188 printf( "Command \"fx\" takes a long time to run in such cases. It is suggested\n" );
189 printf( "that the user changes the network by reducing the size of logic node and\n" );
190 printf( "consequently the number of cube pairs to be processed by this command.\n" );
191 printf( "It can be achieved as follows: \"st; if -K <num>\" or \"st; renode -s -K <num>\"\n" );
192 printf( "as a proprocessing step, while selecting <num> as approapriate.\n" );
193 return NULL;
194 }
195 if ( nPairsTotal > pData->nPairsMax )
197 return NULL;
198
199
200
201 if (
p->lVars.nItems > 1000000 )
202 {
203 printf( "The total number of variables is more than 1,000,000.\n" );
204 printf( "Command \"fx\" takes a long time to run in such cases. It is suggested\n" );
205 printf( "that the user changes the network by reducing the size of logic node and\n" );
206 printf( "consequently the number of cube pairs to be processed by this command.\n" );
207 printf( "It can be achieved as follows: \"st; if -K <num>\" or \"st; renode -s -K <num>\"\n" );
208 printf( "as a proprocessing step, while selecting <num> as approapriate.\n" );
209 return NULL;
210 }
211
212
213
215
216
217 if ( pData->fVerbose )
218 {
219 double Density;
220 Density = ((double)
p->nEntries) /
p->lVars.nItems /
p->lCubes.nItems;
221 fprintf( stdout, "Matrix: [vars x cubes] = [%d x %d] ",
222 p->lVars.nItems,
p->lCubes.nItems );
223 fprintf( stdout, "Lits = %d Density = %.5f%%\n",
224 p->nEntries, Density );
225 fprintf( stdout,
"1-cube divs = %6d. (Total = %6d) ",
p->lSingles.nItems,
p->nSingleTotal );
226 fprintf( stdout,
"2-cube divs = %6d. (Total = %6d)",
p->nDivsTotal, nPairsTotal );
227 fprintf( stdout, "\n" );
228 }
229
231}
#define Abc_SopForEachCube(pSop, nFanins, pCube)
ABC_DLL int Abc_SopGetVarNum(char *pSop)
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
#define ABC_ALLOC(type, num)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
int Fxu_PreprocessCubePairs(Fxu_Matrix *p, Vec_Ptr_t *vCovers, int nPairsTotal, int nPairsMax)
FUNCTION DEFINITIONS ///.
Fxu_Var * Fxu_MatrixAddVar(Fxu_Matrix *p)
Fxu_Matrix * Fxu_MatrixAllocate()
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct FxuMatrix Fxu_Matrix
INCLUDES ///.
void Fxu_MatrixComputeSingles(Fxu_Matrix *p, int fUse0, int nSingleMax)
FUNCTION DEFINITIONS ///.
void Fxu_MatrixAddDivisor(Fxu_Matrix *p, Fxu_Cube *pCube1, Fxu_Cube *pCube2)
Fxu_Cube * Fxu_MatrixAddCube(Fxu_Matrix *p, Fxu_Var *pVar, int iCube)