diff options
author | bd <bdunahu@operationnull.com> | 2025-04-16 22:22:09 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-16 22:22:09 -0400 |
commit | 23d3ebb2702e6b08c7f6b997067e1bc76483b813 (patch) | |
tree | da31aa76d8ea073d92757466985ecdf9ff57a2d9 | |
parent | b778ccc3e7c2f2ac3c4892a87f5269f342fd895f (diff) |
Partial fixes for changes in DRAM/Cache, including uncovered bug
-rw-r--r-- | gui/worker.cc | 2 | ||||
m--------- | ram | 0 | ||||
-rw-r--r-- | src/sim/dum.cc | 1 | ||||
-rw-r--r-- | src/sim/ex.cc | 17 | ||||
-rw-r--r-- | src/sim/stage.cc | 26 | ||||
-rw-r--r-- | tests/controller.cc | 2 | ||||
-rw-r--r-- | tests/ex.cc | 2 | ||||
-rw-r--r-- | tests/id.cc | 4 | ||||
-rw-r--r-- | tests/if.cc | 2 |
9 files changed, 23 insertions, 33 deletions
diff --git a/gui/worker.cc b/gui/worker.cc index e7c9876..947a3a4 100644 --- a/gui/worker.cc +++ b/gui/worker.cc @@ -6,7 +6,7 @@ void Worker::doWork() { qDebug() << "Initializing..."; this->d = new Dram(0); - this->c = new Cache(this->d, 0); + this->c = new Cache(this->d, 5, 0, 0); this->if_stage = new IF(nullptr); this->id_stage = new ID(if_stage); this->ex_stage = new EX(id_stage); diff --git a/ram b/ram -Subproject be2bc108dc112ae7e21d4a77f7bcbfac88d6fcd +Subproject a2381acb5489a735576a43f25053a7a5551a766 diff --git a/src/sim/dum.cc b/src/sim/dum.cc index 76d4acd..f712fce 100644 --- a/src/sim/dum.cc +++ b/src/sim/dum.cc @@ -3,7 +3,6 @@ #include "instrDTO.h" #include "response.h" #include "stage.h" -#include "utils.h" DUM::DUM(Stage *stage) : Stage(stage) { this->id = IDLE; } diff --git a/src/sim/ex.cc b/src/sim/ex.cc index 50f00a8..d20d15f 100644 --- a/src/sim/ex.cc +++ b/src/sim/ex.cc @@ -1,10 +1,9 @@ #include "ex.h" #include "accessor.h" -#include "pipe_spec.h" #include "instrDTO.h" +#include "pipe_spec.h" #include "response.h" #include "stage.h" -#include "utils.h" #include <unordered_map> // clang-format off @@ -313,32 +312,28 @@ EX::EX(Stage *stage) : Stage(stage) INIT_INSTRUCTION( BEQ, { - (this->get_condition(EQ)) ? s1 = wrap_address(pc + s2) - : s1 = -1; + (this->get_condition(EQ)) ? s1 = pc + s2 : s1 = -1; (void)s3; }), INIT_INSTRUCTION( BGT, { - (this->get_condition(GT)) ? s1 = wrap_address(pc + s2) - : s1 = -1; + (this->get_condition(GT)) ? s1 = pc + s2 : s1 = -1; (void)s3; }), INIT_INSTRUCTION( BUF, { - (this->get_condition(UF)) ? s1 = wrap_address(pc + s2) - : s1 = -1; + (this->get_condition(UF)) ? s1 = pc + s2 : s1 = -1; (void)s3; }), INIT_INSTRUCTION( BOF, { - (this->get_condition(OF)) ? s1 = wrap_address(pc + s2) - : s1 = -1; + (this->get_condition(OF)) ? s1 = pc + s2 : s1 = -1; (void)s3; }), @@ -387,7 +382,7 @@ void EX::advance_helper() s3 = this->curr_instr->get_s3(); pc = this->curr_instr->get_pc(); - this->instr_map[m](s1, s2, s3, pc ); + this->instr_map[m](s1, s2, s3, pc); this->curr_instr->set_s1(s1); this->status = OK; diff --git a/src/sim/stage.cc b/src/sim/stage.cc index 8a570f0..b7926fd 100644 --- a/src/sim/stage.cc +++ b/src/sim/stage.cc @@ -1,5 +1,4 @@ #include "stage.h" -#include "utils.h" #include <array> #include <deque> @@ -28,12 +27,12 @@ InstrDTO *Stage::advance(Response p) InstrDTO *s = nullptr; Response n; - // std::cout << "advance: " << this->id << ": " << this->curr_instr << "?: " << p << ": " << this->checked_out.size() << ": "; - // if (curr_instr) + // std::cout << "advance: " << this->id << ": " << this->curr_instr << "?: " + // << p << ": " << this->checked_out.size() << ": "; if (curr_instr) // std::cout << curr_instr->get_mnemonic(); // for (long unsigned int i = 0; i < this->checked_out.size(); ++i) // std::cout << this->checked_out[i] << " "; - // std::cout << std::endl; + // std::cout << std::endl; if (this->curr_instr && this->status != OK) { this->advance_helper(); } @@ -53,9 +52,10 @@ InstrDTO *Stage::advance(Response p) return r; } -std::vector<int> Stage::stage_info() { +std::vector<int> Stage::stage_info() +{ std::vector<int> info; - if(this->curr_instr){ + if (this->curr_instr) { info.push_back(this->curr_instr->get_mnemonic()); info.push_back(this->curr_instr->get_pc()); info.push_back(this->curr_instr->get_s1()); @@ -63,7 +63,7 @@ std::vector<int> Stage::stage_info() { info.push_back(this->curr_instr->get_s3()); } return info; - } +} void Stage::set_condition(CC c, bool v) { @@ -78,10 +78,8 @@ signed int Stage::dereference_register(signed int v) signed int r; if (v < 0 || v >= GPR_NUM + V_NUM) { - throw std::out_of_range(string_format( - "instruction tried to access register %d, which does " - "not exist", - v)); + 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]; @@ -91,10 +89,8 @@ signed int Stage::dereference_register(signed int v) void Stage::store_register(signed int v, signed int d) { if (v < 0 || v >= GPR_NUM + V_NUM) { - throw std::out_of_range(string_format( - "instruction tried to access register %d, which does " - "not exist", - v)); + throw std::out_of_range( + "instruction tried to access register which does not exist"); } if (v >= GPR_NUM) diff --git a/tests/controller.cc b/tests/controller.cc index a009a70..74284b7 100644 --- a/tests/controller.cc +++ b/tests/controller.cc @@ -16,7 +16,7 @@ class ControllerPipeFixture ControllerPipeFixture() { this->d = new Dram(1); - this->c = new Cache(this->d, 0); + this->c = new Cache(this->d, 5, 0, 0); IF *f = new IF(nullptr); ID *d = new ID(f); diff --git a/tests/ex.cc b/tests/ex.cc index 13437f7..a493a21 100644 --- a/tests/ex.cc +++ b/tests/ex.cc @@ -13,7 +13,7 @@ class EXFixture EXFixture() { this->dr = new Dram(3); - this->c = new Cache(this->dr, 1); + this->c = new Cache(this->dr, 5, 0, 1); this->dum = new DUM(nullptr); this->e = new EX(dum); this->ct = new Controller(this->e, this->c, true); diff --git a/tests/id.cc b/tests/id.cc index 77a7cd9..b8d0479 100644 --- a/tests/id.cc +++ b/tests/id.cc @@ -13,7 +13,7 @@ class IDFixture IDFixture() { this->dr = new Dram(3); - this->c = new Cache(this->dr, 1); + this->c = new Cache(this->dr, 5, 0, 1); this->dum = new DUM(nullptr); this->d = new ID(dum); this->ct = new Controller(this->d, this->c, true); @@ -152,7 +152,7 @@ TEST_CASE_METHOD(IDFixture, "Parse arbitrary i-type # two", "[id]") t = this->encode_I_type(0xCC, 0b010, 0b101, 0b1011, 0b1); i = this->decode_bits(t); - + CHECK(i->get_s1() == 0x00000000); // registers are empty CHECK(i->get_s2() == 0x00000000); CHECK(i->get_s3() == 0xCC); diff --git a/tests/if.cc b/tests/if.cc index d6c1bca..5ccd73b 100644 --- a/tests/if.cc +++ b/tests/if.cc @@ -17,7 +17,7 @@ class IFFixture p = {0xC000, 0xC001, 0xC002, 0xC003}; d->load(p); - this->c = new Cache(d, this->c_delay); + this->c = new Cache(d, 5, 0, this->c_delay); this->f = new IF(nullptr); this->ct = new Controller(this->f, this->c, true); } |