From 8b553ef5863a07a0c9ae3a970bf6afe552ce6121 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Tue, 12 Feb 2019 00:39:09 +0100 Subject: Add debug access to rword and friends to allow read data through cache without disturbing statistic. This allows to switch view between CPU and raw memory content. Signed-off-by: Pavel Pisa --- qtmips_machine/memory.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'qtmips_machine/memory.cpp') diff --git a/qtmips_machine/memory.cpp b/qtmips_machine/memory.cpp index af9420b..848669d 100644 --- a/qtmips_machine/memory.cpp +++ b/qtmips_machine/memory.cpp @@ -61,18 +61,18 @@ bool MemoryAccess::write_word(std::uint32_t offset, std::uint32_t value) { return wword(offset, value); } -std::uint8_t MemoryAccess::read_byte(std::uint32_t offset) const { +std::uint8_t MemoryAccess::read_byte(std::uint32_t offset, bool debug_access) const { int nth = SH_NTH_8(offset); - return (std::uint8_t)(rword(offset) >> nth); + return (std::uint8_t)(rword(offset, debug_access) >> nth); } -std::uint16_t MemoryAccess::read_hword(std::uint32_t offset) const { +std::uint16_t MemoryAccess::read_hword(std::uint32_t offset, bool debug_access) const { int nth = SH_NTH_16(offset); - return (std::uint16_t)(rword(offset) >> nth); + return (std::uint16_t)(rword(offset, debug_access) >> nth); } -std::uint32_t MemoryAccess::read_word(std::uint32_t offset) const { - return rword(offset); +std::uint32_t MemoryAccess::read_word(std::uint32_t offset, bool debug_access) const { + return rword(offset, debug_access); } void MemoryAccess::write_ctl(enum AccessControl ctl, std::uint32_t offset, std::uint32_t value) { @@ -151,7 +151,8 @@ bool MemorySection::wword(std::uint32_t offset, std::uint32_t value) { return changed; } -std::uint32_t MemorySection::rword(std::uint32_t offset) const { +std::uint32_t MemorySection::rword(std::uint32_t offset, bool debug_access) const { + (void)debug_access; offset = offset >> 2; if (offset >= this->len) throw QTMIPS_EXCEPTION(OutOfMemoryAccess, "Trying to read outside of the memory section", QString("Accessing using offset: ") + QString(offset)); @@ -263,12 +264,12 @@ bool Memory::wword(std::uint32_t address, std::uint32_t value) { return changed; } -std::uint32_t Memory::rword(std::uint32_t address) const { +std::uint32_t Memory::rword(std::uint32_t address, bool debug_access) const { MemorySection *section = this->get_section(address, false); if (section == nullptr) return 0; else - return section->read_word(SECTION_OFFSET_MASK(address)); + return section->read_word(SECTION_OFFSET_MASK(address), debug_access); } bool Memory::operator==(const Memory&m) const { -- cgit v1.2.3