Implement runner stepping
MODIFY
src/defines.h
src/defines.h
@@ -13,11 +13,13 @@ enum displayTypeN { Hex = 1, Binary = 2, Decimal = 3, Unsigned = 4, ASCII = 5 };
Q_DECLARE_METATYPE(displayTypeN)
typedef struct {
- int IF = 0;
- int ID = 0;
- int EX = 0;
- int MEM = 0;
- int WB = 0;
+ // Initialize to UINT32_MAX. An instruction at PC = 0 should not be defaulted as being inside a pipeline -
+ // therefore, the maximum uint32 value is chosen
+ uint32_t IF = UINT32_MAX;
+ uint32_t ID = UINT32_MAX;
+ uint32_t EX = UINT32_MAX;
+ uint32_t MEM = UINT32_MAX;
+ uint32_t WB = UINT32_MAX;
} StagePCS;
enum Colors {

MODIFY
src/instructionmodel.cpp
src/instructionmodel.cpp
@@ -39,15 +39,16 @@ QVariant InstructionModel::data(const QModelIndex& index, int role) const {
case 0:
return row * 4;
case 1: { // check if instruction is in any pipeline stage
- if (row == m_pcsptr.EX)
+ int byteIndex = row * 4;
+ if (byteIndex == m_pcsptr.EX)
return QString("EX");
- else if (row == m_pcsptr.ID)
+ else if (byteIndex == m_pcsptr.ID)
return QString("ID");
- else if (row == m_pcsptr.IF)
+ else if (byteIndex == m_pcsptr.IF)
return QString("IF");
- else if (row == m_pcsptr.MEM)
+ else if (byteIndex == m_pcsptr.MEM)
return QString("MEM");
- else if (row == m_pcsptr.WB)
+ else if (byteIndex == m_pcsptr.WB)
return QString("WB");
else
return QVariant();

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -66,3 +66,10 @@ void ProcessorTab::on_reset_clicked() {
m_ui->instructionView->update();
m_ui->registerContainer->update();
}
+
+void ProcessorTab::on_step_clicked() {
+ Runner::getRunner()->step();
+ m_instrModel->update();
+ m_ui->instructionView->update();
+ m_ui->registerContainer->update();
+}

MODIFY
src/processortab.h
src/processortab.h
@@ -34,6 +34,8 @@ private slots:
void on_reset_clicked();
+ void on_step_clicked();
+
private:
Ui::ProcessorTab* m_ui;
InstructionModel* m_instrModel;

MODIFY
src/runner.cpp
src/runner.cpp
@@ -37,6 +37,7 @@ int Runner::exec() {
}
int Runner::step() {
+ m_stagePCS.IF = m_pc;
getInstruction(m_pc);
execInstruction(m_currentInstruction);
return 0;

Implement runner stepping