From 3652d0a13857b7c341fb08a882e12c0b2205c8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 8 Apr 2018 11:33:26 +0200 Subject: Add associative cache Not fully tested yet. --- qtmips_machine/cache.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'qtmips_machine/cache.h') 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 #include #include +#include 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; }; } -- cgit v1.2.3