Files
R8VeritasCC-fork/tests/r8_test.cc
T
2026-07-25 01:08:13 +08:00

35 lines
906 B
C++

#include "r8veritas.hh"
#include <iostream>
#include <ostream>
r8veritas::cell func_and(r8veritas::cell inp) {
return ((((inp >> 0) & (inp >> 1)) & r8veritas::cell(0b1)) << 2) |
(inp & 0b11); // inp[0]->arg1, inp[1]->arg2, inp[2]->ans
}
r8veritas::cell func_copy(r8veritas::cell inp) {
return (((inp & 1) << 1) | (inp & 1)); // inp[0] -> from,inp[1]->to
}
r8veritas::cell func_full_add(r8veritas::cell inp) {
bool A = inp & 0b1;
bool B = inp & 0b10;
bool C = inp & 0b100;
bool S = A ^ B ^ C;
bool Ci = (A & B) | (A & C) | (B & C);
return (Ci << 4 | S << 3) | (inp & 0b111);
}
int main() {
auto tab = generate_truthtable(func_full_add);
auto new_tab = compress_stat_space(tab);
if (bfs(new_tab)) {
r8veritas::path p = track_path(tab);
while (!p.empty()) {
std::cout << r8veritas::to_ins(p.top().second) << std::endl;
p.pop();
}
}
return (0);
}