diff options
Diffstat (limited to 'qtmips_gui')
-rw-r--r-- | qtmips_gui/MainWindow.ui | 9 | ||||
-rw-r--r-- | qtmips_gui/cop0dock.cpp | 96 | ||||
-rw-r--r-- | qtmips_gui/cop0dock.h | 67 | ||||
-rw-r--r-- | qtmips_gui/mainwindow.cpp | 5 | ||||
-rw-r--r-- | qtmips_gui/mainwindow.h | 4 | ||||
-rw-r--r-- | qtmips_gui/qtmips_gui.pro | 6 |
6 files changed, 185 insertions, 2 deletions
diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui index 1b9bfbd..4847304 100644 --- a/qtmips_gui/MainWindow.ui +++ b/qtmips_gui/MainWindow.ui @@ -70,6 +70,7 @@ <addaction name="actionData_Cache"/> <addaction name="actionPeripherals"/> <addaction name="actionTerminal"/> + <addaction name="actionCop0State"/> </widget> <widget class="QMenu" name="menuMachine"> <property name="title"> @@ -295,6 +296,14 @@ <string>Ctrl+D</string> </property> </action> + <action name="actionCop0State"> + <property name="text"> + <string>Cop0 State</string> + </property> + <property name="shortcut"> + <string>Ctrl+C</string> + </property> + </action> <action name="actionReload"> <property name="icon"> <iconset resource="icons.qrc"> diff --git a/qtmips_gui/cop0dock.cpp b/qtmips_gui/cop0dock.cpp new file mode 100644 index 0000000..1070444 --- /dev/null +++ b/qtmips_gui/cop0dock.cpp @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0+ +/******************************************************************************* + * QtMips - MIPS 32-bit Architecture Subset Simulator + * + * Implemented to support following courses: + * + * B35APO - Computer Architectures + * https://cw.fel.cvut.cz/wiki/courses/b35apo + * + * B4M35PAP - Advanced Computer Architectures + * https://cw.fel.cvut.cz/wiki/courses/b4m35pap/start + * + * Copyright (c) 2017-2019 Karel Koci<cynerd@email.cz> + * Copyright (c) 2019 Pavel Pisa <pisa@cmp.felk.cvut.cz> + * + * Faculty of Electrical Engineering (http://www.fel.cvut.cz) + * Czech Technical University (http://www.cvut.cz/) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + ******************************************************************************/ + +#include "cop0dock.h" + + +Cop0Dock::Cop0Dock(QWidget *parent) : QDockWidget(parent) { + scrollarea = new QScrollArea(this); + scrollarea->setWidgetResizable(true); + widg = new StaticTable(scrollarea); + +#define INIT(X, LABEL) do{ \ + X = new QLabel("0x00000000", widg); \ + X->setFixedSize(X->sizeHint()); \ + X->setText(""); \ + X->setTextInteractionFlags(Qt::TextSelectableByMouse); \ + widg->addRow({new QLabel(LABEL, widg), X}); \ + } while(false) + + cop0reg[0] = nullptr; + for (int i = 1; i < machine::Cop0State::COP0REGS_CNT; i++) + INIT(cop0reg[i], machine::Cop0State::cop0reg_name((machine::Cop0State::Cop0Registers)i)); +#undef INIT + scrollarea->setWidget(widg); + + setWidget(scrollarea); + setObjectName("Coprocessor0"); + setWindowTitle("Coprocessor0"); +} + +Cop0Dock::~Cop0Dock() { + for (int i = 1; i < machine::Cop0State::COP0REGS_CNT; i++) + delete cop0reg[i]; + delete widg; + delete scrollarea; +} + +void Cop0Dock::setup(machine::QtMipsMachine *machine) { + if (machine == nullptr) { + // Reset data + for (int i = 1; i < machine::Cop0State::COP0REGS_CNT; i++) + cop0reg[i]->setText(""); + return; + } + + const machine::Cop0State *cop0state = machine->cop0state(); + connect(cop0state, &machine::Cop0State::cop0reg_update, + this, &Cop0Dock::cop0reg_changed); + + for (int i = 1; i < machine::Cop0State::COP0REGS_CNT; i++) + labelVal(cop0reg[i], cop0state->read_cop0reg((machine::Cop0State::Cop0Registers)i)); +} + +void Cop0Dock::cop0reg_changed(enum machine::Cop0State::Cop0Registers reg, std::uint32_t val) { + SANITY_ASSERT((uint)reg < machine::Cop0State::COP0REGS_CNT && (uint)reg, + QString("Cop0Dock received signal with invalid cop0 register: ") + + QString::number((uint)reg)); + labelVal(cop0reg[(uint)reg], val); +} + +void Cop0Dock::labelVal(QLabel *label, std::uint32_t value) { + QString t = QString("0x") + QString::number(value, 16); + label->setText(t); +} diff --git a/qtmips_gui/cop0dock.h b/qtmips_gui/cop0dock.h new file mode 100644 index 0000000..5dfa058 --- /dev/null +++ b/qtmips_gui/cop0dock.h @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0+ +/******************************************************************************* + * QtMips - MIPS 32-bit Architecture Subset Simulator + * + * Implemented to support following courses: + * + * B35APO - Computer Architectures + * https://cw.fel.cvut.cz/wiki/courses/b35apo + * + * B4M35PAP - Advanced Computer Architectures + * https://cw.fel.cvut.cz/wiki/courses/b4m35pap/start + * + * Copyright (c) 2017-2019 Karel Koci<cynerd@email.cz> + * Copyright (c) 2019 Pavel Pisa <pisa@cmp.felk.cvut.cz> + * + * Faculty of Electrical Engineering (http://www.fel.cvut.cz) + * Czech Technical University (http://www.cvut.cz/) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + ******************************************************************************/ + +#ifndef COP0DOCK_H +#define COP0DOCK_H + +#include <QDockWidget> +#include <QLabel> +#include <QFormLayout> +#include <QScrollArea> +#include <QPropertyAnimation> +#include "qtmipsmachine.h" +#include "statictable.h" + +class Cop0Dock : public QDockWidget { + Q_OBJECT +public: + Cop0Dock(QWidget *parent); + ~Cop0Dock(); + + void setup(machine::QtMipsMachine *machine); + +private slots: + void cop0reg_changed(enum machine::Cop0State::Cop0Registers reg, std::uint32_t val); + +private: + StaticTable *widg; + QScrollArea *scrollarea; + + QLabel *cop0reg[machine::Cop0State::COP0REGS_CNT]; + + void labelVal(QLabel *label, std::uint32_t val); +}; + +#endif // COP0DOCK_H diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 01321cf..3cefe94 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -67,6 +67,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { peripherals->hide(); terminal = new TerminalDock(this, settings); terminal->hide(); + cop0dock = new Cop0Dock(this); + cop0dock->hide(); // Execution speed actions speed_group = new QActionGroup(this); @@ -90,6 +92,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { connect(ui->actionData_Cache, SIGNAL(triggered(bool)), this, SLOT(show_cache_data())); connect(ui->actionPeripherals, SIGNAL(triggered(bool)), this, SLOT(show_peripherals())); connect(ui->actionTerminal, SIGNAL(triggered(bool)), this, SLOT(show_terminal())); + connect(ui->actionCop0State, SIGNAL(triggered(bool)), this, SLOT(show_cop0dock())); connect(ui->actionAbout, SIGNAL(triggered(bool)), this, SLOT(about_qtmips())); connect(ui->actionAboutQt, SIGNAL(triggered(bool)), this, SLOT(about_qt())); connect(ui->ips1, SIGNAL(toggled(bool)), this, SLOT(set_speed())); @@ -187,6 +190,7 @@ void MainWindow::create_core(const machine::MachineConfig &config) { cache_data->setup(machine->cache_data()); terminal->setup(machine->serial_port()); peripherals->setup(machine->peripheral_spi_led()); + cop0dock->setup(machine); // Connect signals for instruction address followup connect(machine->core(), SIGNAL(fetch_inst_addr_value(std::uint32_t)), @@ -237,6 +241,7 @@ SHOW_HANDLER(cache_program) SHOW_HANDLER(cache_data) SHOW_HANDLER(peripherals) SHOW_HANDLER(terminal) +SHOW_HANDLER(cop0dock) #undef SHOW_HANDLER void MainWindow::show_symbol_dialog(){ diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h index 796dd33..84c9d08 100644 --- a/qtmips_gui/mainwindow.h +++ b/qtmips_gui/mainwindow.h @@ -47,6 +47,7 @@ #include "cachedock.h" #include "peripheralsdock.h" #include "terminaldock.h" +#include "cop0dock.h" #include "qtmipsmachine.h" #include "machineconfig.h" @@ -74,6 +75,7 @@ public slots: void show_cache_program(); void show_peripherals(); void show_terminal(); + void show_cop0dock(); void show_symbol_dialog(); // Actions - help menu void about_qtmips(); @@ -102,6 +104,8 @@ private: CacheDock *cache_program, *cache_data; PeripheralsDock *peripherals; TerminalDock *terminal; + Cop0Dock *cop0dock; + QActionGroup *speed_group; diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro index acdbd55..e10631b 100644 --- a/qtmips_gui/qtmips_gui.pro +++ b/qtmips_gui/qtmips_gui.pro @@ -62,7 +62,8 @@ SOURCES += \ peripheralsview.cpp \ coreview/multitext.cpp \ fontsize.cpp \ - gotosymboldialog.cpp + gotosymboldialog.cpp \ + cop0dock.cpp HEADERS += \ mainwindow.h \ @@ -100,7 +101,8 @@ HEADERS += \ peripheralsview.h \ coreview/multitext.h \ fontsize.h \ - gotosymboldialog.h + gotosymboldialog.h \ + cop0dock.h FORMS += \ NewDialog.ui \ |