summaryrefslogtreecommitdiff
path: root/src/dram.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-14 23:10:18 -0400
committerbd <bdunahu@operationnull.com>2025-04-14 23:10:18 -0400
commit661ba30d5233e1b95ac312e88cd51380e664933b (patch)
treebc9bba3e3e87025eebf86e6b5013485088cf0ccf /src/dram.cc
parent432e6f63ab4742ebf34ba7d031e269af810aa93f (diff)
Initial refactor of is_access_cleared
Diffstat (limited to 'src/dram.cc')
-rw-r--r--src/dram.cc27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/dram.cc b/src/dram.cc
index 18c1a3e..264cadb 100644
--- a/src/dram.cc
+++ b/src/dram.cc
@@ -55,33 +55,18 @@ int
Dram::process(void *id, int address, std::function<void(int line, int word)> request_handler)
{
int r;
- r = this->is_access_cleared(id);
- if (r) {
- int line, word;
- get_memory_index(address, line, word);
- request_handler(line, word);
- }
- return r;
-}
-int
-Dram::is_access_cleared(void *id)
-{
- /* Do this first--then process the first cycle immediately. */
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 (this->wait_time == 0) {
- this->current_request = nullptr;
- this->wait_time = delay;
- return 1;
- } else {
- --this->wait_time;
- }
+ r = (this->current_request == id) ? this->is_access_cleared() : 0;
+ if (r) {
+ int line, word;
+ get_memory_index(address, line, word);
+ request_handler(line, word);
}
- return 0;
+ return r;
}
void