aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui/coreview')
-rw-r--r--qtmips_gui/coreview/programcounter.cpp7
-rw-r--r--qtmips_gui/coreview/programcounter.h9
2 files changed, 16 insertions, 0 deletions
diff --git a/qtmips_gui/coreview/programcounter.cpp b/qtmips_gui/coreview/programcounter.cpp
index ab7d49b..5d34fac 100644
--- a/qtmips_gui/coreview/programcounter.cpp
+++ b/qtmips_gui/coreview/programcounter.cpp
@@ -10,6 +10,8 @@ using namespace coreview;
//////////////////////
ProgramCounter::ProgramCounter(machine::QtMipsMachine *machine) : QGraphicsObject(nullptr), name("PC", this), value(this) {
+ registers = machine->registers();
+
QFont font;
font.setPointSize(7);
@@ -49,6 +51,11 @@ const Connector *ProgramCounter::connector_out() const {
return con_out;
}
+void ProgramCounter::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event __attribute__((unused))) {
+ emit open_program();
+ emit jump_to_pc(registers->read_pc());
+}
+
void ProgramCounter::pc_update(std::uint32_t val) {
value.setText(QString("0x") + QString::number(val, 16));
}
diff --git a/qtmips_gui/coreview/programcounter.h b/qtmips_gui/coreview/programcounter.h
index c60ad36..6b5772a 100644
--- a/qtmips_gui/coreview/programcounter.h
+++ b/qtmips_gui/coreview/programcounter.h
@@ -20,10 +20,19 @@ public:
const Connector *connector_in() const;
const Connector *connector_out() const;
+signals:
+ void open_program();
+ void jump_to_pc(std::uint32_t addr);
+
+protected:
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+
private slots:
void pc_update(std::uint32_t val);
private:
+ const machine::Registers *registers;
+
QGraphicsSimpleTextItem name;
QGraphicsSimpleTextItem value;