From 7f8e314adfb8fc3b90bfea254b551157a66209b5 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sat, 5 Nov 2022 16:56:48 -0700 Subject: Add support for replaying event logs --- io/model.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'io') diff --git a/io/model.cpp b/io/model.cpp index a05c719..d332908 100644 --- a/io/model.cpp +++ b/io/model.cpp @@ -8,20 +8,20 @@ #include "io/model.h" #include "isa/isa.h" -bool iomodel::interact(std::array &ctlregs) { - auto [ebegin, eend] = log.equal_range(time); +bool iomodel::interact(std::uint64_t icount, std::array &ctlregs, bool replay) { + auto [ebegin, eend] = log.equal_range(icount); for (auto e = ebegin; e != eend; ++e) { auto &r = ctlregs[e->second.reg]; r &= ~e->second.mask; r |= e->second.value; } - ++time; - if (ctlregs[TT_BITS] & TTO_TX) { - std::cout << (char)(((ctlregs[TT_BITS] & TTO_DATA) >> TTO_DATA_SHIFT) & 0x7f) << std::flush; + if (!replay) { + std::cout << (char)(((ctlregs[TT_BITS] & TTO_DATA) >> TTO_DATA_SHIFT) & 0x7f) << std::flush; + log.emplace(icount + TT_OUTPUT_DELAY + 1, event(TT_BITS, TTO_FLAG, 0)); + } ctlregs[TT_BITS] &= ~TTO_TX & ~TTO_DATA; - log.emplace(time + TT_OUTPUT_DELAY, event(TT_BITS, TTO_FLAG, 0)); } bool interrupt = false; -- cgit v1.2.3