forked from starcells/R8VeritasCC
[err]202607251724
This commit is contained in:
1 parent
50480ffe04
commit
3e873c4f8e
3 files changed
+57
-17
No files matched your search
@@ -8,6 +8,7 @@
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
@@ -120,6 +121,10 @@ static std::unordered_map<
|
||||
std::pair<r8veritas::stat_ref, r8veritas::ins_bytecode>>
|
||||
visited_op;
|
||||
|
||||
static std::unordered_set<r8veritas::stat> stat_pool;
|
||||
static std::array<std::string, CELL_SIZE> default_nicknames;
|
||||
static std::array<std::string, CELL_SIZE> 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<r8veritas::stat> stat_pool;
|
||||
std::array<std::string, CELL_SIZE> initialize_nicknames();
|
||||
std::array<std::string, CELL_SIZE>
|
||||
initialize_tp_paths(std::array<std::string, CELL_SIZE> nickname_list);
|
||||
#endif
|
||||
+44
-13
@@ -3,10 +3,29 @@
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <ostream>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
std::array<std::string, CELL_SIZE> initialize_nicknames() {
|
||||
std::array<std::string, CELL_SIZE> arr;
|
||||
for (r8veritas::index i = 0; i < CELL_SIZE; i++) {
|
||||
arr[i] = std::to_string(i + 1);
|
||||
}
|
||||
return (arr);
|
||||
}
|
||||
|
||||
std::array<std::string, CELL_SIZE>
|
||||
initialize_tp_paths(std::array<std::string, CELL_SIZE> nickname_list) {
|
||||
std::array<std::string, CELL_SIZE> 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<INS_SIZE>(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);
|
||||
}
|
||||
|
||||
+5
-2
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user