From 25e85c6eed3c9457568de2d64ebfb32b1edfa0d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 15 Apr 2018 10:41:26 +0200 Subject: Show cache statistics in Memory block in coreview --- qtmips_machine/cache.cpp | 5 +++++ qtmips_machine/cache.h | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'qtmips_machine') diff --git a/qtmips_machine/cache.cpp b/qtmips_machine/cache.cpp index d699cd6..d8c1fff 100644 --- a/qtmips_machine/cache.cpp +++ b/qtmips_machine/cache.cpp @@ -93,6 +93,9 @@ void Cache::reset() { // Zero hit and miss rate hitc = 0; missc = 0; + // Trigger signals + emit hit_update(hitc); + emit miss_update(missc); } const MachineConfigCache &Cache::config() const { @@ -153,8 +156,10 @@ void Cache::access(std::uint32_t address, std::uint32_t **data, bool read) const // Update statistics and otherwise read from memory if (cd.valid) { hitc++; + emit hit_update(hitc); } else { missc++; + emit miss_update(missc); for (unsigned i = 0; i < cnf.blocks(); i++) cd.data[i] = mem->rword(base_address(tag, row) + (4*i)); } diff --git a/qtmips_machine/cache.h b/qtmips_machine/cache.h index 1882c6c..8321bbf 100644 --- a/qtmips_machine/cache.h +++ b/qtmips_machine/cache.h @@ -27,6 +27,10 @@ public: const MachineConfigCache &config() const; // TODO getters for cells +signals: + void hit_update(unsigned) const; + void miss_update(unsigned) const; + private: MachineConfigCache cnf; Memory *mem; -- cgit v1.2.3