summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-11 16:30:40 -0400
committerbd <bdunahu@operationnull.com>2025-03-11 16:30:40 -0400
commitaed0a13d39bfe0b189ea43117aeb2e8b9188c3d9 (patch)
tree27633137381adfe656a9a1175d03cb164983549f /src
parent7eea92651e3f7c1a60726b3646dc96fe6118c1d7 (diff)
remove operation.h and branch determined by read/write in cache load
Diffstat (limited to 'src')
-rw-r--r--src/storage/cache.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/storage/cache.cc b/src/storage/cache.cc
index 1224aa9..5e071ac 100644
--- a/src/storage/cache.cc
+++ b/src/storage/cache.cc
@@ -34,7 +34,7 @@ Response Cache::write(Accessor accessor, signed int data, int address)
this->requester = accessor;
if (this->requester == accessor) {
- fetch_resource(WRITE,address);
+ fetch_resource(address);
if (this->is_waiting)
r = BLOCKED;
else if (this->wait_time == 0) {
@@ -49,7 +49,8 @@ Response Cache::write(Accessor accessor, signed int data, int address)
return r;
}
-Response Cache::write_line(Accessor accessor, std::array<signed int, LINE_SIZE> data_line, int address)
+Response Cache::write_line(
+ Accessor accessor, std::array<signed int, LINE_SIZE> data_line, int address)
{
Response r = WAIT;
@@ -58,7 +59,7 @@ Response Cache::write_line(Accessor accessor, std::array<signed int, LINE_SIZE>
this->requester = accessor;
if (this->requester == accessor) {
- fetch_resource(WRITE,address);
+ fetch_resource(address);
if (this->is_waiting)
r = BLOCKED;
else if (this->wait_time == 0) {
@@ -74,13 +75,16 @@ Response Cache::write_line(Accessor accessor, std::array<signed int, LINE_SIZE>
}
// TODO: tests for multi level cache
-Response Cache::read(Accessor accessor, int address, std::array<signed int, LINE_SIZE> &data_line)
+Response Cache::read(
+ Accessor accessor,
+ int address,
+ std::array<signed int, LINE_SIZE> &data_line)
{
Response r = WAIT;
if (this->requester == IDLE)
this->requester = accessor;
if (this->requester == accessor) {
- fetch_resource(READ,address);
+ fetch_resource(address);
if (this->is_waiting)
r = BLOCKED;
else if (this->wait_time == 0) {
@@ -99,7 +103,7 @@ Response Cache::read_word(Accessor accessor, int address, signed int &data)
if (this->requester == IDLE)
this->requester = accessor;
if (this->requester == accessor) {
- fetch_resource(READ,address);
+ fetch_resource(address);
if (this->is_waiting)
r = BLOCKED;
else if (this->wait_time == 0) {
@@ -112,7 +116,7 @@ Response Cache::read_word(Accessor accessor, int address, signed int &data)
return r;
}
-void Cache::fetch_resource(Operation op, int expected)
+void Cache::fetch_resource(int expected)
{
Response r = OK;
int tag, index, offset;
@@ -128,12 +132,12 @@ void Cache::fetch_resource(Operation op, int expected)
if (meta->at(1) >= 0) {
// occupant is dirty
// writing line to DRam in case of dirty cache eviction
- r = this->lower->write_line(L1CACHE, actual, ((index << LINE_SPEC) + (meta->at(0) << (L1_CACHE_SPEC + LINE_SPEC))));
+ r = this->lower->write_line(
+ L1CACHE, actual,
+ ((index << LINE_SPEC) +
+ (meta->at(0) << (L1_CACHE_SPEC + LINE_SPEC))));
if (r == OK) {
meta->at(1) = -1;
- if(op == READ){
- r = WAIT; //if operation is read, need to wait until cache is loaded with right value from memory address, if operation is write, then this is not necessary
- }
}
} else {
r = this->lower->read(L1CACHE, expected, actual);