diff options
Diffstat (limited to '')
| -rw-r--r-- | main.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
| @@ -6,10 +6,12 @@ | |||
| 6 | #include <optional> | 6 | #include <optional> |
| 7 | #include <utility> | 7 | #include <utility> |
| 8 | 8 | ||
| 9 | #include "infra/sim.h" | ||
| 9 | #include "isa/checker.h" | 10 | #include "isa/checker.h" |
| 10 | #include "programs/programs.h" | 11 | #include "programs/programs.h" |
| 12 | #include "uarch/core.h" | ||
| 11 | 13 | ||
| 12 | int load_program(checker &checker, const std::uint8_t *program) { | 14 | int load_program(core &core, const std::uint8_t *program) { |
| 13 | bool seen_non_leader = false; | 15 | bool seen_non_leader = false; |
| 14 | bool comment = false; | 16 | bool comment = false; |
| 15 | unsigned int field = 0; | 17 | unsigned int field = 0; |
| @@ -31,8 +33,10 @@ int load_program(checker &checker, const std::uint8_t *program) { | |||
| 31 | address = ((b1 & 0077) << 6) | *program++; | 33 | address = ((b1 & 0077) << 6) | *program++; |
| 32 | } else if ((b1 & 0300) == 0000) { | 34 | } else if ((b1 & 0300) == 0000) { |
| 33 | seen_non_leader = true; | 35 | seen_non_leader = true; |
| 34 | if (data.has_value()) | 36 | if (data.has_value()) { |
| 35 | checker.mem.store(data->first, data->second); | 37 | core.checker.mem.store(data->first, data->second); |
| 38 | core.mem.store(data->first, data->second); | ||
| 39 | } | ||
| 36 | auto a = field | address++; | 40 | auto a = field | address++; |
| 37 | auto d = ((b1 & 0077) << 6) | *program++; | 41 | auto d = ((b1 & 0077) << 6) | *program++; |
| 38 | data = std::make_pair(a, d); | 42 | data = std::make_pair(a, d); |
| @@ -57,12 +61,14 @@ int main(int argc, const char *argv[]) { | |||
| 57 | return 1; | 61 | return 1; |
| 58 | } | 62 | } |
| 59 | 63 | ||
| 64 | init_disasm_tables(); | ||
| 65 | |||
| 60 | iomodel system; | 66 | iomodel system; |
| 61 | checker checker(system); | 67 | core core(system); |
| 62 | 68 | ||
| 63 | for (--argc, ++argv; argc; --argc, ++argv) { | 69 | for (--argc, ++argv; argc; --argc, ++argv) { |
| 64 | if (auto program = programs.find(*argv); program != programs.end()) { | 70 | if (auto program = programs.find(*argv); program != programs.end()) { |
| 65 | if (auto err = load_program(checker, program->second)) | 71 | if (auto err = load_program(core, program->second)) |
| 66 | return err; | 72 | return err; |
| 67 | } else { | 73 | } else { |
| 68 | std::ifstream fh(*argv); | 74 | std::ifstream fh(*argv); |
| @@ -70,12 +76,21 @@ int main(int argc, const char *argv[]) { | |||
| 70 | } | 76 | } |
| 71 | } | 77 | } |
| 72 | 78 | ||
| 73 | while (!checker.done()) { | 79 | std::ofstream pt("bug.pt"); |
| 74 | // if (!checker.ctlregs[HALTED]) | 80 | infra::pt::ptfile = &pt; |
| 75 | // std::cout << fmt::format("\t{:9} {:04o}\n", system.time, checker.pc); | 81 | |
| 76 | checker.execute(); | 82 | while (!core.checker.done()) { |
| 83 | // if (!checker.ctlregs[HALTED]) { | ||
| 84 | // if (checker.inst.final_address.has_value()) | ||
| 85 | // std::cout << fmt::format("{:05o} {:01o} {:04o} {:04o} {:005o}\n", checker.pc, checker.link, checker.acc, checker.mq, *checker.inst.final_address); | ||
| 86 | // else | ||
| 87 | // std::cout << fmt::format("{:05o} {:01o} {:04o} {:04o} \n", checker.pc, checker.link, checker.acc, checker.mq); | ||
| 88 | // } | ||
| 89 | infra::sim::advance(); | ||
| 77 | } | 90 | } |
| 78 | 91 | ||
| 92 | pt << fmt::format("# icount={} cycles={} ipc={:.04}\n", core.checker.icount, infra::sim::now, (float)core.checker.icount / (float)infra::sim::now); | ||
| 93 | |||
| 79 | // std::ofstream fh("trace.evt"); | 94 | // std::ofstream fh("trace.evt"); |
| 80 | // system.write_evt(fh); | 95 | // system.write_evt(fh); |
| 81 | 96 | ||
