Skip to content

Commit 816b01b

Browse files
committed
Change instruction views background to match stages color.
Signed-off-by: Pavel Pisa <[email protected]>
1 parent 635567e commit 816b01b

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

qtmips_gui/coreview.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
NEW_B(TYPE, VAR, __VA_ARGS__); \
5252
VAR->setPos(X, Y); \
5353
} while(false)
54-
#define NEW_I(VAR, X, Y, SIG) do { \
55-
NEW(InstructionView, VAR, X, Y); \
54+
#define NEW_I(VAR, X, Y, SIG, ...) do { \
55+
NEW(InstructionView, VAR, X, Y, __VA_ARGS__); \
5656
connect(machine->core(), &machine::Core::SIG, \
5757
VAR, &coreview::InstructionView::instruction_update); \
5858
} while(false)
@@ -350,11 +350,11 @@ CoreViewScenePipelined::CoreViewScenePipelined(machine::QtMipsMachine *machine)
350350
NEW(Latch, latch_mem_wb, 660, 70, machine, 400);
351351
latch_mem_wb->setTitle("MEM/WB");
352352

353-
NEW_I(inst_fetch, 79, 2, instruction_fetched);
354-
NEW_I(inst_dec, 275, 2, instruction_decoded);
355-
NEW_I(inst_exec, 464, 2, instruction_executed);
356-
NEW_I(inst_mem, 598, 2, instruction_memory);
357-
NEW_I(inst_wrb, 660, 18, instruction_writeback);
353+
NEW_I(inst_fetch, 79, 2, instruction_fetched, QColor(255, 173, 173));
354+
NEW_I(inst_dec, 275, 2, instruction_decoded, QColor(255, 212, 173));
355+
NEW_I(inst_exec, 464, 2, instruction_executed, QColor(193, 255, 173));
356+
NEW_I(inst_mem, 598, 2, instruction_memory, QColor(173, 255, 229));
357+
NEW_I(inst_wrb, 660, 18, instruction_writeback, QColor(255, 173, 230));
358358

359359
if (machine->config().hazard_unit() != machine::MachineConfig::HU_NONE) {
360360
NEW(LogicBlock, hazard_unit, SC_WIDTH/2, SC_HEIGHT - 15, "Hazard Unit");

qtmips_gui/coreview/instructionview.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ using namespace coreview;
4949
#define PENW 1
5050
//////////////////////
5151

52-
InstructionView::InstructionView() : QGraphicsObject(nullptr), text(this) {
52+
InstructionView::InstructionView(QColor bgnd) : QGraphicsObject(nullptr), text(this) {
5353
QFont f;
5454
f.setPointSize(FontSize::SIZE6);
5555
text.setFont(f);
56-
56+
this->bgnd = bgnd;
5757
// Initialize to NOP
5858
instruction_update(machine::Instruction(), 0, machine::EXCAUSE_NONE);
5959
}
@@ -65,7 +65,7 @@ QRectF InstructionView::boundingRect() const {
6565
void InstructionView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
6666
painter->setPen(QPen(QColor(240, 240, 240)));
6767
if (excause == machine::EXCAUSE_NONE)
68-
painter->setBrush(QBrush(QColor(240, 240, 240)));
68+
painter->setBrush(QBrush(bgnd));
6969
else
7070
painter->setBrush(QBrush(QColor(255, 100, 100)));
7171
painter->drawRoundRect(-WIDTH/2, 0, WIDTH, HEIGHT, ROUND, ROUND);

qtmips_gui/coreview/instructionview.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace coreview {
4545
class InstructionView : public QGraphicsObject {
4646
Q_OBJECT
4747
public:
48-
InstructionView();
48+
InstructionView(QColor bgnd = QColor(240, 240, 240));
4949

5050
QRectF boundingRect() const;
5151
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
@@ -57,6 +57,7 @@ public slots:
5757
private:
5858
QGraphicsSimpleTextItem text;
5959
machine::ExceptionCause excause;
60+
QColor bgnd;
6061
};
6162

6263
}

qtmips_gui/programmodel.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ QVariant ProgramModel::data(const QModelIndex &index, int role) const {
135135
} else if (address == stage_addr[STAGEADDR_MEMORY]) {
136136
QBrush bgd(QColor(173, 255, 229));
137137
return bgd;
138-
} else if (address == stage_addr[STAGEADDR_MEMORY]) {
139-
QBrush bgd(QColor(173, 255, 229));
140-
return bgd;
141138
} else if (address == stage_addr[STAGEADDR_EXECUTE]) {
142139
QBrush bgd(QColor(193, 255, 173));
143140
return bgd;

0 commit comments

Comments
 (0)