summaryrefslogtreecommitdiff
path: root/inc/stage.h
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-29 17:11:17 -0400
committerbd <bdunahu@operationnull.com>2025-03-29 17:11:17 -0400
commitd21a1a9caa1f1791343a5376121936e552b1124c (patch)
treedf28c01f6d01603e5408bc1b1b111a66adafbff7 /inc/stage.h
parentac0ae7206491a42cdba70560b0db41cfc8c7f642 (diff)
Fetch stage properly holds objects until parent is ready
Diffstat (limited to 'inc/stage.h')
-rw-r--r--inc/stage.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/inc/stage.h b/inc/stage.h
index 761b9f6..ff4455b 100644
--- a/inc/stage.h
+++ b/inc/stage.h
@@ -7,6 +7,7 @@
#include "storage.h"
#include <array>
#include <set>
+#include <memory>
class Stage
{
@@ -17,17 +18,16 @@ class Stage
* @return A newly allocated stage object.
*/
Stage(Stage *next);
- virtual ~Stage() = default;
+ virtual ~Stage();
/**
* Advances this stage by a single clock cycle.
- * @param a DTO object containing various information about an instruction
- * moving through the pipeline.
+ * @param a DTO object containing the next instruction to be processed.
* @param a response, indicating whether or not the parent pipe stage is
- * busy.
+ * ready to accept a new instruction object next cycle.
* @return a response, indicating whether this pipeline stage is stalling,
* busy, or done.
*/
- virtual Response advance(InstrDTO &i, Response p) = 0;
+ virtual Response advance(InstrDTO &next_instr, Response p) = 0;
protected:
/**
@@ -57,10 +57,6 @@ class Stage
*/
static unsigned int pc;
/**
- * A pointer to the next stage in the pipeline.
- */
- Stage *next;
- /**
* A pointer to the top-level storage device.
*/
static Storage *storage;
@@ -72,6 +68,18 @@ class Stage
* The current clock cycle.
*/
static int clock_cycle;
+ /**
+ * A pointer to the next stage in the pipeline.
+ */
+ Stage *next;
+ /**
+ * A pointer to the current instruction this stage is processing.
+ */
+ std::unique_ptr<InstrDTO> curr_instr;
+ /**
+ * The current status of this stage.
+ */
+ Response status;
private:
/**