130 unsigned int* xiOFF, * xiON, * xjOFF, * xjON;
132 concat(pOut->exp,
'(',
')', ni->exp, niPolarity, nj->exp, njPolarity);
151 int xiOFFSize = xiOFF[0];
152 int xjOFFSize = xjOFF[0];
153 if (xiOFFSize <= xjOFFSize) {
155 pOut->off[0] = xiOFFSize;
156 for (i = 1; i <= xiOFFSize; i++) {
157 pOut->off[i] = xiOFF[i];
161 pOut->off[0] = xjOFFSize;
162 for (i = 1; i <= xjOFFSize; i++) {
163 pOut->off[i] = xjOFF[i];
167 pOut->pNegCof = niPolarity ? ni->pNegCof : ni->pPosCof;
173 unsigned int xiONSize = xiON[0];
174 unsigned int xjONSize = xjON[0];
175 pOut->on[0] = xiONSize + xjONSize;
176 for (i = 1; i <= (int)xiONSize; i++) {
177 pOut->on[i] = xiON[i];
179 for (j = 1; j <= (int)xjONSize; j++) {
180 pOut->on[i++] = xjON[j];
183 if (xiONSize >= xjONSize) {
184 pOut->pPosCof = niPolarity ? ni->pPosCof : ni->pNegCof;
185 cubeCofactor(pOut->pPosCof, xjON, TRUTH_WORDS);
187 pOut->pPosCof = njPolarity ? nj->pPosCof : nj->pNegCof;
188 cubeCofactor(pOut->pPosCof, xiON, TRUTH_WORDS);
192 pOut->pBoolDiff = njPolarity ? nj->pNegCof : nj->pPosCof;
193 xorInPlace(pOut->pBoolDiff, pOut->pPosCof, TRUTH_WORDS);
198 const unsigned int * xiOFF = ni->off;
199 const unsigned int * xiON = ni->on;
200 const unsigned int * xjOFF = nj->off;
201 const unsigned int * xjON = nj->on;
203 const int xiOFFSize = xiOFF[0];
204 const int xiONSize = xiON[0];
205 const int xjOFFSize = xjOFF[0];
206 const int xjONSize = xjON[0];
208 int minCCSize = xiOFFSize;
209 int minCCPolarity = 0;
212 concat(pOut->exp,
'[',
']', ni->exp, 1, nj->exp, 1);
213 if (minCCSize > xiONSize) {
214 minCCSize = xiONSize;
218 if (minCCSize > xjOFFSize) {
219 minCCSize = xjOFFSize;
223 if (minCCSize > xjONSize) {
224 minCCSize = xjONSize;
229 if (minCCNode == ni) {
232 pOut->pNegCof = nj->pPosCof;
233 cubeCofactor(pOut->pNegCof, xiON, TRUTH_WORDS);
235 pOut->pPosCof = nj->pNegCof;
236 cubeCofactor(pOut->pPosCof, xiON, TRUTH_WORDS);
239 pOut->pNegCof = nj->pNegCof;
240 cubeCofactor(pOut->pNegCof, xiOFF, TRUTH_WORDS);
242 pOut->pPosCof = nj->pPosCof;
243 cubeCofactor(pOut->pPosCof, xiOFF, TRUTH_WORDS);
248 pOut->pNegCof = ni->pPosCof;
249 cubeCofactor(pOut->pNegCof, xjON, TRUTH_WORDS);
251 pOut->pPosCof = ni->pNegCof;
252 cubeCofactor(pOut->pPosCof, xjON, TRUTH_WORDS);
255 pOut->pNegCof = ni->pNegCof;
256 cubeCofactor(pOut->pNegCof, xjOFF, TRUTH_WORDS);
258 pOut->pPosCof = ni->pPosCof;
259 cubeCofactor(pOut->pPosCof, xjOFF, TRUTH_WORDS);
263 pOut->pBoolDiff = ni->pBoolDiff;
267 if ((xiOFFSize+xjOFFSize) <= (xiONSize+xjONSize)) {
268 merge(pOut->off, xiOFF);
269 merge(pOut->off, xjOFF);
271 merge(pOut->off, xiON);
272 merge(pOut->off, xjON);
276 if ((xiOFFSize+xjONSize) <= (xiONSize+xjOFFSize)) {
277 merge(pOut->on, xiOFF);
278 merge(pOut->on, xjON);
280 merge(pOut->on, xiON);
281 merge(pOut->on, xjOFF);
312 const int TRUTH_WORDS = Abc_TtWordNum(nVarsInit);
313 const int NEED_POOL_ALLOC = (pool == NULL);
333 word *pNextTruth = pool;
335 for (iVar = 0; iVar < nVarsInit; iVar++) {
337 Abc_TtCofactor0p(pNextTruth, pTruth, TRUTH_WORDS, iVar);
339 if (!Abc_TtEqual(pNextTruth, pTruth, TRUTH_WORDS)) {
341 node->pNegCof = pNextTruth;
343 pNextTruth += TRUTH_WORDS;
345 node->pPosCof = pNextTruth;
346 Abc_TtCofactor1p(node->pPosCof, pTruth, TRUTH_WORDS, iVar);
348 pNextTruth += TRUTH_WORDS;
350 node->pBoolDiff = pNextTruth;
351 Abc_TtXor(node->pBoolDiff, node->pNegCof, node->pPosCof, TRUTH_WORDS, 0);
353 pNextTruth += TRUTH_WORDS;
355 node->on[0] = 1; node->on[1] = (iVar << 1) | 1u;
357 node->off[0] = 1; node->off[1] = iVar << 1;
359 node->exp[0] =
'a'+iVar;
362 newNodes[n++] = node;
370 if (Abc_TtIsConst0(pTruth, TRUTH_WORDS)) {
371 {
if ( pRes ) pRes[0] =
'0', pRes[1] =
'\0'; }
373 }
else if (Abc_TtIsConst1(pTruth, TRUTH_WORDS)) {
374 {
if ( pRes ) pRes[0] =
'1', pRes[1] =
'\0'; }
377 Abc_Print(-1,
"ERROR. No variable in the support of f, but f isn't constant!\n");
383 int i, j, iPolarity, jPolarity;
385 for (i = 0; i < n; i++) {
391 if (dsc_and_test(ni, nj, TRUTH_WORDS, &iPolarity, &jPolarity)) {
392 newNode = &freeNodes[f++];
393 dsc_and_group(newNode, ni, iPolarity, nj, jPolarity, nVarsInit, TRUTH_WORDS);
396 if ((newNode == NULL) && (dsc_xor_test(ni, nj, TRUTH_WORDS))) {
397 newNode = &freeNodes[f++];
400 if (newNode != NULL) {
401 oldNodes[j] = oldNodes[--o];
407 if (newNode != NULL) {
408 newNodes[tempN++] = newNode;
417 if (Abc_TtIsConst0(solution->pNegCof, TRUTH_WORDS) && Abc_TtIsConst1(solution->pPosCof, TRUTH_WORDS)) {
420 strcpy( pRes, solution->exp);
424 }
else if (Abc_TtIsConst1(solution->pNegCof, TRUTH_WORDS) && Abc_TtIsConst0(solution->pPosCof, TRUTH_WORDS)) {
428 strcpy( &pRes[1], solution->exp);
434 printf(
"DSC ERROR: Final DSC node found, but differs from target function.\n");
void dsc_and_group(Dsc_node_t *pOut, Dsc_node_t *ni, int niPolarity, Dsc_node_t *nj, int njPolarity, int nVars, const int TRUTH_WORDS)