From 6bce0485a0f9ce92bc235f063a1f9aab2d59a1c9 Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 29 Mar 2025 19:45:21 -0400 Subject: Add proper read and write guard methods, clean up id test file --- inc/stage.h | 53 +++++++++++++++++------------------------------------ 1 file changed, 17 insertions(+), 36 deletions(-) (limited to 'inc/stage.h') 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 -#include +#include #include 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 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 checked_out; }; #endif /* STAGE_H_INCLUDED */ -- cgit v1.2.3