Make min points for resampling a settings parameter
MODIFY
src/cachesim/cacheplotwidget.cpp
src/cachesim/cacheplotwidget.cpp
#include "defines.h"
#include "enumcombobox.h"
#include "processorhandler.h"
+#include "ripessettings.h"
#include "limits.h"
@@ -359,8 +360,10 @@ void CachePlotWidget::updateRatioPlot() {
m_mavgSeries->append(newWindowPoints);
}
- // Determine whether to resample; *2 the allowed points to account for the addition of step points.
- const int maxPoints = m_ui->plotView->width() * 2;
+ // Determine whether to resample;
+ // *2 the allowed points to account for the addition of step points.
+ // *2 to account for the fact that the setting specifies the minimum # of points, and we resample at a 2x ratio
+ const int maxPoints = RipesSettings::value(RIPES_SETTING_CACHE_MAXPOINTS).toInt() * 2 * 2;
if (m_series->pointsVector().size() >= maxPoints) {
resample(m_series, maxPoints / 2, m_xStep);
}

MODIFY
src/ripessettings.cpp
src/ripessettings.cpp
@@ -25,6 +25,8 @@ const std::map<QString, QVariant> s_defaultSettings = {
{RIPES_SETTING_ASSEMBLER_BSSSTART, 0x11000000},
{RIPES_SETTING_PERIPHERALS_START, static_cast<unsigned>(0xF0000000)},
+ {RIPES_SETTING_CACHE_MAXPOINTS, 1000},
+
// Program state preserving settings
{RIPES_GLOBALSIGNAL_QUIT, 0},
{RIPES_GLOBALSIGNAL_REQRESET, 0},

MODIFY
src/ripessettings.h
src/ripessettings.h
@@ -23,6 +23,7 @@ namespace Ripes {
#define RIPES_SETTING_ASSEMBLER_BSSSTART ("bss_start")
#define RIPES_SETTING_PERIPHERALS_START ("peripheral_start")
+#define RIPES_SETTING_CACHE_MAXPOINTS ("cacheplot_maxpoints")
#define RIPES_SETTING_PERIPHERAL_SETTINGS ("peripheral_settings")

MODIFY
src/settingsdialog.cpp
src/settingsdialog.cpp
@@ -286,12 +286,20 @@ QWidget* SettingsDialog::createEditorPage() {
}
QWidget* SettingsDialog::createEnvironmentPage() {
+ auto [pageWidget, pageLayout] = constructPage();
+
+ appendToLayout(
+ createSettingsWidgets<QSpinBox>(RIPES_SETTING_CACHE_MAXPOINTS, "Min. cache plot points:"), pageLayout,
+ "Minimum number of points to be kept in the cache plot. Once 2x this amount is reached, the cache "
+ "plot will be resampled to this minimum value, and new points will be added based on the sampling "
+ "rate after the resampling. This resampling allows for real-time plotting regardless of the number of "
+ "simulation cycles.");
+
// Console settings
auto* consoleGroupBox = new QGroupBox("Console");
auto* consoleLayout = new QGridLayout();
consoleGroupBox->setLayout(consoleLayout);
- auto [pageWidget, pageLayout] = constructPage();
appendToLayout(createSettingsWidgets<QCheckBox>(RIPES_SETTING_CONSOLEECHO, "Echo console input:"), consoleLayout);
appendToLayout(createSettingsWidgets<QPushButton, QFontDialog>(RIPES_SETTING_CONSOLEFONT, "Console font:"),
consoleLayout);
@@ -301,11 +309,15 @@ QWidget* SettingsDialog::createEnvironmentPage() {
appendToLayout(
createSettingsWidgets<QPushButton, QColorDialog>(RIPES_SETTING_CONSOLEBG, "Console background color:"),
consoleLayout);
- pageLayout->addWidget(consoleGroupBox);
+ appendToLayout(consoleGroupBox, pageLayout);
return pageWidget;
}
+void SettingsDialog::appendToLayout(QGroupBox* groupBox, QGridLayout* pageLayout, int colSpan) {
+ pageLayout->addWidget(groupBox, pageLayout->rowCount(), 0, 1, colSpan);
+}
+
void SettingsDialog::appendToLayout(std::pair<QLabel*, QWidget*> settingsWidgets, QGridLayout* pageLayout,
const QString& description) {
const unsigned row = pageLayout->rowCount();
@@ -316,6 +328,7 @@ void SettingsDialog::appendToLayout(std::pair<QLabel*, QWidget*> settingsWidgets
auto f = desc->font();
f.setPointSize(f.pointSize() * 0.9);
desc->setFont(f);
+ desc->setWordWrap(true);
pageLayout->addWidget(desc, row + 1, 0);
}
}

MODIFY
src/settingsdialog.h
src/settingsdialog.h
QT_FORWARD_DECLARE_CLASS(QLineEdit);
QT_FORWARD_DECLARE_CLASS(QLabel);
QT_FORWARD_DECLARE_CLASS(QGridLayout);
+QT_FORWARD_DECLARE_CLASS(QGroupBox);
namespace Ripes {
@@ -42,6 +43,7 @@ private:
void addPage(const QString& name, QWidget* page);
void appendToLayout(std::pair<QLabel*, QWidget*> settingsWidgets, QGridLayout* pageLayout,
const QString& description = QString());
+ void appendToLayout(QGroupBox* groupBox, QGridLayout* pageLayout, int colSpan = 2);
std::map<QString, int> m_pageIndex;
};

Make min points for resampling a settings parameter