diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/id.h | 18 | ||||
-rw-r--r-- | inc/instr.h | 47 | ||||
-rw-r--r-- | inc/storage.h | 2 | ||||
-rw-r--r-- | inc/utils.h | 18 |
4 files changed, 64 insertions, 21 deletions
@@ -15,6 +15,24 @@ class ID : public Stage ID(Stage *next); Response advance(InstrDTO &i) override; + + /** + * Parse an instruction into a type, opcode, and fields. If the type is + * invalid, only the type field will be set. + * @param the resulting first field, which varies per type. To call this + * function properly, this field must contain the full instruction bytes on + * function entry. + * @param the resulting second field, which varies per type. + * @param the resulting third field, which varies per type. + * @param the resulting type. + * @param the resulting opcode. + */ + void get_instr_fields( + signed int &s1, + signed int &s2, + signed int &s3, + unsigned int &type, + unsigned int &opcode); }; #endif /* ID_D_INCLUDED */ diff --git a/inc/instr.h b/inc/instr.h index ce08685..98ecf1d 100644 --- a/inc/instr.h +++ b/inc/instr.h @@ -1,13 +1,56 @@ #ifndef INSTR_H #define INSTR_H - #include <functional> +#include <iostream> #include <map> +enum Mnemonic { + ADD, + SUB, + MUL, + QUOT, + REM, + SFTR, + SFTL, + AND, + OR, + NOT, + XOR, + ADDV, + SUBV, + MULV, + DIVV, + CMP, + CEV, + LOAD, + LOADV, + ADDI, + SUBI, + SFTRI, + SFTLI, + ANDI, + ORI, + XORI, + STORE, + STOREV, + JMP, + JRL, + JAL, + BEQ, + BGT, + BUF, + BOF, + PUSH, + POP, +}; + +std::ostream &operator<<(std::ostream &os, Mnemonic a); + namespace instr { // clang-format off -extern const std::map<int,std::map<int,std::function<void(signed int &s1, signed int &s2, signed int &s3)>>> instr_map; + extern const std::map<unsigned int, Mnemonic> mnemonic_map; + extern const std::map<Mnemonic, std::function<void(signed int &s1, signed int &s2, signed int &s3)>> instr_map; // clang-format on } // namespace instr diff --git a/inc/storage.h b/inc/storage.h index ff1fbcb..d6fa094 100644 --- a/inc/storage.h +++ b/inc/storage.h @@ -80,7 +80,7 @@ class Storage /** * The accessor currently being serviced. */ - enum Accessor requester; + Accessor requester; /** * The number of cycles until the current request is completed. */ diff --git a/inc/utils.h b/inc/utils.h index 7fed157..a375b68 100644 --- a/inc/utils.h +++ b/inc/utils.h @@ -13,24 +13,6 @@ void get_cache_fields(int address, int *tag, int *index, int *offset); /** - * Parse an instruction into a type, opcode, and fields. If the type is invalid, - * only the type field will be set. - * @param the resulting first field, which varies per type. To call this - * function properly, this field must contain the full instruction bytes on - * function entry. - * @param the resulting second field, which varies per type. - * @param the resulting third field, which varies per type. - * @param the resulting type. - * @param the resulting opcode. - */ -void get_instr_fields( - signed int &s1, - signed int &s2, - signed int &s3, - unsigned int &type, - unsigned int &opcode); - -/** * Formats a string using snprintf. * @param an object that represents the format string * @param arguments to be formatted |