summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/instrDTO.h4
-rw-r--r--src/controller.cc1
-rw-r--r--src/ex.cc2
-rw-r--r--src/id.cc5
-rw-r--r--tests/id.cc16
5 files changed, 22 insertions, 6 deletions
diff --git a/inc/instrDTO.h b/inc/instrDTO.h
index f3d4597..f4ef416 100644
--- a/inc/instrDTO.h
+++ b/inc/instrDTO.h
@@ -19,7 +19,7 @@
#define INSTRDTO_H
#include "instr.h"
#include "pipe_spec.h"
-#include<array>
+#include <array>
struct U_INT_TYPE {
signed int slot_one;
@@ -33,7 +33,7 @@ struct V_TYPE {
std::array<signed int, V_R_LIMIT> slot_three;
};
-struct LOAD_STORE_V_TYPE{
+struct LOAD_STORE_V_TYPE {
signed int base_addr;
signed int immediate;
std::array<signed int, V_R_LIMIT> vector_register;
diff --git a/src/controller.cc b/src/controller.cc
index e439b30..190d3e2 100644
--- a/src/controller.cc
+++ b/src/controller.cc
@@ -32,6 +32,7 @@ Controller::Controller(Stage *stage, Storage *storage, bool is_pipelined)
this->checked_out = {};
this->gprs = {0};
this->vrs.fill({0});
+ this->vrs.at(0).fill(1); // constant 1 vector register
this->gprs.at(2) = MEM_WORDS; // set the stack pointer
}
diff --git a/src/ex.cc b/src/ex.cc
index f0ca5b5..73ed615 100644
--- a/src/ex.cc
+++ b/src/ex.cc
@@ -50,7 +50,7 @@ void EX::advance_helper()
v_base_addr =
this->curr_instr->operands.load_store_vector.base_addr;
}
- v_len = this->curr_instr->slot_A;
+ v_len = this->curr_instr->slot_B;
if (v_len == 0) {
// clear destination vector reg
v1.fill(0);
diff --git a/src/id.cc b/src/id.cc
index 43975fb..490b03a 100644
--- a/src/id.cc
+++ b/src/id.cc
@@ -49,7 +49,6 @@ void ID::get_instr_fields(signed int instr_bits)
this->decode_J_type(instr_bits);
break;
case 0b11:
- this->curr_instr->mnemonic = NOP;
this->status = OK;
}
@@ -79,9 +78,9 @@ Response ID::set_vlen()
vlen_reg = vlen_reg & 0xf;
if (r == OK) {
if (vlen_reg > V_R_LIMIT) {
- this->curr_instr->slot_A = V_R_LIMIT;
+ this->curr_instr->slot_B = V_R_LIMIT;
} else {
- this->curr_instr->slot_A = vlen_reg;
+ this->curr_instr->slot_B = vlen_reg;
}
}
return r;
diff --git a/tests/id.cc b/tests/id.cc
index 0e7de3b..b52ad9c 100644
--- a/tests/id.cc
+++ b/tests/id.cc
@@ -129,6 +129,22 @@ TEST_CASE_METHOD(IDFixture, "Parse arbitrary r-type # two", "[id]")
delete i;
}
+TEST_CASE_METHOD(IDFixture, "Parse arbitrary r-type # three", "[id]")
+{
+ signed int t;
+ InstrDTO *i;
+
+ t = this->encode_R_type(0b10000, 0b10001, 0b10101, 0b1110, 0b0);
+ i = this->decode_bits(t);
+
+ CHECK(i->operands.integer.slot_one == 0x00000000); // registers are empty
+ CHECK(i->operands.integer.slot_two == 0x00000000);
+ CHECK(i->operands.integer.slot_three == 0x00000000);
+ CHECK(i->mnemonic == MULV);
+
+ delete i;
+}
+
TEST_CASE_METHOD(IDFixture, "Parse arbitrary i-type # one", "[id]")
{
signed int t;