diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-04-12 13:04:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-12 13:04:10 -0400 |
commit | 561f7a6e6c24b05383b6db86b48125ee80a8355f (patch) | |
tree | 6acbfd27652c2b83686df93c21918a877a0451e8 /src/utils/utils.cc | |
parent | c9e35a8f3aa2047701e87a50f12b4bed23d5e7db (diff) | |
parent | 3ae113c7d6f1b6f46d8960b284837a44fbeb2e77 (diff) |
Merge pull request #50 from bdunahu/bdunahu
Move storage to a separate git repository.
Diffstat (limited to 'src/utils/utils.cc')
-rw-r--r-- | src/utils/utils.cc | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/utils/utils.cc b/src/utils/utils.cc deleted file mode 100644 index e12a0e0..0000000 --- a/src/utils/utils.cc +++ /dev/null @@ -1,42 +0,0 @@ -#include "utils.h" -#include "definitions.h" -#include <cstdarg> -#include <string> -#include <vector> - -void get_cache_fields(int address, int *tag, int *index, int *offset) -{ - *tag = GET_MID_BITS(address, L1_CACHE_LINE_SPEC + LINE_SPEC, MEM_WORD_SPEC); - *index = GET_MID_BITS(address, LINE_SPEC, L1_CACHE_LINE_SPEC + LINE_SPEC); - *offset = GET_LS_BITS(address, LINE_SPEC); -} - -const std::string string_format(const char *const zcFormat, ...) -{ - va_list vaArgs; - va_start(vaArgs, zcFormat); - - va_list vaArgsCopy; - va_copy(vaArgsCopy, vaArgs); - const int iLen = std::vsnprintf(NULL, 0, zcFormat, vaArgsCopy); - va_end(vaArgsCopy); - - std::vector<char> zc(iLen + 1); - std::vsnprintf(zc.data(), zc.size(), zcFormat, vaArgs); - va_end(vaArgs); - return std::string(zc.data(), iLen); -} - -int wrap_address(int address) -{ - if (address < 0) { - return ((address % MEM_WORDS) + MEM_WORDS) % MEM_WORDS; - } - return address % MEM_WORDS; -} - -void get_memory_index(int address, int &line, int &word) -{ - line = wrap_address(address) / LINE_SIZE; - word = address % LINE_SIZE; -} |