aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/coreview.cpp33
-rw-r--r--qtmips_gui/coreview.h1
-rw-r--r--qtmips_gui/coreview/registers.cpp1
-rw-r--r--qtmips_gui/coreview/value.cpp51
-rw-r--r--qtmips_gui/coreview/value.h30
-rw-r--r--qtmips_gui/qtmips_gui.pro6
6 files changed, 119 insertions, 3 deletions
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index 5652a21..b2d9b7d 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -19,10 +19,13 @@
NEW(InstructionView, VAR, X, Y); \
connect(machine->core(), SIGNAL(SIG), VAR, SLOT(instruction_update(const machine::Instruction&))); \
} while(false)
+#define NEW_V(X, Y, ...) NEW(Value, val, X, Y, __VA_ARGS__)
CoreViewScene::CoreViewScene(machine::QtMipsMachine *machine) : QGraphicsScene() {
setSceneRect(0, 0, SC_WIDTH, SC_HEIGHT);
+ coreview::Value *val;
+
// Elements //
// Primary points
NEW(ProgramMemory, mem_program, 90, 240, machine);
@@ -93,6 +96,36 @@ CoreViewScene::CoreViewScene(machine::QtMipsMachine *machine) : QGraphicsScene()
con = new_bus(wb.mem_or_reg->connector_out(), regs->connector_write());
con->setAxes({CON_AXIS_Y(710), CON_AXIS_X(510), CON_AXIS_Y(172)});
+ // Decode stage values
+ NEW_V(200, 200); // Instruction
+ connect(machine->core(), SIGNAL(decode_instruction_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ NEW_V(360, 250); // Register output 1
+ connect(machine->core(), SIGNAL(decode_reg1_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ NEW_V(360, 270); // Register output 2
+ connect(machine->core(), SIGNAL(decode_reg2_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ NEW_V(335, 415); // Sign extended immediate value
+ connect(machine->core(), SIGNAL(decode_immediate_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ // Execute stage
+ NEW_V(430, 250); // Register 1
+ connect(machine->core(), SIGNAL(execute_reg1_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ NEW_V(420, 310, true); // Register 2
+ connect(machine->core(), SIGNAL(execute_reg2_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ NEW_V(520, 280, true); // Alu output
+ connect(machine->core(), SIGNAL(execute_alu_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ NEW_V(430, 415); // Immediate value
+ connect(machine->core(), SIGNAL(execute_immediate_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ // Memory stage
+ NEW_V(560, 275, true); // Alu output
+ connect(machine->core(), SIGNAL(memory_alu_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ NEW_V(560, 345, true); // rt
+ connect(machine->core(), SIGNAL(memory_rt_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ NEW_V(650, 290, true); // Memory output
+ connect(machine->core(), SIGNAL(memory_mem_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+ // Write back stage
+ NEW_V(710, 330, true); // Write back value
+ connect(machine->core(), SIGNAL(writeback_value(std::uint32_t)), val, SLOT(value_update(std::uint32_t)));
+
+
connect(regs, SIGNAL(open_registers()), this, SIGNAL(request_registers()));
connect(mem_program, SIGNAL(open_mem()), this, SIGNAL(request_program_memory()));
connect(mem_data, SIGNAL(open_mem()), this, SIGNAL(request_data_memory()));
diff --git a/qtmips_gui/coreview.h b/qtmips_gui/coreview.h
index b2668c1..e4885d8 100644
--- a/qtmips_gui/coreview.h
+++ b/qtmips_gui/coreview.h
@@ -18,6 +18,7 @@
#include "coreview/constant.h"
#include "coreview/logicblock.h"
#include "coreview/and.h"
+#include "coreview/value.h"
class CoreViewScene : public QGraphicsScene {
Q_OBJECT
diff --git a/qtmips_gui/coreview/registers.cpp b/qtmips_gui/coreview/registers.cpp
index ba46f53..e4515c0 100644
--- a/qtmips_gui/coreview/registers.cpp
+++ b/qtmips_gui/coreview/registers.cpp
@@ -46,7 +46,6 @@ QRectF Registers::boundingRect() const {
void Registers::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute((unused)), QWidget *widget __attribute((unused))) {
painter->drawRect(0, 0, WIDTH, HEIGHT);
- // TODO anything else?
}
void Registers::setPos(qreal x, qreal y) {
diff --git a/qtmips_gui/coreview/value.cpp b/qtmips_gui/coreview/value.cpp
new file mode 100644
index 0000000..557abfe
--- /dev/null
+++ b/qtmips_gui/coreview/value.cpp
@@ -0,0 +1,51 @@
+#include "value.h"
+
+using namespace coreview;
+
+#define HEIGHT 8
+#define LETWIDTH 7
+
+// TODO orientation
+Value::Value(bool vertical, unsigned width, std::uint32_t init_val) : QGraphicsObject(nullptr) {
+ wid = width;
+ val = init_val;
+ this->vertical = vertical;
+}
+
+QRectF Value::boundingRect() const {
+ if (vertical)
+ return QRectF(-LETWIDTH/2 - 1, -HEIGHT*(int)wid/2 - 1, LETWIDTH + 2, HEIGHT*wid + 2);
+ else
+ return QRectF(-(LETWIDTH*(int)wid)/2 - 1, -HEIGHT/2 - 1, LETWIDTH*wid + 2, HEIGHT + 2);
+}
+
+void Value::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))){
+ QFont f;
+ f.setPointSize(7);
+ painter->setFont(f);
+
+ QRectF rect;
+ if (vertical)
+ rect = QRectF(-LETWIDTH/2 - 0.5, -(HEIGHT*(int)wid)/2 - 0.5, LETWIDTH + 1, HEIGHT*wid + 1);
+ else
+ rect = QRectF(-(LETWIDTH*(int)wid)/2 - 0.5, -HEIGHT/2 - 0.5, LETWIDTH*wid + 1, HEIGHT + 1);
+ painter->setBrush(QBrush(QColor(Qt::white)));
+ painter->setBackgroundMode(Qt::OpaqueMode);
+ painter->drawRect(rect);
+ painter->setBackgroundMode(Qt::TransparentMode);
+ QString str = QString("%1").arg(val, wid, 16, QChar('0'));
+ if (vertical) {
+ rect.setHeight(HEIGHT + 1);
+ for (unsigned i = 0; i < wid; i++) {
+ painter->drawText(rect, Qt::AlignCenter, QString(str[i]));
+ // TODO this is probably broken (it is offseted)
+ rect.setY(rect.y() + HEIGHT + 8);
+ }
+ } else
+ painter->drawText(rect, Qt::AlignCenter, str);
+}
+
+void Value::value_update(std::uint32_t val) {
+ this->val = val;
+ update();
+}
diff --git a/qtmips_gui/coreview/value.h b/qtmips_gui/coreview/value.h
new file mode 100644
index 0000000..c454024
--- /dev/null
+++ b/qtmips_gui/coreview/value.h
@@ -0,0 +1,30 @@
+#ifndef VALUE_H
+#define VALUE_H
+
+#include <QGraphicsObject>
+#include <QPainter>
+
+namespace coreview {
+
+class Value : public QGraphicsObject {
+ Q_OBJECT
+public:
+ Value(bool vertical = false, unsigned width = 8, unsigned init_val = 0); // width is for number of character to be shown from number
+
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+public slots:
+ void value_update(std::uint32_t);
+
+protected:
+ std::uint32_t val;
+
+private:
+ unsigned wid;
+ bool vertical;
+};
+
+}
+
+#endif // VALUE_H
diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro
index eb5f392..e7736f9 100644
--- a/qtmips_gui/qtmips_gui.pro
+++ b/qtmips_gui/qtmips_gui.pro
@@ -38,7 +38,8 @@ SOURCES += \
statictable.cpp \
cacheview.cpp \
cachedock.cpp \
- graphicsview.cpp
+ graphicsview.cpp \
+ coreview/value.cpp
HEADERS += \
mainwindow.h \
@@ -64,7 +65,8 @@ HEADERS += \
statictable.h \
cacheview.h \
cachedock.h \
- graphicsview.h
+ graphicsview.h \
+ coreview/value.h
FORMS += \
NewDialog.ui \