Create CacheInspector class for plotting cache data
ADD
src/cacheinspector.cpp
+#include "cacheinspector.h"
+#include "ui_cacheinspector.h"
+
+#include "qcustomplot.h"
+
+CacheInspector::CacheInspector(QWidget *parent)
+ : QWidget(parent), m_ui(new Ui::CacheInspector) {
+ m_ui->setupUi(this);
+
+ // Set initial data
+ m_hitData = {5, 7, 9};
+ m_missData = {2, 0, 5};
+
+ // Setup bars
+ m_hits =
+ new QCPBars(m_ui->plottingwidget->xAxis, m_ui->plottingwidget->yAxis);
+ m_hits->setName("Cache hit");
+ m_hits->setPen(QPen(QColor(136, 240, 0).lighter(170)));
+ m_hits->setBrush(QColor(136, 240, 0));
+
+ m_misses =
+ new QCPBars(m_ui->plottingwidget->xAxis, m_ui->plottingwidget->yAxis);
+ m_misses->setName("Cache Miss");
+ m_misses->setPen(QPen(QColor(255, 35, 0).lighter(170)));
+ m_misses->setBrush(QColor(255, 35, 0));
+
+ // Stack hit bars on top of miss bars
+ setupBar(m_hits);
+ setupBar(m_misses);
+ m_misses->moveAbove(m_hits);
+
+ // Setup ticker
+ QSharedPointer<QCPAxisTickerText> ticker(new QCPAxisTickerText);
+ QVector<double> ticks = {1, 2, 3};
+ ticker->addTicks(ticks,
+ QVector<QString>() << "L1"
+ << "L2"
+ << "L3");
+ m_ui->plottingwidget->xAxis->setTicker(ticker);
+ m_ui->plottingwidget->xAxis->setRange(0, 4);
+ m_ui->plottingwidget->xAxis->setLabel("Cache level");
+ m_ui->plottingwidget->yAxis->setLabel("Cache requests");
+
+ QFont font;
+ font.setPointSize(10);
+ m_ui->plottingwidget->yAxis->setLabelFont(font);
+ m_ui->plottingwidget->xAxis->setTickLabelFont(font);
+ m_ui->plottingwidget->xAxis->setLabelFont(font);
+
+ // Setup legend
+ m_ui->plottingwidget->legend->setVisible(true);
+
+ // Set data
+ m_hits->setData(ticks, m_hitData);
+ m_misses->setData(ticks, m_missData);
+
+ m_ui->plottingwidget->yAxis->rescale(true);
+}
+
+void CacheInspector::setupBar(QCPBars *bar) {
+ bar->setAntialiased(false);
+ bar->setStackingGap(1);
+}
+
+void CacheInspector::updateData(int value, dataRole role, cacheLevel level) {
+ if (role == dataRole::miss) {
+ m_missData[level] = value;
+ } else {
+ m_hitData[level] = value;
+ }
+}
+
+CacheInspector::~CacheInspector() { delete m_ui; }

ADD
src/cacheinspector.h
+#ifndef CACHEINSPECTOR_H
+#define CACHEINSPECTOR_H
+
+#include <QWidget>
+
+#include "defines.h"
+#include "qcustomplot.h"
+
+enum dataRole { hit, miss };
+
+namespace Ui {
+class CacheInspector;
+}
+
+class CacheInspector : public QWidget {
+ Q_OBJECT
+
+public:
+ explicit CacheInspector(QWidget *parent = 0);
+ ~CacheInspector();
+
+ void updateData(int value, dataRole role, cacheLevel level);
+
+private:
+ Ui::CacheInspector *m_ui;
+
+ QCPBars *m_hits;
+ QCPBars *m_misses;
+
+ QVector<double> m_missData;
+ QVector<double> m_hitData;
+
+ void setupBar(QCPBars *bar);
+};
+
+#endif // CACHEINSPECTOR_H

ADD
src/cacheinspector.ui
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CacheInspector</class>
+ <widget class="QWidget" name="CacheInspector">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Select plot view</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QRadioButton" name="radioButton">
+ <property name="text">
+ <string>Cache requests</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioButton_3">
+ <property name="text">
+ <string>Cache requests (ratio)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioButton_2">
+ <property name="text">
+ <string>Temporal requests</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="radioButton_4">
+ <property name="text">
+ <string>Temporal requests (ratio)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCustomPlot" name="plottingwidget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QCustomPlot</class>
+ <extends>QWidget</extends>
+ <header>external/qcustomplot/qcustomplot.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

MODIFY
src/cachetab.ui
src/cachetab.ui
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<attribute name="title">
<string>Inspect</string>
</attribute>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="CacheInspector" name="widget" native="true"/>
+ </item>
+ </layout>
</widget>
</widget>
</item>
<header>cachesetupwidget.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>CacheInspector</class>
+ <extends>QWidget</extends>
+ <header>cacheinspector.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>

MODIFY
src/defines.h
src/defines.h
@@ -20,7 +20,7 @@ enum instrType {
INVALID = 0b0
};
-enum cacheLevel { L1, L2, L3 };
+enum cacheLevel { L1 = 0, L2 = 1, L3 = 2 };
enum cacheType { DM, SA, FA };

Create CacheInspector class for plotting cache data