aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--qtmips_machine/core.cpp2
-rw-r--r--qtmips_machine/qtmips_machine.pro6
-rw-r--r--qtmips_machine/qtmipsmachine.cpp25
-rw-r--r--qtmips_machine/qtmipsmachine.h6
-rw-r--r--qtmips_machine/serialport.cpp72
-rw-r--r--qtmips_machine/serialport.h65
17 files changed, 461 insertions, 15 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
diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp
index 5c8d8f3..d4a3ce6 100644
--- a/qtmips_machine/core.cpp
+++ b/qtmips_machine/core.cpp
@@ -603,7 +603,7 @@ void CorePipelined::do_step(bool skip_break) {
if (HAZARD(dt_e)) {
// Hazard with instruction in execute stage
if (hazard_unit == MachineConfig::HU_STALL_FORWARD) {
- if (dt_e.memread) // TODO extend by branch instructions
+ if (dt_e.memread)
stall = true;
else {
// Forward result value
diff --git a/qtmips_machine/qtmips_machine.pro b/qtmips_machine/qtmips_machine.pro
index 286847f..e63c8a1 100644
--- a/qtmips_machine/qtmips_machine.pro
+++ b/qtmips_machine/qtmips_machine.pro
@@ -25,7 +25,8 @@ SOURCES += \
machineconfig.cpp \
utils.cpp \
physaddrspace.cpp \
- peripheral.cpp
+ peripheral.cpp \
+ serialport.cpp
HEADERS += \
qtmipsmachine.h \
@@ -41,4 +42,5 @@ HEADERS += \
utils.h \
machinedefs.h \
physaddrspace.h \
- peripheral.h
+ peripheral.h \
+ serialport.h
diff --git a/qtmips_machine/qtmipsmachine.cpp b/qtmips_machine/qtmipsmachine.cpp
index 81f733b..61cac0c 100644
--- a/qtmips_machine/qtmipsmachine.cpp
+++ b/qtmips_machine/qtmipsmachine.cpp
@@ -51,14 +51,14 @@ QtMipsMachine::QtMipsMachine(const MachineConfig &cc) : QObject(), mcnf(&cc) {
if (program.get_executable_entry())
regs->pc_abs_jmp(program.get_executable_entry());
mem = new Memory(*mem_program_only);
- cpu_mem = mem;
-#if 1
+
physaddrspace = new PhysAddrSpace();
physaddrspace->insert_range(mem, 0x00000000, 0xefffffff, false);
- MemoryAccess *periph = new SimplePeripheral();
- physaddrspace->insert_range(periph, 0xffffc000, 0xffffcfff, true);
cpu_mem = physaddrspace;
-#endif
+
+ ser_port = new SerialPort();
+ addressapce_insert_range(ser_port, 0xffffc000, 0xffffc0ff, true);
+
cch_program = new Cache(cpu_mem, &cc.cache_program(), cc.memory_access_time_read(), cc.memory_access_time_write());
cch_data = new Cache(cpu_mem, &cc.cache_data(), cc.memory_access_time_read(), cc.memory_access_time_write());
@@ -132,6 +132,10 @@ Cache *QtMipsMachine::cache_data_rw() {
return cch_data;
}
+SerialPort *QtMipsMachine::serial_port() {
+ return ser_port;
+}
+
const Core *QtMipsMachine::core() {
return cr;
}
@@ -180,7 +184,7 @@ void QtMipsMachine::step_internal(bool skip_break) {
do {
cr->step(skip_break);
} while(time_chunk != 0 && stat == ST_BUSY &&
- start_time.msecsTo(QTime::currentTime()) < time_chunk);
+ start_time.msecsTo(QTime::currentTime()) < (int)time_chunk);
} catch (QtMipsException &e) {
run_t->stop();
set_status(ST_TRAPPED);
@@ -229,6 +233,15 @@ void QtMipsMachine::register_exception_handler(ExceptionCause excause,
cr->register_exception_handler(excause, exhandler);
}
+bool QtMipsMachine::addressapce_insert_range(MemoryAccess *mem_acces,
+ std::uint32_t start_addr, std::uint32_t last_addr,
+ bool move_ownership) {
+ if (physaddrspace == nullptr)
+ return false;
+ return physaddrspace->insert_range(mem_acces, start_addr, last_addr,
+ move_ownership);
+}
+
void QtMipsMachine::insert_hwbreak(std::uint32_t address) {
if (cr != nullptr)
cr->insert_hwbreak(address);
diff --git a/qtmips_machine/qtmipsmachine.h b/qtmips_machine/qtmipsmachine.h
index 2a191f0..3680a71 100644
--- a/qtmips_machine/qtmipsmachine.h
+++ b/qtmips_machine/qtmipsmachine.h
@@ -47,6 +47,7 @@
#include <cache.h>
#include <physaddrspace.h>
#include <peripheral.h>
+#include <serialport.h>
namespace machine {
@@ -65,6 +66,7 @@ public:
const Cache *cache_program();
const Cache *cache_data();
Cache *cache_data_rw();
+ SerialPort *serial_port();
const Core *core();
const CoreSingle *core_singe();
const CorePipelined *core_pipelined();
@@ -80,6 +82,9 @@ public:
bool exited();
void register_exception_handler(ExceptionCause excause, ExceptionHandler *exhandler);
+ bool addressapce_insert_range(MemoryAccess *mem_acces, std::uint32_t start_addr,
+ std::uint32_t last_addr, bool move_ownership);
+
void insert_hwbreak(std::uint32_t address);
void remove_hwbreak(std::uint32_t address);
bool is_hwbreak(std::uint32_t address);
@@ -107,6 +112,7 @@ private:
Registers *regs;
Memory *mem, *mem_program_only;
PhysAddrSpace *physaddrspace;
+ SerialPort *ser_port;
Cache *cch_program, *cch_data;
Core *cr;
diff --git a/qtmips_machine/serialport.cpp b/qtmips_machine/serialport.cpp
new file mode 100644
index 0000000..0fc0ad2
--- /dev/null
+++ b/qtmips_machine/serialport.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 "serialport.h"
+
+using namespace machine;
+
+SerialPort::SerialPort() {
+
+}
+
+SerialPort::~SerialPort() {
+
+}
+
+bool SerialPort::wword(std::uint32_t address, std::uint32_t value) {
+#if 0
+ printf("SerialPort::wword address 0x%08lx data 0x%08lx\n",
+ (unsigned long)address, (unsigned long)value);
+#endif
+ emit write_notification(address, value);
+
+ if (address == 0x04)
+ emit tx_byte(value & 0xff);
+
+ return true;
+}
+
+std::uint32_t SerialPort::rword(std::uint32_t address, bool debug_access) const {
+ (void)debug_access;
+ std::uint32_t value = 0x00000000;
+#if 0
+ printf("SerialPort::rword address 0x%08lx\n",
+ (unsigned long)address);
+#endif
+
+ emit read_notification(address, &value);
+
+ return value;
+}
diff --git a/qtmips_machine/serialport.h b/qtmips_machine/serialport.h
new file mode 100644
index 0000000..2b14a7e
--- /dev/null
+++ b/qtmips_machine/serialport.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 SERIALPORT_H
+#define SERIALPORT_H
+
+#include <QObject>
+#include <QMap>
+#include <cstdint>
+#include <qtmipsexception.h>
+#include "peripheral.h"
+
+namespace machine {
+
+class SerialPort : public MemoryAccess {
+ Q_OBJECT
+public:
+ SerialPort();
+ ~SerialPort();
+
+signals:
+ void tx_byte(unsigned int data);
+ void write_notification(std::uint32_t address, std::uint32_t value);
+ void read_notification(std::uint32_t address, std::uint32_t *value) const;
+
+public:
+ bool wword(std::uint32_t address, std::uint32_t value);
+ std::uint32_t rword(std::uint32_t address, bool debug_access = false) const;
+};
+
+}
+
+#endif // SERIALPORT_H