diff options
author | bd <bdunahu@operationnull.com> | 2025-03-08 15:19:57 -0500 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-03-08 15:19:57 -0500 |
commit | dcc22079fc1c455df70ab1263ea09400e4c948d6 (patch) | |
tree | a55d0f640d9eb94c58ac25cf5c551c0d7506e43e | |
parent | 8fc631090fd88a7e8e62f284c3dfd3c515d14613 (diff) |
Remove queue in storage.h
-rw-r--r-- | inc/storage.h | 23 | ||||
-rw-r--r-- | src/storage/dram.cc | 5 | ||||
-rw-r--r-- | src/storage/storage.cc | 4 | ||||
-rw-r--r-- | tests/dram.cc | 45 |
4 files changed, 8 insertions, 69 deletions
diff --git a/inc/storage.h b/inc/storage.h index 95b6749..4bf4591 100644 --- a/inc/storage.h +++ b/inc/storage.h @@ -4,33 +4,16 @@ #include "response.h" #include <algorithm> #include <array> -#include <deque> #include <vector> enum Accessor { + IDLE, MEM, FETCH, L1CACHE, SIDE, }; -/** - * Wrapper class for std::deque. - * - * Implements a deque that does not push duplicate objects. - */ -template <typename T> class Deque : public std::deque<T> -{ - public: - using std::deque<T>::deque; - - void push_back(const T &value) - { - if (std::find(this->begin(), this->end(), value) == this->end()) - std::deque<T>::push_back(value); - } -}; - class Storage { public: @@ -83,9 +66,9 @@ class Storage */ int delay; /** - * The accessors currently being serviced, in first come first serve order. + * The accessor currently being serviced. */ - Deque<enum Accessor> deque; + enum Accessor requester; /** * The number of cycles until the current request is completed. */ diff --git a/src/storage/dram.cc b/src/storage/dram.cc index 5b4c63b..7197668 100644 --- a/src/storage/dram.cc +++ b/src/storage/dram.cc @@ -23,9 +23,10 @@ Response Dram::write(Accessor accessor, signed int data, int address) r = OK; } else { /* Do this first--then process the first cycle immediately. */ - this->deque.push_back(accessor); + if (this->requester == IDLE) + this->requester = accessor; - if (this->deque.front() == accessor) { + if (this->requester == accessor) { if (this->wait_time == 0) { this->do_write(data, address); r = OK; diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 429f8aa..e3067a2 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -24,9 +24,9 @@ void Storage::do_write(signed data, int address) void Storage::resolve() { if (this->wait_time == 0) { - this->deque.pop_front(); + this->requester = IDLE; this->wait_time = delay; - } else if (!this->deque.empty()) { + } else if (this->requester != IDLE) { --this->wait_time; } } diff --git a/tests/dram.cc b/tests/dram.cc index e0189c7..c646135 100644 --- a/tests/dram.cc +++ b/tests/dram.cc @@ -188,51 +188,6 @@ TEST_CASE( delete d; } -TEST_CASE("Many conflicting requests first-come first serve", "[dram]") -{ - int delay = 1; - Dram *d = new Dram(1, delay); - std::array<signed int, LINE_SIZE> expected = {0, 0, 0, 0}; - std::array<signed int, LINE_SIZE> actual = d->view(0, 1)[0]; - CHECK(expected == actual); - - signed int w = 0x11223344; - - Response r; - r = d->write(FETCH, w, 0x00000000); - r = d->write(MEM, w, 0x00000001); - - actual = d->view(0, 1)[0]; - REQUIRE(expected == actual); - d->resolve(); - - r = d->write(FETCH, w, 0x00000000); - r = d->write(L1CACHE, w, 0x00000002); - // call mem after cache - r = d->write(MEM, w, 0x00000001); - - expected.at(0) = w; - actual = d->view(0, 1)[0]; - REQUIRE(expected == actual); - d->resolve(); - - r = d->write(MEM, w, 0x00000001); - r = d->write(L1CACHE, w, 0x00000002); - - actual = d->view(0, 1)[0]; - REQUIRE(expected == actual); - d->resolve(); - - r = d->write(MEM, w, 0x00000001); - r = d->write(L1CACHE, w, 0x00000002); - - expected.at(1) = w; - actual = d->view(0, 1)[0]; - REQUIRE(expected == actual); - - delete d; -} - TEST_CASE("Sidedoor bypasses delay", "[dram]") { int delay = 3; |