aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-04 10:30:00 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-04 10:30:00 +0100
commite6bb3b28987b7c521a4a8b35342f71a147b55fec (patch)
tree1c7926e339cd9daa683ab0c3e247d22c6a0c204f /qtmips_machine
parent361f5aab10d72e2200dfc7985a1511044b987db8 (diff)
downloadqtmips-e6bb3b28987b7c521a4a8b35342f71a147b55fec.tar.gz
qtmips-e6bb3b28987b7c521a4a8b35342f71a147b55fec.tar.bz2
qtmips-e6bb3b28987b7c521a4a8b35342f71a147b55fec.zip
Correct write-back cache behavior.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_machine')
-rw-r--r--qtmips_machine/cache.cpp4
1 files changed, 2 insertions, 2 deletions
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;