diff options
author | Karel Kočí <cynerd@email.cz> | 2017-11-19 21:23:04 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-11-19 21:23:04 +0100 |
commit | f0ad502e4651243d6a96194b3393bd460c0f7fc9 (patch) | |
tree | 4f912c24b5943bd93b5a3378df75f9611de6779b /qtmips_machine/instruction.h | |
parent | 2c6562fa78e884d66b8c2a306f020101e8803f2e (diff) | |
download | qtmips-f0ad502e4651243d6a96194b3393bd460c0f7fc9.tar.gz qtmips-f0ad502e4651243d6a96194b3393bd460c0f7fc9.tar.bz2 qtmips-f0ad502e4651243d6a96194b3393bd460c0f7fc9.zip |
Another huge pile of work for about two months
Well I should commit every change instead of this madness. I am not
documenting changes as all this is just improvements and implementation
progression.
Diffstat (limited to 'qtmips_machine/instruction.h')
-rw-r--r-- | qtmips_machine/instruction.h | 66 |
1 files changed, 16 insertions, 50 deletions
diff --git a/qtmips_machine/instruction.h b/qtmips_machine/instruction.h index 8c5ede9..3b76fba 100644 --- a/qtmips_machine/instruction.h +++ b/qtmips_machine/instruction.h @@ -2,64 +2,30 @@ #define INSTRUCTION_H #include <qstring.h> -#include <qvector.h> -#include "registers.h" -#include "memory.h" - -enum InstructionState { - IS_FETCH, - IS_DECODE, - IS_EXECUTE, - IS_MEMORY, - IS_WRITE_BACK, -}; class Instruction { public: - Instruction(); + Instruction(std::uint32_t inst); + Instruction(std::uint8_t opcode, std::uint8_t rs, std::uint8_t rt, std::uint8_t rd, std::uint8_t shamt, std::uint8_t funct); // Type R + Instruction(std::uint8_t opcode, std::uint8_t rs, std::uint8_t rt, std::uint16_t immediate); // Type I + Instruction(std::uint8_t opcode, std::uint32_t address); // Type J - // TODO return some info for forwarding, stall, flush - virtual void decode(Registers *regs); // Read and prepare instructions - virtual void execute(); // ALU operations - virtual void memory(Memory *mem); // Read or write to memory - virtual void write_back(Registers *regs); // Write results to registers + QString to_str(); - enum InstructionState state(); - bool running(); - bool done(); + std::uint8_t opcode() const; + std::uint8_t rs() const; + std::uint8_t rt() const; + std::uint8_t rd() const; + std::uint8_t shamt() const; + std::uint8_t funct() const; + std::uint16_t immediate() const; + std::uint32_t address() const; + std::uint32_t data() const; - virtual QVector<QString> to_strs() = 0; // Returns all fields of instructions in string + bool operator ==(const Instruction &c) const; private: - enum InstructionState st; -}; - -class InstructionR : public Instruction { -public: - InstructionR(std::uint8_t rs, std::uint8_t rd, std::uint8_t rt, std::uint8_t sa); - - QVector<QString> to_strs(); -protected: - std::uint8_t rs, rd, rt, sa; -}; - -class InstructionI : public Instruction { -public: - InstructionI(std::uint8_t rs, std::uint8_t rt, std::uint16_t immediate); - - QVector<QString> to_strs(); -protected: - std::uint8_t rs, rt; - std::uint16_t immediate; -}; - -class InstructionJ : public Instruction { -public: - InstructionJ(std::uint32_t address); - - QVector<QString> to_strs(); -protected: - std::uint32_t address; + std::uint32_t dt; }; #endif // INSTRUCTION_H |