summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-10-31 21:23:09 -0700
committerJulian Blake Kongslie2022-10-31 21:23:09 -0700
commitec5b362c3cda195178697192ba5a31643e5c358d (patch)
tree949e8d4368892a4799a36a01d92293b346a9655a
parentFix trivial typo (diff)
downloadbiggolf-ec5b362c3cda195178697192ba5a31643e5c358d.tar.xz
Fix FLAGS bit handling by IO model
Diffstat (limited to '')
-rw-r--r--io/model.cpp8
-rw-r--r--isa/isa.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/io/model.cpp b/io/model.cpp
index fb9f62b..79bc511 100644
--- a/io/model.cpp
+++ b/io/model.cpp
@@ -33,16 +33,16 @@ bool iomodel::interact(std::array<std::uint_fast32_t, NUM_CTLREGS> &ctlregs) {
33 if (interrupt) 33 if (interrupt)
34 ctlregs[FLAGS] |= FLAG_INT_REQUEST; 34 ctlregs[FLAGS] |= FLAG_INT_REQUEST;
35 else 35 else
36 ctlregs[FLAGS] &= !FLAG_INT_REQUEST; 36 ctlregs[FLAGS] &= ~FLAG_INT_REQUEST;
37 interrupt = interrupt && (ctlregs[FLAGS] & FLAG_INT_ENABLE); 37 interrupt = interrupt && (ctlregs[FLAGS] & FLAG_INT_ENABLE);
38 38
39 if (ctlregs[FLAGS] & FLAG_INT_ENABLE_DELAY)
40 ctlregs[FLAGS] |= FLAG_INT_ENABLE;
41
39 if (interrupt) { 42 if (interrupt) {
40 ctlregs[FLAGS_SAVED] = ctlregs[FLAGS]; 43 ctlregs[FLAGS_SAVED] = ctlregs[FLAGS];
41 ctlregs[FLAGS] = 0; 44 ctlregs[FLAGS] = 0;
42 ctlregs[HALTED] = 0; 45 ctlregs[HALTED] = 0;
43 } else {
44 if (ctlregs[FLAGS] & FLAG_INT_ENABLE_DELAY)
45 ctlregs[FLAGS] |= FLAG_INT_ENABLE;
46 } 46 }
47 47
48 return interrupt; 48 return interrupt;
diff --git a/isa/isa.h b/isa/isa.h
index 71f852e..8156c08 100644
--- a/isa/isa.h
+++ b/isa/isa.h
@@ -36,7 +36,7 @@ static constexpr std::uint_fast32_t FLAG_INT_ENABLE = 1 << 7;
36static constexpr std::uint_fast32_t FLAG_INT_INHIBIT = 1 << 8; 36static constexpr std::uint_fast32_t FLAG_INT_INHIBIT = 1 << 8;
37static constexpr std::uint_fast32_t FLAG_INT_REQUEST = 1 << 9; 37static constexpr std::uint_fast32_t FLAG_INT_REQUEST = 1 << 9;
38static constexpr std::uint_fast32_t FLAG_GREATER_THAN = 1 << 10; 38static constexpr std::uint_fast32_t FLAG_GREATER_THAN = 1 << 10;
39static constexpr std::uint_fast32_t FLAG_INT_ENABLE_DELAY = 1 << 12; 39static constexpr std::uint_fast32_t FLAG_INT_ENABLE_DELAY = 1 << 12; // n.b. this is not a "visible" flag
40 40
41// TT_BITS 41// TT_BITS
42static constexpr std::uint_fast32_t TTI_FLAG = 1 << 0; 42static constexpr std::uint_fast32_t TTI_FLAG = 1 << 0;