aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/cache.h
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-08 19:55:47 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-08 19:55:47 +0100
commitc22e9cb1e18f35d02eb76b4f03a319a673168285 (patch)
tree729e6b6bf605d3ca3a80c50fc92e210ac5e38b94 /qtmips_machine/cache.h
parent89afab40d3e7c3d2ec0830b0cce897954c202d14 (diff)
downloadqtmips-c22e9cb1e18f35d02eb76b4f03a319a673168285.tar.gz
qtmips-c22e9cb1e18f35d02eb76b4f03a319a673168285.tar.bz2
qtmips-c22e9cb1e18f35d02eb76b4f03a319a673168285.zip
Move computation of cache row, column and tag to single inline function.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_machine/cache.h')
-rw-r--r--qtmips_machine/cache.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/qtmips_machine/cache.h b/qtmips_machine/cache.h
index 6027bd3..d08e66a 100644
--- a/qtmips_machine/cache.h
+++ b/qtmips_machine/cache.h
@@ -101,6 +101,15 @@ private:
void kick(unsigned associat_indx, unsigned row) const;
std::uint32_t base_address(std::uint32_t tag, unsigned row) const;
void update_statistics() const;
+ inline void compute_row_col_tag(std::uint32_t &row, std::uint32_t &col,
+ std::uint32_t &tag, std::uint32_t address) const {
+ address = address >> 2;
+ std::uint32_t ssize = cnf.blocks() * cnf.sets();
+ tag = address / ssize;
+ std::uint32_t index = address % ssize;
+ row = index / cnf.blocks();
+ col = index % cnf.blocks();
+ }
};
}