summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorbd <bdunaisky@umass.edu>2025-04-18 00:58:40 +0000
committerGitHub <noreply@github.com>2025-04-18 00:58:40 +0000
commit480181957b3f3dbcf7731023504c2cacc8d181ea (patch)
treee936781b52c6846d87c98381ed47bc7da7c43bff /inc
parent62b9e280d5d0222710e491dcd28fe26bea915dcd (diff)
parent984ce6eef2e439955ff991f90c2b654be7c6c3f3 (diff)
Merge pull request #54 from bdunahu/bdunahu
The pipeline says some things and there are numbers
Diffstat (limited to 'inc')
-rw-r--r--inc/controller.h6
-rw-r--r--inc/ex.h19
-rw-r--r--inc/id.h2
-rw-r--r--inc/stage.h6
4 files changed, 25 insertions, 8 deletions
diff --git a/inc/controller.h b/inc/controller.h
index f56b1b4..778c5bc 100644
--- a/inc/controller.h
+++ b/inc/controller.h
@@ -19,7 +19,7 @@ class Controller : public Stage
*/
Controller(Stage *stage, Storage *storage, bool is_pipelined);
InstrDTO *advance(Response p) override;
-
+
/**
* Direct the simulator to run for `number` clock cycles.
* @param the number of clock cycles to run for.
@@ -38,10 +38,6 @@ class Controller : public Stage
*/
int get_pc();
- void set_gprs(int index, int value);
-
- void set_pipelined(bool value);
-
private:
void advance_helper() override;
};
diff --git a/inc/ex.h b/inc/ex.h
index e4c9d2b..f63539c 100644
--- a/inc/ex.h
+++ b/inc/ex.h
@@ -3,8 +3,16 @@
#include "instrDTO.h"
#include "response.h"
#include "stage.h"
+#include <exception>
#include <unordered_map>
+class HaltException : public std::exception
+{
+ const char *what() const noexcept override {
+ return "";
+ }
+};
+
class EX : public Stage
{
public:
@@ -19,13 +27,22 @@ class EX : public Stage
private:
void advance_helper();
/**
+ * Wrapper for division functions, which detects HALT instructinos (division
+ * by 0).
+ * @param the numerator
+ * @param the denominator
+ * @param if the modulo operator should instead be used
+ */
+ void handle_divide(signed int &s1, signed int s2, bool is_mod);
+ /**
* Maps each mnemonic to a function which carries out the instruction's base
* logic.
* All instructions store the result into s1.
*/
std::unordered_map<
Mnemonic,
- std::function<void(signed int &s1, signed int s2, signed int s3, unsigned int pc)>>
+ 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 c1810ae..09f0a7c 100644
--- a/inc/id.h
+++ b/inc/id.h
@@ -69,7 +69,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, Mnemonic &m);
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, signed int &s3);
+ void decode_J_type(signed int &s1, signed int &s2, signed int &s3, Mnemonic &m);
/**
* Helper for `get_instr_fields`.
* Given a raw instruction, returns the mnemonic and type.
diff --git a/inc/stage.h b/inc/stage.h
index 1cedac6..996c21c 100644
--- a/inc/stage.h
+++ b/inc/stage.h
@@ -119,6 +119,11 @@ class Stage
*/
static bool is_pipelined;
/**
+ * A flag which tells fetch when the pipe is empty. Only used when the pipe
+ * is turned off.
+ */
+ static bool is_empty;
+ /**
* The current clock cycle.
*/
static int clock_cycle;
@@ -134,7 +139,6 @@ class Stage
* The current status of this stage.
*/
Response status;
-
};
#endif /* STAGE_H_INCLUDED */