#include "sweep.hpp" #include "circuit.hpp" extern "C" { #include "aiger.h" } int Sweep::get_time() { return std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - clk_st).count(); } void Sweep::aiger_preprocess() { aiger_read_from_file(aig, file); maxvar = aig->maxvar; output = aig->outputs[0].lit; num_inputs = aig->num_inputs; used = new int[maxvar + 1]; C = new circuit[maxvar + 1]; memset(used, 0, (maxvar + 1) * sizeof(int)); sum_pos = new int[2 * maxvar + 2]; sum_neg = new int[2 * maxvar + 2]; memset(sum_pos, 0, sizeof(int) * (2 * maxvar + 2)); memset(sum_neg, 0, sizeof(int) * (2 * maxvar + 2)); for(int i=0; inum_ands; i++) { auto gate = aig->ands[i]; int o = aiger_lit2var(gate.lhs); int i0 = aiger_lit2var(gate.rhs0); int i1 = aiger_lit2var(gate.rhs1); graph.add(i0, o, gate.rhs0 & 1); graph.add(i1, o, gate.rhs1 & 1); assert((gate.lhs & 1) == 0); C[o].push(i0 * (gate.rhs0 & 1 ? -1 : 1)); C[o].push(i1 * (gate.rhs1 & 1 ? -1 : 1)); } // for (int i = 1; i <= maxvar; i++) { // circuit *c = &C[i]; // if (!c->sz) continue; // printf("%d = %s ( ", i, gate_type[c->type].c_str()); // for (int j = 0; j < c->sz; j++) { // printf("%d ", c->to[j]); // } // puts(")"); // } return; printf("c inputs: \nc "); for(int i=0; inum_inputs; i++) { printf("%d ", aig->inputs[i].lit); } printf("\nc outputs: \nc "); for(int i=0; inum_outputs; i++) { printf("%d ", aig->outputs[i].lit); } printf("\nc maxvar: \nc %d\n", maxvar); // int x = det_v > 0 ? det_v : -det_v; // if (x > maxvar) det_v = 0; printf("assume:"); for (int i = 0; i < det_v_sz; i++) { printf(" %d", det_v[i]); } puts(""); cal_topo_index(); } void Sweep::solve() { aiger_preprocess(); printf("c preprocess finish: %.2lf s\n", 0.001 * get_time()); identify(); printf("c identify finish: %.2lf s\n", 0.001 * get_time()); }