summaryrefslogtreecommitdiff
path: root/src/utils/utils.cc
diff options
context:
space:
mode:
authorbd <bdunaisky@umass.edu>2025-03-11 21:16:25 +0000
committerGitHub <noreply@github.com>2025-03-11 21:16:25 +0000
commit92e8c2583695a3bf652e0e8dedb79e7a99922f5f (patch)
tree0574ee516499001244d33785a5fc380801c557c9 /src/utils/utils.cc
parent33c7c78b1c65c375d0291fd435e02ddc9d35681b (diff)
parent5f13f583e373bb02b7bf20cbcc9298dc1480a697 (diff)
Merge pull request #25 from bdunahu/dev-sid
support for read word, write line in all levels of storage, cache load, dirty cache eviction, memory address wrapping
Diffstat (limited to 'src/utils/utils.cc')
-rw-r--r--src/utils/utils.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/utils/utils.cc b/src/utils/utils.cc
index 5de8e89..f95d88f 100644
--- a/src/utils/utils.cc
+++ b/src/utils/utils.cc
@@ -28,3 +28,10 @@ const std::string string_format(const char *const zcFormat, ...)
va_end(vaArgs);
return std::string(zc.data(), iLen);
}
+
+int wrap_address(int address) {
+ if (address < 0){
+ return ((address % MEM_SIZE) + MEM_SIZE) % MEM_SIZE;
+ }
+ return address % MEM_SIZE;
+}