diff options
| -rw-r--r-- | io/model.cpp | 17 | ||||
| -rw-r--r-- | io/model.h | 3 | ||||
| -rw-r--r-- | main.cpp | 3 |
3 files changed, 23 insertions, 0 deletions
diff --git a/io/model.cpp b/io/model.cpp index 79bc511..81cf318 100644 --- a/io/model.cpp +++ b/io/model.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #include <array> | 1 | #include <array> |
| 2 | #include <cassert> | 2 | #include <cassert> |
| 3 | #include <cstdint> | 3 | #include <cstdint> |
| 4 | #include <fmt/format.h> | ||
| 4 | #include <iostream> | 5 | #include <iostream> |
| 5 | #include <utility> | 6 | #include <utility> |
| 6 | 7 | ||
| @@ -85,3 +86,19 @@ void iomodel::load_evt(std::istream &fh) { | |||
| 85 | } | 86 | } |
| 86 | } | 87 | } |
| 87 | } | 88 | } |
| 89 | |||
| 90 | std::ostream & iomodel::write_evt(std::ostream &fh) { | ||
| 91 | std::uint64_t time = 0; | ||
| 92 | for (const auto &e : log) { | ||
| 93 | if (e.first != time) { | ||
| 94 | fh << fmt::format("+{}\n", e.first - time); | ||
| 95 | time = e.first; | ||
| 96 | } | ||
| 97 | if (e.second.mask == ~(std::uint_fast32_t)0) { | ||
| 98 | fh << fmt::format("{}=0x{:x}\n", ctlreg_names[e.second.reg], e.second.value); | ||
| 99 | } else { | ||
| 100 | fh << fmt::format("{}=0x{:x}/0x{:x}\n", ctlreg_names[e.second.reg], e.second.value, e.second.mask); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | return fh; | ||
| 104 | } | ||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include <array> | 3 | #include <array> |
| 4 | #include <cstdint> | 4 | #include <cstdint> |
| 5 | #include <istream> | 5 | #include <istream> |
| 6 | #include <ostream> | ||
| 6 | 7 | ||
| 7 | #include "io/event.h" | 8 | #include "io/event.h" |
| 8 | #include "isa/isa.h" | 9 | #include "isa/isa.h" |
| @@ -19,4 +20,6 @@ struct iomodel { | |||
| 19 | 20 | ||
| 20 | std::uint64_t load_time = 0; | 21 | std::uint64_t load_time = 0; |
| 21 | void load_evt(std::istream &fh); | 22 | void load_evt(std::istream &fh); |
| 23 | |||
| 24 | std::ostream & write_evt(std::ostream &fh); | ||
| 22 | }; | 25 | }; |
| @@ -76,5 +76,8 @@ int main(int argc, const char *argv[]) { | |||
| 76 | checker.execute(); | 76 | checker.execute(); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | std::ofstream fh("trace.evt"); | ||
| 80 | system.write_evt(fh); | ||
| 81 | |||
| 79 | return 0; | 82 | return 0; |
| 80 | } | 83 | } |
