From 4676d633edaea37b5661e4f91742b42fcf5b7881 Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 9 Mar 2025 20:56:00 -0400 Subject: cache store single test --- src/storage/cache.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/storage/cache.cc b/src/storage/cache.cc index ec14ce6..f1ae238 100644 --- a/src/storage/cache.cc +++ b/src/storage/cache.cc @@ -4,7 +4,7 @@ #include "utils.h" #include -Cache::Cache(int lines, Storage *lower, int delay) +Cache::Cache(Storage *lower, int delay) { this->data = new std::vector>; this->data->resize(L1_CACHE_SIZE); @@ -28,6 +28,10 @@ Response Cache::write(Accessor accessor, signed int data, int address) if (this->is_waiting == true) r = BLOCKED; else if (this->wait_time == 0) { + int tag, index, offset; + get_bit_fields(address, &tag, &index, &offset); + this->data->at(index).at(offset) = data; + r = OK; } } @@ -44,22 +48,23 @@ Response Cache::read( void Cache::fetch_resource(int expected) { Response r = OK; - int etag, index, atag; + int etag, index, eoffset, atag; std::array actual; std::array meta; - get_bit_fields(expected, &etag, &index, nullptr); + get_bit_fields(expected, &etag, &index, &eoffset); meta = this->meta.at(index); if (atag != etag) { // address not in cache - if (this->meta[index][0]) { + if (this->meta[index][0] >= 0) { // occupant is dirty // TODO r = WAIT; } else { actual = this->data->at(index); r = this->lower->read(L1CACHE, expected, actual); + // clear dirty bit and set tag? } } -- cgit v1.2.3