From a0bc62d72314aa1c1946f0b1affe5bbe0dc64274 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Thu, 7 Feb 2019 21:05:44 +0100 Subject: Correct cache LocationStatus when cache is disabled. Signed-off-by: Pavel Pisa --- qtmips_machine/cache.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'qtmips_machine') diff --git a/qtmips_machine/cache.cpp b/qtmips_machine/cache.cpp index e327d7b..8767ee1 100644 --- a/qtmips_machine/cache.cpp +++ b/qtmips_machine/cache.cpp @@ -225,13 +225,15 @@ enum LocationStatus Cache::location_status(std::uint32_t address) const { std::uint32_t index = address % ssize; std::uint32_t row = index / cnf.blocks(); - for (unsigned indx = 0; indx < cnf.associativity(); indx++) { - if (dt[indx][row].valid && dt[indx][row].tag == tag) { - if (dt[indx][row].dirty && - cnf.write_policy() == MachineConfigCache::WP_BACK) - return (enum LocationStatus)(LOCSTAT_CACHED | LOCSTAT_DIRTY); - else - return (enum LocationStatus)LOCSTAT_CACHED; + if (cnf.enabled()) { + for (unsigned indx = 0; indx < cnf.associativity(); indx++) { + if (dt[indx][row].valid && dt[indx][row].tag == tag) { + if (dt[indx][row].dirty && + cnf.write_policy() == MachineConfigCache::WP_BACK) + return (enum LocationStatus)(LOCSTAT_CACHED | LOCSTAT_DIRTY); + else + return (enum LocationStatus)LOCSTAT_CACHED; + } } } return mem->location_status(address); -- cgit v1.2.3