diff options
author | Karel Kočí <cynerd@email.cz> | 2018-01-03 19:19:06 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2018-01-03 19:19:06 +0100 |
commit | 1473699d8e204d9bf8b00c160b097b4adf85a66b (patch) | |
tree | 204fe38be7511764310053f05b198de6c18c30b8 | |
parent | 615060bc4017a3db864568ee3bb7bfb3ec18d2e7 (diff) | |
download | qtmips-1473699d8e204d9bf8b00c160b097b4adf85a66b.tar.gz qtmips-1473699d8e204d9bf8b00c160b097b4adf85a66b.tar.bz2 qtmips-1473699d8e204d9bf8b00c160b097b4adf85a66b.zip |
Add memory template for gui coreview
-rw-r--r-- | qtmips_gui/coreview/memory.cpp | 63 | ||||
-rw-r--r-- | qtmips_gui/coreview/memory.h | 41 | ||||
-rw-r--r-- | qtmips_gui/qtmips_gui.pro | 6 |
3 files changed, 108 insertions, 2 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 diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro index 66d9189..c16fed7 100644 --- a/qtmips_gui/qtmips_gui.pro +++ b/qtmips_gui/qtmips_gui.pro @@ -24,7 +24,8 @@ SOURCES += \ coreview/multiplexer.cpp \ coreview/connection.cpp \ coreview/latch.cpp \ - coreview/alu.cpp + coreview/alu.cpp \ + coreview/memory.cpp HEADERS += \ mainwindow.h \ @@ -37,7 +38,8 @@ HEADERS += \ coreview/multiplexer.h \ coreview/connection.h \ coreview/latch.h \ - coreview/alu.h + coreview/alu.h \ + coreview/memory.h FORMS += \ NewDialog.ui \ |