diff options
Diffstat (limited to 'isa/checker.cpp')
| -rw-r--r-- | isa/checker.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/isa/checker.cpp b/isa/checker.cpp index 1919bd1..7bca5c9 100644 --- a/isa/checker.cpp +++ b/isa/checker.cpp | |||
| @@ -4,16 +4,17 @@ | |||
| 4 | #include "isa/isa.h" | 4 | #include "isa/isa.h" |
| 5 | 5 | ||
| 6 | void checker::execute() { | 6 | void checker::execute() { |
| 7 | assert(!halted); | 7 | bool interrupt = system.interact(ctlregs); |
| 8 | auto int_enable_delay = ctlregs[INT_ENABLE] >> 1; | 8 | |
| 9 | if (ctlregs[INT_ENABLE] & 1) { | 9 | if (ctlregs[HALTED]) |
| 10 | // check for interrupt | 10 | return; |
| 11 | } | 11 | |
| 12 | ctlregs[INT_ENABLE] = (int_enable_delay << 1) | int_enable_delay; | ||
| 13 | inst = decode(ctlregs[DATA_INSTRUCTION_FIELD_BUFFER], | 12 | inst = decode(ctlregs[DATA_INSTRUCTION_FIELD_BUFFER], |
| 14 | pc, | 13 | pc, |
| 15 | mem.fetch(pc)); | 14 | mem.fetch(pc), |
| 15 | interrupt); | ||
| 16 | auto next_pc = inst.next_pc; | 16 | auto next_pc = inst.next_pc; |
| 17 | |||
| 17 | if (inst.need_indirect_load) { | 18 | if (inst.need_indirect_load) { |
| 18 | auto addr = mem.fetch(inst.init_address.value()); | 19 | auto addr = mem.fetch(inst.init_address.value()); |
| 19 | if (inst.need_autoinc_store) | 20 | if (inst.need_autoinc_store) |
| @@ -22,8 +23,10 @@ void checker::execute() { | |||
| 22 | } else { | 23 | } else { |
| 23 | assert(!inst.need_autoinc_store); | 24 | assert(!inst.need_autoinc_store); |
| 24 | } | 25 | } |
| 26 | |||
| 25 | if (inst.need_exec_load) | 27 | if (inst.need_exec_load) |
| 26 | inst.data = mem.fetch(inst.final_address.value()); | 28 | inst.data = mem.fetch(inst.final_address.value()); |
| 29 | |||
| 27 | if (inst.need_read_acc) | 30 | if (inst.need_read_acc) |
| 28 | inst.acc = acc; | 31 | inst.acc = acc; |
| 29 | if (inst.need_read_link) | 32 | if (inst.need_read_link) |
| @@ -32,7 +35,9 @@ void checker::execute() { | |||
| 32 | inst.mq = mq; | 35 | inst.mq = mq; |
| 33 | if (inst.read_ctlreg.has_value()) | 36 | if (inst.read_ctlreg.has_value()) |
| 34 | inst.ctlval = ctlregs[*inst.read_ctlreg]; | 37 | inst.ctlval = ctlregs[*inst.read_ctlreg]; |
| 38 | |||
| 35 | inst.execute(); | 39 | inst.execute(); |
| 40 | |||
| 36 | if (inst.need_write_acc) | 41 | if (inst.need_write_acc) |
| 37 | acc = inst.acc.value(); | 42 | acc = inst.acc.value(); |
| 38 | if (inst.need_write_link) | 43 | if (inst.need_write_link) |
| @@ -41,9 +46,10 @@ void checker::execute() { | |||
| 41 | mq = inst.mq.value(); | 46 | mq = inst.mq.value(); |
| 42 | if (inst.write_ctlreg.has_value()) | 47 | if (inst.write_ctlreg.has_value()) |
| 43 | ctlregs[*inst.write_ctlreg] = inst.ctlval.value(); | 48 | ctlregs[*inst.write_ctlreg] = inst.ctlval.value(); |
| 49 | |||
| 44 | if (inst.need_exec_store) | 50 | if (inst.need_exec_store) |
| 45 | mem.store(inst.final_address.value(), inst.data.value()); | 51 | mem.store(inst.final_address.value(), inst.data.value()); |
| 52 | |||
| 46 | assert(inst.next_pc == next_pc || inst.possibly_redirects); | 53 | assert(inst.next_pc == next_pc || inst.possibly_redirects); |
| 47 | pc = inst.next_pc; | 54 | pc = inst.next_pc; |
| 48 | halted = inst.halt; | ||
| 49 | } | 55 | } |
