diff options
| author | Julian Blake Kongslie | 2022-10-02 15:32:49 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-10-02 15:32:49 -0700 |
| commit | 82cc71261d3d32012d33d3bebe56ca5e3b0bcdbd (patch) | |
| tree | f1358a38d244e27d9740e914c54328d753cb0b4f /isa/isa.h | |
| download | biggolf-82cc71261d3d32012d33d3bebe56ca5e3b0bcdbd.tar.xz | |
Initial commit.
Diffstat (limited to 'isa/isa.h')
| -rw-r--r-- | isa/isa.h | 44 |
1 files changed, 44 insertions, 0 deletions
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 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <functional> | ||
| 4 | #include <optional> | ||
| 5 | |||
| 6 | #include "infra/pipetrace.h" | ||
| 7 | |||
| 8 | enum class ctlreg { | ||
| 9 | DATA_INSTRUCTION_FIELD_BUFFER, // (df << 3) | if_buffer | ||
| 10 | DATA_INSTRUCTION_FIELD_SAVED, // (df_saved << 3) | if_saved | ||
| 11 | INT_ENABLE, // (int_enable_delay << 1) | int_enable | ||
| 12 | }; | ||
| 13 | |||
| 14 | struct instruction_context { | ||
| 15 | infra::transaction transaction; | ||
| 16 | |||
| 17 | // Known statically at decode time | ||
| 18 | bool need_indirect_load = false; // final_address = mem[init_address] | ||
| 19 | bool need_autoinc_store = false; // mem[init_address] += 1 | ||
| 20 | bool need_exec_load = false; // data = mem[final_address] | ||
| 21 | bool need_read_acc = false; // acc = %acc | ||
| 22 | bool need_read_link = false; // link = %link | ||
| 23 | std::optional<ctlreg> read_ctlreg; // ctlval = %[read_ctlreg] | ||
| 24 | bool need_write_acc = false; // %acc = acc | ||
| 25 | bool need_write_link = false; // %link = link | ||
| 26 | std::optional<ctlreg> write_ctlreg; // %[write_ctlreg] = ctlval | ||
| 27 | bool need_exec_store = false; // mem[final_address] = data | ||
| 28 | bool possibly_redirects = false; // %pc = next_pc | ||
| 29 | |||
| 30 | std::function<void(instruction_context &ctx)> ef; | ||
| 31 | void execute() { ef(*this); } | ||
| 32 | |||
| 33 | // May change over the lifetime of the instruction execution | ||
| 34 | unsigned int next_pc; // includes IF | ||
| 35 | std::optional<unsigned int> init_address; // includes DF | ||
| 36 | std::optional<unsigned int> final_address; // includes DF | ||
| 37 | std::optional<unsigned int> ctlval; | ||
| 38 | std::optional<unsigned int> data; | ||
| 39 | std::optional<unsigned int> acc; | ||
| 40 | std::optional<bool> link; | ||
| 41 | bool halt = false; | ||
| 42 | }; | ||
| 43 | |||
| 44 | instruction_context decode(unsigned int df, unsigned int pc, unsigned int bits); | ||
