From 6528cdb58abcbe432dd387d565c9a1157f90795a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 5 Jan 2018 16:24:29 +0100 Subject: Implement initial dialog for program memory dock I am missing memory view for now. --- qtmips_gui/mainwindow.cpp | 14 ++++++-- qtmips_gui/mainwindow.h | 8 +++-- qtmips_gui/programdock.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++ qtmips_gui/programdock.h | 32 +++++++++++++++++ qtmips_gui/programmemory.ui | 20 ----------- qtmips_gui/qtmips_gui.pro | 9 ++--- 6 files changed, 139 insertions(+), 29 deletions(-) create mode 100644 qtmips_gui/programdock.cpp create mode 100644 qtmips_gui/programdock.h delete mode 100644 qtmips_gui/programmemory.ui (limited to 'qtmips_gui') diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index d1a9770..92d1a74 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -14,12 +14,14 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { this->setCentralWidget(coreview); // Create/prepare other widgets ndialog = new NewDialog(this, settings); + registers = new RegistersDock(this); + registers->hide(); + program = new ProgramDock(this); + program->hide(); cache_content = new CacheContentDock(this); cache_content->hide(); cache_statictics = new CacheStatisticsDock(this); cache_statictics->hide(); - registers = new RegistersDock(this); - registers->hide(); // Execution speed actions speed_group = new QActionGroup(this); @@ -32,9 +34,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { // Connect signals from menu connect(ui->actionExit, SIGNAL(triggered(bool)), this, SLOT(close())); connect(ui->actionNew, SIGNAL(triggered(bool)), this, SLOT(new_machine())); + connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers())); + connect(ui->actionProgram_memory, SIGNAL(triggered(bool)), this, SLOT(show_program())); connect(ui->actionCache, SIGNAL(triggered(bool)), this, SLOT(show_cache_content())); connect(ui->actionCache_statistics, SIGNAL(triggered(bool)), this, SLOT(show_cache_statictics())); - connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers())); connect(ui->ips1, SIGNAL(toggled(bool)), this, SLOT(set_speed())); connect(ui->ips5, SIGNAL(toggled(bool)), this, SLOT(set_speed())); connect(ui->ips10, SIGNAL(toggled(bool)), this, SLOT(set_speed())); @@ -88,6 +91,7 @@ void MainWindow::create_core(machine::MachineConfig *config) { // Setup docks registers->setup(machine); + program->setup(machine); // Set status to ready machine_status(machine::QtMipsMachine::ST_READY); } @@ -112,6 +116,10 @@ void MainWindow::show_registers() { show_dockwidget(registers); } +void MainWindow::show_program() { + show_dockwidget(program); +} + void MainWindow::set_speed() { if (machine == nullptr) return; // just ignore diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h index d2ab9bb..1afe137 100644 --- a/qtmips_gui/mainwindow.h +++ b/qtmips_gui/mainwindow.h @@ -9,6 +9,7 @@ #include "cachecontent.h" #include "cachestatistics.h" #include "registersdock.h" +#include "programdock.h" #include "qtmipsmachine.h" #include "machineconfig.h" @@ -28,9 +29,10 @@ public: public slots: // Actions signals void new_machine(); + void show_registers(); + void show_program(); void show_cache_content(); void show_cache_statictics(); - void show_registers(); // Actions - execution speed void set_speed(); // Machine signals @@ -49,9 +51,11 @@ private: CoreView *coreview; CoreViewScene *corescene; + RegistersDock *registers; + ProgramDock *program; + // TODO implement cahce docks CacheContentDock *cache_content; CacheStatisticsDock *cache_statictics; - RegistersDock *registers; QActionGroup *speed_group; diff --git a/qtmips_gui/programdock.cpp b/qtmips_gui/programdock.cpp new file mode 100644 index 0000000..240fb0a --- /dev/null +++ b/qtmips_gui/programdock.cpp @@ -0,0 +1,85 @@ +#include "programdock.h" +#include "qtmipsexception.h" + +ProgramDock::ProgramDock(QWidget *parent) : QDockWidget(parent) { + widg = new QWidget(this); + widg_layout = new QBoxLayout(QBoxLayout::TopToBottom, widg); + widg_layout->setSizeConstraint(QLayout::SetMinAndMaxSize); + + // TODO memory view + + /* + ctlline = new QLineEdit(widg); + ctlline->setText("0x00000000"); + ctlline->setInputMask("\\0\\xHHHHHHHH"); + ctlline->hide(); + widg_layout->addWidget(ctlline); + connect(ctlline, SIGNAL(returnPressed()), this, SLOT(ctlline_returnPress())); + */ + + ctlbox_single = new QComboBox(widg); + ctlbox_single->addItems({ + "Don't follow", + "Follow executing instruction" + }); + ctlbox_single->setCurrentIndex(1); + ctlbox_single->hide(); + widg_layout->addWidget(ctlbox_single); + connect(ctlbox_single, SIGNAL(currentIndexChanged(int)), this, SLOT(ctlbox_single_changed(int))); + + ctlbox_pipelined = new QComboBox(widg); + ctlbox_pipelined->addItems({ + "Don't follow", + "Follow Instruction fetch stage", + "Follow Instruction decode stage", + "Follow Execution stage", + "Follow Memory access stage", + "Follow Registers write back stage", + }); + ctlbox_pipelined->hide(); + ctlbox_pipelined->setCurrentIndex(1); + widg_layout->addWidget(ctlbox_pipelined); + connect(ctlbox_pipelined, SIGNAL(currentIndexChanged(int)), this, SLOT(ctlbox_pipelined_changed(int))); + + setWidget(widg); + setObjectName("Program"); + setWindowTitle("Program memory"); +} + +ProgramDock::~ProgramDock() { + delete ctlbox_single; + delete ctlbox_pipelined; + delete widg; + delete widg_layout; +} + +void ProgramDock::setup(machine::QtMipsMachine *machine) { + if (machine == nullptr) { + // TODO zero memory viewer + return; + } + + // TODO pass to viewer + + bool pipelined = machine->config().pipelined(); + ctlbox_single->setVisible(!pipelined); + ctlbox_pipelined->setVisible(pipelined); + // Sync selection somewhat + if (pipelined) { + if (ctlbox_single->currentIndex() == 0) + ctlbox_pipelined->setCurrentIndex(0); + else if (ctlbox_pipelined->currentIndex() == 0) + ctlbox_pipelined->setCurrentIndex(1); + } else + ctlbox_single->setCurrentIndex(ctlbox_pipelined->currentIndex() == 0 ? 0 : 1); + + // TODO also update current setting of memory viewer +} + +void ProgramDock::ctlbox_single_changed(int index) { + // TODO set memory view +} + +void ProgramDock::ctlbox_pipelined_changed(int index) { + // TODO set memory view +} diff --git a/qtmips_gui/programdock.h b/qtmips_gui/programdock.h new file mode 100644 index 0000000..033cf54 --- /dev/null +++ b/qtmips_gui/programdock.h @@ -0,0 +1,32 @@ +#ifndef PROGRAMDOCK_H +#define PROGRAMDOCK_H + +#include +#include +#include +#include +#include +#include "qtmipsmachine.h" + +class ProgramDock : public QDockWidget { + Q_OBJECT +public: + ProgramDock(QWidget *parent); + ~ProgramDock(); + + void setup(machine::QtMipsMachine *machine); + +private slots: + void ctlbox_single_changed(int index); + void ctlbox_pipelined_changed(int index); + +private: + QWidget *widg; + QBoxLayout *widg_layout; + + //QLineEdit *ctlline; + QComboBox *ctlbox_single; + QComboBox *ctlbox_pipelined; +}; + +#endif // PROGRAMDOCK_H diff --git a/qtmips_gui/programmemory.ui b/qtmips_gui/programmemory.ui deleted file mode 100644 index f1c29f3..0000000 --- a/qtmips_gui/programmemory.ui +++ /dev/null @@ -1,20 +0,0 @@ - - - DockWidget - - - - 0 - 0 - 413 - 495 - - - - DockWidget - - - - - - diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro index c16fed7..c4bff75 100644 --- a/qtmips_gui/qtmips_gui.pro +++ b/qtmips_gui/qtmips_gui.pro @@ -25,7 +25,8 @@ SOURCES += \ coreview/connection.cpp \ coreview/latch.cpp \ coreview/alu.cpp \ - coreview/memory.cpp + coreview/memory.cpp \ + programdock.cpp HEADERS += \ mainwindow.h \ @@ -39,14 +40,14 @@ HEADERS += \ coreview/connection.h \ coreview/latch.h \ coreview/alu.h \ - coreview/memory.h + coreview/memory.h \ + programdock.h FORMS += \ NewDialog.ui \ MainWindow.ui \ CacheContent.ui \ - CacheStatistics.ui \ - programmemory.ui + CacheStatistics.ui RESOURCES += \ icons.qrc -- cgit v1.2.3