From ebbbf190825d6d098116f6bdd5245a4498b17815 Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 8 Mar 2025 22:50:57 -0500 Subject: Add get_bit_fields, which parses cache fields from a memory address --- src/utils/utils.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/utils/utils.cc (limited to 'src/utils/utils.cc') diff --git a/src/utils/utils.cc b/src/utils/utils.cc new file mode 100644 index 0000000..b4bdb2f --- /dev/null +++ b/src/utils/utils.cc @@ -0,0 +1,11 @@ +#include "definitions.h" +#include "utils.h" + +void get_bit_fields(int address, int *tag, int *index, int *offset) +{ + *tag = + MID(address, LINE_SPEC + L1_CACHE_SPEC, + MEM_SPEC + LINE_SPEC + L1_CACHE_SPEC); + *index = MID(address, LINE_SPEC, L1_CACHE_SPEC + LINE_SPEC); + *offset = LAST(address, LINE_SPEC); +} -- cgit v1.2.3