From a59407a215d6112c2e20b1a746b33742209e5f87 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sun, 16 Oct 2022 16:24:49 -0700 Subject: Support for log-based event model --- isa/decode.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'isa/decode.cpp') diff --git a/isa/decode.cpp b/isa/decode.cpp index 1979982..d24632b 100644 --- a/isa/decode.cpp +++ b/isa/decode.cpp @@ -2,15 +2,21 @@ #include "isa/isa.h" -instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bits) +instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bits, bool interrupt) { - instruction_context inst; - auto df = dfifb >> 3; auto ifb = dfifb & 00007; + instruction_context inst; inst.next_pc = (pc & ~07777) | ((pc + 1) & 07777); + if (interrupt) { + bits = 04000; + assert(df == 0); + assert(ifb == 0); + inst.next_pc = pc; + } + switch (bits >> 9) { case 0: // AND inst.need_exec_load = true; @@ -121,6 +127,8 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit inst.need_read_acc = sma || sza; inst.need_read_link = snl; inst.need_write_acc = cla; + if (hlt) + inst.write_ctlreg = HALTED; inst.possibly_redirects = true; inst.ef = [cla, sma, sza, snl, osr, hlt](auto &ctx) { bool skip = false; @@ -129,7 +137,7 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit if (snl && ctx.link.value()) skip = true; if (cla) ctx.acc = 0; assert(!osr); - if (hlt) ctx.halt = true; + if (hlt) ctx.ctlval = 1; if (skip) ctx.next_pc = (ctx.next_pc & 070000) | ((ctx.next_pc + 1) & 007777); }; @@ -143,6 +151,8 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit inst.need_read_acc = spa || sna; inst.need_read_link = szl; inst.need_write_acc = cla; + if (hlt) + inst.write_ctlreg = HALTED; inst.possibly_redirects = true; inst.ef = [cla, spa, sna, szl, osr, hlt](auto &ctx) { bool skip = true; @@ -151,7 +161,7 @@ instruction_context decode(unsigned int dfifb, unsigned int pc, unsigned int bit if (szl && ctx.link.value()) skip = false; if (cla) ctx.acc = 0; assert(!osr); - if (hlt) ctx.halt = true; + if (hlt) ctx.ctlval = 1; if (skip) ctx.next_pc = (ctx.next_pc & 070000) | ((ctx.next_pc + 1) & 007777); }; -- cgit v1.2.3