aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-06-28 00:53:34 +0200
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-06-28 00:53:34 +0200
commitedabdffead6d33a4e6a0e5a84d9e15f25a6acf83 (patch)
tree4df2aebac195a75a5cc1364fc0593a29105c6daa /qtmips_gui
parent30b15c6d1a328df5d8b0f99a5cbb1f72f25c9cdf (diff)
downloadqtmips-edabdffead6d33a4e6a0e5a84d9e15f25a6acf83.tar.gz
qtmips-edabdffead6d33a4e6a0e5a84d9e15f25a6acf83.tar.bz2
qtmips-edabdffead6d33a4e6a0e5a84d9e15f25a6acf83.zip
Initial optimized version LCD display emulation.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/MainWindow.ui6
-rw-r--r--qtmips_gui/lcddisplaydock.cpp57
-rw-r--r--qtmips_gui/lcddisplaydock.h57
-rw-r--r--qtmips_gui/lcddisplayview.cpp52
-rw-r--r--qtmips_gui/lcddisplayview.h31
-rw-r--r--qtmips_gui/mainwindow.cpp6
-rw-r--r--qtmips_gui/mainwindow.h3
-rw-r--r--qtmips_gui/qtmips_gui.pro4
8 files changed, 216 insertions, 0 deletions
diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui
index 753460b..13d02fc 100644
--- a/qtmips_gui/MainWindow.ui
+++ b/qtmips_gui/MainWindow.ui
@@ -75,6 +75,7 @@
<addaction name="actionData_Cache"/>
<addaction name="actionPeripherals"/>
<addaction name="actionTerminal"/>
+ <addaction name="actionLcdDisplay"/>
<addaction name="actionCop0State"/>
</widget>
<widget class="QMenu" name="menuMachine">
@@ -396,6 +397,11 @@
<string>Terminal</string>
</property>
</action>
+ <action name="actionLcdDisplay">
+ <property name="text">
+ <string>LCD display</string>
+ </property>
+ </action>
<action name="actionShow_Symbol">
<property name="text">
<string>Show Symbol</string>
diff --git a/qtmips_gui/lcddisplaydock.cpp b/qtmips_gui/lcddisplaydock.cpp
new file mode 100644
index 0000000..6517f4a
--- /dev/null
+++ b/qtmips_gui/lcddisplaydock.cpp
@@ -0,0 +1,57 @@
+// 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 <QString>
+#include <QTextBlock>
+#include <QTextCursor>
+
+#include "lcddisplaydock.h"
+#include "lcddisplayview.h"
+
+LcdDisplayDock::LcdDisplayDock(QWidget *parent, QSettings *settings) : QDockWidget(parent) {
+ lcd_display_widget = new LcdDisplayView(this);
+ setWidget(lcd_display_widget);
+
+ setObjectName("LCD Display");
+ setWindowTitle("LCD Display");
+}
+
+LcdDisplayDock::~LcdDisplayDock() {
+ delete lcd_display_widget;
+}
+
+void LcdDisplayDock::setup(machine::LcdDisplay *lcd_display) {
+ lcd_display_widget->setup(lcd_display);
+}
diff --git a/qtmips_gui/lcddisplaydock.h b/qtmips_gui/lcddisplaydock.h
new file mode 100644
index 0000000..9a4f866
--- /dev/null
+++ b/qtmips_gui/lcddisplaydock.h
@@ -0,0 +1,57 @@
+// 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 LCDDISPLAYDOCK_H
+#define LCDDISPLAYDOCK_H
+
+#include <QDockWidget>
+#include "lcddisplayview.h"
+#include "qtmipsmachine.h"
+
+class LcdDisplayDock : public QDockWidget {
+ Q_OBJECT
+public:
+ LcdDisplayDock(QWidget *parent, QSettings *settings);
+ ~LcdDisplayDock();
+
+ void setup(machine::LcdDisplay *lcd_display);
+
+//public slots:
+
+private:
+ LcdDisplayView *lcd_display_widget;
+};
+
+#endif // LCDDISPLAYDOCK_H
diff --git a/qtmips_gui/lcddisplayview.cpp b/qtmips_gui/lcddisplayview.cpp
new file mode 100644
index 0000000..450e7d4
--- /dev/null
+++ b/qtmips_gui/lcddisplayview.cpp
@@ -0,0 +1,52 @@
+#include <QPainter>
+#include <QStyle>
+#include "lcddisplay.h"
+#include "lcddisplayview.h"
+
+LcdDisplayView::LcdDisplayView(QWidget *parent) : Super(parent) {
+ setMinimumSize(100, 100);
+ fb_pixels = nullptr;
+}
+
+LcdDisplayView::~LcdDisplayView() {
+ if (fb_pixels != nullptr)
+ delete fb_pixels;
+}
+
+void LcdDisplayView::setup(machine::LcdDisplay *lcd_display) {
+ if (lcd_display == nullptr)
+ return;
+ connect(lcd_display, SIGNAL(pixel_update(uint,uint,uint,uint,uint)),
+ this, SLOT(pixel_update(uint,uint,uint,uint,uint)));
+ if (fb_pixels != nullptr)
+ delete fb_pixels;
+ fb_pixels = nullptr;
+ fb_pixels = new QImage(lcd_display->height(),
+ lcd_display->width(), QImage::Format_RGB32);
+ fb_pixels->fill(qRgb(0, 0, 0));
+ update();
+}
+
+void LcdDisplayView::pixel_update(uint x, uint y, uint r, uint g, uint b) {
+ if (fb_pixels != nullptr) {
+ fb_pixels->setPixel(x, y, qRgb(r, g, b));
+ update();
+ }
+}
+
+void LcdDisplayView::paintEvent(QPaintEvent *event) {
+ if (fb_pixels == nullptr)
+ return Super::paintEvent(event);
+ if (fb_pixels->width() == 0)
+ return Super::paintEvent(event);
+
+ QPainter painter(this);
+ QSize widgetSize = rect().size();
+ const auto newHeight = widgetSize.width() * fb_pixels->height() / fb_pixels->width();
+ if(newHeight <= widgetSize.height())
+ widgetSize.setHeight(newHeight);
+ else
+ widgetSize.setWidth(widgetSize.height() * fb_pixels->width() / fb_pixels->height());
+ painter.drawImage(rect(), fb_pixels->scaled(widgetSize));
+}
+
diff --git a/qtmips_gui/lcddisplayview.h b/qtmips_gui/lcddisplayview.h
new file mode 100644
index 0000000..010a106
--- /dev/null
+++ b/qtmips_gui/lcddisplayview.h
@@ -0,0 +1,31 @@
+#ifndef LCDDISPLAYVIEW_H
+#define LCDDISPLAYVIEW_H
+
+#include <QWidget>
+#include <QImage>
+
+#include "lcddisplay.h"
+
+class LcdDisplayView : public QWidget
+{
+ Q_OBJECT
+
+ using Super = QWidget;
+
+public:
+ explicit LcdDisplayView(QWidget *parent = 0);
+ ~LcdDisplayView();
+
+ void setup(machine::LcdDisplay *lcd_display);
+
+public slots:
+ void pixel_update(uint x, uint y, uint r, uint g, uint b);
+
+protected:
+ virtual void paintEvent(QPaintEvent *event) override;
+
+private:
+ QImage *fb_pixels;
+};
+
+#endif // LCDDISPLAYVIEW_H
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index cdf943d..4b2b7fd 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -74,6 +74,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
peripherals->hide();
terminal = new TerminalDock(this, settings);
terminal->hide();
+ lcd_display = new LcdDisplayDock(this, settings);
+ lcd_display->hide();
cop0dock = new Cop0Dock(this);
cop0dock->hide();
@@ -100,6 +102,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->actionLcdDisplay, SIGNAL(triggered(bool)), this, SLOT(show_lcd_display()));
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()));
@@ -128,6 +131,7 @@ MainWindow::~MainWindow() {
delete cache_data;
delete peripherals;
delete terminal;
+ delete lcd_display;
delete ui;
if (machine != nullptr)
delete machine;
@@ -211,6 +215,7 @@ void MainWindow::create_core(const machine::MachineConfig &config, bool load_exe
cache_data->setup(machine->cache_data());
terminal->setup(machine->serial_port());
peripherals->setup(machine->peripheral_spi_led());
+ lcd_display->setup(machine->peripheral_lcd_display());
cop0dock->setup(machine);
// Connect signals for instruction address followup
@@ -293,6 +298,7 @@ SHOW_HANDLER(cache_program, Qt::RightDockWidgetArea)
SHOW_HANDLER(cache_data, Qt::RightDockWidgetArea)
SHOW_HANDLER(peripherals, Qt::RightDockWidgetArea)
SHOW_HANDLER(terminal, Qt::RightDockWidgetArea)
+SHOW_HANDLER(lcd_display, Qt::RightDockWidgetArea)
SHOW_HANDLER(cop0dock, Qt::RightDockWidgetArea)
#undef SHOW_HANDLER
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index 1ee8032..788c118 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 "lcddisplaydock.h"
#include "cop0dock.h"
#include "qtmipsmachine.h"
@@ -76,6 +77,7 @@ public slots:
void show_cache_program();
void show_peripherals();
void show_terminal();
+ void show_lcd_display();
void show_cop0dock();
void show_symbol_dialog();
// Actions - help menu
@@ -105,6 +107,7 @@ private:
CacheDock *cache_program, *cache_data;
PeripheralsDock *peripherals;
TerminalDock *terminal;
+ LcdDisplayDock *lcd_display;
Cop0Dock *cop0dock;
diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro
index 4c52596..5bedaa1 100644
--- a/qtmips_gui/qtmips_gui.pro
+++ b/qtmips_gui/qtmips_gui.pro
@@ -65,6 +65,8 @@ SOURCES += \
peripheralsdock.cpp \
terminaldock.cpp \
peripheralsview.cpp \
+ lcddisplaydock.cpp \
+ lcddisplayview.cpp \
coreview/multitext.cpp \
fontsize.cpp \
gotosymboldialog.cpp \
@@ -106,6 +108,8 @@ HEADERS += \
peripheralsdock.h \
terminaldock.h \
peripheralsview.h \
+ lcddisplaydock.h \
+ lcddisplayview.h \
coreview/multitext.h \
fontsize.h \
gotosymboldialog.h \