summaryrefslogtreecommitdiff
path: root/io
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-10-31 19:55:32 -0700
committerJulian Blake Kongslie2022-10-31 19:55:32 -0700
commit6b45e0f81267be6140f0f178579494ca6d24443b (patch)
treec0ed8beeb65259e3069dd04ddff54b4b16593310 /io
parentLevel-trigger on TTO_FLAG instead of edge-trigger. (diff)
downloadbiggolf-6b45e0f81267be6140f0f178579494ca6d24443b.tar.xz
Restructure a lot of the control registers
Diffstat (limited to '')
-rw-r--r--io/model.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/io/model.cpp b/io/model.cpp
index fcabbd2..fb9f62b 100644
--- a/io/model.cpp
+++ b/io/model.cpp
@@ -24,24 +24,25 @@ bool iomodel::interact(std::array<std::uint_fast32_t, NUM_CTLREGS> &ctlregs) {
24 } 24 }
25 25
26 bool interrupt = false; 26 bool interrupt = false;
27 if (ctlregs[TT_INT_ENABLE]) { 27 if (ctlregs[TT_FLAGS] & TTF_INT_ENABLE) {
28 if (ctlregs[TT_BITS] & TTI_FLAG) 28 if (ctlregs[TT_BITS] & TTI_FLAG)
29 interrupt = true; 29 interrupt = true;
30 }
31 if (ctlregs[TT_INT_ENABLE]) {
32 if (ctlregs[TT_BITS] & TTO_FLAG) 30 if (ctlregs[TT_BITS] & TTO_FLAG)
33 interrupt = true; 31 interrupt = true;
34 } 32 }
35 ctlregs[INT_PENDING] = interrupt; 33 if (interrupt)
36 interrupt = interrupt && (ctlregs[INT_ENABLE] & 1); 34 ctlregs[FLAGS] |= FLAG_INT_REQUEST;
35 else
36 ctlregs[FLAGS] &= !FLAG_INT_REQUEST;
37 interrupt = interrupt && (ctlregs[FLAGS] & FLAG_INT_ENABLE);
37 38
38 if (interrupt) { 39 if (interrupt) {
39 ctlregs[DATA_INSTRUCTION_FIELD_SAVED] = ctlregs[DATA_INSTRUCTION_FIELD_BUFFER]; 40 ctlregs[FLAGS_SAVED] = ctlregs[FLAGS];
40 ctlregs[DATA_INSTRUCTION_FIELD_BUFFER] = 0; 41 ctlregs[FLAGS] = 0;
41 ctlregs[HALTED] = 0; 42 ctlregs[HALTED] = 0;
42 ctlregs[INT_ENABLE] = 0;
43 } else { 43 } else {
44 ctlregs[INT_ENABLE] = (ctlregs[INT_ENABLE] >> 1) * 3; 44 if (ctlregs[FLAGS] & FLAG_INT_ENABLE_DELAY)
45 ctlregs[FLAGS] |= FLAG_INT_ENABLE;
45 } 46 }
46 47
47 return interrupt; 48 return interrupt;