From 3e873c4f8e07a947baaa8efda4c8a849c19ef5c9 Mon Sep 17 00:00:00 2001 From: StarCells Date: Sat, 25 Jul 2026 17:24:35 +0800 Subject: [PATCH] [err]202607251724 --- include/r8veritas.hh | 10 ++++++-- src/r8veritas.cc | 57 ++++++++++++++++++++++++++++++++++---------- tests/r8_test.cc | 7 ++++-- 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/include/r8veritas.hh b/include/r8veritas.hh index 3f6c37b..5246acd 100644 --- a/include/r8veritas.hh +++ b/include/r8veritas.hh @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -120,6 +121,10 @@ static std::unordered_map< std::pair> visited_op; +static std::unordered_set stat_pool; +static std::array default_nicknames; +static std::array tp_paths; + std::ostream &operator<<(std::ostream &os, const r8veritas::stat &s); r8veritas::truthtable @@ -131,6 +136,7 @@ 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_ref &s); std::ostream &operator<<(std::ostream &os, const r8veritas::ins &s); - -static std::unordered_set stat_pool; +std::array initialize_nicknames(); +std::array +initialize_tp_paths(std::array nickname_list); #endif \ No newline at end of file diff --git a/src/r8veritas.cc b/src/r8veritas.cc index dbb2d52..b4be030 100644 --- a/src/r8veritas.cc +++ b/src/r8veritas.cc @@ -3,10 +3,29 @@ #include #include #include +#include #include #include +#include #include #include +std::array initialize_nicknames() { + std::array arr; + for (r8veritas::index i = 0; i < CELL_SIZE; i++) { + arr[i] = std::to_string(i + 1); + } + return (arr); +} + +std::array +initialize_tp_paths(std::array nickname_list) { + std::array arr; + for (r8veritas::index i = 0; i < CELL_SIZE; i++) { + arr[i] = ".tp %" + nickname_list[i]; + } + + return (arr); +} r8veritas::stat_ref generate_empty_stat() { r8veritas::stat arr; @@ -71,21 +90,34 @@ std::ostream &operator<<(std::ostream &os, const r8veritas::stat_ref &s) { std::ostream &operator<<(std::ostream &os, const r8veritas::ins &s) { auto str = std::bitset(s.bc).to_string(); - os << "SACRIFICE:" << s.sacrifice; + os << tp_paths[s.sacrifice] << std::endl + << "biz" << std::endl + << "\tflb" << std::endl; + /* + .tp xxx + biz + flb + */ std::reverse(&str[0], &str[CELL_SIZE]); if ((s.bc != 0b0) && (s.bc != 0b1)) { - os << ",OPERATION:"; - if (str[0] == '0') - os << "SET1: "; - else - os << "FLIP: "; - os << '{'; for (r8veritas::index i = 0; i < str.length() - 1; i++) { - if (str[i] == '1') - os << i << ' '; + if (str[i] == '1') { + os << "\t" << tp_paths[i] << std::endl; + /* + .tp yyy + */ + if (str[CELL_SIZE] == '1') + os << "\tflb" << std::endl; + else + os << "\tset_1" << std::endl; + } } - os << '}'; + os << "\t" << tp_paths[s.sacrifice] << std::endl; } + os << "rnz" << std::endl; + /* + rnz + */ return (os); } @@ -135,11 +167,10 @@ bool bfs(const r8veritas::truthtable &truthtable, r8veritas::index layer) { if (tmp_ans.first == truthtable.second) { while (!stats.empty()) stats.pop(); - remembered_stats.erase(remembered_stats.begin(), - remembered_stats.end()); + remembered_stats.clear(); return (true); } - if (!((tmp_ans.second) || remembered_stats.contains(tmp_ans.first))) { + if (!remembered_stats.contains(tmp_ans.first)) { stats.push(tmp_ans.first); remembered_stats.insert(tmp_ans.first); } diff --git a/tests/r8_test.cc b/tests/r8_test.cc index 989f4fc..359a569 100644 --- a/tests/r8_test.cc +++ b/tests/r8_test.cc @@ -30,7 +30,9 @@ r8veritas::cell func_full_add_S(r8veritas::cell inp) { } int main() { - auto tab1 = generate_truthtable(func_full_add_Co); + default_nicknames = initialize_nicknames(); + tp_paths = initialize_tp_paths(default_nicknames); + auto tab1 = generate_truthtable(func_and); auto new_tab1 = compress_stat_space(tab1); if (bfs(new_tab1)) { r8veritas::path p = track_path(tab1); @@ -39,6 +41,7 @@ int main() { p.pop(); } } + /* auto tab2 = generate_truthtable(func_full_add_S); auto new_tab2 = compress_stat_space(tab2); if (bfs(new_tab2)) { @@ -47,6 +50,6 @@ int main() { std::cout << r8veritas::to_ins(p.top().second) << std::endl; p.pop(); } - } + }*/ return (0); }