Files
R8VeritasCC/tests/r8_test.cc
T

70 lines
1.6 KiB
C++

#include "r8veritas.hh"
#include <iostream>
#include <ostream>
using problem_t = r8veritas<5>;
problem_t::cell func_copy(problem_t::cell inp) {
bool A = inp & 0b1;
return (A << 1) | A;
}
problem_t::cell func_clb_and(problem_t::cell inp) {
bool A = inp & 0b1;
bool B = inp & 0b10;
bool S = A & B;
return S << 2;
}
problem_t::cell func_full_add_Co(problem_t::cell inp) {
bool A = inp & 0b1;
bool B = inp & 0b10;
bool C = inp & 0b100;
bool S = A ^ B ^ C;
bool Co = (A & B) | (A & C) | (B & C);
return (Co << 4) | (inp & 0b111);
}
problem_t::cell func_full_add_S(problem_t::cell inp) {
bool A = inp & 0b1;
bool B = inp & 0b10;
bool C = inp & 0b100;
bool S = A ^ B ^ C;
bool Co = (A & B) | (A & C) | (B & C);
return (S << 3) | (inp & 0b111);
}
problem_t::cell func_clb_half_add(problem_t::cell inp) {
bool A = inp & 0b1;
bool B = inp & 0b10;
bool S = A ^ B;
bool Co = A & B;
return (S << 1) | Co;
}
problem_t::cell func_half_add(problem_t::cell inp) {
bool A = inp & 0b1;
bool B = inp & 0b10;
bool S = A ^ B;
bool Co = A & B;
return (S << 3) | (Co << 2) | (inp & 0b11);
}
int main() {
problem_t problem;
problem.initialize_nicknames();
problem.initialize_tp_paths();
auto tab1 = problem.generate_truthtable(func_full_add_Co);
auto new_tab1 = problem.compress_stat_space(tab1);
if (problem.bfs(new_tab1, true)) {
auto p = problem.track_path(tab1);
while (!p.empty()) {
problem.output_ins(problem.to_ins(p.top().second), true);
std::cout << std::endl;
p.pop();
}
} else
std::cout << "PATH NOT FOUND!";
return (0);
}