summaryrefslogtreecommitdiff
path: root/src/storage
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-09 12:05:12 -0400
committerbd <bdunahu@operationnull.com>2025-03-09 12:05:12 -0400
commit2b458c01aca16e26939e169f1b545982e0f8626f (patch)
treea5dd7456fe035bad6c310215d4f6076ff92f90c6 /src/storage
parentebbbf190825d6d098116f6bdd5245a4498b17815 (diff)
Add bitset field to cache.h for keeping track of write/validity
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/cache.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/storage/cache.cc b/src/storage/cache.cc
index bbefb2a..bf1126a 100644
--- a/src/storage/cache.cc
+++ b/src/storage/cache.cc
@@ -6,17 +6,31 @@
Cache::Cache(int lines, Storage *lower, int delay)
{
this->data = new std::vector<std::array<signed int, LINE_SIZE>>;
- this->data->resize(lines);
+ this->data->resize(L1_CACHE_SIZE);
this->lower = lower;
this->delay = delay;
- this->lower = nullptr;
+ for (int i = 0; i < L1_CACHE_SIZE; ++i)
+ this->stat[i] = 0b01;
}
Cache::~Cache() { delete this->data; }
Response Cache::write(Accessor accessor, signed int data, int address)
{
- return WAIT;
+ Response r = WAIT;
+
+ /* Do this first--then process the first cycle immediately. */
+ if (this->requester == IDLE)
+ this->requester = accessor;
+
+ if (this->requester == accessor) {
+ if (this->wait_time == 0) {
+ this->do_write(data, address);
+ r = OK;
+ }
+ }
+
+ return r;
}
Response Cache::read(Accessor accessor, int address) { return WAIT; }