diff options
author | bd <bdunahu@operationnull.com> | 2025-03-11 19:52:30 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-03-11 19:52:30 -0400 |
commit | 1400c65a1d19f96fff8b4a0e98fcd9ed792f4883 (patch) | |
tree | 0ef2bb95b1fafda0739ea6f04451a32988f18a5f | |
parent | fb7735049f571ac45a193481e962f497b4759fa4 (diff) |
Fix issue where fetch_resource did not update cache data
-rw-r--r-- | src/storage/cache.cc | 22 | ||||
-rw-r--r-- | src/storage/dram.cc | 6 |
2 files changed, 16 insertions, 12 deletions
diff --git a/src/storage/cache.cc b/src/storage/cache.cc index ea90f50..4842ed5 100644 --- a/src/storage/cache.cc +++ b/src/storage/cache.cc @@ -120,12 +120,12 @@ void Cache::fetch_resource(int expected) { Response r = OK; int tag, index, offset; - std::array<signed int, LINE_SIZE> actual; + std::array<signed int, LINE_SIZE> *actual; std::array<int, 2> *meta; get_bit_fields(expected, &tag, &index, &offset); meta = &this->meta.at(index); - actual = this->data->at(index); + actual = &this->data->at(index); if (meta->at(0) != tag) { // address not in cache @@ -133,7 +133,7 @@ void Cache::fetch_resource(int expected) // occupant is dirty // writing line to DRam in case of dirty cache eviction r = this->lower->write_line( - L1CACHE, actual, + L1CACHE, *actual, ((index << LINE_SPEC) + (meta->at(0) << (L1_CACHE_LINE_SPEC + LINE_SPEC)))); if (r == OK) { @@ -141,7 +141,7 @@ void Cache::fetch_resource(int expected) r = WAIT; } } else { - r = this->lower->read_line(L1CACHE, expected, actual); + r = this->lower->read_line(L1CACHE, expected, *actual); if (r == OK) { meta->at(0) = tag; } @@ -166,16 +166,16 @@ std::ostream &operator<<(std::ostream &os, const Cache &c) std::vector<std::array<signed int, LINE_SIZE>> data = c.view(0, L1_CACHE_LINES); std::array<std::array<int, 2>, L1_CACHE_LINES> meta = c.get_meta(); - std::cout << "FOO " << meta.at(31)[0]; - os << " " << std::setfill(' ') << std::setw(L1_CACHE_LINE_SPEC + 2) << "INDEX" + os << " " << std::setfill(' ') << std::setw(L1_CACHE_LINE_SPEC + 2) + << "INDEX" << " | " << std::setfill(' ') << std::setw((8 + 3) * 4 - 1) << "DATA" << " | " << std::setfill(' ') << std::setw(MEM_LINE_SPEC - L1_CACHE_LINE_SPEC + 2) << "TAG" << " | D" << std::endl; for (int i = 0; i < L1_CACHE_LINES; ++i) { - os << " 0b" << std::setw(L1_CACHE_LINE_SPEC) << std::bitset<L1_CACHE_LINE_SPEC>(i) - << " | "; + os << " 0b" << std::setw(L1_CACHE_LINE_SPEC) + << std::bitset<L1_CACHE_LINE_SPEC>(i) << " | "; for (int j = 0; j < LINE_SIZE; ++j) { os << "0x" << std::setfill('0') << std::setw(8) << std::hex << data.at(i).at(j) << " "; @@ -183,9 +183,11 @@ std::ostream &operator<<(std::ostream &os, const Cache &c) os << "| 0b" << std::setfill(' '); if (meta.at(i)[0] < 0) - os << std::setfill('?') << std::setw(MEM_LINE_SPEC - L1_CACHE_LINE_SPEC) << ""; + os << std::setfill('?') + << std::setw(MEM_LINE_SPEC - L1_CACHE_LINE_SPEC) << ""; else - os << std::bitset<MEM_LINE_SPEC - L1_CACHE_LINE_SPEC>(meta.at(i)[0]); + os << std::bitset<MEM_LINE_SPEC - L1_CACHE_LINE_SPEC>( + meta.at(i)[0]); os << " | " << (int)(meta.at(i)[0] >= 0) << std::endl; } diff --git a/src/storage/dram.cc b/src/storage/dram.cc index 60b4ae5..56eec47 100644 --- a/src/storage/dram.cc +++ b/src/storage/dram.cc @@ -143,11 +143,13 @@ std::ostream &operator<<(std::ostream &os, const Dram &d) std::vector<std::array<signed int, LINE_SIZE>> data = d.view(0, MEM_LINES); - os << " " << std::setfill(' ') << std::setw(MEM_LINE_SPEC + 2 + LINE_SPEC) << "ADDRESS" + os << " " << std::setfill(' ') << std::setw(MEM_LINE_SPEC + 2 + LINE_SPEC) + << "ADDRESS" << " | " << std::setfill(' ') << std::setw((8 + 3) * 4 - 1) << "DATA" << std::endl; for (int i = 0; i < MEM_LINES; ++i) { - os << " 0b" << std::setw(MEM_LINE_SPEC+LINE_SPEC) << left << std::bitset<MEM_LINE_SPEC>(i) << " | "; + os << " 0b" << std::setw(MEM_LINE_SPEC + LINE_SPEC) << left + << std::bitset<MEM_LINE_SPEC>(i) << " | "; for (int j = 0; j < LINE_SIZE; ++j) { os << "0x" << std::setfill('0') << std::setw(8) << std::hex << data.at(i).at(j) << ' '; |