Add CPI and IPC to statistics
MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -60,8 +60,6 @@ ProcessorTab::ProcessorTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolba
m_ui->viewSplitter->setStretchFactor(0, 1);
m_ui->viewSplitter->setStretchFactor(1, 0);
- m_ui->consolesTab->removeTab(1);
-
// Initially, no file is loaded, disable toolbuttons
enableSimulatorControls();
}
@@ -162,9 +160,19 @@ void ProcessorTab::setupSimulatorActions() {
}
void ProcessorTab::updateStatistics() {
- m_ui->cycleCount->setText(QString::number(ProcessorHandler::get()->getProcessor()->getCycleCount()));
- m_ui->instructionsRetired->setText(
- QString::number(ProcessorHandler::get()->getProcessor()->getInstructionsRetired()));
+ const auto cycles = ProcessorHandler::get()->getProcessor()->getCycleCount();
+ const auto instrsRetired = ProcessorHandler::get()->getProcessor()->getInstructionsRetired();
+ m_ui->cycleCount->setText(QString::number(cycles));
+ m_ui->instructionsRetired->setText(QString::number(instrsRetired));
+ QString cpiText, ipcText;
+ if (cycles != 0 && instrsRetired != 0) {
+ const double cpi = static_cast<double>(cycles) / static_cast<double>(instrsRetired);
+ const double ipc = 1 / cpi;
+ cpiText = QString::number(cpi, 'g', 3);
+ ipcText = QString::number(ipc, 'g', 3);
+ }
+ m_ui->cpi->setText(cpiText);
+ m_ui->ipc->setText(ipcText);
}
void ProcessorTab::pause() {

MODIFY
src/processortab.ui
src/processortab.ui
<rect>
<x>0</x>
<y>0</y>
- <width>1138</width>
- <height>739</height>
+ <width>868</width>
+ <height>413</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QGridLayout" name="gridLayout_5">
+ <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QSplitter" name="viewSplitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="childrenCollapsible">
- <bool>false</bool>
- </property>
- <widget class="QWidget" name="layoutWidget">
- <layout class="QVBoxLayout" name="verticalLayout" stretch="0">
- <item>
<widget class="QSplitter" name="pipelinesplitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="childrenCollapsible">
- <bool>false</bool>
- </property>
<widget class="vsrtl::VSRTLWidget" name="vsrtlWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
</sizepolicy>
</property>
</widget>
- <widget class="QTabWidget" name="consolesTab">
+ <widget class="QWidget" name="horizontalLayoutWidget_2">
+ <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0">
+ <item>
+ <widget class="QGroupBox" name="groupBox_4">
+ <property name="title">
+ <string>Output</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_6">
+ <item row="0" column="0">
+ <widget class="QPlainTextEdit" name="console">
<property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="minimumSize">
<size>
<width>0</width>
- <height>150</height>
+ <height>0</height>
</size>
</property>
- <property name="currentIndex">
- <number>1</number>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Statistics</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_8">
+ <item row="0" column="0">
+ <layout class="QGridLayout" name="gridLayout_7">
+ <item row="2" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>CPI:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Cycles:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="cycleCount">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="nInstrExecutedLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Instrs. retired:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="cpi">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <widget class="QWidget" name="tab">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
- <attribute name="title">
- <string>Output</string>
- </attribute>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QPlainTextEdit" name="console">
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="instructionsRetired">
<property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>IPC:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="ipc">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<height>0</height>
</size>
</property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
</widget>
</item>
</layout>
- </widget>
- <widget class="QWidget" name="tab_2">
- <attribute name="title">
- <string>Tab 2</string>
- </attribute>
- </widget>
- </widget>
+ </item>
+ <item row="1" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</widget>
</item>
</layout>
</widget>
+ </widget>
<widget class="QWidget" name="verticalLayoutWidget">
- <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0">
+ <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
</item>
</layout>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Cycle count:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="cycleCount">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="nInstrExecutedLabel">
- <property name="text">
- <string># instructions retired:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="instructionsRetired">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</widget>
</widget>

Add CPI and IPC to statistics