summaryrefslogtreecommitdiff
path: root/src/stage.cc
diff options
context:
space:
mode:
authorbd <bdunaisky@umass.edu>2025-04-28 03:44:42 +0000
committerGitHub <noreply@github.com>2025-04-28 03:44:42 +0000
commit013a79547aa465872d0262b2f5c24e73f9556869 (patch)
tree28cc8f2ea6e5aa1a74f328de8594b0ad5995fa66 /src/stage.cc
parent5653b2a033e7a4173d2f178b5ce52384666d3d7b (diff)
parent336faf3fd701aaf962613abd1ff0a69cbdf021ce (diff)
Merge pull request #69 from bdunahu/vector_ext
Vector ext
Diffstat (limited to 'src/stage.cc')
-rw-r--r--src/stage.cc43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/stage.cc b/src/stage.cc
index 4efe2fe..ac688d8 100644
--- a/src/stage.cc
+++ b/src/stage.cc
@@ -16,6 +16,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "stage.h"
+#include "pipe_spec.h"
#include <array>
#include <deque>
@@ -29,7 +30,7 @@ Stage::Stage(Stage *next)
Stage::~Stage() { delete this->next; };
std::array<int, GPR_NUM> Stage::gprs;
-std::array<int, V_NUM> Stage::vrs;
+std::array<std::array<signed int, V_R_LIMIT>, V_NUM> Stage::vrs;
std::deque<signed int> Stage::checked_out;
unsigned int Stage::pc;
Storage *Stage::storage;
@@ -65,40 +66,28 @@ InstrDTO *Stage::advance(Response p)
return r;
}
-InstrDTO *Stage::get_instr() { return this->curr_instr; }
-
-void Stage::set_condition(CC c, bool v)
+bool Stage::is_vector_type(Mnemonic m)
{
- if (v)
- this->gprs[3] = this->gprs[3] | 1 << c;
- else
- this->gprs[3] = this->gprs[3] & ~(1 << c);
+ return (
+ m == ADDV || m == SUBV || m == MULV || m == DIVV || m == CEV ||
+ m == LOADV || m == STOREV);
}
-signed int Stage::dereference_register(signed int v)
+bool Stage::is_logical(Mnemonic m)
{
- signed int r;
-
- if (v < 0 || v >= GPR_NUM + V_NUM) {
- throw std::out_of_range(
- "instruction tried to access register which does not exist");
- }
-
- r = (v >= GPR_NUM) ? this->vrs[v % GPR_NUM] : this->gprs[v];
- return r;
+ return (
+ m == ANDI || m == ORI || m == XORI || m == AND || m == OR || m == XOR ||
+ m == NOT);
}
-void Stage::store_register(signed int v, signed int d)
-{
- if (v < 0 || v >= GPR_NUM + V_NUM) {
- throw std::out_of_range(
- "instruction tried to access register which does not exist");
- }
+InstrDTO *Stage::get_instr() { return this->curr_instr; }
- if (v >= GPR_NUM)
- this->vrs[v % GPR_NUM] = d;
+void Stage::set_condition(CC c, bool v)
+{
+ if (v)
+ this->gprs[3] = this->gprs[3] | 1 << c;
else
- this->gprs[v] = d;
+ this->gprs[3] = this->gprs[3] & ~(1 << c);
}
bool Stage::is_checked_out(signed int r)