Files
R8VeritasCC/tests/r8_test.cc
T
2026-07-23 12:40:40 +08:00

32 lines
901 B
C++

#include "r8veritas.hh"
#include <bitset>
#include <iostream>
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
}
int main() {
auto tab = generate_truthtable(func_and);
r8veritas::ins i = {0, 2};
for (r8veritas::index i = 0; i < (1 << CELL_SIZE); i++) {
if (!(i % 4))
std::cout << std::endl;
std::cout << std::bitset<CELL_SIZE>(tab.first[i]).to_string() << " ";
}
std::cout << std::endl;
r8veritas::ins ins = {0b010, 2};
tab.second = operate_ins(tab.first, ins);
tab.second = operate_ins(tab.first, ins);
for (r8veritas::index i = 0; i < (1 << CELL_SIZE); i++) {
if (!(i % 4))
std::cout << std::endl;
std::cout << std::bitset<CELL_SIZE>(tab.second[i]).to_string() << " ";
}
std::cout << std::endl;
return (0);
}