summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/controller.h12
-rw-r--r--inc/dram.h5
-rw-r--r--inc/ex.h3
-rw-r--r--inc/id.h3
-rw-r--r--inc/if.h9
-rw-r--r--inc/instrDTO.h39
-rw-r--r--inc/mm.h3
-rw-r--r--inc/stage.h16
-rw-r--r--inc/wb.h3
9 files changed, 78 insertions, 15 deletions
diff --git a/inc/controller.h b/inc/controller.h
index 56f3836..4b102ce 100644
--- a/inc/controller.h
+++ b/inc/controller.h
@@ -2,6 +2,7 @@
#define CONTROLLER_H
#include "response.h"
#include "stage.h"
+#include "instrDTO.h"
/**
* Houses the clock, and acts as the main API to the GUI.
@@ -11,11 +12,12 @@ class Controller : public Stage
public:
/**
* Constructor.
+ * @param The stage(s) to interface with.
* @param The storage object to use.
* @param Whether or not efficient pipelining will be used.
* @return A newly allocated controller object.
*/
- Controller(Storage *storage, bool is_pipelined);
+ Controller(Stage *stage, Storage *storage, bool is_pipelined);
/**
* Direct the simulator to run for `number` clock cycles.
@@ -34,13 +36,7 @@ class Controller : public Stage
* @return the pc.
*/
int get_pc();
- Response advance();
-
- private:
- /**
- * The current clock cycle.
- */
- int clock_cycle;
+ Response advance(InstrDTO &i) override;
};
#endif /* CONTROLLER_H_INCLUDED */
diff --git a/inc/dram.h b/inc/dram.h
index 0799015..102ec0f 100644
--- a/inc/dram.h
+++ b/inc/dram.h
@@ -29,6 +29,11 @@ class Dram : public Storage
Response
read_word(Accessor accessor, int address, signed int &data) override;
+ /**
+ * TODO This will accept a file at a later date.
+ */
+ void load(std::vector<signed int> program);
+
private:
/**
* Helper for all access methods.
diff --git a/inc/ex.h b/inc/ex.h
index c560eda..f9b2f78 100644
--- a/inc/ex.h
+++ b/inc/ex.h
@@ -1,5 +1,6 @@
#ifndef EX_H
#define EX_H
+#include "instrDTO.h"
#include "response.h"
#include "stage.h"
@@ -8,7 +9,7 @@ class EX : public Stage
public:
using Stage::Stage;
- Response advance();
+ Response advance(InstrDTO &i) override;
};
#endif /* EX_H_INCLUDED */
diff --git a/inc/id.h b/inc/id.h
index dcfda82..de8f677 100644
--- a/inc/id.h
+++ b/inc/id.h
@@ -1,5 +1,6 @@
#ifndef ID_H
#define ID_H
+#include "instrDTO.h"
#include "response.h"
#include "stage.h"
@@ -8,7 +9,7 @@ class ID : public Stage
public:
using Stage::Stage;
- Response advance();
+ Response advance(InstrDTO &i) override;
};
#endif /* ID_D_INCLUDED */
diff --git a/inc/if.h b/inc/if.h
index d9599dd..437fa8d 100644
--- a/inc/if.h
+++ b/inc/if.h
@@ -1,5 +1,6 @@
#ifndef IF_H
#define IF_H
+#include "instrDTO.h"
#include "response.h"
#include "stage.h"
@@ -8,7 +9,13 @@ class IF : public Stage
public:
using Stage::Stage;
- Response advance();
+ Response advance(InstrDTO &i) override;
+
+ private:
+ /**
+ * The name this pipeline stages uses to access storage.
+ */
+ const Accessor id = FETCH;
};
#endif /* IF_H_INCLUDED */
diff --git a/inc/instrDTO.h b/inc/instrDTO.h
new file mode 100644
index 0000000..86cec05
--- /dev/null
+++ b/inc/instrDTO.h
@@ -0,0 +1,39 @@
+#ifndef INSTRDTO_H
+#define INSTRDTO_H
+
+class InstrDTO
+{
+ public:
+ /**
+ * Constructor.
+ */
+ InstrDTO();
+ ~InstrDTO() = default;
+
+ /**
+ * @return if_cycle
+ */
+ int get_if_cycle();
+ /**
+ * @return instr_bits
+ */
+ signed int get_instr_bits();
+
+ /**
+ * @param if_cycle
+ */
+ void set_if_cycle(int);
+ /**
+ * @param instr_bits
+ */
+ void set_instr_bits(signed int);
+
+ private:
+ /**
+ * The current clock cycle.
+ */
+ int if_cycle;
+ signed int instr_bits;
+};
+
+#endif /* INSTRDTO_H_INCLUDED */
diff --git a/inc/mm.h b/inc/mm.h
index e9d04d5..5e2b029 100644
--- a/inc/mm.h
+++ b/inc/mm.h
@@ -1,5 +1,6 @@
#ifndef MM_H
#define MM_H
+#include "instrDTO.h"
#include "response.h"
#include "stage.h"
@@ -8,7 +9,7 @@ class MM : public Stage
public:
using Stage::Stage;
- Response advance();
+ Response advance(InstrDTO &i) override;
};
#endif /* MM_H_INCLUDED */
diff --git a/inc/stage.h b/inc/stage.h
index 494f3d3..ac810a9 100644
--- a/inc/stage.h
+++ b/inc/stage.h
@@ -1,6 +1,7 @@
#ifndef STAGE_H
#define STAGE_H
#include "definitions.h"
+#include "instrDTO.h"
#include "response.h"
#include "storage.h"
#include <array>
@@ -8,14 +9,21 @@
class Stage
{
public:
+ /**
+ * Constructor.
+ * @param The next stage in the pipeline.
+ * @return A newly allocated stage object.
+ */
Stage(Stage *next);
virtual ~Stage() = default;
/**
* Advances this stage by a single clock cycle.
+ * @param a DTO object containing various information about an instruction
+ * moving through the pipeline.
* @return a response, indicating whether this pipeline stage is stalled,
* busy, or done.
*/
- virtual Response advance() = 0;
+ virtual Response advance(InstrDTO &i) = 0;
protected:
/**
@@ -37,7 +45,11 @@ class Stage
/**
* A flag indicating whether pipelining should be used.
*/
- bool is_pipelined;
+ static bool is_pipelined;
+ /**
+ * The current clock cycle.
+ */
+ static int clock_cycle;
};
#endif /* STAGE_H_INCLUDED */
diff --git a/inc/wb.h b/inc/wb.h
index 031bf20..b1d65f7 100644
--- a/inc/wb.h
+++ b/inc/wb.h
@@ -2,13 +2,14 @@
#define WB_H
#include "response.h"
#include "stage.h"
+#include "instrDTO.h"
class WB : public Stage
{
public:
using Stage::Stage;
- Response advance();
+ Response advance(InstrDTO &i) override;
};
#endif /* WB_H_INCLUDED */