aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/MainWindow.ui32
-rw-r--r--qtmips_gui/cachedock.cpp44
-rw-r--r--qtmips_gui/cachedock.h27
-rw-r--r--qtmips_gui/coreview.h2
-rw-r--r--qtmips_gui/mainwindow.cpp14
-rw-r--r--qtmips_gui/mainwindow.h5
-rw-r--r--qtmips_gui/qtmips_gui.pro6
7 files changed, 114 insertions, 16 deletions
diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui
index a3f5fcc..1c49fe3 100644
--- a/qtmips_gui/MainWindow.ui
+++ b/qtmips_gui/MainWindow.ui
@@ -64,10 +64,10 @@
<string>Windows</string>
</property>
<addaction name="actionRegisters"/>
- <addaction name="actionMemory"/>
<addaction name="actionProgram_memory"/>
- <addaction name="actionCache"/>
- <addaction name="actionCache_statistics"/>
+ <addaction name="actionMemory"/>
+ <addaction name="actionProgram_Cache"/>
+ <addaction name="actionData_Cache"/>
</widget>
<widget class="QMenu" name="menuMachine">
<property name="title">
@@ -271,16 +271,6 @@
<string>Ctrl+P</string>
</property>
</action>
- <action name="actionCache">
- <property name="text">
- <string>Cache content</string>
- </property>
- </action>
- <action name="actionCache_statistics">
- <property name="text">
- <string>Cache statistics</string>
- </property>
- </action>
<action name="actionRegisters">
<property name="text">
<string>Registers</string>
@@ -301,6 +291,22 @@
<string>Ctrl+Shift+R</string>
</property>
</action>
+ <action name="actionProgram_Cache">
+ <property name="text">
+ <string>Program Cache</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Shift+P</string>
+ </property>
+ </action>
+ <action name="actionData_Cache">
+ <property name="text">
+ <string>Data Cache</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Shift+M</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
diff --git a/qtmips_gui/cachedock.cpp b/qtmips_gui/cachedock.cpp
new file mode 100644
index 0000000..eb96e06
--- /dev/null
+++ b/qtmips_gui/cachedock.cpp
@@ -0,0 +1,44 @@
+#include "cachedock.h"
+
+CacheDock::CacheDock(QWidget *parent, const QString &type) : QDockWidget(parent) {
+ top_widget = new QWidget(this);
+ setWidget(top_widget);
+ layout_box = new QVBoxLayout(top_widget);
+
+ no_cache = new QLabel("No " + type + " Cache configured", top_widget);
+ layout_box->addWidget(no_cache);
+
+ top_form = new QWidget(top_widget);
+ top_form->setVisible(false);
+ layout_box->addWidget(top_form);
+ layout_top_form = new QFormLayout(top_form);
+
+ l_hit = new QLabel("0", top_form);
+ layout_top_form->addRow("Hit:", l_hit);
+ l_miss = new QLabel("0", top_form);
+ layout_top_form->addRow("Miss:", l_miss);
+
+ // TODO cache view
+
+ setObjectName(type + "Cache");
+ setWindowTitle(type + " Cache");
+}
+
+void CacheDock::setup(const machine::Cache *cache) {
+ l_hit->setText("0");
+ l_miss->setText("0");
+ if (cache) {
+ connect(cache, SIGNAL(hit_update(uint)), this, SLOT(hit_update(uint)));
+ connect(cache, SIGNAL(miss_update(uint)), this, SLOT(miss_update(uint)));
+ }
+ top_form->setVisible((bool)cache);
+ no_cache->setVisible(!(bool)cache);
+}
+
+void CacheDock::hit_update(unsigned val) {
+ l_hit->setText(QString::number(val));
+}
+
+void CacheDock::miss_update(unsigned val) {
+ l_miss->setText(QString::number(val));
+}
diff --git a/qtmips_gui/cachedock.h b/qtmips_gui/cachedock.h
new file mode 100644
index 0000000..a13cd08
--- /dev/null
+++ b/qtmips_gui/cachedock.h
@@ -0,0 +1,27 @@
+#ifndef CACHEDOCK_H
+#define CACHEDOCK_H
+
+#include <QDockWidget>
+#include <QLabel>
+#include <QFormLayout>
+#include "qtmipsmachine.h"
+
+class CacheDock : public QDockWidget {
+ Q_OBJECT
+public:
+ CacheDock(QWidget *parent, const QString &type);
+
+ void setup(const machine::Cache *cache);
+
+private slots:
+ void hit_update(unsigned);
+ void miss_update(unsigned);
+
+private:
+ QVBoxLayout *layout_box;
+ QWidget *top_widget, *top_form;
+ QFormLayout *layout_top_form;
+ QLabel *l_hit, *l_miss, *no_cache;
+};
+
+#endif // CACHEDOCK_H
diff --git a/qtmips_gui/coreview.h b/qtmips_gui/coreview.h
index 1504483..9fdf0a3 100644
--- a/qtmips_gui/coreview.h
+++ b/qtmips_gui/coreview.h
@@ -41,6 +41,8 @@ signals:
void request_data_memory();
void request_program_memory();
void request_jump_to_program_counter(std::uint32_t addr);
+ void request_cache_program();
+ void request_cache_data();
protected:
coreview::ProgramMemory *mem_program;
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 21581d2..ce6f52c 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -20,6 +20,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
program->hide();
memory = new MemoryDock(this);
memory->hide();
+ cache_program = new CacheDock(this, "Program");
+ cache_program->hide();
+ cache_data = new CacheDock(this, "Data");
+ cache_data->hide();
// Execution speed actions
speed_group = new QActionGroup(this);
@@ -36,6 +40,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers()));
connect(ui->actionProgram_memory, SIGNAL(triggered(bool)), this, SLOT(show_program()));
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->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()));
@@ -57,6 +63,8 @@ MainWindow::~MainWindow() {
delete registers;
delete program;
delete memory;
+ delete cache_program;
+ delete cache_data;
delete ui;
if (machine != nullptr)
delete machine;
@@ -101,11 +109,15 @@ void MainWindow::create_core(const machine::MachineConfig &config) {
connect(corescene, SIGNAL(request_program_memory()), this, SLOT(show_program()));
connect(corescene, SIGNAL(request_data_memory()), this, SLOT(show_memory()));
connect(corescene, SIGNAL(request_jump_to_program_counter(std::uint32_t)), program, SLOT(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()));
// Setup docks
registers->setup(machine);
program->setup(machine);
memory->setup(machine);
+ cache_program->setup(machine->config().cache_program().enabled() ? machine->cache_program() : nullptr);
+ cache_data->setup(machine->config().cache_data().enabled() ? machine->cache_data() : nullptr);
// Set status to ready
machine_status(machine::QtMipsMachine::ST_READY);
}
@@ -139,6 +151,8 @@ void MainWindow::machine_reload() {
SHOW_HANDLER(registers)
SHOW_HANDLER(program)
SHOW_HANDLER(memory)
+SHOW_HANDLER(cache_program)
+SHOW_HANDLER(cache_data)
#undef SHOW_HANDLER
void MainWindow::set_speed() {
diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h
index 999c966..3c1cf9f 100644
--- a/qtmips_gui/mainwindow.h
+++ b/qtmips_gui/mainwindow.h
@@ -9,6 +9,7 @@
#include "registersdock.h"
#include "programdock.h"
#include "memorydock.h"
+#include "cachedock.h"
#include "qtmipsmachine.h"
#include "machineconfig.h"
@@ -32,6 +33,8 @@ public slots:
void show_registers();
void show_program();
void show_memory();
+ void show_cache_data();
+ void show_cache_program();
// Actions - execution speed
void set_speed();
// Machine signals
@@ -53,7 +56,7 @@ private:
RegistersDock *registers;
ProgramDock *program;
MemoryDock *memory;
- // TODO implement cache docks
+ CacheDock *cache_program, *cache_data;
QActionGroup *speed_group;
diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro
index 59111d6..2d8ba78 100644
--- a/qtmips_gui/qtmips_gui.pro
+++ b/qtmips_gui/qtmips_gui.pro
@@ -35,7 +35,8 @@ SOURCES += \
coreview/junction.cpp \
coreview/logicblock.cpp \
coreview/and.cpp \
- statictable.cpp
+ statictable.cpp \
+ cachedock.cpp \
HEADERS += \
mainwindow.h \
@@ -58,7 +59,8 @@ HEADERS += \
coreview/junction.h \
coreview/logicblock.h \
coreview/and.h \
- statictable.h
+ statictable.h \
+ cachedock.h \
FORMS += \
NewDialog.ui \