From 12a822e68b2e82d4b86888304f94b60752465a0a Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 11 Mar 2025 16:30:40 -0400 Subject: remove operation.h and branch determined by read/write in cache load --- src/storage/cache.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/storage/cache.cc') diff --git a/src/storage/cache.cc b/src/storage/cache.cc index 1224aa9..5e071ac 100644 --- a/src/storage/cache.cc +++ b/src/storage/cache.cc @@ -34,7 +34,7 @@ Response Cache::write(Accessor accessor, signed int data, int address) this->requester = accessor; if (this->requester == accessor) { - fetch_resource(WRITE,address); + fetch_resource(address); if (this->is_waiting) r = BLOCKED; else if (this->wait_time == 0) { @@ -49,7 +49,8 @@ Response Cache::write(Accessor accessor, signed int data, int address) return r; } -Response Cache::write_line(Accessor accessor, std::array data_line, int address) +Response Cache::write_line( + Accessor accessor, std::array data_line, int address) { Response r = WAIT; @@ -58,7 +59,7 @@ Response Cache::write_line(Accessor accessor, std::array this->requester = accessor; if (this->requester == accessor) { - fetch_resource(WRITE,address); + fetch_resource(address); if (this->is_waiting) r = BLOCKED; else if (this->wait_time == 0) { @@ -74,13 +75,16 @@ Response Cache::write_line(Accessor accessor, std::array } // TODO: tests for multi level cache -Response Cache::read(Accessor accessor, int address, std::array &data_line) +Response Cache::read( + Accessor accessor, + int address, + std::array &data_line) { Response r = WAIT; if (this->requester == IDLE) this->requester = accessor; if (this->requester == accessor) { - fetch_resource(READ,address); + fetch_resource(address); if (this->is_waiting) r = BLOCKED; else if (this->wait_time == 0) { @@ -99,7 +103,7 @@ Response Cache::read_word(Accessor accessor, int address, signed int &data) if (this->requester == IDLE) this->requester = accessor; if (this->requester == accessor) { - fetch_resource(READ,address); + fetch_resource(address); if (this->is_waiting) r = BLOCKED; else if (this->wait_time == 0) { @@ -112,7 +116,7 @@ Response Cache::read_word(Accessor accessor, int address, signed int &data) return r; } -void Cache::fetch_resource(Operation op, int expected) +void Cache::fetch_resource(int expected) { Response r = OK; int tag, index, offset; @@ -128,12 +132,12 @@ void Cache::fetch_resource(Operation op, int expected) if (meta->at(1) >= 0) { // occupant is dirty // writing line to DRam in case of dirty cache eviction - r = this->lower->write_line(L1CACHE, actual, ((index << LINE_SPEC) + (meta->at(0) << (L1_CACHE_SPEC + LINE_SPEC)))); + r = this->lower->write_line( + L1CACHE, actual, + ((index << LINE_SPEC) + + (meta->at(0) << (L1_CACHE_SPEC + LINE_SPEC)))); if (r == OK) { meta->at(1) = -1; - if(op == READ){ - r = WAIT; //if operation is read, need to wait until cache is loaded with right value from memory address, if operation is write, then this is not necessary - } } } else { r = this->lower->read(L1CACHE, expected, actual); -- cgit v1.2.3