aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui/coreview')
-rw-r--r--qtmips_gui/coreview/memory.cpp63
-rw-r--r--qtmips_gui/coreview/memory.h41
2 files changed, 104 insertions, 0 deletions
diff --git a/qtmips_gui/coreview/memory.cpp b/qtmips_gui/coreview/memory.cpp
new file mode 100644
index 0000000..e6044fe
--- /dev/null
+++ b/qtmips_gui/coreview/memory.cpp
@@ -0,0 +1,63 @@
+#include "memory.h"
+
+using namespace coreview;
+
+//////////////////////
+#define WIDTH 80
+#define HEIGHT 100
+#define PENW 1
+//////////////////////
+
+Memory::Memory(machine::QtMipsMachine *machine) : QGraphicsObject(nullptr) {
+#define CON_INIT(X) do { \
+ X.in = new Connector(); \
+ X.out = new Connector(); \
+ X.read = new Connector(); \
+ X.write = new Connector(); \
+ } while(false)
+ CON_INIT(con_program);
+ CON_INIT(con_data);
+#undef CON_INIT
+ // TODO cache?
+}
+
+QRectF Memory::boundingRect() const {
+ // TODO
+}
+
+void Memory::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
+ // TODO
+}
+
+void Memory::setPos(qreal x, qreal y) {
+ QGraphicsObject::setPos(x, y);
+ // TODO con
+}
+
+const Connector *Memory::connector_in(bool program) const {
+ if (program)
+ return con_program.in;
+ else
+ return con_data.in;
+}
+
+const Connector *Memory::connector_out(bool program) const {
+ if (program)
+ return con_program.out;
+ else
+ return con_data.out;
+}
+
+const Connector *Memory::connector_read(bool program) const {
+ if (program)
+ return con_program.read;
+ else
+ return con_data.read;
+}
+
+const Connector *Memory::connector_write(bool program) const {
+ if (program)
+ return con_program.write;
+ else
+ return con_data.write;
+}
diff --git a/qtmips_gui/coreview/memory.h b/qtmips_gui/coreview/memory.h
new file mode 100644
index 0000000..0f0d40d
--- /dev/null
+++ b/qtmips_gui/coreview/memory.h
@@ -0,0 +1,41 @@
+#ifndef COREVIEW_MEMORY_H
+#define COREVIEW_MEMORY_H
+
+#include <QGraphicsObject>
+#include <QPainter>
+#include <qtmipsmachine.h>
+#include "../coreview.h"
+#include "connection.h"
+
+namespace coreview{
+
+class Memory : public QGraphicsObject {
+ Q_OBJECT
+public:
+ Memory(machine::QtMipsMachine *machine);
+
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+ void setPos(qreal x, qreal y);
+ const Connector *connector_in(bool program) const;
+ const Connector *connector_out(bool program) const;
+ const Connector *connector_read(bool program) const;
+ const Connector *connector_write(bool program) const;
+ // TODO integrate cache
+
+private:
+ struct {
+ Connector *in, *out, *read, *write;
+ } con_program, con_data;
+};
+
+}
+
+#else
+
+namespace coreview {
+ class Memory;
+}
+
+#endif // MEMORY_H