From e6bb3b28987b7c521a4a8b35342f71a147b55fec Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Mon, 4 Feb 2019 10:30:00 +0100 Subject: Correct write-back cache behavior. Signed-off-by: Pavel Pisa --- qtmips_machine/cache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qtmips_machine/cache.cpp') diff --git a/qtmips_machine/cache.cpp b/qtmips_machine/cache.cpp index 9f4bfb0..f724561 100644 --- a/qtmips_machine/cache.cpp +++ b/qtmips_machine/cache.cpp @@ -216,7 +216,7 @@ bool Cache::access(std::uint32_t address, std::uint32_t *data, bool write, std:: } cd.valid = true; // We either write to it or we read from memory. Either way it's valid when we leave Cache class - cd.dirty = cd.dirty || !write; + cd.dirty = cd.dirty || write; cd.tag = tag; *data = cd.data[col]; @@ -233,7 +233,7 @@ void Cache::kick(unsigned associat_indx, unsigned row) const { struct cache_data &cd = dt[associat_indx][row]; if (cd.dirty && cnf.write_policy() == MachineConfigCache::WP_BACK) for (unsigned i = 0; i < cnf.blocks(); i++) - mem->wword(base_address(associat_indx, row) + (4*i), cd.data[i]); + mem->wword(base_address(cd.tag, row) + (4*i), cd.data[i]); cd.valid = false; cd.dirty = false; -- cgit v1.2.3