summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-21 16:42:16 -0400
committerbd <bdunahu@operationnull.com>2025-03-21 16:42:16 -0400
commit58ca44a7a02426ff493c60323241d40f084c6362 (patch)
tree9386aa3ccd2302fceb9750858d74ab56f156b4e2 /inc
parent75f78c215131499165101a499197313ba77ea230 (diff)
add 'process' function to handle boilerplate on every request
Diffstat (limited to 'inc')
-rw-r--r--inc/cache.h12
-rw-r--r--inc/dram.h12
2 files changed, 24 insertions, 0 deletions
diff --git a/inc/cache.h b/inc/cache.h
index a5fa16e..ef9c9e4 100644
--- a/inc/cache.h
+++ b/inc/cache.h
@@ -42,6 +42,18 @@ class Cache : public Storage
private:
/**
+ * Helper for all access methods.
+ * Calls `request_handler` when `accessor` is allowed to complete its
+ * request cycle.
+ * @param the source making the request
+ * @param the address to write to
+ * @param the function to call when an access should be completed
+ */
+ Response process(
+ Accessor accessor,
+ int address,
+ std::function<void(int index, int offset)> request_handler);
+ /**
* Returns OK if `accessor` is allowed to complete its request this cycle.
* Handles cache misses, wait times, and setting the current accessor this
* storage is serving.
diff --git a/inc/dram.h b/inc/dram.h
index ff2c298..e6db633 100644
--- a/inc/dram.h
+++ b/inc/dram.h
@@ -32,6 +32,18 @@ class Dram : public Storage
private:
/**
+ * Helper for all access methods.
+ * Calls `request_handler` when `accessor` is allowed to complete its
+ * request cycle.
+ * @param the source making the request
+ * @param the address to write to
+ * @param the function to call when an access should be completed
+ */
+ Response process(
+ Accessor accessor,
+ int address,
+ std::function<void(int line, int word)> request_handler);
+ /**
* Returns OK if `accessor` is allowed to complete its request this cycle.
* Handles wait times, side door, and setting the current accessor this
* storage is serving.