From eaa87e9fcd90c00d6261cbdb854efb7a09467f1d Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 27 Mar 2025 20:30:18 -0400 Subject: Instr, InstrDTO gets/sets, other structures required for decode --- src/sim/instr.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/sim/instr.cc (limited to 'src/sim/instr.cc') diff --git a/src/sim/instr.cc b/src/sim/instr.cc new file mode 100644 index 0000000..608b871 --- /dev/null +++ b/src/sim/instr.cc @@ -0,0 +1,30 @@ +#include "instr.h" +#include +#include + +// clang-format off +#define INIT_INSTRUCTION(type, opcode, body) \ + {type, {{opcode, [](signed int &s1, signed int &s2, signed int &s3) { \ + body; \ + }}}} +// clang-format on + +namespace instr +{ +// clang-format off +const std::map>> + // clang-format on + instr_map = { + + /* R type instructions */ + // TODO these need to be WRAPPED with a function that sets overflow. + // future note to self, if these are more than 2 lines each, you're + // doing it wrong + INIT_INSTRUCTION(0b00, 0b00001, s3 = s1 + s2), + INIT_INSTRUCTION(0b00, 0b00010, s3 = s1 - s2), + + /* I type instructions */ + + /* J type instructions */ +}; +} // namespace instr -- cgit v1.2.3