Resize/reorder cache config widget
MODIFY
src/cachesim/cacheconfigwidget.cpp
src/cachesim/cacheconfigwidget.cpp
#include "ui_cacheconfigwidget.h"
#include <QMessageBox>
+#include <QPushButton>
#include <QSpinBox>
-#include <QTimer>
+#include <QToolButton>
#include <QtCharts/QChartView>
#include "cacheplotwidget.h"
@@ -58,49 +59,7 @@ void CacheConfigWidget::setCache(CacheSim* cache) {
setupPresets();
m_ui->replacementPolicy->setCurrentIndex(0);
-
- // For testing purposes only
- connect(m_ui->randomread, &QPushButton::clicked, [=] {
- unsigned address = (std::rand() % 128) & ~0b11;
- m_cache->access(address, CacheSim::AccessType::Read);
- });
- connect(m_ui->randomwrite, &QPushButton::clicked, [=] {
- unsigned address = (std::rand() % 128) & ~0b11;
- m_cache->access(address, CacheSim::AccessType::Write);
- });
-
- connect(m_ui->undo, &QPushButton::clicked, m_cache, &CacheSim::undo);
-
- // Synchronize config widgets with initial cache configuration
handleConfigurationChanged();
-
- QTimer* timer = new QTimer(this);
- timer->setInterval(20);
- connect(timer, &QTimer::timeout, [=] {
- static int address;
- static int strideCount = 0;
-
- // Simulate some random access pattern with a bit of spatial locality
- if (strideCount == 0) {
- strideCount = (std::rand() % 32);
- address = (std::rand() % (int)std::pow(2, 14)) & ~0b11;
- } else {
- strideCount--;
- address += 4;
- }
-
- CacheSim::AccessType type = (std::rand() % 100) > 80 ? CacheSim::AccessType::Write : CacheSim::AccessType::Read;
- m_cache->access(address, type);
- });
-
- m_ui->autoAccess->setCheckable(true);
- connect(m_ui->autoAccess, &QPushButton::toggled, [=](bool enabled) {
- if (enabled) {
- timer->start();
- } else {
- timer->stop();
- }
- });
}
void CacheConfigWidget::showCachePlot() {

MODIFY
src/cachesim/cacheconfigwidget.ui
src/cachesim/cacheconfigwidget.ui
<rect>
<x>0</x>
<y>0</y>
- <width>665</width>
- <height>271</height>
+ <width>730</width>
+ <height>239</height>
</rect>
</property>
<property name="windowTitle">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Preset:</string>
</property>
</widget>
</item>
<item>
- <widget class="QComboBox" name="presets"/>
+ <widget class="QComboBox" name="presets">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
</item>
</layout>
</item>
</item>
</layout>
</item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_3">
- <property name="title">
- <string>Cache indexing breakdown:</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout_5">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="indexingText">
- <property name="text">
- <string/>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
</property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
+ <property name="sizeType">
+ <enum>QSizePolicy::MinimumExpanding</enum>
</property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_8">
- <item>
- <widget class="QLabel" name="indexingKey">
- <property name="text">
- <string>#=tag</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>1</height>
+ </size>
</property>
- </widget>
- </item>
- </layout>
+ </spacer>
</item>
</layout>
</item>
</item>
</layout>
</item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
</property>
</widget>
</item>
- <item>
- <widget class="QToolButton" name="cachePlot">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
+ </layout>
</item>
</layout>
</item>
+ <item row="1" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_6">
- <item>
- <widget class="QLabel" name="label_5">
+ <widget class="QToolButton" name="cachePlot">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
- <string>Hit rate:</string>
+ <string>...</string>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
</property>
</widget>
</item>
<item>
+ <layout class="QGridLayout" name="gridLayout_6">
+ <item row="0" column="1">
<widget class="QLineEdit" name="hitrate">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</property>
</widget>
</item>
- <item>
+ <item row="0" column="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Writebacks:</string>
</property>
</widget>
</item>
- <item>
+ <item row="0" column="3">
<widget class="QLineEdit" name="writebacks">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</property>
</widget>
</item>
- </layout>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Hit rate:</string>
+ </property>
+ </widget>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
- <item>
+ <item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Hits:</string>
</property>
</widget>
</item>
- <item>
+ <item row="1" column="1">
<widget class="QLineEdit" name="hits">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</property>
</widget>
</item>
- <item>
+ <item row="1" column="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Misses:</string>
</property>
</widget>
</item>
- <item>
+ <item row="1" column="3">
<widget class="QLineEdit" name="misses">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</item>
</layout>
</item>
- <item row="6" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Cache indexing breakdown:</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="indexingText">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- </spacer>
- </item>
- <item row="5" column="0">
- <widget class="QPushButton" name="autoAccess">
<property name="text">
- <string>auto</string>
+ <string/>
</property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QPushButton" name="randomwrite">
- <property name="text">
- <string>Random write</string>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QPushButton" name="randomread">
- <property name="text">
- <string>Random read</string>
- </property>
- </widget>
+ </layout>
</item>
- <item row="4" column="0">
- <widget class="QPushButton" name="undo">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_8">
+ <item>
+ <widget class="QLabel" name="indexingKey">
<property name="text">
- <string>Undo</string>
+ <string>#=tag</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
</widget>
</item>
</layout>
</item>
</layout>
+ </item>
+ </layout>
</widget>
<resources/>
<connections/>

MODIFY
src/cachesim/cachewidget.ui
src/cachesim/cachewidget.ui
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout" stretch="0,2">
- <item>
- <widget class="CacheConfigWidget" name="cacheConfig" native="true"/>
- </item>
- <item>
- <widget class="CacheView" name="cacheView"/>
- </item>
- </layout>
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="CacheConfigWidget" name="cacheConfig" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="CacheView" name="cacheView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>3</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </widget>
</item>
</layout>
</widget>

MODIFY
src/memorytab.ui
src/memorytab.ui
</property>
<widget class="MemoryViewerWidget" name="memoryViewerWidget" native="true">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QTabWidget" name="tabWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="currentIndex">
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">

Resize/reorder cache config widget