aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-13 18:37:51 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-13 18:37:51 +0100
commit93c5ade08250e419b7dbc3177db6fba93163fd34 (patch)
treeb28d4f1bb4c36edbd60bf634d0d71a6d880b592d /qtmips_gui
parent9f1ddc2b38469d5028aec5ba7b68131d711f2622 (diff)
downloadqtmips-93c5ade08250e419b7dbc3177db6fba93163fd34.tar.gz
qtmips-93c5ade08250e419b7dbc3177db6fba93163fd34.tar.bz2
qtmips-93c5ade08250e419b7dbc3177db6fba93163fd34.zip
Include simple serial port terminal and prepare empty peripheral dock.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/coreview.cpp4
-rw-r--r--qtmips_gui/coreview.h4
-rw-r--r--qtmips_gui/coreview/logicblock.cpp9
-rw-r--r--qtmips_gui/coreview/logicblock.h12
-rw-r--r--qtmips_gui/mainwindow.cpp13
-rw-r--r--qtmips_gui/mainwindow.h6
-rw-r--r--qtmips_gui/peripheralsdock.cpp49
-rw-r--r--qtmips_gui/peripheralsdock.h58
-rw-r--r--qtmips_gui/qtmips_gui.pro8
-rw-r--r--qtmips_gui/terminaldock.cpp72
-rw-r--r--qtmips_gui/terminaldock.h65
11 files changed, 294 insertions, 6 deletions
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index 749bdcf..63f9ea6 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -69,6 +69,8 @@ CoreViewScene::CoreViewScene(machine::QtMipsMachine *machine) : QGraphicsScene()
NEW(DataMemory, mem_data, 580, 258, machine);
NEW(Registers, regs, 230, 240);
NEW(Alu, alu, 490, 233);
+ NEW(LogicBlock, peripherals, 610, 350, "Peripherals");
+ NEW(LogicBlock, terminal, 610, 400, "Terminal");
// Fetch stage
NEW(ProgramCounter, ft.pc, 2, 280, machine);
NEW(Latch, ft.latch, 55, 250, machine, 20);
@@ -195,6 +197,8 @@ CoreViewScene::CoreViewScene(machine::QtMipsMachine *machine) : QGraphicsScene()
connect(ft.pc, SIGNAL(jump_to_pc(std::uint32_t)), this, SIGNAL(request_jump_to_program_counter(std::uint32_t)));
connect(mem_program, SIGNAL(open_cache()), this, SIGNAL(request_cache_program()));
connect(mem_data, SIGNAL(open_cache()), this, SIGNAL(request_cache_data()));
+ connect(peripherals, SIGNAL(open_block()), this, SIGNAL(request_peripherals()));
+ connect(terminal, SIGNAL(open_block()), this, SIGNAL(request_terminal()));
}
CoreViewScene::~CoreViewScene() {
diff --git a/qtmips_gui/coreview.h b/qtmips_gui/coreview.h
index a253e32..4852e25 100644
--- a/qtmips_gui/coreview.h
+++ b/qtmips_gui/coreview.h
@@ -68,12 +68,16 @@ signals:
void request_jump_to_program_counter(std::uint32_t addr);
void request_cache_program();
void request_cache_data();
+ void request_peripherals();
+ void request_terminal();
protected:
coreview::ProgramMemory *mem_program;
coreview::DataMemory *mem_data;
coreview::Registers *regs;
coreview::Alu *alu;
+ coreview::LogicBlock *peripherals;
+ coreview::LogicBlock *terminal;
struct {
coreview::ProgramCounter *pc;
coreview::Latch *latch;
diff --git a/qtmips_gui/coreview/logicblock.cpp b/qtmips_gui/coreview/logicblock.cpp
index 2aabe7f..e2c5e24 100644
--- a/qtmips_gui/coreview/logicblock.cpp
+++ b/qtmips_gui/coreview/logicblock.cpp
@@ -47,7 +47,7 @@ using namespace coreview;
LogicBlock::LogicBlock(QString name) : LogicBlock(QVector<QString>({name})) { }
-LogicBlock::LogicBlock(QVector<QString> name) : QGraphicsItem(nullptr) {
+LogicBlock::LogicBlock(QVector<QString> name) : QGraphicsObject(nullptr) {
QFont font;
font.setPointSize(7);
@@ -82,7 +82,7 @@ void LogicBlock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
}
void LogicBlock::setPos(qreal x, qreal y) {
- QGraphicsItem::setPos(x, y);
+ QGraphicsObject::setPos(x, y);
for (int i = 0; i < connectors.size(); i++) {
struct Con &c = connectors[i];
c.con->setPos(x + c.p.x(), y + c.p.y());
@@ -134,3 +134,8 @@ QPointF LogicBlock::con_pos(qreal x, qreal y) {
py += GAP * sign(y);
return QPointF(px, py);
}
+
+void LogicBlock::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
+ QGraphicsObject::mouseDoubleClickEvent(event);
+ emit open_block();
+}
diff --git a/qtmips_gui/coreview/logicblock.h b/qtmips_gui/coreview/logicblock.h
index 27c2951..a384b06 100644
--- a/qtmips_gui/coreview/logicblock.h
+++ b/qtmips_gui/coreview/logicblock.h
@@ -36,15 +36,17 @@
#ifndef LOGICBLOCK_H
#define LOGICBLOCK_H
-#include <QGraphicsItem>
+#include <QGraphicsObject>
#include <QPainter>
#include <QGraphicsSimpleTextItem>
#include <QVector>
+#include <QObject>
#include "connection.h"
namespace coreview {
-class LogicBlock : public QGraphicsItem {
+class LogicBlock : public QGraphicsObject {
+ Q_OBJECT
public:
LogicBlock(QString name);
LogicBlock(QVector<QString> name);
@@ -61,6 +63,9 @@ public:
// Using x=y and x=-y coordinates is not supported
const Connector *new_connector(qreal x, qreal y);
+signals:
+ void open_block();
+
private:
QVector<QGraphicsSimpleTextItem*> text;
QRectF box;
@@ -72,6 +77,9 @@ private:
};
QVector<struct Con> connectors;
QPointF con_pos(qreal x, qreal y);
+
+protected:
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
};
}
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 4e716cb..b77d0d6 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -60,6 +60,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
cache_program->hide();
cache_data = new CacheDock(this, "Data");
cache_data->hide();
+ peripherals = new PeripheralsDock(this, settings);
+ peripherals->hide();
+ terminal = new TerminalDock(this, settings);
+ terminal->hide();
// Execution speed actions
speed_group = new QActionGroup(this);
@@ -80,6 +84,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
connect(ui->actionMemory, SIGNAL(triggered(bool)), this, SLOT(show_memory()));
connect(ui->actionProgram_Cache, SIGNAL(triggered(bool)), this, SLOT(show_cache_program()));
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->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()));
@@ -105,6 +111,8 @@ MainWindow::~MainWindow() {
delete memory;
delete cache_program;
delete cache_data;
+ delete peripherals;
+ delete terminal;
delete ui;
if (machine != nullptr)
delete machine;
@@ -153,6 +161,8 @@ void MainWindow::create_core(const machine::MachineConfig &config) {
connect(corescene, SIGNAL(request_jump_to_program_counter(std::uint32_t)), program, SIGNAL(jump_to_pc(std::uint32_t)));
connect(corescene, SIGNAL(request_cache_program()), this, SLOT(show_cache_program()));
connect(corescene, SIGNAL(request_cache_data()), this, SLOT(show_cache_data()));
+ connect(corescene, SIGNAL(request_peripherals()), this, SLOT(show_peripherals()));
+ connect(corescene, SIGNAL(request_terminal()), this, SLOT(show_terminal()));
// Connect signal from break to machine pause
connect(machine->core(), SIGNAL(stop_on_exception_reached()), machine, SLOT(pause()));
@@ -163,6 +173,7 @@ void MainWindow::create_core(const machine::MachineConfig &config) {
memory->setup(machine);
cache_program->setup(machine->cache_program());
cache_data->setup(machine->cache_data());
+ terminal->setup(machine->serial_port());
// Connect signals for instruction address followup
connect(machine->core(), SIGNAL(fetch_inst_addr_value(std::uint32_t)),
@@ -211,6 +222,8 @@ SHOW_HANDLER(program)
SHOW_HANDLER(memory)
SHOW_HANDLER(cache_program)
SHOW_HANDLER(cache_data)
+SHOW_HANDLER(peripherals)
+SHOW_HANDLER(terminal)
#undef SHOW_HANDLER
void MainWindow::about_qtmips()
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index 48883e5..61e6896 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -45,6 +45,8 @@
#include "programdock.h"
#include "memorydock.h"
#include "cachedock.h"
+#include "peripheralsdock.h"
+#include "terminaldock.h"
#include "qtmipsmachine.h"
#include "machineconfig.h"
@@ -70,6 +72,8 @@ public slots:
void show_memory();
void show_cache_data();
void show_cache_program();
+ void show_peripherals();
+ void show_terminal();
// Actions - help menu
void about_qtmips();
void about_qt();
@@ -95,6 +99,8 @@ private:
ProgramDock *program;
MemoryDock *memory;
CacheDock *cache_program, *cache_data;
+ PeripheralsDock *peripherals;
+ TerminalDock *terminal;
QActionGroup *speed_group;
diff --git a/qtmips_gui/peripheralsdock.cpp b/qtmips_gui/peripheralsdock.cpp
new file mode 100644
index 0000000..ad423a0
--- /dev/null
+++ b/qtmips_gui/peripheralsdock.cpp
@@ -0,0 +1,49 @@
+// 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 "peripheralsdock.h"
+
+PeripheralsDock::PeripheralsDock(QWidget *parent, QSettings *settings) : QDockWidget(parent) {
+ top_widget = new QWidget(this);
+ setWidget(top_widget);
+ layout_box = new QVBoxLayout(top_widget);
+
+ setObjectName("Peripherals");
+ setWindowTitle("Peripherals");
+}
+
+void PeripheralsDock::setup(const machine::QtMipsMachine *machine) {
+
+}
diff --git a/qtmips_gui/peripheralsdock.h b/qtmips_gui/peripheralsdock.h
new file mode 100644
index 0000000..b611515
--- /dev/null
+++ b/qtmips_gui/peripheralsdock.h
@@ -0,0 +1,58 @@
+// 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 PERIPHERALSDOCK_H
+#define PERIPHERALSDOCK_H
+
+#include <QDockWidget>
+#include <QLabel>
+#include <QFormLayout>
+#include "peripheral.h"
+#include "qtmipsmachine.h"
+
+class PeripheralsDock : public QDockWidget {
+ Q_OBJECT
+public:
+ PeripheralsDock(QWidget *parent, QSettings *settings);
+
+ void setup(const machine::QtMipsMachine *machine);
+
+private:
+ QVBoxLayout *layout_box;
+ QWidget *top_widget, *top_form;
+ QFormLayout *layout_top_form;
+};
+
+#endif // PERIPHERALSDOCK_H
diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro
index 8822e38..fa1cbc6 100644
--- a/qtmips_gui/qtmips_gui.pro
+++ b/qtmips_gui/qtmips_gui.pro
@@ -51,7 +51,9 @@ SOURCES += \
hexlineedit.cpp \
programmodel.cpp \
programtableview.cpp \
- aboutdialog.cpp
+ aboutdialog.cpp \
+ peripheralsdock.cpp \
+ terminaldock.cpp
HEADERS += \
mainwindow.h \
@@ -83,7 +85,9 @@ HEADERS += \
hexlineedit.h \
programmodel.h \
programtableview.h \
- aboutdialog.h
+ aboutdialog.h \
+ peripheralsdock.h \
+ terminaldock.h
FORMS += \
NewDialog.ui \
diff --git a/qtmips_gui/terminaldock.cpp b/qtmips_gui/terminaldock.cpp
new file mode 100644
index 0000000..31e8c68
--- /dev/null
+++ b/qtmips_gui/terminaldock.cpp
@@ -0,0 +1,72 @@
+// 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 "serialport.h"
+#include "terminaldock.h"
+
+TerminalDock::TerminalDock(QWidget *parent, QSettings *settings) : QDockWidget(parent) {
+ top_widget = new QWidget(this);
+ setWidget(top_widget);
+ layout_box = new QVBoxLayout(top_widget);
+
+ terminal_text = new QTextEdit(top_widget);
+ terminal_text->setMinimumSize(30, 30);
+ layout_box->addWidget(terminal_text);
+ append_cursor = new QTextCursor(terminal_text->document());
+
+ setObjectName("Terminal");
+ setWindowTitle("Terminal");
+}
+
+TerminalDock::~TerminalDock() {
+ delete append_cursor;
+}
+
+void TerminalDock::setup(const machine::SerialPort *ser_port) {
+ if (ser_port == nullptr)
+ return;
+ connect(ser_port, SIGNAL(tx_byte(uint)), this, SLOT(tx_byte(uint)));
+}
+
+void TerminalDock::tx_byte(unsigned int data) {
+ if (data == '\n')
+ append_cursor->insertBlock();
+ else
+ append_cursor->insertText(QString(QChar(data)));
+}
diff --git a/qtmips_gui/terminaldock.h b/qtmips_gui/terminaldock.h
new file mode 100644
index 0000000..b0c76cf
--- /dev/null
+++ b/qtmips_gui/terminaldock.h
@@ -0,0 +1,65 @@
+// 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 TERMINALDOCK_H
+#define TERMINALDOCK_H
+
+#include <QDockWidget>
+#include <QLabel>
+#include <QFormLayout>
+#include <QTextEdit>
+#include <QTextCursor>
+#include "qtmipsmachine.h"
+
+class TerminalDock : public QDockWidget {
+ Q_OBJECT
+public:
+ TerminalDock(QWidget *parent, QSettings *settings);
+ ~TerminalDock();
+
+ void setup(const machine::SerialPort *ser_port);
+
+public slots:
+ void tx_byte(unsigned int data);
+
+private:
+ QVBoxLayout *layout_box;
+ QWidget *top_widget, *top_form;
+ QFormLayout *layout_top_form;
+ QTextEdit *terminal_text;
+ QTextCursor *append_cursor;
+};
+
+#endif // TERMINALDOCK_H