aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/cachedock.cpp
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-04-15 12:59:45 +0200
committerKarel Kočí <cynerd@email.cz>2018-04-15 13:01:08 +0200
commitd7ca8071777cc1b11572dbb0d79dcf8a677a0bcd (patch)
tree98bc03c2819f1aff5c21e077ec20fb3a04c1e755 /qtmips_gui/cachedock.cpp
parent20ab37e56818d24e088f554aa82143545b33ad77 (diff)
downloadqtmips-d7ca8071777cc1b11572dbb0d79dcf8a677a0bcd.tar.gz
qtmips-d7ca8071777cc1b11572dbb0d79dcf8a677a0bcd.tar.bz2
qtmips-d7ca8071777cc1b11572dbb0d79dcf8a677a0bcd.zip
Add cache dock
Diffstat (limited to 'qtmips_gui/cachedock.cpp')
-rw-r--r--qtmips_gui/cachedock.cpp44
1 files changed, 44 insertions, 0 deletions
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));
+}