diff options
author | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-06-30 18:22:27 +0200 |
---|---|---|
committer | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-06-30 18:22:27 +0200 |
commit | 9dc519887f61ae33ff82bb125fb69398503f91f6 (patch) | |
tree | c0074870df060adc0f546715e39169cacc8d5667 /qtmips_gui | |
parent | c86a491e26800f620b51ced800b612e73da1cced (diff) | |
download | qtmips-9dc519887f61ae33ff82bb125fb69398503f91f6.tar.gz qtmips-9dc519887f61ae33ff82bb125fb69398503f91f6.tar.bz2 qtmips-9dc519887f61ae33ff82bb125fb69398503f91f6.zip |
Memory change counter moved to MemoryAccess and external changes notification added.
This change together with use of PhysAddrSpace as the memory
content source for memory and program view allows to access
and monitor contents of peripheral registers and frame-buffer
memory from graphic user interface.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r-- | qtmips_gui/memorymodel.cpp | 39 | ||||
-rw-r--r-- | qtmips_gui/memorymodel.h | 2 | ||||
-rw-r--r-- | qtmips_gui/programmodel.cpp | 41 | ||||
-rw-r--r-- | qtmips_gui/programmodel.h | 2 |
4 files changed, 64 insertions, 20 deletions
diff --git a/qtmips_gui/memorymodel.cpp b/qtmips_gui/memorymodel.cpp index 329891e..2927279 100644 --- a/qtmips_gui/memorymodel.cpp +++ b/qtmips_gui/memorymodel.cpp @@ -49,6 +49,22 @@ MemoryModel::MemoryModel(QObject *parent) access_through_cache = 0; } +const machine::MemoryAccess *MemoryModel::mem_access() const { + if (machine == nullptr) + return nullptr; + if (machine->physical_address_space() != nullptr) + return machine->physical_address_space(); + return machine->memory(); +} + +machine::MemoryAccess *MemoryModel::mem_access_rw() const { + if (machine == nullptr) + return nullptr; + if (machine->physical_address_space_rw() != nullptr) + return machine->physical_address_space_rw(); + return machine->memory_rw(); +} + int MemoryModel::rowCount(const QModelIndex & /*parent*/) const { // std::uint64_t rows = (0x2000 + cells_per_row - 1) / cells_per_row; return 750; @@ -91,7 +107,7 @@ QVariant MemoryModel::data(const QModelIndex &index, int role) const { } if (machine == nullptr) return QString(""); - mem = machine->memory(); + mem = mem_access(); if (mem == nullptr) return QString(""); if ((access_through_cache > 0) && (machine->cache_data() != nullptr)) @@ -155,6 +171,9 @@ void MemoryModel::setup(machine::QtMipsMachine *machine) { this->machine = machine; if (machine != nullptr) connect(machine, SIGNAL(post_tick()), this, SLOT(check_for_updates())); + if (mem_access() != nullptr) + connect(mem_access(), SIGNAL(external_change_notify(const MemoryAccess*,std::uint32_t,std::uint32_t,bool)), + this, SLOT(check_for_updates())); emit update_all(); emit setup_done(); } @@ -174,8 +193,10 @@ void MemoryModel::set_cell_size(int index) { } void MemoryModel::update_all() { - if (machine != nullptr && machine->memory() != nullptr) { - memory_change_counter = machine->memory()->get_change_counter(); + const machine::MemoryAccess *mem; + mem = mem_access(); + if (mem != nullptr) { + memory_change_counter = mem->get_change_counter(); if (machine->cache_data() != nullptr) cache_data_change_counter = machine->cache_data()->get_change_counter(); } @@ -184,12 +205,12 @@ void MemoryModel::update_all() { void MemoryModel::check_for_updates() { bool need_update = false; - if (machine == nullptr) - return; - if (machine->memory() == nullptr) + const machine::MemoryAccess *mem; + mem = mem_access(); + if (mem == nullptr) return; - if (memory_change_counter != machine->memory()->get_change_counter()) + if (memory_change_counter != mem->get_change_counter()) need_update = true; if (machine->cache_data() != nullptr) { if (cache_data_change_counter != machine->cache_data()->get_change_counter()) @@ -235,15 +256,15 @@ bool MemoryModel::setData(const QModelIndex & index, const QVariant & value, int { bool ok; std::uint32_t address; + machine::MemoryAccess *mem; std::uint32_t data = value.toString().toULong(&ok, 16); if (!ok) return false; - machine::MemoryAccess *mem; if (!get_row_address(address, index.row())) return false; if (index.column() == 0 || machine == nullptr) return false; - mem = machine->memory_rw(); + mem = mem_access_rw(); if (mem == nullptr) return false; if ((access_through_cache > 0) && (machine->cache_data_rw() != nullptr)) diff --git a/qtmips_gui/memorymodel.h b/qtmips_gui/memorymodel.h index bab07fa..353757a 100644 --- a/qtmips_gui/memorymodel.h +++ b/qtmips_gui/memorymodel.h @@ -115,6 +115,8 @@ signals: void setup_done(); private: + const machine::MemoryAccess *mem_access() const; + machine::MemoryAccess *mem_access_rw() const; enum MemoryCellSize cell_size; unsigned int cells_per_row; std::uint32_t index0_offset; diff --git a/qtmips_gui/programmodel.cpp b/qtmips_gui/programmodel.cpp index 90e161b..9098ab1 100644 --- a/qtmips_gui/programmodel.cpp +++ b/qtmips_gui/programmodel.cpp @@ -49,6 +49,22 @@ ProgramModel::ProgramModel(QObject *parent) stages_need_update = false; } +const machine::MemoryAccess *ProgramModel::mem_access() const { + if (machine == nullptr) + return nullptr; + if (machine->physical_address_space() != nullptr) + return machine->physical_address_space(); + return machine->memory(); +} + +machine::MemoryAccess *ProgramModel::mem_access_rw() const { + if (machine == nullptr) + return nullptr; + if (machine->physical_address_space_rw() != nullptr) + return machine->physical_address_space_rw(); + return machine->memory_rw(); +} + int ProgramModel::rowCount(const QModelIndex & /*parent*/) const { return 750; } @@ -79,6 +95,8 @@ QVariant ProgramModel::headerData(int section, Qt::Orientation orientation, int } QVariant ProgramModel::data(const QModelIndex &index, int role) const { + const machine::MemoryAccess *mem; + if (role == Qt::DisplayRole || role == Qt::EditRole) { QString s, t; @@ -92,12 +110,11 @@ QVariant ProgramModel::data(const QModelIndex &index, int role) const { return "0x" + s + t.toUpper(); } - if (machine == nullptr) - return QString(" "); - if (machine->memory() == nullptr) + mem = mem_access(); + if (mem == nullptr) return QString(" "); - machine::Instruction inst(machine->memory()->read_word(address)); + machine::Instruction inst(mem->read_word(address)); switch (index.column()) { case 0: @@ -163,8 +180,10 @@ void ProgramModel::setup(machine::QtMipsMachine *machine) { } void ProgramModel::update_all() { - if (machine != nullptr && machine->memory() != nullptr) { - memory_change_counter = machine->memory()->get_change_counter(); + const machine::MemoryAccess *mem; + mem = mem_access(); + if (mem != nullptr) { + memory_change_counter = mem->get_change_counter(); if (machine->cache_program() != nullptr) cache_program_change_counter = machine->cache_program()->get_change_counter(); } @@ -174,12 +193,12 @@ void ProgramModel::update_all() { void ProgramModel::check_for_updates() { bool need_update = stages_need_update; - if (machine == nullptr) - return; - if (machine->memory() == nullptr) + const machine::MemoryAccess *mem; + mem = mem_access(); + if (mem == nullptr) return; - if (memory_change_counter != machine->memory()->get_change_counter()) + if (memory_change_counter != mem->get_change_counter()) need_update = true; if (machine->cache_data() != nullptr) { if (cache_program_change_counter != machine->cache_program()->get_change_counter()) @@ -241,7 +260,7 @@ bool ProgramModel::setData(const QModelIndex & index, const QVariant & value, in return false; if (index.column() == 0 || machine == nullptr) return false; - mem = machine->memory_rw(); + mem = mem_access_rw(); if (mem == nullptr) return false; switch (index.column()) { diff --git a/qtmips_gui/programmodel.h b/qtmips_gui/programmodel.h index a7c1699..d458eef 100644 --- a/qtmips_gui/programmodel.h +++ b/qtmips_gui/programmodel.h @@ -100,6 +100,8 @@ public slots: void update_stage_addr(uint stage, std::uint32_t addr); private: + const machine::MemoryAccess *mem_access() const; + machine::MemoryAccess *mem_access_rw() const; std::uint32_t index0_offset; QFont data_font; machine::QtMipsMachine *machine; |