Fix bug in cache data generation
MODIFY
src/cacheinspector.cpp
src/cacheinspector.cpp
@@ -10,17 +10,17 @@ CacheInspector::CacheInspector(QWidget *parent)
// Generate some data
m_hitData = {{0}, {0}, {0}};
m_missData = {{0}, {0}, {0}};
- int dataSize = 100;
+ int dataSize = 1000;
for (int i = 0; i < 3; i++) {
for (int j = 1; j < dataSize; j++) {
// create data that increases hits linearly
int r = (rand() % dataSize);
- if (r * (i + 1) > j) {
- m_hitData[i].append(m_hitData[i].last() + 1);
- m_missData[i].append(m_hitData[i].last());
- } else {
+ if (r * (i + 0.5) > j) {
m_missData[i].append(m_missData[i].last() + 1);
m_hitData[i].append(m_hitData[i].last());
+ } else {
+ m_hitData[i].append(m_hitData[i].last() + 1);
+ m_missData[i].append(m_missData[i].last());
}
}
}
@@ -160,8 +160,8 @@ void CacheInspector::setupTemporalRatioPlot() {
for (int j = 0; j < 3; j++) {
for (int i = 0; i < m_missData[j].size(); i++) {
- auto miss_data = m_missData[j].at(i);
- auto hit_data = m_hitData[j].at(i);
+ auto miss_data = m_missData[j][i];
+ auto hit_data = m_hitData[j][i];
graphData[j][i].key = i;
graphData[j][i].value = ((miss_data * 100) / (miss_data + hit_data));
}
@@ -174,11 +174,14 @@ void CacheInspector::setupTemporalRatioPlot() {
m_ui->temporalRatioPlot->graph()->setPen(QPen(color.lighter(200)));
m_ui->temporalRatioPlot->graph()->setBrush(QBrush(color));
m_ui->temporalRatioPlot->graph()->data()->set(graphData[i]);
- m_ui->temporalRatioPlot->graph()->setName(QString("L%1").arg(i + 1));
+ m_ui->temporalRatioPlot->graph()->setName(
+ QString("L%1 miss ratio").arg(i + 1));
}
- m_ui->temporalRatioPlot->yAxis->setRange(0, m_hitData[0].size());
+ m_ui->temporalRatioPlot->yAxis->setRange(0, 100);
m_ui->temporalRatioPlot->xAxis->rescale(true);
m_ui->temporalRatioPlot->legend->setVisible(true);
+ m_ui->temporalRatioPlot->xAxis->setLabel("Instruction count [n]");
+ m_ui->temporalRatioPlot->yAxis->setLabel("Miss ratio [%]");
}
CacheInspector::~CacheInspector() { delete m_ui; }

MODIFY
src/cachesetupwidget.ui
src/cachesetupwidget.ui
<item row="3" column="1">
<widget class="QComboBox" name="cachetype"/>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Miss penalty (cycles)</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Cache size</string>
- </property>
- </widget>
- </item>
<item row="2" column="1">
<widget class="QSpinBox" name="cachedelay">
<property name="alignment">
</property>
</widget>
</item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Cache size</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Miss penalty (cycles)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QComboBox" name="setsize"/>
+ </item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
</property>
</widget>
</item>
- <item row="4" column="1">
- <widget class="QComboBox" name="setsize"/>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Replacement strategy</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QComboBox" name="comboBox">
+ <item>
+ <property name="text">
+ <string>LRU</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Random</string>
+ </property>
+ </item>
+ </widget>
</item>
</layout>
</item>

MODIFY
src/processortab.cpp
src/processortab.cpp
#include "processortab.h"
#include "ui_processortab.h"
-ProcessorTab::ProcessorTab(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::ProcessorTab)
-{
- ui->setupUi(this);
-}
+ProcessorTab::ProcessorTab(QWidget *parent)
+ : QWidget(parent), m_ui(new Ui::ProcessorTab) {
+ m_ui->setupUi(this);
-ProcessorTab::~ProcessorTab()
-{
- delete ui;
+ connect(m_ui->pipeline, &QRadioButton::toggled, m_ui->forwarding,
+ &QCheckBox::setEnabled);
}
+
+ProcessorTab::~ProcessorTab() { delete m_ui; }

MODIFY
src/processortab.h
src/processortab.h
@@ -16,7 +16,7 @@ public:
~ProcessorTab();
private:
- Ui::ProcessorTab *ui;
+ Ui::ProcessorTab *m_ui;
};
#endif // PROCESSORTAB_H

MODIFY
src/processortab.ui
src/processortab.ui
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
- <widget class="QRadioButton" name="radioButton_3">
+ <widget class="QRadioButton" name="singlecycle">
<property name="text">
<string>Single cycle</string>
</property>
</widget>
</item>
<item>
- <widget class="QRadioButton" name="radioButton_4">
+ <widget class="QRadioButton" name="pipeline">
<property name="text">
<string>5-stage pipeline</string>
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="forwarding">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Forwarding</string>
+ </property>
+ </widget>
+ </item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">

Fix bug in cache data generation