Files
R8VeritasCC/tests/r8_test.cc
T
2026-08-14 18:01:06 +08:00

70 lines
1.6 KiB
C++

#include "r8veritas.hh"
#include <iostream>
#include <ostream>
#define r8veritas r8veritas<6>
r8veritas::cell func_copy(r8veritas::cell inp) {
bool A = inp & 0b1;
return (A << 1) | A;
}
r8veritas::cell func_clb_and(r8veritas::cell inp) {
bool A = inp & 0b1;
bool B = inp & 0b10;
bool S = A & B;
return S << 2;
}
r8veritas::cell func_full_add_Co(r8veritas::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);
}
r8veritas::cell func_full_add_S(r8veritas::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);
}
r8veritas::cell func_clb_half_add(r8veritas::cell inp) {
bool A = inp & 0b1;
bool B = inp & 0b10;
bool S = A ^ B;
bool Co = A & B;
return (S << 1) | Co;
}
r8veritas::cell func_half_add(r8veritas::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() {
static r8veritas problem;
problem.initialize_nicknames();
problem.initialize_tp_paths();
problem.disable_debug_output();
auto tab1 = problem.generate_truthtable(func_full_add_Co);
auto new_tab1 = problem.compress_stat_space(tab1);
if (problem.bfs(new_tab1)) {
auto p = problem.track_path(tab1);
while (!p.empty()) {
std::cout << problem.to_ins(p.top().second) << std::endl;
p.pop();
}
} else
std::cout << "PATH NOT FOUND!";
return (0);
}