From 82cc71261d3d32012d33d3bebe56ca5e3b0bcdbd Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sun, 2 Oct 2022 15:32:49 -0700 Subject: Initial commit. --- isa/isa.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 isa/isa.h (limited to 'isa/isa.h') diff --git a/isa/isa.h b/isa/isa.h new file mode 100644 index 0000000..3effb5b --- /dev/null +++ b/isa/isa.h @@ -0,0 +1,44 @@ +#pragma once + +#include +#include + +#include "infra/pipetrace.h" + +enum class ctlreg { + DATA_INSTRUCTION_FIELD_BUFFER, // (df << 3) | if_buffer + DATA_INSTRUCTION_FIELD_SAVED, // (df_saved << 3) | if_saved + INT_ENABLE, // (int_enable_delay << 1) | int_enable +}; + +struct instruction_context { + infra::transaction transaction; + + // Known statically at decode time + bool need_indirect_load = false; // final_address = mem[init_address] + bool need_autoinc_store = false; // mem[init_address] += 1 + bool need_exec_load = false; // data = mem[final_address] + bool need_read_acc = false; // acc = %acc + bool need_read_link = false; // link = %link + std::optional read_ctlreg; // ctlval = %[read_ctlreg] + bool need_write_acc = false; // %acc = acc + bool need_write_link = false; // %link = link + std::optional write_ctlreg; // %[write_ctlreg] = ctlval + bool need_exec_store = false; // mem[final_address] = data + bool possibly_redirects = false; // %pc = next_pc + + std::function ef; + void execute() { ef(*this); } + + // May change over the lifetime of the instruction execution + unsigned int next_pc; // includes IF + std::optional init_address; // includes DF + std::optional final_address; // includes DF + std::optional ctlval; + std::optional data; + std::optional acc; + std::optional link; + bool halt = false; +}; + +instruction_context decode(unsigned int df, unsigned int pc, unsigned int bits); -- cgit v1.2.3