summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/id.h45
-rw-r--r--inc/stage.h53
2 files changed, 53 insertions, 45 deletions
diff --git a/inc/id.h b/inc/id.h
index 34e1a47..f8c167d 100644
--- a/inc/id.h
+++ b/inc/id.h
@@ -34,7 +34,42 @@ class ID : public Stage
void get_instr_fields(
signed int &s1, signed int &s2, signed int &s3, Mnemonic &m);
+ /* The following methods are made public so that they may be tested, and are
+ * not to be called from outside classes during standard execution.
+ */
+
+ /**
+ * Facilitates register checkout and data hazard management.
+ * It does this by checking that the register passed in is not currently
+ * checked out. If true, then replaces r with the value of the register and
+ * returns OK. If false, returns STALLED.
+ *
+ * @param the registers number, to be dereferenced.
+ * @return OK if `r` is not checked out, STALLED otherwise.
+ */
+ Response read_guard(signed int &r);
+ /**
+ * Facilitates register checkout and data hazard management.
+ * Checks out a register and returns it.
+ *
+ * @param the registers number, to be dereferenced and checked out.
+ */
+ void write_guard(signed int &r);
+
private:
+ // TODO write me
+ /**
+ * Helper for ``
+ * Attempts to parse and dereference instruction arguments. If a desc
+
+ * @param the resulting first field. To call this function properly, this
+ * field must contain the section of the instruction to be parsed.
+ * @param the resulting second field.
+ * @param the resulting third field.
+ */
+ 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_J_type(signed int &s1, signed int &s2);
/**
* Helper for `get_instr_fields`.
* Given a raw instruction, returns the mnemonic and type.
@@ -44,14 +79,6 @@ class ID : public Stage
* @param the resulting type.
*/
void split_instr(signed int &raw, unsigned int &type, Mnemonic &m);
- /**
- * Facilitates checking out a register by dereferencing the register
- specified by the first parameter. Registers that are checked out cannot be
- checked out until they are checked in.
- * @param
- * @return the contents of the register.
- */
- Response dereference_register(signed int &);
};
-#endif /* ID_D_INCLUDED */
+#endif /* ID_H_INCLUDED */
diff --git a/inc/stage.h b/inc/stage.h
index ff4455b..19e3896 100644
--- a/inc/stage.h
+++ b/inc/stage.h
@@ -6,7 +6,7 @@
#include "response.h"
#include "storage.h"
#include <array>
-#include <set>
+#include <deque>
#include <memory>
class Stage
@@ -31,15 +31,18 @@ class Stage
protected:
/**
- * Facilitates register checkout.
- * It does this by checking that the register passed in is not currently
- * checked out. If true, then replaces r with the value of the register and
- * returns OK. If false, returns STALLED.
- *
- * @param the registers number, to be dereferenced.
- * @return OK if `r` is not checked out, STALLED otherwise.
+ * Helper for `check_out`.
+ * Returns true if r are not checked out, false otherwise.
+ * @param a list of register numbers.
+ * @return true if registers are not in checked_out, false otherwise.
+ */
+ bool is_checked_out(signed int r);
+ /**
+ * Returns the value of the register corresponding to `v`.
+ * @param the register number.
+ * @return the value in the associated register.
*/
- Response check_out(unsigned int &r);
+ signed int dereference_register(signed int v);
/**
* The name of the pipeline stage.
*/
@@ -68,6 +71,11 @@ 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.
*/
@@ -80,33 +88,6 @@ class Stage
* The current status of this stage.
*/
Response status;
-
- private:
- /**
- * Helper for `check_out`.
- * Returns true if r are not checked out, false otherwise.
- * @param a list of register numbers.
- * @return true if registers are not in checked_out, false otherwise.
- */
- bool is_checked_out(unsigned int r);
- /**
- * Helper for `check_out`.
- * Checks out a single register, and places it in checked_out.
- * @param a register number.
- * @return the value in the register.
- */
- signed int check_out_register(unsigned int r);
- // TODO fix this comment after writeback stage
- /**
- * Helper for `check_out_register`
- * @param the register number.
- * @return the value in the associated register.
- */
- signed int dereference_register(unsigned int r);
- /**
- * The set of registers currently checked out.
- */
- static std::set<unsigned int> checked_out;
};
#endif /* STAGE_H_INCLUDED */