diff options
author | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-02-07 18:26:45 +0100 |
---|---|---|
committer | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-02-07 18:26:45 +0100 |
commit | 1126b91af5bd2d4477b3e78e8c648b3a512b24f7 (patch) | |
tree | 38b5f319914865b63258b99a8c01ab984fb2f6ba /qtmips_machine/cache.cpp | |
parent | 780b3a9daa6a4c4eca9c095ad990334b43cc0dfa (diff) | |
download | qtmips-1126b91af5bd2d4477b3e78e8c648b3a512b24f7.tar.gz qtmips-1126b91af5bd2d4477b3e78e8c648b3a512b24f7.tar.bz2 qtmips-1126b91af5bd2d4477b3e78e8c648b3a512b24f7.zip |
Added method to retrieve memory location status.
It can inform if given location is cached or if given range
is invalid in address space.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_machine/cache.cpp')
-rw-r--r-- | qtmips_machine/cache.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/qtmips_machine/cache.cpp b/qtmips_machine/cache.cpp index 6a00c27..94e314b 100644 --- a/qtmips_machine/cache.cpp +++ b/qtmips_machine/cache.cpp @@ -216,6 +216,23 @@ const MachineConfigCache &Cache::config() const { return cnf; } +enum LocationStatus Cache::location_status(std::uint32_t address) { + unsigned ssize = cnf.blocks() * cnf.sets(); + std::uint32_t tag = address / ssize; + 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) + return (enum LocationStatus)(LOCSTAT_CACHED | LOCSTAT_DIRTY); + else + return (enum LocationStatus)LOCSTAT_CACHED; + } + } + return mem->location_status(address); +} + bool Cache::access(std::uint32_t address, std::uint32_t *data, bool write, std::uint32_t value) const { bool changed = false; address = address >> 2; |