Implement stepping timer
MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -11,13 +11,22 @@ ProcessorTab::ProcessorTab(QWidget* parent) : QWidget(parent), m_ui(new Ui::Proc
connect(m_ui->start, &QPushButton::toggled, [=](bool state) {
if (state) {
m_ui->start->setText("Pause simulation");
+ m_timer.start();
} else {
m_ui->start->setText("Start simulation");
+ m_timer.stop();
};
m_ui->step->setEnabled(!state);
});
+ // Setup speed slider
+ m_timer.setInterval(1500 - 200 * m_ui->execSpeed->sliderPosition());
+ connect(m_ui->execSpeed, &QSlider::valueChanged, [=](int pos) { m_timer.setInterval(1500 - 200 * pos); });
+
connect(m_ui->reset, &QPushButton::clicked, [=] { m_ui->start->setChecked(false); });
+
+ // Setup stepping timer
+ connect(&m_timer, &QTimer::timeout, this, &ProcessorTab::on_step_clicked);
}
void ProcessorTab::update() {
@@ -63,6 +72,7 @@ void ProcessorTab::on_run_clicked() {
void ProcessorTab::on_reset_clicked() {
Runner::getRunner()->restart();
+ m_instrModel->update();
m_ui->instructionView->update();
m_ui->registerContainer->update();
}

MODIFY
src/processortab.h
src/processortab.h
#ifndef PROCESSORTAB_H
#define PROCESSORTAB_H
+#include <QTimer>
#include <QWidget>
+
#include "defines.h"
namespace Ui {
@@ -39,6 +41,8 @@ private slots:
private:
Ui::ProcessorTab* m_ui;
InstructionModel* m_instrModel;
+
+ QTimer m_timer;
};
#endif // PROCESSORTAB_H

MODIFY
src/processortab.ui
src/processortab.ui
</sizepolicy>
</property>
<property name="minimum">
- <number>1</number>
+ <number>0</number>
</property>
<property name="maximum">
- <number>5</number>
+ <number>4</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>

MODIFY
src/runner.cpp
src/runner.cpp
@@ -451,6 +451,8 @@ void Runner::restart() {
m_reg[2] = m_stackStart;
m_reg[3] = m_dataStart;
m_pc = 0;
+
+ m_stagePCS = StagePCS();
}
void Runner::update() {

Implement stepping timer