From 063da67766585bd1db5e8afd83e2f9eda88119c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 25 Jan 2018 17:37:34 +0100 Subject: Jump to pc address when program counter is double clicked --- qtmips_gui/coreview.cpp | 2 ++ qtmips_gui/coreview.h | 1 + qtmips_gui/coreview/programcounter.cpp | 7 +++++++ qtmips_gui/coreview/programcounter.h | 9 +++++++++ qtmips_gui/mainwindow.cpp | 1 + qtmips_gui/programdock.cpp | 8 ++++++++ qtmips_gui/programdock.h | 5 +++++ 7 files changed, 33 insertions(+) diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp index eb39a47..d811208 100644 --- a/qtmips_gui/coreview.cpp +++ b/qtmips_gui/coreview.cpp @@ -140,6 +140,8 @@ CoreViewScene::CoreViewScene(CoreView *view, machine::QtMipsMachine *machine) : connect(regs, SIGNAL(open_registers()), this, SIGNAL(request_registers())); connect(mem_program, SIGNAL(open_mem()), this, SIGNAL(request_program_memory())); connect(mem_data, SIGNAL(open_mem()), this, SIGNAL(request_data_memory())); + connect(ft.pc, SIGNAL(open_program()), this, SIGNAL(request_program_memory())); + connect(ft.pc, SIGNAL(jump_to_pc(std::uint32_t)), this, SIGNAL(request_jump_to_program_counter(std::uint32_t))); } CoreViewScene::~CoreViewScene() { diff --git a/qtmips_gui/coreview.h b/qtmips_gui/coreview.h index d5b39c1..5f74f4f 100644 --- a/qtmips_gui/coreview.h +++ b/qtmips_gui/coreview.h @@ -40,6 +40,7 @@ signals: void request_registers(); void request_data_memory(); void request_program_memory(); + void request_jump_to_program_counter(std::uint32_t addr); protected: coreview::ProgramMemory *mem_program; 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; diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 0f5d11a..21581d2 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -100,6 +100,7 @@ void MainWindow::create_core(const machine::MachineConfig &config) { connect(corescene, SIGNAL(request_registers()), this, SLOT(show_registers())); connect(corescene, SIGNAL(request_program_memory()), this, SLOT(show_program())); connect(corescene, SIGNAL(request_data_memory()), this, SLOT(show_memory())); + connect(corescene, SIGNAL(request_jump_to_program_counter(std::uint32_t)), program, SLOT(jump_to_pc(std::uint32_t))); // Setup docks registers->setup(machine); diff --git a/qtmips_gui/programdock.cpp b/qtmips_gui/programdock.cpp index 3d881df..70d6a83 100644 --- a/qtmips_gui/programdock.cpp +++ b/qtmips_gui/programdock.cpp @@ -45,6 +45,10 @@ void ProgramView::setup(machine::QtMipsMachine *machine) { cb_single->setCurrentIndex(cb_pipelined->currentIndex() == 0 ? 0 : 1); } +void ProgramView::jump_to_pc(std::uint32_t addr) { + set_focus(addr); +} + QList ProgramView::row_widget(std::uint32_t address, QWidget *parent) { QList widgs; QLabel *l; @@ -86,3 +90,7 @@ ProgramDock::ProgramDock(QWidget *parent) : QDockWidget(parent) { void ProgramDock::setup(machine::QtMipsMachine *machine) { view->setup(machine); } + +void ProgramDock::jump_to_pc(std::uint32_t addr) { + view->jump_to_pc(addr); +} diff --git a/qtmips_gui/programdock.h b/qtmips_gui/programdock.h index 9ed0896..156c380 100644 --- a/qtmips_gui/programdock.h +++ b/qtmips_gui/programdock.h @@ -16,6 +16,8 @@ public: void setup(machine::QtMipsMachine*); + void jump_to_pc(std::uint32_t); + protected: QList row_widget(std::uint32_t address, QWidget *parent); @@ -35,6 +37,9 @@ public: void setup(machine::QtMipsMachine *machine); +public slots: + void jump_to_pc(std::uint32_t); + private: ProgramView *view; }; -- cgit v1.2.3