From 71bc1229d67e7ddde351d92ccebfabf0ba79c814 Mon Sep 17 00:00:00 2001 From: bd Date: Wed, 16 Apr 2025 17:38:42 -0400 Subject: Wrap all addresses immediately --- inc/dram.h | 9 --------- inc/storage.h | 9 +++++++++ src/cache.cc | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/inc/dram.h b/inc/dram.h index 2a4e358..847642d 100644 --- a/inc/dram.h +++ b/inc/dram.h @@ -5,15 +5,6 @@ #include #include -// clang-format off -/** - * Ensures address is within the current memory size using a clean wrap. - * @param an address - */ -#define WRAP_ADDRESS(a) \ - ((a < 0) ? ((a % MEM_WORDS) + MEM_WORDS) % MEM_WORDS : a % MEM_WORDS) -// clang-format on - class Dram : public Storage { public: diff --git a/inc/storage.h b/inc/storage.h index 1bf5805..994bb8f 100644 --- a/inc/storage.h +++ b/inc/storage.h @@ -7,6 +7,15 @@ #include #include +// clang-format off +/** + * Ensures address is within the current memory size using a clean wrap. + * @param an address + */ +#define WRAP_ADDRESS(a) \ + ((a < 0) ? ((a % MEM_WORDS) + MEM_WORDS) % MEM_WORDS : a % MEM_WORDS) +// clang-format on + class Storage { public: diff --git a/src/cache.cc b/src/cache.cc index a2d4525..c934a26 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -62,6 +62,7 @@ Cache::read_word(void *id, int address, signed int &data) int Cache::process(void *id, int address, std::function request_handler) { + address = WRAP_ADDRESS(address); if (!preprocess(id) || priming_address(address) || !this->is_data_ready()) return 0; -- cgit v1.2.3