From d4de41da0bd70a51aeb26b3d1a8d70bd59b3447e Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sat, 15 Oct 2022 14:30:18 -0700 Subject: Add MQ register support. --- isa/checker.cpp | 4 ++++ isa/checker.h | 1 + isa/decode.cpp | 19 +++++++++++++++++++ isa/isa.h | 3 +++ 4 files changed, 27 insertions(+) (limited to 'isa') diff --git a/isa/checker.cpp b/isa/checker.cpp index 05b59a9..1919bd1 100644 --- a/isa/checker.cpp +++ b/isa/checker.cpp @@ -28,6 +28,8 @@ void checker::execute() { 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(); @@ -35,6 +37,8 @@ void checker::execute() { 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) diff --git a/isa/checker.h b/isa/checker.h index 1ea572b..d70997f 100644 --- a/isa/checker.h +++ b/isa/checker.h @@ -38,6 +38,7 @@ struct funcmem { struct checker { unsigned int acc = 0; unsigned int link = 0; + unsigned int mq = 0; unsigned int pc = 00200; std::array ctlregs; instruction_context inst; diff --git a/isa/decode.cpp b/isa/decode.cpp index 1d46375..1979982 100644 --- a/isa/decode.cpp +++ b/isa/decode.cpp @@ -155,6 +155,25 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit if (skip) ctx.next_pc = (ctx.next_pc & 070000) | ((ctx.next_pc + 1) & 007777); }; + } else if ((bits & 0401) == 0401) { + bool cla = bits & 0200; + bool mqa = bits & 0100; + bool mql = bits & 0020; + bool extended_arith = bits & 0056; + inst.need_read_acc = mqa || mql; + inst.need_read_mq = mqa; + inst.need_write_acc = cla || mqa; + inst.need_write_mq = mql; + inst.ef = [cla, mqa, mql, extended_arith](auto &ctx) { + assert(!extended_arith); + if (cla) ctx.acc = 0; + auto new_acc = ctx.acc; + auto new_mq = ctx.mq; + if (mqa) new_acc = ctx.acc.value() | ctx.mq.value(); + if (mql) new_mq = ctx.acc.value(); + ctx.acc = new_acc; + ctx.mq = new_mq; + }; } else { assert(false); } diff --git a/isa/isa.h b/isa/isa.h index 3b8220e..11a8db2 100644 --- a/isa/isa.h +++ b/isa/isa.h @@ -22,9 +22,11 @@ struct instruction_context { bool need_exec_load = false; // data = mem[final_address] bool need_read_acc = false; // acc = %acc bool need_read_link = false; // link = %link + bool need_read_mq = false; // mq = %mq std::optional read_ctlreg; // ctlval = %[read_ctlreg] bool need_write_acc = false; // %acc = acc bool need_write_link = false; // %link = link + bool need_write_mq = false; // %mq = mq std::optional write_ctlreg; // %[write_ctlreg] = ctlval bool need_exec_store = false; // mem[final_address] = data bool possibly_redirects = false; // %pc = next_pc @@ -40,6 +42,7 @@ struct instruction_context { std::optional data; std::optional acc; std::optional link; + std::optional mq; bool halt = false; }; -- cgit v1.2.3