aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/coreview.cpp24
-rw-r--r--qtmips_gui/coreview/instructionview.cpp34
-rw-r--r--qtmips_gui/coreview/instructionview.h9
3 files changed, 49 insertions, 18 deletions
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index 02e6f13..e51345f 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -220,20 +220,20 @@ CoreViewSceneSimple::~CoreViewSceneSimple() {
}
CoreViewScenePipelined::CoreViewScenePipelined(CoreView *view, machine::QtMipsMachine *machine) : CoreViewScene(view, machine) {
- NEW(Latch, latch_if_id, 158, 90, machine, 380);
+ NEW(Latch, latch_if_id, 158, 70, machine, 400);
latch_if_id->setTitle("IF/ID");
- NEW(Latch, latch_id_ex, 392, 90, machine, 380);
+ NEW(Latch, latch_id_ex, 392, 70, machine, 400);
latch_id_ex->setTitle("ID/EX");
- NEW(Latch, latch_ex_mem, 536, 90, machine, 380);
+ NEW(Latch, latch_ex_mem, 536, 70, machine, 400);
latch_ex_mem->setTitle("EX/MEM");
- NEW(Latch, latch_mem_wb, 660, 90, machine, 380);
+ NEW(Latch, latch_mem_wb, 660, 70, machine, 400);
latch_mem_wb->setTitle("MEM/WB");
- NEW_I(inst_fetch, 100, 2, instruction_fetched(const machine::Instruction&));
- NEW_I(inst_dec, 250, 2, instruction_decoded(const machine::Instruction&));
- NEW_I(inst_exec, 400, 2, instruction_executed(const machine::Instruction&));
- NEW_I(inst_mem, 540, 2, instruction_memory(const machine::Instruction&));
- NEW_I(inst_wrb, 670, 2, instruction_writeback(const machine::Instruction&));
+ NEW_I(inst_fetch, 79, 2, instruction_fetched(const machine::Instruction&));
+ NEW_I(inst_dec, 275, 2, instruction_decoded(const machine::Instruction&));
+ NEW_I(inst_exec, 464, 2, instruction_executed(const machine::Instruction&));
+ NEW_I(inst_mem, 598, 2, instruction_memory(const machine::Instruction&));
+ NEW_I(inst_wrb, 660, 18, instruction_writeback(const machine::Instruction&));
if (machine->config().hazard_unit() != machine::MachineConfig::HU_NONE) {
NEW(LogicBlock, hazard_unit, SC_WIDTH/2, SC_HEIGHT - 15, "Hazard Unit");
@@ -244,7 +244,7 @@ CoreViewScenePipelined::CoreViewScenePipelined(CoreView *view, machine::QtMipsMa
// Fetch stage
struct coreview::Latch::ConnectorPair lp_ft_inst = latch_if_id->new_connector(mem_program->connector_instruction()->y() - latch_if_id->y());
new_bus(mem_program->connector_instruction(), lp_ft_inst.in);
- struct coreview::Latch::ConnectorPair lp_ft_pc = latch_if_id->new_connector(370);
+ struct coreview::Latch::ConnectorPair lp_ft_pc = latch_if_id->new_connector(390);
new_bus(ft.junc_pc_4->new_connector(coreview::Connector::AX_Y), lp_ft_pc.in);
// Decode stage
new_bus(lp_ft_inst.out, dc.instr_bus->new_connector(lp_ft_inst.out->point()));
@@ -264,14 +264,14 @@ CoreViewScenePipelined::CoreViewScenePipelined(CoreView *view, machine::QtMipsMa
con = new_bus(lp_dc_immed.out, ex.mux_imm->connector_in(1));
con->setAxes({CON_AXIS_Y(440)});
struct coreview::Latch::ConnectorPair lp_ex_alu = latch_ex_mem->new_connector(alu->connector_out()->y() - latch_ex_mem->y());
- struct coreview::Latch::ConnectorPair lp_ex_dt = latch_ex_mem->new_connector(270);
+ struct coreview::Latch::ConnectorPair lp_ex_dt = latch_ex_mem->new_connector(290);
new_bus(alu->connector_out(), lp_ex_alu.in);
new_bus(ex.j_mux->new_connector(CON_AX_Y), lp_ex_dt.in);
// Memory
new_bus(lp_ex_alu.out, mm.j_addr->new_connector(CON_AX_X));
con = new_bus(lp_ex_dt.out, mem_data->connector_data_in());
con->setAxes({CON_AXIS_Y(560)});
- struct coreview::Latch::ConnectorPair lp_mem_alu = latch_mem_wb->new_connector(160);
+ struct coreview::Latch::ConnectorPair lp_mem_alu = latch_mem_wb->new_connector(180);
struct coreview::Latch::ConnectorPair lp_mem_mem = latch_mem_wb->new_connector(mem_data->connector_data_out()->y() - latch_mem_wb->y());
new_bus(mm.j_addr->new_connector(CON_AX_Y), lp_mem_alu.in);
new_bus(mem_data->connector_data_out(), lp_mem_mem.in);
diff --git a/qtmips_gui/coreview/instructionview.cpp b/qtmips_gui/coreview/instructionview.cpp
index bab9bc8..0c9ec68 100644
--- a/qtmips_gui/coreview/instructionview.cpp
+++ b/qtmips_gui/coreview/instructionview.cpp
@@ -1,15 +1,39 @@
#include "instructionview.h"
+#include <QPainter>
#include <QFont>
using namespace coreview;
-InstructionView::InstructionView() : QObject(), QGraphicsSimpleTextItem() {
+//////////////////////
+#define WIDTH 120
+#define HEIGHT 14
+#define ROUND 5
+#define GAP 2
+#define PENW 1
+//////////////////////
+
+InstructionView::InstructionView() : QGraphicsObject(nullptr), text(this) {
QFont f;
- f.setPointSize(8);
- setFont(f);
- instruction_update(machine::Instruction());
+ f.setPointSize(6);
+ text.setFont(f);
+
+ instruction_update(machine::Instruction()); // Initialize to NOP
+}
+
+QRectF InstructionView::boundingRect() const {
+ return QRectF(-WIDTH/2 - PENW/2, -PENW/2, WIDTH + PENW, HEIGHT + PENW);
+}
+
+void InstructionView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
+ painter->setPen(QPen(QColor(240, 240, 240)));
+ painter->setBrush(QBrush(QColor(240, 240, 240)));
+ painter->drawRoundRect(-WIDTH/2, 0, WIDTH, HEIGHT, ROUND, ROUND);
}
void InstructionView::instruction_update(const machine::Instruction &i) {
- setText(i.to_str());
+ QRectF prev_box = boundingRect();
+ text.setText(i.to_str());
+ QRectF box = text.boundingRect();
+ text.setPos(-box.width()/2, GAP);
+ update(prev_box.united(boundingRect()));
}
diff --git a/qtmips_gui/coreview/instructionview.h b/qtmips_gui/coreview/instructionview.h
index 4b7d171..2b0e340 100644
--- a/qtmips_gui/coreview/instructionview.h
+++ b/qtmips_gui/coreview/instructionview.h
@@ -1,18 +1,25 @@
#ifndef INSTRUCTIONVIEW_H
#define INSTRUCTIONVIEW_H
+#include <QGraphicsObject>
#include <QGraphicsSimpleTextItem>
#include "qtmipsmachine.h"
namespace coreview {
-class InstructionView : public QObject, public QGraphicsSimpleTextItem {
+class InstructionView : public QGraphicsObject {
Q_OBJECT
public:
InstructionView();
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
public slots:
void instruction_update(const machine::Instruction &i);
+
+private:
+ QGraphicsSimpleTextItem text;
};
}