summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-01 20:36:31 -0400
committerbd <bdunahu@operationnull.com>2025-04-01 20:36:31 -0400
commit68324683cde10c636a4a602644f3e64d24b0e412 (patch)
treeb87195d06940fbb526785a5e4c59b76780d00b22 /inc
parent25ce77db5f0dbfe6064eb0553591f1b956bad24a (diff)
Lots of fixes and tests
Diffstat (limited to 'inc')
-rw-r--r--inc/ex.h2
-rw-r--r--inc/id.h2
-rw-r--r--inc/instrDTO.h15
-rw-r--r--inc/stage.h10
4 files changed, 20 insertions, 9 deletions
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<void(signed int &s1, signed int s2, signed int s3)>>
+ std::function<void(signed int &s1, signed int s2, signed int s3, unsigned int pc)>>
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<signed int> 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<signed int> checked_out;
/**
* A pointer to the next stage in the pipeline.
*/