72 unsigned* notLit1Func =
ABC_ALLOC(
unsigned, Kit_TruthWordNum(nVars));
73 unsigned* notLit2Func =
ABC_ALLOC(
unsigned, Kit_TruthWordNum(nVars));
78 Kit_TruthNot(notLit1Func, lit1->
function, nVars);
79 Kit_TruthNot(notLit2Func, lit2->
function, nVars);
80 and1 =
ABC_ALLOC(
unsigned, Kit_TruthWordNum(nVars));
81 and2 =
ABC_ALLOC(
unsigned, Kit_TruthWordNum(nVars));
82 Kit_TruthAnd(and1, lit1->
transition, notLit2Func, nVars);
83 isZero = Kit_TruthIsConst0(and1, nVars);
85 Kit_TruthAnd(and2, lit2->
transition, notLit1Func, nVars);
86 isZero = Kit_TruthIsConst0(and2, nVars);
107 unsigned* and1 =
ABC_ALLOC(
unsigned, Kit_TruthWordNum(nVars));
108 unsigned* and2 =
ABC_ALLOC(
unsigned, Kit_TruthWordNum(nVars));
111 isZero = Kit_TruthIsConst0(and1, nVars);
114 isZero = Kit_TruthIsConst0(and2, nVars);
133 int minCostIndex = -1;
134 int minVertexIndex = -1;
135 unsigned int minCost = ~0;
137 unsigned int edgeCost;
140 for (i = 0; i < edgeCount; ++i) {
142 if (!edge->visited) {
143 edgeCost = vertexDegree[edge->idx1] + vertexDegree[edge->idx2];
144 minVertex = (edge->idx1 < edge->idx2) ? edge->idx1 : edge->idx2;
145 if (edgeCost < minCost) {
148 minVertexIndex = minVertex;
149 }
else if ((edgeCost == minCost) && minVertex < minVertexIndex) {
152 minVertexIndex = minVertex;
176 int nLitCap = nVars * 2;
182 int thresholdCount = 0;
184 if (Kit_TruthIsConst0(target, nVars)) {
185 return Lit_CreateLiteralConst(target, nVars, 0);
186 }
else if (Kit_TruthIsConst1(target, nVars)) {
187 return Lit_CreateLiteralConst(target, nVars, 1);
194 Abc_Print(-2,
"Target: ");
195 Lit_PrintTT(target, nVars);
200 for (w = nVars - 1; w >= 0; w--) {
201 lit = Lit_Alloc(target, nVars, w,
'+');
206 lit = Lit_Alloc(target, nVars, w,
'-');
213 Abc_Print(-2,
"Allocated %d literal clusters\n", nLit);
216 result =
Rpo_Recursion(target, vecLit, nLit, nLit, nVars, &thresholdCount, nThreshold, verbose);
219 for (w = 0; w < nLit; ++w) {
247 *thresholdCount = *thresholdCount + 1;
248 if (*thresholdCount == thresholdMax) {
252 Abc_Print(-2,
"Entering recursion %d\n", *thresholdCount);
255 if (nLitCount == 1) {
257 Abc_Print(-2,
"Checking solution: ");
259 for (k = 0; k < nLit; ++k) {
260 if (vecLit[k] != NULL) {
261 if (Kit_TruthIsEqual(target, vecLit[k]->function, nVars)) {
262 copyResult = Lit_Copy(vecLit[k], nVars);
264 Abc_Print(-2,
"FOUND!\n", thresholdCount);
272 Abc_Print(-2,
"FAILED!\n", thresholdCount);
281 for (v = 0; v < nLit; v++) {
285 edgeSize = (nLit * (nLit - 1)) / 2;
288 Abc_Print(-2,
"Creating Edges: \n");
291 for (i = 0; i < nLit; ++i) {
292 if (vecLit[i] == NULL) {
295 for (j = i; j < nLit; ++j) {
296 if (vecLit[j] == NULL) {
303 Abc_Print(-2,
"Grouped: ");
304 Lit_PrintExp(vecLit[j]);
305 Abc_Print(-2,
" AND ");
306 Lit_PrintExp(vecLit[i]);
311 edges[edgeCount++] = edge;
315 Abc_Print(-2,
"Grouped: ");
316 Lit_PrintExp(vecLit[j]);
317 Abc_Print(-2,
" OR ");
318 Lit_PrintExp(vecLit[i]);
323 edges[edgeCount++] = edge;
328 Abc_Print(-2,
"%d edges created.\n", edgeCount);
337 Abc_Print(-2,
"There is no edges unvisited... Exiting recursion.\n");
343 edge = edges[edgeIndex];
346 minLitIndex = (edge->idx1 < edge->idx2) ? edge->idx1 : edge->idx2;
347 maxLitIndex = (edge->idx1 > edge->idx2) ? edge->idx1 : edge->idx2;
348 oldLit1 = vecLit[minLitIndex];
349 oldLit2 = vecLit[maxLitIndex];
350 newLit = Lit_GroupLiterals(oldLit1, oldLit2, (
Operator_t)edge->connectionType, nVars);
351 vecLit[minLitIndex] = newLit;
352 vecLit[maxLitIndex] = NULL;
355 Abc_Print(-2,
"New Literal Cluster found: ");
356 Lit_PrintExp(newLit);
357 Abc_Print(-2,
" -> ");
358 Lit_PrintTT(newLit->
function, nVars);
361 result =
Rpo_Recursion(target, vecLit, nLit, (nLitCount - 1), nVars, thresholdCount, thresholdMax, verbose);
364 vecLit[minLitIndex] = oldLit1;
365 vecLit[maxLitIndex] = oldLit2;
366 if (*thresholdCount == thresholdMax) {
369 }
while (result == NULL);
375 for (i = 0; i < edgeCount; ++i) {
Literal_t * Rpo_Recursion(unsigned *target, Literal_t **vecLit, int nLit, int nLitCount, int nVars, int *thresholdCount, int thresholdMax, int verbose)