aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/cache.h
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-04-08 11:33:26 +0200
committerKarel Kočí <cynerd@email.cz>2018-04-08 11:33:26 +0200
commit3652d0a13857b7c341fb08a882e12c0b2205c8c0 (patch)
tree1c8db1bdb118cf60c78b478c2d672d48d6873e0b /qtmips_machine/cache.h
parentd80338e5cfff59f0e9f2be4cd86e312000b2d8c0 (diff)
downloadqtmips-3652d0a13857b7c341fb08a882e12c0b2205c8c0.tar.gz
qtmips-3652d0a13857b7c341fb08a882e12c0b2205c8c0.tar.bz2
qtmips-3652d0a13857b7c341fb08a882e12c0b2205c8c0.zip
Add associative cache
Not fully tested yet.
Diffstat (limited to 'qtmips_machine/cache.h')
-rw-r--r--qtmips_machine/cache.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/qtmips_machine/cache.h b/qtmips_machine/cache.h
index 3ad3bdb..9372a1a 100644
--- a/qtmips_machine/cache.h
+++ b/qtmips_machine/cache.h
@@ -4,6 +4,7 @@
#include <memory.h>
#include <machineconfig.h>
#include <stdint.h>
+#include <time.h>
namespace machine {
@@ -20,7 +21,10 @@ public:
unsigned hit(); // Number of recorded hits
unsigned miss(); // Number of recorded misses
- // TODO reset
+ void reset(); // Reset whole state of cache
+
+ const MachineConfigCache &config();
+ // TODO getters for cells
private:
MachineConfigCache cnf;
@@ -33,9 +37,16 @@ private:
};
mutable struct cache_data **dt;
- mutable unsigned hitc, missc;
+ union {
+ time_t ** lru; // Access time
+ unsigned **lfu; // Access count
+ } replc; // Data used for replacement policy
+
+ mutable unsigned hitc, missc; // Hit and miss counters
void access(std::uint32_t address, std::uint32_t **data, bool read) const;
+ void kick(unsigned associat_indx, unsigned row) const;
+ std::uint32_t base_address(std::uint32_t tag, unsigned row) const;
};
}