From 62517a8004419591dd031faebb7a9a4827bc002a Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Tue, 1 Nov 2022 10:08:59 -0700 Subject: Support writing a trace at the end of execution. --- io/model.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'io/model.cpp') 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 @@ #include #include #include +#include #include #include @@ -85,3 +86,19 @@ void iomodel::load_evt(std::istream &fh) { } } } + +std::ostream & iomodel::write_evt(std::ostream &fh) { + std::uint64_t time = 0; + for (const auto &e : log) { + if (e.first != time) { + fh << fmt::format("+{}\n", e.first - time); + time = e.first; + } + if (e.second.mask == ~(std::uint_fast32_t)0) { + fh << fmt::format("{}=0x{:x}\n", ctlreg_names[e.second.reg], e.second.value); + } else { + fh << fmt::format("{}=0x{:x}/0x{:x}\n", ctlreg_names[e.second.reg], e.second.value, e.second.mask); + } + } + return fh; +} -- cgit v1.2.3