Record pipeline diagram cycles up to a settings-defined amount
MODIFY
src/pipelinediagrammodel.cpp
src/pipelinediagrammodel.cpp
#include "pipelinediagrammodel.h"
+#include "ripessettings.h"
+
#include <vector>
namespace Ripes {
@@ -12,8 +14,9 @@ static inline uint32_t indexToAddress(unsigned index) {
}
PipelineDiagramModel::PipelineDiagramModel(QObject* parent) : QAbstractTableModel(parent) {
- connect(ProcessorHandler::get(), &ProcessorHandler::procStateChangedNonRun, this,
- &PipelineDiagramModel::processorWasClocked);
+ connect(ProcessorHandler::get(), &ProcessorHandler::processorClocked, this,
+ &PipelineDiagramModel::processorWasClocked, Qt::DirectConnection);
+ connect(ProcessorHandler::get(), &ProcessorHandler::processorReset, this, &PipelineDiagramModel::reset);
}
QVariant PipelineDiagramModel::headerData(int section, Qt::Orientation orientation, int role) const {
@@ -37,16 +40,28 @@ int PipelineDiagramModel::columnCount(const QModelIndex&) const {
}
void PipelineDiagramModel::processorWasClocked() {
+ if (m_atMaxCycles) {
+ return;
+ }
gatherStageInfo();
+
+ const auto cycleCount = ProcessorHandler::getProcessor()->getCycleCount();
+ if (cycleCount >= RipesSettings::value(RIPES_SETTING_PIPEDIAGRAM_MAXCYCLES).toInt()) {
+ m_atMaxCycles = true;
+ }
}
void PipelineDiagramModel::reset() {
- beginResetModel();
+ m_atMaxCycles = false;
m_cycleStageInfos.clear();
- endResetModel();
gatherStageInfo();
}
+void PipelineDiagramModel::prepareForView() {
+ beginResetModel();
+ endResetModel();
+}
+
void PipelineDiagramModel::gatherStageInfo() {
long long cycleCount = ProcessorHandler::getProcessor()->getCycleCount();
if (m_cycleStageInfos.count(cycleCount)) {

MODIFY
src/pipelinediagrammodel.h
src/pipelinediagrammodel.h
@@ -17,6 +17,7 @@ public:
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
+ void prepareForView();
public slots:
void processorWasClocked();
@@ -30,5 +31,13 @@ private:
* map<cycle, map<stageId, stageInfo>>
*/
std::map<long long, std::map<unsigned, StageInfo>> m_cycleStageInfos;
+
+ /**
+ * @brief m_atMaxCycles
+ * Records the state that we've crossed the threshold set for RIPES_SETTING_PIPEDIAGRAM_MAXCYCLES.
+ * This is to speed up execution by not having to check the settings value during each cycle of simulation,
+ * after the value has been reached.
+ */
+ bool m_atMaxCycles = false;
};
} // namespace Ripes

MODIFY
src/pipelinediagramwidget.cpp
src/pipelinediagramwidget.cpp
#include <QHeaderView>
#include "pipelinediagrammodel.h"
+#include "ripessettings.h"
namespace Ripes {
@@ -17,6 +18,8 @@ PipelineDiagramWidget::PipelineDiagramWidget(PipelineDiagramModel* model, QWidge
m_ui->pipelineDiagramView->resizeColumnsToContents();
m_ui->copy->setIcon(QIcon(":/icons/documents.svg"));
+
+ m_stageModel->prepareForView();
}
PipelineDiagramWidget::~PipelineDiagramWidget() {

MODIFY
src/pipelinediagramwidget.ui
src/pipelinediagramwidget.ui
</property>
</widget>
</item>
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note: &lt;/span&gt;Stage information is &lt;span style=&quot; font-style:italic;&quot;&gt;not &lt;/span&gt;recorded while executing the processor via the &amp;quot;Run&amp;quot; option.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="textFormat">
- <enum>Qt::RichText</enum>
- </property>
- </widget>
- </item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
</property>
</spacer>
</item>
+ <item>
+ <widget class="QLabel" name="infoLabel">
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:10pt; font-style:italic;&quot;&gt;# of recorded cycles can be changed in settings&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -414,7 +414,7 @@ void ProcessorTab::enableSimulatorControls() {
m_runAction->setEnabled(true);
m_reverseAction->setEnabled(m_vsrtlWidget->isReversible());
m_resetAction->setEnabled(true);
- m_pipelineDiagramAction->setEnabled(!m_hasRun);
+ m_pipelineDiagramAction->setEnabled(true);
}
void ProcessorTab::updateInstructionLabels() {
@@ -445,10 +445,8 @@ void ProcessorTab::updateInstructionLabels() {
}
void ProcessorTab::reset() {
- m_hasRun = false;
m_autoClockAction->setChecked(false);
m_vsrtlWidget->reset();
- m_stageModel->reset();
enableSimulatorControls();
printToLog("\n");
@@ -478,7 +476,6 @@ void ProcessorTab::runFinished() {
}
void ProcessorTab::run(bool state) {
- m_hasRun = true;
// Stop any currently exeuting auto-clocking
if (m_autoClockAction->isChecked()) {
m_autoClockAction->setChecked(false);
@@ -498,7 +495,7 @@ void ProcessorTab::run(bool state) {
m_reverseAction->setEnabled(!state);
m_resetAction->setEnabled(!state);
m_displayValuesAction->setEnabled(!state);
- m_pipelineDiagramAction->setEnabled(false);
+ m_pipelineDiagramAction->setEnabled(!state);
// Disable widgets which are not updated when running the processor
m_vsrtlWidget->setEnabled(!state);

MODIFY
src/processortab.h
src/processortab.h
@@ -86,11 +86,5 @@ private:
QAction* m_darkmodeAction = nullptr;
QSpinBox* m_autoClockInterval = nullptr;
-
- /**
- * @brief m_hasRun
- * True whenever the processor has been executed through the "Run" action.
- */
- bool m_hasRun = false;
};
} // namespace Ripes

MODIFY
src/ripessettings.cpp
src/ripessettings.cpp
@@ -26,6 +26,7 @@ const std::map<QString, QVariant> s_defaultSettings = {
{RIPES_SETTING_ASSEMBLER_BSSSTART, 0x11000000},
{RIPES_SETTING_PERIPHERALS_START, static_cast<unsigned>(0xF0000000)},
+ {RIPES_SETTING_PIPEDIAGRAM_MAXCYCLES, 100},
{RIPES_SETTING_CACHE_MAXCYCLES, 10000},
{RIPES_SETTING_CACHE_MAXPOINTS, 1000},
{RIPES_SETTING_CACHE_PRESETS,

MODIFY
src/ripessettings.h
src/ripessettings.h
@@ -22,6 +22,7 @@ namespace Ripes {
#define RIPES_SETTING_ASSEMBLER_DATASTART ("data_start")
#define RIPES_SETTING_ASSEMBLER_BSSSTART ("bss_start")
+#define RIPES_SETTING_PIPEDIAGRAM_MAXCYCLES ("pipelinediagram_maxcycles")
#define RIPES_SETTING_PERIPHERALS_START ("peripheral_start")
#define RIPES_SETTING_CACHE_MAXCYCLES ("cacheplot_maxcycles")
#define RIPES_SETTING_CACHE_MAXPOINTS ("cacheplot_maxpoints")

MODIFY
src/settingsdialog.cpp
src/settingsdialog.cpp
@@ -291,6 +291,7 @@ QWidget* SettingsDialog::createEnvironmentPage() {
auto [maxcyclesLabel, maxcyclesSb] =
createSettingsWidgets<QSpinBox>(RIPES_SETTING_CACHE_MAXCYCLES, "Max. cache plot cycles");
maxcyclesSb->setMinimum(0);
+ maxcyclesSb->setMaximum(INT_MAX);
appendToLayout({maxcyclesLabel, maxcyclesSb}, pageLayout,
"Maximum number of cache cycles to plot. Increasing this may incur substantial slowdown for long "
"time executing programs, given the number of points to be plotted.");
@@ -298,6 +299,7 @@ QWidget* SettingsDialog::createEnvironmentPage() {
auto [maxPointsLabel, maxPointsSb] =
createSettingsWidgets<QSpinBox>(RIPES_SETTING_CACHE_MAXPOINTS, "Min. cache plot points:");
maxPointsSb->setMinimum(2);
+ maxPointsSb->setMaximum(INT_MAX);
appendToLayout(
{maxPointsLabel, maxPointsSb}, pageLayout,
"Minimum number of points to be kept in the cache plot. Once 2x this amount is reached, the cache "
@@ -305,6 +307,13 @@ QWidget* SettingsDialog::createEnvironmentPage() {
"rate after the resampling. This resampling allows for real-time plotting regardless of the number of "
"simulation cycles.");
+ auto [maxPipeDiagCycLabel, maxPipeDiagCycSb] =
+ createSettingsWidgets<QSpinBox>(RIPES_SETTING_PIPEDIAGRAM_MAXCYCLES, "Max. pipeline diagram cycles:");
+ maxPipeDiagCycSb->setMinimum(0);
+ maxPipeDiagCycSb->setMaximum(INT_MAX);
+ appendToLayout({maxPipeDiagCycLabel, maxPipeDiagCycSb}, pageLayout,
+ "Maximum number of cycles to be recorded in the pipeline diagram.");
+
// Console settings
auto* consoleGroupBox = new QGroupBox("Console");
auto* consoleLayout = new QGridLayout();

Record pipeline diagram cycles up to a settings-defined amount