summaryrefslogtreecommitdiff
path: root/io
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-11-05 16:56:48 -0700
committerJulian Blake Kongslie2022-11-05 16:56:48 -0700
commit7f8e314adfb8fc3b90bfea254b551157a66209b5 (patch)
treecd0cae5cb64f9e87c6ea80feb774d1839e16814e /io
parentStricter and more accurate decoder for RMF instruction (diff)
downloadbiggolf-7f8e314adfb8fc3b90bfea254b551157a66209b5.tar.xz
Add support for replaying event logs
Diffstat (limited to '')
-rw-r--r--io/model.cpp12
1 files changed, 6 insertions, 6 deletions
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 @@
8#include "io/model.h" 8#include "io/model.h"
9#include "isa/isa.h" 9#include "isa/isa.h"
10 10
11bool iomodel::interact(std::array<std::uint_fast32_t, NUM_CTLREGS> &ctlregs) { 11bool iomodel::interact(std::uint64_t icount, std::array<std::uint_fast32_t, NUM_CTLREGS> &ctlregs, bool replay) {
12 auto [ebegin, eend] = log.equal_range(time); 12 auto [ebegin, eend] = log.equal_range(icount);
13 for (auto e = ebegin; e != eend; ++e) { 13 for (auto e = ebegin; e != eend; ++e) {
14 auto &r = ctlregs[e->second.reg]; 14 auto &r = ctlregs[e->second.reg];
15 r &= ~e->second.mask; 15 r &= ~e->second.mask;
16 r |= e->second.value; 16 r |= e->second.value;
17 } 17 }
18 18
19 ++time;
20
21 if (ctlregs[TT_BITS] & TTO_TX) { 19 if (ctlregs[TT_BITS] & TTO_TX) {
22 std::cout << (char)(((ctlregs[TT_BITS] & TTO_DATA) >> TTO_DATA_SHIFT) & 0x7f) << std::flush; 20 if (!replay) {
21 std::cout << (char)(((ctlregs[TT_BITS] & TTO_DATA) >> TTO_DATA_SHIFT) & 0x7f) << std::flush;
22 log.emplace(icount + TT_OUTPUT_DELAY + 1, event(TT_BITS, TTO_FLAG, 0));
23 }
23 ctlregs[TT_BITS] &= ~TTO_TX & ~TTO_DATA; 24 ctlregs[TT_BITS] &= ~TTO_TX & ~TTO_DATA;
24 log.emplace(time + TT_OUTPUT_DELAY, event(TT_BITS, TTO_FLAG, 0));
25 } 25 }
26 26
27 bool interrupt = false; 27 bool interrupt = false;