aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/programdock.cpp22
-rw-r--r--qtmips_gui/programdock.h1
-rw-r--r--qtmips_gui/programmodel.cpp37
-rw-r--r--qtmips_gui/programmodel.h12
4 files changed, 66 insertions, 6 deletions
diff --git a/qtmips_gui/programdock.cpp b/qtmips_gui/programdock.cpp
index 60a23b0..f3d3d78 100644
--- a/qtmips_gui/programdock.cpp
+++ b/qtmips_gui/programdock.cpp
@@ -101,6 +101,8 @@ ProgramDock::ProgramDock(QWidget *parent, QSettings *settings) : Super(parent) {
program_content, SLOT(focus_address_with_save(std::uint32_t)));
connect(program_content, SIGNAL(doubleClicked(QModelIndex)),
program_model, SLOT(toggle_hw_break(QModelIndex)));
+ connect(this, SIGNAL(stage_addr_changed(uint,std::uint32_t)),
+ program_model, SLOT(update_stage_addr(uint,std::uint32_t)));
}
void ProgramDock::setup(machine::QtMipsMachine *machine) {
@@ -121,31 +123,41 @@ void ProgramDock::set_follow_inst(int follow) {
}
void ProgramDock::fetch_inst_addr(std::uint32_t addr) {
- follow_addr[FOLLOWSRC_FETCH] = addr;
+ if (addr != machine::STAGEADDR_NONE)
+ follow_addr[FOLLOWSRC_FETCH] = addr;
+ emit stage_addr_changed(ProgramModel::STAGEADDR_FETCH, addr);
if (follow_source == FOLLOWSRC_FETCH)
update_follow_position();
}
void ProgramDock::decode_inst_addr(std::uint32_t addr) {
- follow_addr[FOLLOWSRC_DECODE] = addr;
+ if (addr != machine::STAGEADDR_NONE)
+ follow_addr[FOLLOWSRC_DECODE] = addr;
+ emit stage_addr_changed(ProgramModel::STAGEADDR_DECODE, addr);
if (follow_source == FOLLOWSRC_DECODE)
update_follow_position();
}
void ProgramDock::execute_inst_addr(std::uint32_t addr) {
- follow_addr[FOLLOWSRC_EXECUTE] = addr;
+ if (addr != machine::STAGEADDR_NONE)
+ follow_addr[FOLLOWSRC_EXECUTE] = addr;
+ emit stage_addr_changed(ProgramModel::STAGEADDR_EXECUTE, addr);
if (follow_source == FOLLOWSRC_EXECUTE)
update_follow_position();
}
void ProgramDock::memory_inst_addr(std::uint32_t addr) {
- follow_addr[FOLLOWSRC_MEMORY] = addr;
+ if (addr != machine::STAGEADDR_NONE)
+ follow_addr[FOLLOWSRC_MEMORY] = addr;
+ emit stage_addr_changed(ProgramModel::STAGEADDR_MEMORY, addr);
if (follow_source == FOLLOWSRC_MEMORY)
update_follow_position();
}
void ProgramDock::writeback_inst_addr(std::uint32_t addr) {
- follow_addr[FOLLOWSRC_WRITEBACK] = addr;
+ if (addr != machine::STAGEADDR_NONE)
+ follow_addr[FOLLOWSRC_WRITEBACK] = addr;
+ emit stage_addr_changed(ProgramModel::STAGEADDR_WRITEBACK, addr);
if (follow_source == FOLLOWSRC_WRITEBACK)
update_follow_position();
}
diff --git a/qtmips_gui/programdock.h b/qtmips_gui/programdock.h
index 356666f..0dec65d 100644
--- a/qtmips_gui/programdock.h
+++ b/qtmips_gui/programdock.h
@@ -57,6 +57,7 @@ signals:
void jump_to_pc(std::uint32_t);
void focus_addr(std::uint32_t);
void focus_addr_with_save(std::uint32_t);
+ void stage_addr_changed(uint stage, std::uint32_t addr);
public slots:
void set_follow_inst(int);
void fetch_inst_addr(std::uint32_t addr);
diff --git a/qtmips_gui/programmodel.cpp b/qtmips_gui/programmodel.cpp
index 838c058..6fda037 100644
--- a/qtmips_gui/programmodel.cpp
+++ b/qtmips_gui/programmodel.cpp
@@ -44,6 +44,9 @@ ProgramModel::ProgramModel(QObject *parent)
machine = nullptr;
memory_change_counter = 0;
cache_program_change_counter = 0;
+ for (int i = 0 ; i < STAGEADDR_COUNT; i++)
+ stage_addr[i] = machine::STAGEADDR_NONE;
+ stages_need_update = false;
}
int ProgramModel::rowCount(const QModelIndex & /*parent*/) const {
@@ -125,6 +128,26 @@ QVariant ProgramModel::data(const QModelIndex &index, int role) const {
} else if (index.column() == 0 && machine->is_hwbreak(address)) {
QBrush bgd(Qt::red);
return bgd;
+ } else if (index.column() == 3) {
+ if (address == stage_addr[STAGEADDR_WRITEBACK]) {
+ QBrush bgd(QColor(255, 173, 230));
+ return bgd;
+ } else if (address == stage_addr[STAGEADDR_MEMORY]) {
+ QBrush bgd(QColor(173, 255, 229));
+ return bgd;
+ } else if (address == stage_addr[STAGEADDR_MEMORY]) {
+ QBrush bgd(QColor(173, 255, 229));
+ return bgd;
+ } else if (address == stage_addr[STAGEADDR_EXECUTE]) {
+ QBrush bgd(QColor(193, 255, 173));
+ return bgd;
+ } else if (address == stage_addr[STAGEADDR_DECODE]) {
+ QBrush bgd(QColor(255, 212, 173));
+ return bgd;
+ } else if (address == stage_addr[STAGEADDR_FETCH]) {
+ QBrush bgd(QColor(255, 173, 173));
+ return bgd;
+ }
}
return QVariant();
}
@@ -135,6 +158,8 @@ QVariant ProgramModel::data(const QModelIndex &index, int role) const {
void ProgramModel::setup(machine::QtMipsMachine *machine) {
this->machine = machine;
+ for (int i = 0 ; i < STAGEADDR_COUNT; i++)
+ stage_addr[i] = machine::STAGEADDR_NONE;
if (machine != nullptr)
connect(machine, SIGNAL(post_tick()), this, SLOT(check_for_updates()));
emit update_all();
@@ -146,11 +171,12 @@ void ProgramModel::update_all() {
if (machine->cache_program() != nullptr)
cache_program_change_counter = machine->cache_program()->get_change_counter();
}
+ stages_need_update = false;
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
}
void ProgramModel::check_for_updates() {
- bool need_update = false;
+ bool need_update = stages_need_update;
if (machine == nullptr)
return;
if (machine->memory() == nullptr)
@@ -240,3 +266,12 @@ bool ProgramModel::setData(const QModelIndex & index, const QVariant & value, in
}
return true;
}
+
+void ProgramModel::update_stage_addr(uint stage, std::uint32_t addr) {
+ if (stage < STAGEADDR_COUNT) {
+ if (stage_addr[stage] != addr) {
+ stage_addr[stage] = addr;
+ stages_need_update = true;
+ }
+ }
+}
diff --git a/qtmips_gui/programmodel.h b/qtmips_gui/programmodel.h
index f5159af..a7c1699 100644
--- a/qtmips_gui/programmodel.h
+++ b/qtmips_gui/programmodel.h
@@ -84,10 +84,20 @@ public:
return true;
}
+ enum StageAddress {
+ STAGEADDR_FETCH,
+ STAGEADDR_DECODE,
+ STAGEADDR_EXECUTE,
+ STAGEADDR_MEMORY,
+ STAGEADDR_WRITEBACK,
+ STAGEADDR_COUNT,
+ };
+
public slots:
void setup(machine::QtMipsMachine *machine);
void check_for_updates();
void toggle_hw_break(const QModelIndex & index);
+ void update_stage_addr(uint stage, std::uint32_t addr);
private:
std::uint32_t index0_offset;
@@ -95,6 +105,8 @@ private:
machine::QtMipsMachine *machine;
std::uint32_t memory_change_counter;
std::uint32_t cache_program_change_counter;
+ std::uint32_t stage_addr[STAGEADDR_COUNT];
+ bool stages_need_update;
};
#endif // PROGRAMMODEL_H