diff --git a/src/processortab.cpp b/src/processortab.cpp index a80796610..b7f17c824 100644 --- a/src/processortab.cpp +++ b/src/processortab.cpp @@ -140,6 +140,11 @@ ProcessorTab::ProcessorTab(QToolBar *controlToolbar, connect(ProcessorHandler::get(), &ProcessorHandler::stopping, this, &ProcessorTab::pause); + connect(ProcessorHandler::get(), &ProcessorHandler::processorClocked, this, + &ProcessorTab::processorClocked); + connect(ProcessorHandler::get(), &ProcessorHandler::processorReversed, this, + &ProcessorTab::processorReversed); + // Make processor view stretch wrt. consoles m_ui->pipelinesplitter->setStretchFactor(0, 1); m_ui->pipelinesplitter->setStretchFactor(1, 0); @@ -308,6 +313,7 @@ void ProcessorTab::updateStatistics() { const auto cycleCount = ProcessorHandler::getProcessor()->getCycleCount(); const auto instrsRetired = ProcessorHandler::getProcessor()->getInstructionsRetired(); + const auto timeDiff = std::chrono::duration_cast( timeNow - lastUpdateTime) .count() / @@ -318,10 +324,14 @@ void ProcessorTab::updateStatistics() { m_ui->cycleCount->setText(QString::number(cycleCount)); // Instructions retired m_ui->instructionsRetired->setText(QString::number(instrsRetired)); + // Stall Count + m_ui->stallCount->setText(QString::number(m_stallCount)); + // Flush Cycle Count + m_ui->flushCycleCount->setText(QString::number(m_flushCycleCount)); + QString cpiText, ipcText; if (cycleCount != 0 && instrsRetired != 0) { - const double cpi = - static_cast(cycleCount) / static_cast(instrsRetired); + const double cpi = static_cast(cycleCount) / static_cast(instrsRetired); const double ipc = 1 / cpi; cpiText = QString::number(cpi, 'g', 3); ipcText = QString::number(ipc, 'g', 3); @@ -499,6 +509,10 @@ void ProcessorTab::reset() { m_autoClockAction->setChecked(false); enableSimulatorControls(); SystemIO::printString("\n"); + + // Reset Statistics + m_stallCount = 0; + m_flushCycleCount = 0; } void ProcessorTab::setInstructionViewCenterRow(int row) { @@ -582,4 +596,27 @@ void ProcessorTab::showPipelineDiagram() { auto w = PipelineDiagramWidget(m_stageModel); w.exec(); } + +void ProcessorTab::processorClocked() { + const auto proc = ProcessorHandler::get()->getProcessor(); + for (auto lane : proc->structure()) { + const auto laneLastStage = proc->stageInfo({lane.first, lane.second - 1}); + if (laneLastStage.state == StageInfo::State::Stalled) + m_stallCount++; + if (laneLastStage.state == StageInfo::State::Flushed) + m_flushCycleCount++; + } +} + +void ProcessorTab::processorReversed() { + const auto proc = ProcessorHandler::get()->getProcessor(); + for (auto lane : proc->structure()) { + const auto laneLastStage = proc->stageInfo({lane.first, lane.second - 1}); + if (laneLastStage.state == StageInfo::State::Stalled) + m_stallCount--; + if (laneLastStage.state == StageInfo::State::Flushed) + m_flushCycleCount--; + } +} + } // namespace Ripes diff --git a/src/processortab.h b/src/processortab.h index e5b525b60..a0d358f04 100644 --- a/src/processortab.h +++ b/src/processortab.h @@ -45,6 +45,8 @@ public slots: void reverse(); void processorFinished(); void runFinished(); + void processorClocked(); + void processorReversed(); void updateStatistics(); void updateInstructionLabels(); void fitToScreen(); @@ -73,6 +75,10 @@ private slots: std::map m_stageInstructionLabels; + // Statistics + long long m_stallCount = 0; + long long m_flushCycleCount = 0; + QTimer *m_statUpdateTimer; // Actions diff --git a/src/processortab.ui b/src/processortab.ui index c50963456..9371c3c2f 100644 --- a/src/processortab.ui +++ b/src/processortab.ui @@ -56,22 +56,6 @@ - - - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - @@ -82,25 +66,19 @@ - - + + - + 0 0 - - - 0 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + <html><head/><body><p>Cycles:</p></body></html> - - true + + Qt::RichText @@ -114,24 +92,47 @@ - - + + - + 0 0 - - An instruction has been retired once leaving the final stage of the processor + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + - <html><head/><body><p>Instrs. retired:</p></body></html> + Clock rate: - - + + 0 @@ -168,31 +169,76 @@ - - + + + + Stalls + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + 0 0 + + An instruction has been retired once leaving the final stage of the processor + - <html><head/><body><p>Cycles:</p></body></html> + <html><head/><body><p>Instrs. retired:</p></body></html> - - Qt::RichText + + + + + + + 0 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true - - + + - Clock rate: + Flush Cycles - - + + 0