summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-11 20:26:59 -0400
committerbd <bdunahu@operationnull.com>2025-03-11 20:26:59 -0400
commitc55104f8e99ea6ccb0c66a5e0d3cfc81dbbc19ab (patch)
tree30947c7018653ca18d4a69de20936b3615768f9e
parent1400c65a1d19f96fff8b4a0e98fcd9ed792f4883 (diff)
Fix small issue in fetch_resource wih off by one cycle count
-rw-r--r--inc/definitions.h2
-rw-r--r--src/storage/cache.cc11
2 files changed, 7 insertions, 6 deletions
diff --git a/inc/definitions.h b/inc/definitions.h
index 80fccbe..eced554 100644
--- a/inc/definitions.h
+++ b/inc/definitions.h
@@ -39,7 +39,7 @@
/**
* The total number of cycles a level one cache access takes
*/
-#define L1_CACHE_DELAY 1
+#define L1_CACHE_DELAY 0
/**
* Return the N least-significant bits from integer K using a bit mask
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<signed int, LINE_SIZE> *actual;
std::array<int, 2> *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;
}
}