diff --git a/include/r8veritas.hh b/include/r8veritas.hh index e710ac4..5363f69 100644 --- a/include/r8veritas.hh +++ b/include/r8veritas.hh @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -134,5 +135,7 @@ compress_stat_space(const r8veritas::truthtable &raw_truthtable); bool bfs(const r8veritas::truthtable &truthtable, r8veritas::index layer = 1); r8veritas::path track_path(const r8veritas::truthtable &truthtable); +std::ostream &operator<<(std::ostream &os, const r8veritas::stat &s); +std::ostream &operator<<(std::ostream &os, const r8veritas::ins &s); #endif \ No newline at end of file diff --git a/src/r8veritas.cc b/src/r8veritas.cc index 2135eeb..1b4e775 100644 --- a/src/r8veritas.cc +++ b/src/r8veritas.cc @@ -54,20 +54,21 @@ std::ostream &operator<<(std::ostream &os, const r8veritas::stat &s) { std::ostream &operator<<(std::ostream &os, const r8veritas::ins &s) { auto str = std::bitset(s.bc).to_string(); - std::reverse(str.begin(), str.end()); - os << s.bc << ":{"; + os << "SACRIFICE:" << s.sacrifice; + std::reverse(&str[0], &str[CELL_SIZE]); if ((s.bc != 0b0) && (s.bc != 0b1)) { - os << "OPERATION:"; + os << ",OPERATION:"; if (str[0] == '0') os << "SET1: "; else os << "FLIP: "; - for (r8veritas::index i = 1; i < str.length(); i++) { + os << '{'; + for (r8veritas::index i = 0; i < str.length() - 1; i++) { if (str[i] == '1') - os << i << " "; + os << i << ' '; } + os << '}'; } - os << ",SACRIFICE:" << s.sacrifice << "}"; return (os); } @@ -129,7 +130,6 @@ r8veritas::path track_path(const r8veritas::truthtable &truthtable) { for (auto tmp_stat = truthtable.second; tmp_stat != truthtable.first;) { p.push(visited_op[tmp_stat]); tmp_stat = p.top().first; - std::cout << r8veritas::to_ins(p.top().second) << std::endl; } return p; } \ No newline at end of file diff --git a/tests/r8_test.cc b/tests/r8_test.cc index 75438e9..99a73d3 100644 --- a/tests/r8_test.cc +++ b/tests/r8_test.cc @@ -22,8 +22,13 @@ r8veritas::cell func_full_add(r8veritas::cell inp) { int main() { auto tab = generate_truthtable(func_and); - tab = compress_stat_space(tab); - std::cout << bfs(tab) << std::endl; - r8veritas::path p = track_path(tab); + 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); }