From 2140a23041d3920e001457f2c2acb0853094963d Mon Sep 17 00:00:00 2001 From: bd Date: Mon, 14 Apr 2025 23:27:54 -0400 Subject: Simplify cache/dram process functions --- src/dram.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/dram.cc') diff --git a/src/dram.cc b/src/dram.cc index 264cadb..5e7e57a 100644 --- a/src/dram.cc +++ b/src/dram.cc @@ -54,19 +54,22 @@ Dram::load(std::vector program) int Dram::process(void *id, int address, std::function request_handler) { - int r; - if (id == nullptr) throw std::invalid_argument("Accessor cannot be nullptr."); + if (this->current_request == nullptr) this->current_request = id; - 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 r; + + if (this->current_request != id) + return 0; + + if (!this->is_data_ready()) + return 0; + + int line, word; + get_memory_index(address, line, word); + request_handler(line, word); + return 1; } void -- cgit v1.2.3