diff options
| author | Julian Blake Kongslie | 2023-01-22 14:27:12 -0800 |
|---|---|---|
| committer | Julian Blake Kongslie | 2023-01-22 14:27:12 -0800 |
| commit | d0208c8159e7e454e9d3eec8f65a7050afa0e8af (patch) | |
| tree | 282fe11e0df49af44eecf776c364ffa589b57139 | |
| parent | Ignore redundant fill responses in inline_cache. (diff) | |
| download | nanosim-d0208c8159e7e454e9d3eec8f65a7050afa0e8af.tar.xz | |
Diffstat (limited to '')
| -rw-r--r-- | memory/cache.h | 14 |
1 files changed, 14 insertions, 0 deletions
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 { | |||
| 59 | d = r.data; | 59 | d = r.data; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | void opportunistic_store(std::uint64_t address, unsigned int d) { | ||
| 63 | auto line_address = address >> LINE_BYTES_LOG2; | ||
| 64 | auto set_address = line_address & LINE_SET_OFFSET_MASK; | ||
| 65 | auto &stags = tags[set_address]; | ||
| 66 | auto &sdata = data[set_address]; | ||
| 67 | for (unsigned int i = 0; i < WAYS; ++i) { | ||
| 68 | auto &stag = stags[i]; | ||
| 69 | if (stag.serial && stag.line_address == line_address) { | ||
| 70 | sdata[i][address & LINE_BYTE_OFFSET_MASK] = d; | ||
| 71 | return; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 62 | std::optional<tag> probe(std::uint64_t address) { | 76 | std::optional<tag> probe(std::uint64_t address) { |
| 63 | auto line_address = address >> LINE_BYTES_LOG2; | 77 | auto line_address = address >> LINE_BYTES_LOG2; |
| 64 | auto set_address = line_address & LINE_SET_OFFSET_MASK; | 78 | auto set_address = line_address & LINE_SET_OFFSET_MASK; |
