202607242142

This commit is contained in:
starcells committed 2026-07-24 21:42:48 +08:00
1 parent ef35a553b3
commit f42aca2e4f
3 files changed
+18 -10

No files matched your search

+3
View File
@@ -6,6 +6,7 @@
#include <cstddef>
#include <functional>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
@@ -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
+7 -7
View File
@@ -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<INS_SIZE>(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;
}
+8 -3
View File
@@ -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);
}