summaryrefslogtreecommitdiff
path: root/src/cache.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-14 23:27:54 -0400
committerbd <bdunahu@operationnull.com>2025-04-14 23:27:54 -0400
commit2140a23041d3920e001457f2c2acb0853094963d (patch)
treed159da923af1a70279676780677bdcd9381a7011 /src/cache.cc
parent661ba30d5233e1b95ac312e88cd51380e664933b (diff)
Simplify cache/dram process functions
Diffstat (limited to 'src/cache.cc')
-rw-r--r--src/cache.cc31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/cache.cc b/src/cache.cc
index 44a770d..ee4b00c 100644
--- a/src/cache.cc
+++ b/src/cache.cc
@@ -58,25 +58,26 @@ Cache::read_word(void *id, int address, signed int &data)
int
Cache::process(void *id, int address, std::function<void(int index, int offset)> request_handler)
{
- int r;
-
- r = 0;
if (id == nullptr)
throw std::invalid_argument("Accessor cannot be nullptr.");
+
if (this->current_request == nullptr)
this->current_request = id;
- if (this->current_request == id) {
- if (is_address_missing(address))
- r = 0;
- else
- r = this->is_access_cleared();
- }
- if (r) {
- int tag, index, offset;
- GET_FIELDS(address, &tag, &index, &offset);
- request_handler(index, offset);
- }
- return r;
+
+ if (this->current_request != id)
+ return 0;
+
+ if (is_address_missing(address))
+ return 0;
+
+ if (!this->is_data_ready())
+ return 0;
+
+ int tag, index, offset;
+ GET_FIELDS(address, &tag, &index, &offset);
+ request_handler(index, offset);
+
+ return 1;
}
int