Highlight stalls and flushes using red text
MODIFY
src/graphics/backgrounditems.cpp
src/graphics/backgrounditems.cpp
@@ -50,8 +50,15 @@ QRectF Text::boundingRect() const {
return rect;
}
+void Text::setText(const QString& text, QColor col) {
+ m_textColor = col;
+ m_text = text;
+ update();
+}
+
void Text::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) {
QRectF rect = boundingRect();
+ painter->setPen(m_textColor);
painter->setFont(m_font);
painter->drawText(rect, Qt::AlignCenter, m_text);
}

MODIFY
src/graphics/backgrounditems.h
src/graphics/backgrounditems.h
@@ -21,10 +21,7 @@ private:
class Text : public QGraphicsItem {
public:
Text(QPointF pos);
- void setText(const QString& text) {
- m_text = text;
- update();
- }
+ void setText(const QString& text, QColor col = QColor());
QRectF boundingRect() const;
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
@@ -32,6 +29,7 @@ private:
QString m_text;
QFont m_font;
QPointF m_pos;
+ QColor m_textColor;
};
} // namespace Graphics

MODIFY
src/graphics/pipelinewidget.cpp
src/graphics/pipelinewidget.cpp
@@ -468,22 +468,22 @@ void PipelineWidget::setSignal(Graphics::Connection* conn, SignalBase* sig) {
m_animatedItems.push_back(conn->getLabel());
}
-void PipelineWidget::stageTextChanged(Stage stage, const QString& text) {
+void PipelineWidget::stageTextChanged(Stage stage, const QString& text, QColor col) {
switch (stage) {
case Stage::IF:
- if_instr->setText(text);
+ if_instr->setText(text, col);
break;
case Stage::ID:
- id_instr->setText(text);
+ id_instr->setText(text, col);
break;
case Stage::EX:
- ex_instr->setText(text);
+ ex_instr->setText(text, col);
break;
case Stage::MEM:
- mem_instr->setText(text);
+ mem_instr->setText(text, col);
break;
case Stage::WB:
- wb_instr->setText(text);
+ wb_instr->setText(text, col);
break;
}
}

MODIFY
src/graphics/pipelinewidget.h
src/graphics/pipelinewidget.h
@@ -32,7 +32,7 @@ public:
public slots:
void update();
- void stageTextChanged(Stage stage, const QString& text);
+ void stageTextChanged(Stage stage, const QString& text, QColor col);
signals:
void displayAllValuesSig(bool state);

MODIFY
src/instructionmodel.cpp
src/instructionmodel.cpp
@@ -31,9 +31,9 @@ namespace {
if (!m_pcsptr.stage.initialized) { \
emit textChanged(Stage::stage, ""); \
} else if (m_pcsptr.stage.invalidReason == 1) { \
- emit textChanged(Stage::stage, "nop (flush)"); \
+ emit textChanged(Stage::stage, "nop (flush)", QColor(Qt::red)); \
} else if (m_pcsptr.stage.invalidReason == 2) { \
- emit textChanged(Stage::stage, "nop (stall)"); \
+ emit textChanged(Stage::stage, "nop (stall)", QColor(Qt::red)); \
} else if (m_pcsptr.stage.invalidReason == 3) { \
emit textChanged(Stage::stage, ""); /*EOF*/ \
}

MODIFY
src/instructionmodel.h
src/instructionmodel.h
#ifndef INSTRUCTIONMODEL_H
#define INSTRUCTIONMODEL_H
+#include <QColor>
#include <set>
#include "defines.h"
#include "mainmemory.h"
@@ -39,7 +40,7 @@ private:
uint32_t memRead(uint32_t address) const;
signals:
- void textChanged(Stage stage, QString text) const;
+ void textChanged(Stage stage, QString text, QColor col = QColor()) const;
void currentIFRow(int) const;
public slots:

Highlight stalls and flushes using red text