diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/accessor.h | 3 | ||||
-rw-r--r-- | inc/ex.h | 7 | ||||
-rw-r--r-- | inc/id.h | 7 | ||||
-rw-r--r-- | inc/if.h | 14 | ||||
-rw-r--r-- | inc/instr.h | 14 | ||||
-rw-r--r-- | inc/instrDTO.h | 60 | ||||
-rw-r--r-- | inc/mm.h | 7 | ||||
-rw-r--r-- | inc/stage.h | 9 | ||||
-rw-r--r-- | inc/wb.h | 7 |
9 files changed, 114 insertions, 14 deletions
diff --git a/inc/accessor.h b/inc/accessor.h index fb4999d..eb56785 100644 --- a/inc/accessor.h +++ b/inc/accessor.h @@ -4,7 +4,10 @@ enum Accessor { IDLE, + WRITE, MEM, + EXEC, + DCDE, FETCH, L1CACHE, SIDE, @@ -7,7 +7,12 @@ class EX : public Stage { public: - using Stage::Stage; + /** + * Constructor. + * @param The next stage in the pipeline. + * @return A newly allocated EX object. + */ + EX(Stage *next); Response advance(InstrDTO &i) override; }; @@ -7,7 +7,12 @@ class ID : public Stage { public: - using Stage::Stage; + /** + * Constructor. + * @param The next stage in the pipeline. + * @return A newly allocated ID object. + */ + ID(Stage *next); Response advance(InstrDTO &i) override; }; @@ -1,5 +1,6 @@ #ifndef IF_H #define IF_H +#include "accessor.h" #include "instrDTO.h" #include "response.h" #include "stage.h" @@ -7,15 +8,14 @@ class IF : public Stage { public: - using Stage::Stage; - - Response advance(InstrDTO &i) override; - - private: /** - * The name this pipeline stages uses to access storage. + * Constructor. + * @param The next stage in the pipeline. + * @return A newly allocated IF object. */ - const Accessor id = FETCH; + IF(Stage *next); + + Response advance(InstrDTO &i) override; }; #endif /* IF_H_INCLUDED */ diff --git a/inc/instr.h b/inc/instr.h new file mode 100644 index 0000000..ce08685 --- /dev/null +++ b/inc/instr.h @@ -0,0 +1,14 @@ +#ifndef INSTR_H +#define INSTR_H + +#include <functional> +#include <map> + +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; +// clang-format on +} // namespace instr + +#endif /* INSTR_H_INCLUDED */ diff --git a/inc/instrDTO.h b/inc/instrDTO.h index 86cec05..7f2c688 100644 --- a/inc/instrDTO.h +++ b/inc/instrDTO.h @@ -1,5 +1,7 @@ #ifndef INSTRDTO_H #define INSTRDTO_H +#include <string> +#include <functional> class InstrDTO { @@ -15,25 +17,81 @@ class InstrDTO */ int get_if_cycle(); /** + * @return id_cycle + */ + int get_id_cycle(); + /** * @return instr_bits */ signed int get_instr_bits(); + /** + * @return s1 + */ + signed int get_s1(); + /** + * @return s2 + */ + signed int get_s2(); + /** + * @return s3 + */ + signed int get_s3(); + /** + * @return the string representation of oper. + */ + std::string get_oper_name(); /** * @param if_cycle */ void set_if_cycle(int); /** + * @param id_cycle + */ + void set_id_cycle(int); + /** * @param instr_bits */ void set_instr_bits(signed int); + /** + * @param s1 + */ + void set_s1(signed int); + /** + * @param s2 + */ + void set_s2(signed int); + /** + * @param s3 + */ + void set_s3(signed int); private: /** - * The current clock cycle. + * The clock cycle this instruction finished being fetched. */ int if_cycle; + /** + * The clock cycle this instruction finished being identified. + */ + int id_cycle; + /** + * The raw bits encoding the instruction. + */ signed int instr_bits; + /** + * Slots in this instruction, for storing temporary registers, immediates, + * or other. + * Some instruction types may use these differently. + * The `oper` function is in charge of knowing how to parse these. + */ + signed int s1; + signed int s2; + signed int s3; + /** + * The operation to be conducted during the execute phase. + */ + std::function<void()> instr; }; #endif /* INSTRDTO_H_INCLUDED */ @@ -7,7 +7,12 @@ class MM : public Stage { public: - using Stage::Stage; + /** + * Constructor. + * @param The next stage in the pipeline. + * @return A newly allocated MM object. + */ + MM(Stage *next); Response advance(InstrDTO &i) override; }; diff --git a/inc/stage.h b/inc/stage.h index ac810a9..04de475 100644 --- a/inc/stage.h +++ b/inc/stage.h @@ -4,6 +4,7 @@ #include "instrDTO.h" #include "response.h" #include "storage.h" +#include "accessor.h" #include <array> class Stage @@ -27,13 +28,17 @@ class Stage protected: /** + * The name of the pipeline stage. + */ + Accessor id; + /** * The shared pool of general-purpose integer registers. */ - static std::array<int, GPR_NUM> gprs; + static std::array<signed int, GPR_NUM> gprs; /** * The address of the currently executing instruction. */ - static int pc; + static unsigned int pc; /** * A pointer to the next stage in the pipeline. */ @@ -7,7 +7,12 @@ class WB : public Stage { public: - using Stage::Stage; + /** + * Constructor. + * @param The next stage in the pipeline. + * @return A newly allocated WB object. + */ + WB(Stage *next); Response advance(InstrDTO &i) override; }; |