aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-03-22 17:25:28 +0100
committerKarel Kočí <cynerd@email.cz>2018-03-22 17:25:28 +0100
commit3230238711ad444a8172b45a516a3205494d13d9 (patch)
treeba48c9cb91ae73c4b3d110ce8e4a7def7f1478fb
parente869534670e1e1cb3b68c1e60205c36dff2dcb16 (diff)
downloadqtmips-3230238711ad444a8172b45a516a3205494d13d9.tar.gz
qtmips-3230238711ad444a8172b45a516a3205494d13d9.tar.bz2
qtmips-3230238711ad444a8172b45a516a3205494d13d9.zip
Add control signals for non-pipelined cpu
-rw-r--r--qtmips_gui/coreview.cpp29
-rw-r--r--qtmips_gui/coreview.h2
-rw-r--r--qtmips_gui/coreview/alu.cpp2
-rw-r--r--qtmips_gui/coreview/memory.cpp4
-rw-r--r--qtmips_gui/coreview/registers.cpp6
5 files changed, 24 insertions, 19 deletions
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index d811208..afd8623 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -58,16 +58,6 @@ void CoreView::update_scale() {
CoreViewScene::CoreViewScene(CoreView *view, machine::QtMipsMachine *machine) : QGraphicsScene(view) {
setSceneRect(0, 0, SC_WIDTH, SC_HEIGHT);
- // Identification cross (TODO remove)
- /*
- QPen pen;
- pen.setBrush(QBrush(QColor(220, 220, 220)));
- addLine(width()/2, 0, width()/2, height(), pen);
- addLine(0, height()/2, width(), height()/2, pen);
- addRect(0.5, 0.5, width() - 0.5, height() - 0.5, pen);
- */
- // TODO remove
-
// Elements //
// Primary points
NEW(ProgramMemory, mem_program, 90, 240, machine);
@@ -98,11 +88,12 @@ CoreViewScene::CoreViewScene(CoreView *view, machine::QtMipsMachine *machine) :
NEW(Junction, dc.j_inst_down, 190, dc_con_sign_ext->y());
// Execute stage
NEW(Junction, ex.j_mux, 420, 316);
- NEW(Multiplexer, ex.mux_imm, 450, 306, 2);
+ NEW(Multiplexer, ex.mux_imm, 450, 306, 2, true);
+ NEW(Multiplexer, ex.mux_regdest, 410, 370, 2, true);
// Memory
NEW(Junction, mm.j_addr, 570, mem_data->connector_address()->y());
// WriteBack stage
- NEW(Multiplexer, wb.mem_or_reg, 690, 252, 2);
+ NEW(Multiplexer, wb.mem_or_reg, 690, 252, 2, true);
// Connections //
coreview::Connection *con;
@@ -188,6 +179,7 @@ CoreViewSceneSimple::CoreViewSceneSimple(CoreView *view, machine::QtMipsMachine
con->setAxes({CON_AXIS_Y(420)});
con = new_bus(dc.j_sign_ext->new_connector(coreview::Connector::AX_X), ex.mux_imm->connector_in(1));
con->setAxes({CON_AXIS_Y(440)});
+ new_signal(dc.ctl_block->new_connector(1, -0.6), regs->connector_ctl_write());
// Execute
new_bus(alu->connector_out(), mm.j_addr->new_connector(CON_AX_X));
con = new_bus(ex.j_mux->new_connector(CON_AX_Y), mem_data->connector_data_in());
@@ -215,6 +207,19 @@ CoreViewSceneSimple::CoreViewSceneSimple(CoreView *view, machine::QtMipsMachine
con = new_bus(dc.add->connector_out(), ft.multiplex->connector_in(1));
con->setAxes({CON_AXIS_Y(360), CON_AXIS_X(480), CON_AXIS_Y(10)});
}
+ // From decode to execute stage
+ new_signal(dc.ctl_block->new_connector(1, 0.4), ex.mux_imm->connector_ctl());
+ new_signal(dc.ctl_block->new_connector(1, 0.2), alu->connector_ctl());
+ new_bus(dc.instr_bus->new_connector(ex.mux_regdest->connector_in(0)->point()), ex.mux_regdest->connector_in(0), 2);
+ new_bus(dc.instr_bus->new_connector(ex.mux_regdest->connector_in(1)->point()), ex.mux_regdest->connector_in(1), 2);
+ // From decode to memory stage
+ new_signal(dc.ctl_block->new_connector(1, 0.0), mem_data->connector_req_write());
+ new_signal(dc.ctl_block->new_connector(1, -0.2), mem_data->connector_req_read());
+ // From decode to write back stage
+ new_signal(dc.ctl_block->new_connector(1, -0.4), wb.mem_or_reg->connector_ctl());
+ // From execute to decode stage
+ con = new_bus(ex.mux_regdest->connector_out(), regs->connector_write_reg(), 2);
+ con->setAxes({CON_AXIS_Y(430), CON_AXIS_X(500), CON_AXIS_Y(210)});
}
CoreViewScenePipelined::CoreViewScenePipelined(CoreView *view, machine::QtMipsMachine *machine) : CoreViewScene(view, machine) {
diff --git a/qtmips_gui/coreview.h b/qtmips_gui/coreview.h
index 5f74f4f..1504483 100644
--- a/qtmips_gui/coreview.h
+++ b/qtmips_gui/coreview.h
@@ -65,7 +65,7 @@ protected:
} dc;
struct {
coreview::Junction *j_mux;
- coreview::Multiplexer *mux_imm;
+ coreview::Multiplexer *mux_imm, *mux_regdest;
} ex;
struct {
coreview::Junction *j_addr;
diff --git a/qtmips_gui/coreview/alu.cpp b/qtmips_gui/coreview/alu.cpp
index 2f24210..7644e40 100644
--- a/qtmips_gui/coreview/alu.cpp
+++ b/qtmips_gui/coreview/alu.cpp
@@ -45,7 +45,7 @@ void coreview::Alu::setPos(qreal x, qreal y) {
con_in_a->setPos(x, y + off);
con_in_b->setPos(x, y + HEIGHT - off);
con_out->setPos(x + WIDTH, y + HEIGHT/2);
- con_ctl->setPos(x + WIDTH/2, y + HEIGHT - (WIDTH/2));
+ con_ctl->setPos(x + WIDTH/2, y + (WIDTH/2));
}
const coreview::Connector *coreview::Alu::connector_in_a() const {
diff --git a/qtmips_gui/coreview/memory.cpp b/qtmips_gui/coreview/memory.cpp
index a2e5899..f4ba058 100644
--- a/qtmips_gui/coreview/memory.cpp
+++ b/qtmips_gui/coreview/memory.cpp
@@ -84,8 +84,8 @@ DataMemory::DataMemory(machine::QtMipsMachine *machine) : Memory(machine) {
con_address = new Connector(Connector::AX_X);
con_data_out = new Connector(Connector::AX_X);
con_data_in = new Connector(Connector::AX_X);
- con_req_write = new Connector(Connector::AX_X);
- con_req_read = new Connector(Connector::AX_X);
+ con_req_write = new Connector(Connector::AX_Y);
+ con_req_read = new Connector(Connector::AX_Y);
}
DataMemory::~DataMemory() {
diff --git a/qtmips_gui/coreview/registers.cpp b/qtmips_gui/coreview/registers.cpp
index 2b1c1b5..ba46f53 100644
--- a/qtmips_gui/coreview/registers.cpp
+++ b/qtmips_gui/coreview/registers.cpp
@@ -57,9 +57,9 @@ void Registers::setPos(qreal x, qreal y) {
con_read1->setPos(x + WIDTH, y + 10);
con_read2->setPos(x + WIDTH, y + 30);
- con_write_reg->setPos(x + WIDTH/2, y);
- con_write->setPos(x, y + HEIGHT - 10);
- con_ctl_write->setPos(x, y + HEIGHT - 20);
+ con_write_reg->setPos(x, y + HEIGHT - 10);
+ con_write->setPos(x, y + HEIGHT - 20);
+ con_ctl_write->setPos(x + WIDTH - 10, y);
}
const Connector *Registers::connector_read1() const {