summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/definitions.h5
-rw-r--r--inc/id.h33
-rw-r--r--inc/instr.h9
-rw-r--r--inc/stage.h4
4 files changed, 39 insertions, 12 deletions
diff --git a/inc/definitions.h b/inc/definitions.h
index c9367ff..3238a8b 100644
--- a/inc/definitions.h
+++ b/inc/definitions.h
@@ -52,6 +52,11 @@
#define GPR_NUM 16
/**
+ * The number of vector registers
+ */
+#define V_NUM 8
+
+/**
* The number of bits to specify an instruction type
*/
#define TYPE_SIZE 2
diff --git a/inc/id.h b/inc/id.h
index 1503457..2411402 100644
--- a/inc/id.h
+++ b/inc/id.h
@@ -1,5 +1,6 @@
#ifndef ID_H
#define ID_H
+#include "instr.h"
#include "instrDTO.h"
#include "response.h"
#include "stage.h"
@@ -19,20 +20,38 @@ class ID : public Stage
/**
* Parse an instruction into a type, opcode, and fields. If the type is
* invalid, only the type field will be set.
+ *
+ * This method is marked public so it may be tested, and is not used outside
+ * of this class during normal execution.
+ *
* @param the resulting first field, which varies per type. To call this
* function properly, this field must contain the full instruction bytes on
* function entry.
* @param the resulting second field, which varies per type.
* @param the resulting third field, which varies per type.
- * @param the resulting type.
- * @param the resulting opcode.
+ * @param the resulting mnemonic.
*/
void get_instr_fields(
- signed int &s1,
- signed int &s2,
- signed int &s3,
- unsigned int &type,
- unsigned int &opcode);
+ signed int &s1, signed int &s2, signed int &s3, Mnemonic &m);
+
+ private:
+ /**
+ * Helper for `get_instr_fields`.
+ * Given a raw instruction, returns the mnemonic and type.
+ * This operation will destroy the original arguments.
+ * @param the raw bits to parse.
+ * @param the resulting mnemonic.
+ * @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 */
diff --git a/inc/instr.h b/inc/instr.h
index 98ecf1d..08b4fd0 100644
--- a/inc/instr.h
+++ b/inc/instr.h
@@ -2,7 +2,7 @@
#define INSTR_H
#include <functional>
#include <iostream>
-#include <map>
+#include <unordered_map>
enum Mnemonic {
ADD,
@@ -42,15 +42,14 @@ enum Mnemonic {
BOF,
PUSH,
POP,
+ NOP,
};
-std::ostream &operator<<(std::ostream &os, Mnemonic a);
-
namespace instr
{
// clang-format off
- extern const std::map<unsigned int, Mnemonic> mnemonic_map;
- extern const std::map<Mnemonic, std::function<void(signed int &s1, signed int &s2, signed int &s3)>> instr_map;
+ extern const std::unordered_map<unsigned int, Mnemonic> mnemonic_map;
+ extern const std::unordered_map<Mnemonic, std::function<void(signed int &s1, signed int &s2, signed int &s3)>> instr_map;
// clang-format on
} // namespace instr
diff --git a/inc/stage.h b/inc/stage.h
index 04de475..f6bad41 100644
--- a/inc/stage.h
+++ b/inc/stage.h
@@ -36,6 +36,10 @@ class Stage
*/
static std::array<signed int, GPR_NUM> gprs;
/**
+ * The shared pool of general-purpose vector registers.
+ */
+ static std::array<signed int, V_NUM> vrs;
+ /**
* The address of the currently executing instruction.
*/
static unsigned int pc;