Add global reset request signal
Cleans up things a bit, compared to having reset associated with ProcessorTab (even though reset is still performed by the ProcessorTab).
MODIFY
src/cachetabwidget.cpp
src/cachetabwidget.cpp
#include "memorytab.h"
#include "memoryviewerwidget.h"
+#include "ripessettings.h"
#include <QTabBar>
#include <QWheelEvent>
@@ -23,17 +24,6 @@ public:
};
CacheTabWidget::CacheTabWidget(QWidget* parent) : QWidget(parent), m_ui(new Ui::CacheTabWidget) {
- while (parent != nullptr) {
- auto* mt = dynamic_cast<MemoryTab*>(parent);
- if (mt) {
- m_parent = mt;
- break;
- } else {
- parent = parent->parentWidget();
- }
- }
- Q_ASSERT(m_parent);
-
m_ui->setupUi(this);
m_l1dShim = std::make_unique<L1CacheShim>(L1CacheShim::CacheType::DataCache, this);
@@ -42,15 +32,6 @@ CacheTabWidget::CacheTabWidget(QWidget* parent) : QWidget(parent), m_ui(new Ui::
m_l1dShim->setNextLevelCache(m_ui->dataCacheWidget->getCacheSim());
m_l1iShim->setNextLevelCache(m_ui->instructionCacheWidget->getCacheSim());
- // Make selection changes in the cache trigger the memory viewer to set its central address to the selected address
- connectCacheWidget(m_ui->dataCacheWidget);
- connectCacheWidget(m_ui->instructionCacheWidget);
-
- // Make cache configuration changes emit processor reset requests
- connect(m_ui->dataCacheWidget, &CacheWidget::configurationChanged, [=] { emit m_parent->reqProcessorReset(); });
- connect(m_ui->instructionCacheWidget, &CacheWidget::configurationChanged,
- [=] { emit m_parent->reqProcessorReset(); });
-
m_addTabIdx = m_ui->tabWidget->addTab(new QLabel("Placeholder"), QIcon((":/icons/plus.svg")),
QString("L%1 Cache").arg(m_nextCacheLevel));

MODIFY
src/cachetabwidget.h
src/cachetabwidget.h
#include "cachesim/l1cacheshim.h"
namespace Ripes {
-class MemoryTab;
class CacheWidget;
namespace Ui {
@@ -28,7 +27,6 @@ private:
void handleTabCloseRequest(int index);
Ui::CacheTabWidget* m_ui;
- MemoryTab* m_parent = nullptr;
int m_addTabIdx = -1;
int m_nextCacheLevel = 2;

MODIFY
src/mainwindow.cpp
src/mainwindow.cpp
@@ -101,8 +101,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), m_ui(new Ui::Main
setupStatusBar();
// Reset and program reload signals
- connect(m_memoryTab, &MemoryTab::reqProcessorReset, m_processorTab, &ProcessorTab::reset);
- connect(ProcessorHandler::get(), &ProcessorHandler::reqProcessorReset, m_processorTab, &ProcessorTab::reset);
connect(ProcessorHandler::get(), &ProcessorHandler::processorChanged, m_editTab, &EditTab::onProcessorChanged);
connect(ProcessorHandler::get(), &ProcessorHandler::stopping, m_processorTab, &ProcessorTab::pause);

MODIFY
src/memorytab.h
src/memorytab.h
@@ -27,9 +27,6 @@ public:
public slots:
void update();
-signals:
- void reqProcessorReset();
-
private:
Ui::MemoryTab* m_ui = nullptr;
};

MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -69,7 +69,7 @@ void ProcessorHandler::loadProgram(std::shared_ptr<Program> p) {
m_breakpoints.erase(bp);
}
- emit reqProcessorReset();
+ RipesSettings::getObserver(RIPES_GLOBALSIGNAL_REQRESET)->trigger();
}
void ProcessorHandler::_writeMem(uint32_t address, uint32_t value, int size) {

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -113,6 +113,10 @@ ProcessorTab::ProcessorTab(QToolBar* controlToolbar, QToolBar* additionalToolbar
connect(RipesSettings::getObserver(RIPES_SETTING_REWINDSTACKSIZE), &SettingObserver::modified,
[=](const auto&) { m_reverseAction->setEnabled(m_vsrtlWidget->isReversible()); });
+ // Connect the global reset request signal to reset()
+ connect(RipesSettings::getObserver(RIPES_GLOBALSIGNAL_REQRESET), &SettingObserver::modified, this,
+ &ProcessorTab::reset);
+
// Send input data from the console to the SystemIO stdin stream
connect(m_ui->console, &Console::sendData, &SystemIO::get(), &SystemIO::putStdInData);
@@ -176,7 +180,8 @@ void ProcessorTab::setupSimulatorActions(QToolBar* controlToolbar) {
const QIcon resetIcon = QIcon(":/icons/reset.svg");
m_resetAction = new QAction(resetIcon, "Reset (F3)", this);
- connect(m_resetAction, &QAction::triggered, this, &ProcessorTab::reset);
+ connect(m_resetAction, &QAction::triggered, this,
+ [=] { RipesSettings::getObserver(RIPES_GLOBALSIGNAL_REQRESET)->trigger(); });
m_resetAction->setShortcut(QKeySequence("F3"));
m_resetAction->setToolTip("Reset the simulator (F3)");
controlToolbar->addAction(m_resetAction);

MODIFY
src/ripessettings.cpp
src/ripessettings.cpp
@@ -27,6 +27,8 @@ const std::map<QString, QVariant> s_defaultSettings = {
// Program state preserving settings
{RIPES_GLOBALSIGNAL_QUIT, 0},
+ {RIPES_GLOBALSIGNAL_REQRESET, 0},
+
{RIPES_SETTING_SETTING_TAB, 0},
{RIPES_SETTING_VIEW_ZOOM, 250},
{RIPES_SETTING_PERIPHERAL_SETTINGS, ""},
@@ -45,6 +47,10 @@ void SettingObserver::setValue(const QVariant& v) {
emit modified(value());
}
+void SettingObserver::trigger() {
+ setValue(0);
+}
+
QVariant SettingObserver::value() const {
QSettings settings;
Q_ASSERT(settings.contains(m_key));

MODIFY
src/ripessettings.h
src/ripessettings.h
@@ -29,6 +29,7 @@ namespace Ripes {
// This is not really a setting, but instead a method to leverage the static observer objects that are generated for a
// setting. Used for other objects to hook into a signal emitted just before the application closes.
#define RIPES_GLOBALSIGNAL_QUIT ("sig_quit")
+#define RIPES_GLOBALSIGNAL_REQRESET ("req_reset")
// Program state preserving settings
#define RIPES_SETTING_SETTING_TAB ("settings_tab")
@@ -62,6 +63,7 @@ signals:
public slots:
void setValue(const QVariant& value);
+ void trigger();
private:
QString m_key;

Add global reset request signal

Cleans up things a bit, compared to having reset associated with ProcessorTab (even though reset is still performed by the ProcessorTab).