diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-03-10 10:28:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-10 10:28:28 -0400 |
commit | 66edce63597093cf5f3afa5b577fd9e3ecae0ef6 (patch) | |
tree | a0b0df4fff6f7d680901cd6007df67b15b3df3b6 /inc/cache.h | |
parent | 92b41d1a8b970c46b0c6d2d8d538c68855a4de25 (diff) | |
parent | 1f8b8babcfb383f1fb0281663561161061684206 (diff) |
Merge pull request #19 from bdunahu/bdunahu
cache store, handle load requests to memory, write allocate policy
-- changes look good
Diffstat (limited to 'inc/cache.h')
-rw-r--r-- | inc/cache.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/inc/cache.h b/inc/cache.h index d470e6c..e8b7030 100644 --- a/inc/cache.h +++ b/inc/cache.h @@ -1,6 +1,8 @@ #ifndef CACHE_H #define CACHE_H -#include <storage.h> +#include "definitions.h" +#include "storage.h" +#include <array> class Cache : public Storage { @@ -14,11 +16,30 @@ class Cache : public Storage * @param The number of clock cycles each access takes. * @return A new cache object. */ - Cache(int lines, Storage *lower, int delay); + Cache(Storage *lower, int delay); ~Cache(); Response write(Accessor accessor, signed int data, int address) override; - Response read(Accessor accessor, int address, std::array<signed int, LINE_SIZE>& data) override; + Response read( + Accessor accessor, + int address, + std::array<signed int, LINE_SIZE> &data) override; + + private: + /** + * Fetches `address` from a lower level of storage if it is not already + * present. If it is not, temporarily sets the is_blocked attribute of this + * cache level to true, and the victim line is chosen/written back. + * @param the address that must be present in cache. + */ + void fetch_resource(int address); + /** + * An array of metadata about elements in `data`. + * If the first value of an element is negative, the corresponding + * element in `data` is invalid. If the most second value of an element + * is nonzero, the corresponding element in `data` is dirty. + */ + std::array<std::array<int, 2>, L1_CACHE_SIZE> meta; }; #endif /* CACHE_H_INCLUDED */ |