aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/memorymodel.cpp39
-rw-r--r--qtmips_gui/memorymodel.h2
-rw-r--r--qtmips_gui/programmodel.cpp41
-rw-r--r--qtmips_gui/programmodel.h2
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;