summaryrefslogtreecommitdiff
path: root/src/storage
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-09 20:56:00 -0400
committerbd <bdunahu@operationnull.com>2025-03-09 20:56:00 -0400
commit4676d633edaea37b5661e4f91742b42fcf5b7881 (patch)
tree9b5670221859de5f042f677a7b294c6b46d83518 /src/storage
parent4dc12d82699520bdc6875e5177ae8a6a2c2dea04 (diff)
cache store single test
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/cache.cc13
1 files changed, 9 insertions, 4 deletions
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 <bits/stdc++.h>
-Cache::Cache(int lines, Storage *lower, int delay)
+Cache::Cache(Storage *lower, int delay)
{
this->data = new std::vector<std::array<signed int, LINE_SIZE>>;
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<signed int, LINE_SIZE> actual;
std::array<int, 2> 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?
}
}