From eb3fd68203fee7c63245c702914c2acd3332d65a Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Thu, 22 Sep 2022 11:29:07 -0700 Subject: Initial commit. --- inst.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 inst.h (limited to 'inst.h') diff --git a/inst.h b/inst.h new file mode 100644 index 0000000..15ae9d7 --- /dev/null +++ b/inst.h @@ -0,0 +1,56 @@ +#pragma once + +#include + +#include "infra/pipetrace.h" + +struct inst { + infra::transaction transaction; + unsigned int generation; + unsigned int size = 0; + std::uint64_t linear_next_pc; + std::optional predicted_next_pc; + std::uint64_t field[4] = {}; + std::optional result; +}; + +constexpr unsigned int OPCODE = 0; +constexpr unsigned int FLAGS_DST = 1; +constexpr unsigned int SRC1 = 2; +constexpr unsigned int SRC2 = 3; + +constexpr std::uint64_t FLAG_IMM1 = 1 << 4; +constexpr std::uint64_t FLAG_IMM2 = 1 << 5; + +enum { + OP_JUMP_ABS_IF_ZERO, + OP_JUMP_ABS_IF_NONZERO, + OP_EMIT, + OP_ADD, + OP_LOAD, + OP_STORE, +}; + +struct decodebyte { + std::uint8_t bits:4; + std::uint8_t field:2; + std::uint8_t invert:1; + std::uint8_t hold:1; +} __attribute__((packed)); + +// 0x - shift opcode and issue +// 1x - shift flagsdst and issue +// 2x - shift src1 and issue +// 3x - shift src2 and issue +// 4x - invert+shift opcode and issue +// 5x - invert+shift flagsdst and issue +// 6x - invert+shift src1 and issue +// 7x - invert+shift src2 and issue +// 8x - shift opcode +// 9x - shift flagsdst +// Ax - shift src1 +// Bx - shift src2 +// Cx - invert+shift opcode +// Dx - invert+shift flagsdst +// Ex - invert+shift src1 +// Fx - invert+shift src2 -- cgit v1.2.3