From 8027941b705e219fd202b7c01d5a4a311670cbee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 7 Apr 2018 21:13:42 +0200 Subject: Add initial implementatio of caches --- qtmips_machine/cache.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'qtmips_machine/cache.h') 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 #include +#include 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; }; } -- cgit v1.2.3