From d0208c8159e7e454e9d3eec8f65a7050afa0e8af Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sun, 22 Jan 2023 14:27:12 -0800 Subject: Add write-through store support in inline_cache. --- memory/cache.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/memory/cache.h b/memory/cache.h index c7fb602..4c3b3d9 100644 --- a/memory/cache.h +++ b/memory/cache.h @@ -59,6 +59,20 @@ namespace memory { d = r.data; } + void opportunistic_store(std::uint64_t address, unsigned int d) { + auto line_address = address >> LINE_BYTES_LOG2; + auto set_address = line_address & LINE_SET_OFFSET_MASK; + auto &stags = tags[set_address]; + auto &sdata = data[set_address]; + for (unsigned int i = 0; i < WAYS; ++i) { + auto &stag = stags[i]; + if (stag.serial && stag.line_address == line_address) { + sdata[i][address & LINE_BYTE_OFFSET_MASK] = d; + return; + } + } + } + std::optional probe(std::uint64_t address) { auto line_address = address >> LINE_BYTES_LOG2; auto set_address = line_address & LINE_SET_OFFSET_MASK; -- cgit v1.2.3