diff options
| author | Julian Blake Kongslie | 2022-11-01 10:08:59 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-11-01 10:08:59 -0700 |
| commit | 62517a8004419591dd031faebb7a9a4827bc002a (patch) | |
| tree | 14d9b6dae5474fd5d42b78da12b3974a2bcd0584 /io | |
| parent | Implemented the remaining instructions required for echo_optimal. (diff) | |
| download | biggolf-62517a8004419591dd031faebb7a9a4827bc002a.tar.xz | |
Support writing a trace at the end of execution.
Diffstat (limited to 'io')
| -rw-r--r-- | io/model.cpp | 17 | ||||
| -rw-r--r-- | io/model.h | 3 |
2 files changed, 20 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 | }; |
