From 68bdebd8cae39c30acc384664faa136aeaa9bb84 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sat, 5 Nov 2022 16:59:17 -0700 Subject: Add initial uarch model --- isa/checker.cpp | 97 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 48 insertions(+), 49 deletions(-) (limited to 'isa/checker.cpp') 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 @@ #include "isa/checker.h" #include "isa/isa.h" -void checker::execute() { - bool interrupt = system.interact(ctlregs); - - if (ctlregs[HALTED]) - return; - - inst = decode(ctlregs[FLAGS], - pc, - mem.fetch(pc), - interrupt); - auto next_pc = inst.next_pc; - - if (inst.need_indirect_load) { - auto addr = mem.fetch(inst.init_address.value()); - if (inst.need_autoinc_store) { - addr = (addr + 1) & 07777; - mem.store(*inst.init_address, addr); +void funcchecker::execute() { + if (!ctlregs[HALTED]) { + inst = decode(ctlregs[FLAGS], + pc, + mem.fetch(pc), + interrupt); + auto next_pc = inst.next_pc; + + if (inst.need_indirect_load) { + auto addr = mem.fetch(inst.init_address.value()); + if (inst.need_autoinc_store) { + addr = (addr + 1) & 07777; + mem.store(*inst.init_address, addr); + } + auto df = (ctlregs[FLAGS] & FLAG_DF) >> FLAG_DF_SHIFT; + inst.final_address = (df << 12) | addr; + } else { + assert(!inst.need_autoinc_store); } - auto df = (ctlregs[FLAGS] & FLAG_DF) >> FLAG_DF_SHIFT; - inst.final_address = (df << 12) | addr; - } else { - assert(!inst.need_autoinc_store); + + if (inst.need_exec_load) + inst.data = mem.fetch(inst.final_address.value()); + + if (inst.need_read_acc) + inst.acc = acc; + if (inst.need_read_link) + inst.link = link; + if (inst.need_read_mq) + inst.mq = mq; + if (inst.read_ctlreg.has_value()) + inst.ctlval = ctlregs[*inst.read_ctlreg]; + + inst.execute(); + + if (inst.need_write_acc) + acc = inst.acc.value(); + if (inst.need_write_link) + link = inst.link.value(); + if (inst.need_write_mq) + mq = inst.mq.value(); + if (inst.write_ctlreg.has_value()) + ctlregs[*inst.write_ctlreg] = inst.ctlval.value(); + + if (inst.need_exec_store) + mem.store(inst.final_address.value(), inst.data.value()); + + assert(inst.next_pc == next_pc || inst.possibly_redirects); + pc = inst.next_pc; } - if (inst.need_exec_load) - inst.data = mem.fetch(inst.final_address.value()); - - if (inst.need_read_acc) - inst.acc = acc; - if (inst.need_read_link) - inst.link = link; - if (inst.need_read_mq) - inst.mq = mq; - if (inst.read_ctlreg.has_value()) - inst.ctlval = ctlregs[*inst.read_ctlreg]; - - inst.execute(); - - if (inst.need_write_acc) - acc = inst.acc.value(); - if (inst.need_write_link) - link = inst.link.value(); - if (inst.need_write_mq) - mq = inst.mq.value(); - if (inst.write_ctlreg.has_value()) - ctlregs[*inst.write_ctlreg] = inst.ctlval.value(); - - if (inst.need_exec_store) - mem.store(inst.final_address.value(), inst.data.value()); - - assert(inst.next_pc == next_pc || inst.possibly_redirects); - pc = inst.next_pc; + interrupt = system.interact(icount++, ctlregs, true); } -- cgit v1.2.3