From c55104f8e99ea6ccb0c66a5e0d3cfc81dbbc19ab Mon Sep 17 00:00:00 2001 From: bd Date: Tue, 11 Mar 2025 20:26:59 -0400 Subject: Fix small issue in fetch_resource wih off by one cycle count --- src/storage/cache.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/storage/cache.cc') diff --git a/src/storage/cache.cc b/src/storage/cache.cc index 4842ed5..3e2a5e0 100644 --- a/src/storage/cache.cc +++ b/src/storage/cache.cc @@ -119,6 +119,7 @@ Response Cache::read_word(Accessor accessor, int address, signed int &data) void Cache::fetch_resource(int expected) { Response r = OK; + Response q; int tag, index, offset; std::array *actual; std::array *meta; @@ -128,21 +129,21 @@ void Cache::fetch_resource(int expected) actual = &this->data->at(index); if (meta->at(0) != tag) { + r = WAIT; // address not in cache if (meta->at(1) >= 0) { // occupant is dirty // writing line to DRam in case of dirty cache eviction - r = this->lower->write_line( + q = this->lower->write_line( L1CACHE, *actual, ((index << LINE_SPEC) + (meta->at(0) << (L1_CACHE_LINE_SPEC + LINE_SPEC)))); - if (r == OK) { + if (q == OK) { meta->at(1) = -1; - r = WAIT; } } else { - r = this->lower->read_line(L1CACHE, expected, *actual); - if (r == OK) { + q = this->lower->read_line(L1CACHE, expected, *actual); + if (q == OK) { meta->at(0) = tag; } } -- cgit v1.2.3