From 68324683cde10c636a4a602644f3e64d24b0e412 Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 1 Apr 2025 20:36:31 -0400 Subject: Lots of fixes and tests --- inc/ex.h | 2 +- inc/id.h | 2 +- inc/instrDTO.h | 15 +++++++++++++-- inc/stage.h | 10 +++++----- 4 files changed, 20 insertions(+), 9 deletions(-) (limited to 'inc') diff --git a/inc/ex.h b/inc/ex.h index 6d4254e..e4c9d2b 100644 --- a/inc/ex.h +++ b/inc/ex.h @@ -25,7 +25,7 @@ class EX : public Stage */ std::unordered_map< Mnemonic, - std::function> + std::function> instr_map; }; diff --git a/inc/id.h b/inc/id.h index ebbe290..6178ad2 100644 --- a/inc/id.h +++ b/inc/id.h @@ -66,7 +66,7 @@ class ID : public Stage */ void get_instr_fields(signed int &s1, signed int &s2, signed int &s3, Mnemonic &m, Type &t); void decode_R_type(signed int &s1, signed int &s2, signed int &s3); - void decode_I_type(signed int &s1, signed int &s2, signed int &s3); + void decode_I_type(signed int &s1, signed int &s2, signed int &s3, Mnemonic &m); void decode_J_type(signed int &s1, signed int &s2); /** * Helper for `get_instr_fields`. diff --git a/inc/instrDTO.h b/inc/instrDTO.h index 8249122..b6dec06 100644 --- a/inc/instrDTO.h +++ b/inc/instrDTO.h @@ -47,6 +47,10 @@ class InstrDTO * @return the type of the instruction */ Type get_type(); + /** + * @return the program counter at the time this instruction was fetched + */ + unsigned int get_pc(); /** * @param set hist key @@ -72,11 +76,15 @@ class InstrDTO * @param the mnemonic of the instruction */ void set_mnemonic(Mnemonic); - + /** * @param the type of the instruction */ void set_type(Type); + /** + * @param the program counter at the time this instruction was fetched + */ + void set_pc(unsigned int pc); private: /** @@ -100,11 +108,14 @@ class InstrDTO * The mnemonic of the operation. */ Mnemonic mnemonic; - /** * Type of the instruction */ Type type; + /** + * The PC of the instruction + */ + unsigned int pc; }; #endif /* INSTRDTO_H_INCLUDED */ diff --git a/inc/stage.h b/inc/stage.h index 87ee9c1..20f0191 100644 --- a/inc/stage.h +++ b/inc/stage.h @@ -64,6 +64,11 @@ class Stage */ void squash(); + /** + * The set of registers currently checked out. + */ + static std::deque checked_out; + protected: /** * The function expected to do the majority of the work. @@ -120,11 +125,6 @@ class Stage * The current clock cycle. */ static int clock_cycle; - // TODO fix this comment after writeback stage - /** - * The set of registers currently checked out. - */ - static std::deque checked_out; /** * A pointer to the next stage in the pipeline. */ -- cgit v1.2.3