aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_machine/cache.h')
-rw-r--r--qtmips_machine/cache.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/qtmips_machine/cache.h b/qtmips_machine/cache.h
index 1bf82bf..3ad3bdb 100644
--- a/qtmips_machine/cache.h
+++ b/qtmips_machine/cache.h
@@ -3,12 +3,39 @@
#include <memory.h>
#include <machineconfig.h>
+#include <stdint.h>
namespace machine {
class Cache : public MemoryAccess {
+ Q_OBJECT
public:
Cache(Memory *m, MachineConfigCache *c);
+
+ void wword(std::uint32_t address, std::uint32_t value);
+ std::uint32_t rword(std::uint32_t address) const;
+
+ void flush(); // flush/sync cache
+
+ unsigned hit(); // Number of recorded hits
+ unsigned miss(); // Number of recorded misses
+
+ // TODO reset
+
+private:
+ MachineConfigCache cnf;
+ Memory *mem;
+
+ struct cache_data {
+ bool valid, dirty;
+ std::uint32_t tag;
+ std::uint32_t *data;
+ };
+ mutable struct cache_data **dt;
+
+ mutable unsigned hitc, missc;
+
+ void access(std::uint32_t address, std::uint32_t **data, bool read) const;
};
}