summaryrefslogtreecommitdiff
path: root/isa/checker.cpp
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-11-05 16:59:17 -0700
committerJulian Blake Kongslie2022-11-05 16:59:31 -0700
commit68bdebd8cae39c30acc384664faa136aeaa9bb84 (patch)
tree4b0c489accd2eb10af6bc359c9ee0d4b22af64ff /isa/checker.cpp
parentSupport for more line formats in evt reader (diff)
downloadbiggolf-68bdebd8cae39c30acc384664faa136aeaa9bb84.tar.xz
Add initial uarch model
Diffstat (limited to 'isa/checker.cpp')
-rw-r--r--isa/checker.cpp87
1 files changed, 43 insertions, 44 deletions
diff --git a/isa/checker.cpp b/isa/checker.cpp
index c6ab161..70b0f88 100644
--- a/isa/checker.cpp
+++ b/isa/checker.cpp
@@ -3,56 +3,55 @@
3#include "isa/checker.h" 3#include "isa/checker.h"
4#include "isa/isa.h" 4#include "isa/isa.h"
5 5
6void checker::execute() { 6void funcchecker::execute() {
7 bool interrupt = system.interact(ctlregs); 7 if (!ctlregs[HALTED]) {
8 inst = decode(ctlregs[FLAGS],
9 pc,
10 mem.fetch(pc),
11 interrupt);
12 auto next_pc = inst.next_pc;
8 13
9 if (ctlregs[HALTED]) 14 if (inst.need_indirect_load) {
10 return; 15 auto addr = mem.fetch(inst.init_address.value());
11 16 if (inst.need_autoinc_store) {
12 inst = decode(ctlregs[FLAGS], 17 addr = (addr + 1) & 07777;
13 pc, 18 mem.store(*inst.init_address, addr);
14 mem.fetch(pc), 19 }
15 interrupt); 20 auto df = (ctlregs[FLAGS] & FLAG_DF) >> FLAG_DF_SHIFT;
16 auto next_pc = inst.next_pc; 21 inst.final_address = (df << 12) | addr;
17 22 } else {
18 if (inst.need_indirect_load) { 23 assert(!inst.need_autoinc_store);
19 auto addr = mem.fetch(inst.init_address.value());
20 if (inst.need_autoinc_store) {
21 addr = (addr + 1) & 07777;
22 mem.store(*inst.init_address, addr);
23 } 24 }
24 auto df = (ctlregs[FLAGS] & FLAG_DF) >> FLAG_DF_SHIFT;
25 inst.final_address = (df << 12) | addr;
26 } else {
27 assert(!inst.need_autoinc_store);
28 }
29 25
30 if (inst.need_exec_load) 26 if (inst.need_exec_load)
31 inst.data = mem.fetch(inst.final_address.value()); 27 inst.data = mem.fetch(inst.final_address.value());
32 28
33 if (inst.need_read_acc) 29 if (inst.need_read_acc)
34 inst.acc = acc; 30 inst.acc = acc;
35 if (inst.need_read_link) 31 if (inst.need_read_link)
36 inst.link = link; 32 inst.link = link;
37 if (inst.need_read_mq) 33 if (inst.need_read_mq)
38 inst.mq = mq; 34 inst.mq = mq;
39 if (inst.read_ctlreg.has_value()) 35 if (inst.read_ctlreg.has_value())
40 inst.ctlval = ctlregs[*inst.read_ctlreg]; 36 inst.ctlval = ctlregs[*inst.read_ctlreg];
41 37
42 inst.execute(); 38 inst.execute();
43 39
44 if (inst.need_write_acc) 40 if (inst.need_write_acc)
45 acc = inst.acc.value(); 41 acc = inst.acc.value();
46 if (inst.need_write_link) 42 if (inst.need_write_link)
47 link = inst.link.value(); 43 link = inst.link.value();
48 if (inst.need_write_mq) 44 if (inst.need_write_mq)
49 mq = inst.mq.value(); 45 mq = inst.mq.value();
50 if (inst.write_ctlreg.has_value()) 46 if (inst.write_ctlreg.has_value())
51 ctlregs[*inst.write_ctlreg] = inst.ctlval.value(); 47 ctlregs[*inst.write_ctlreg] = inst.ctlval.value();
52 48
53 if (inst.need_exec_store) 49 if (inst.need_exec_store)
54 mem.store(inst.final_address.value(), inst.data.value()); 50 mem.store(inst.final_address.value(), inst.data.value());
51
52 assert(inst.next_pc == next_pc || inst.possibly_redirects);
53 pc = inst.next_pc;
54 }
55 55
56 assert(inst.next_pc == next_pc || inst.possibly_redirects); 56 interrupt = system.interact(icount++, ctlregs, true);
57 pc = inst.next_pc;
58} 57}