diff options
author | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-02-07 17:27:22 +0100 |
---|---|---|
committer | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-02-07 17:27:22 +0100 |
commit | 60c7bfa8260f9aa68bd7947ecddfe64e030b0c7a (patch) | |
tree | 3c5c41ab02dac35a1aafca3d29da3a146a6dfb7e | |
parent | 556d9b08fee6d54a2b2ec62862a84d97c91b9792 (diff) | |
download | qtmips-60c7bfa8260f9aa68bd7947ecddfe64e030b0c7a.tar.gz qtmips-60c7bfa8260f9aa68bd7947ecddfe64e030b0c7a.tar.bz2 qtmips-60c7bfa8260f9aa68bd7947ecddfe64e030b0c7a.zip |
Add address to emitted instruction to allow its use for branch address decoding.
The new Qt5 syntax is used to create connections because
old syntax does not work with multiple arguments for some
unresolved reason.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
-rw-r--r-- | qtmips_gui/coreview.cpp | 17 | ||||
-rw-r--r-- | qtmips_gui/coreview/instructionview.cpp | 4 | ||||
-rw-r--r-- | qtmips_gui/coreview/instructionview.h | 2 | ||||
-rw-r--r-- | qtmips_machine/core.cpp | 14 | ||||
-rw-r--r-- | qtmips_machine/core.h | 12 |
5 files changed, 25 insertions, 24 deletions
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp index 5eace7d..b360520 100644 --- a/qtmips_gui/coreview.cpp +++ b/qtmips_gui/coreview.cpp @@ -52,7 +52,8 @@ } while(false) #define NEW_I(VAR, X, Y, SIG) do { \ NEW(InstructionView, VAR, X, Y); \ - connect(machine->core(), SIGNAL(SIG), VAR, SLOT(instruction_update(const machine::Instruction&))); \ + connect(machine->core(), &machine::Core::SIG, \ + VAR, &coreview::InstructionView::instruction_update); \ } while(false) #define NEW_V(X, Y, SIG, ...) do { \ NEW(Value, val, X, Y, __VA_ARGS__); \ @@ -229,10 +230,10 @@ QGraphicsSimpleTextItem *CoreViewScene::new_label(const QString &str, qreal x, q } CoreViewSceneSimple::CoreViewSceneSimple(machine::QtMipsMachine *machine) : CoreViewScene(machine) { - NEW_I(instr_prim, 230, 60, instruction_fetched(const machine::Instruction&)); + NEW_I(instr_prim, 230, 60, instruction_fetched); if (machine->config().delay_slot()) { NEW(Latch, delay_slot_latch, 55, 470, machine, 25); - NEW_I(instr_delay, 60, 500, instruction_program_counter(const machine::Instruction&)); + NEW_I(instr_delay, 60, 500, instruction_program_counter); } coreview::Connection *con; @@ -311,11 +312,11 @@ CoreViewScenePipelined::CoreViewScenePipelined(machine::QtMipsMachine *machine) NEW(Latch, latch_mem_wb, 660, 70, machine, 400); latch_mem_wb->setTitle("MEM/WB"); - 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&)); + NEW_I(inst_fetch, 79, 2, instruction_fetched); + NEW_I(inst_dec, 275, 2, instruction_decoded); + NEW_I(inst_exec, 464, 2, instruction_executed); + NEW_I(inst_mem, 598, 2, instruction_memory); + NEW_I(inst_wrb, 660, 18, instruction_writeback); if (machine->config().hazard_unit() != machine::MachineConfig::HU_NONE) { NEW(LogicBlock, hazard_unit, SC_WIDTH/2, SC_HEIGHT - 15, "Hazard Unit"); diff --git a/qtmips_gui/coreview/instructionview.cpp b/qtmips_gui/coreview/instructionview.cpp index 5d131eb..342a1d4 100644 --- a/qtmips_gui/coreview/instructionview.cpp +++ b/qtmips_gui/coreview/instructionview.cpp @@ -52,7 +52,7 @@ InstructionView::InstructionView() : QGraphicsObject(nullptr), text(this) { f.setPointSize(6); text.setFont(f); - instruction_update(machine::Instruction()); // Initialize to NOP + instruction_update(machine::Instruction(), 0); // Initialize to NOP } QRectF InstructionView::boundingRect() const { @@ -65,7 +65,7 @@ void InstructionView::paint(QPainter *painter, const QStyleOptionGraphicsItem *o painter->drawRoundRect(-WIDTH/2, 0, WIDTH, HEIGHT, ROUND, ROUND); } -void InstructionView::instruction_update(const machine::Instruction &i) { +void InstructionView::instruction_update(const machine::Instruction &i, std::uint32_t inst_addr) { QRectF prev_box = boundingRect(); text.setText(i.to_str()); QRectF box = text.boundingRect(); diff --git a/qtmips_gui/coreview/instructionview.h b/qtmips_gui/coreview/instructionview.h index 57b1fbc..8c63fc1 100644 --- a/qtmips_gui/coreview/instructionview.h +++ b/qtmips_gui/coreview/instructionview.h @@ -51,7 +51,7 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); public slots: - void instruction_update(const machine::Instruction &i); + void instruction_update(const machine::Instruction &i, std::uint32_t inst_addr); private: QGraphicsSimpleTextItem text; diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp index 7a1e4ba..7fc696e 100644 --- a/qtmips_machine/core.cpp +++ b/qtmips_machine/core.cpp @@ -102,7 +102,7 @@ bool Core::handle_exception(Core *core, Registers *regs, ExceptionCause excause, struct Core::dtFetch Core::fetch() { std::uint32_t inst_addr = regs->read_pc(); Instruction inst(mem_program->read_word(inst_addr)); - emit instruction_fetched(inst); + emit instruction_fetched(inst, inst_addr); return { .inst = inst, .inst_addr = inst_addr, @@ -112,7 +112,7 @@ struct Core::dtFetch Core::fetch() { struct Core::dtDecode Core::decode(const struct dtFetch &dt) { uint8_t rwrite; - emit instruction_decoded(dt.inst); + emit instruction_decoded(dt.inst, dt.inst_addr); enum InstructionFlags flags; enum AluOp alu_op; enum AccessControl mem_ctl; @@ -199,7 +199,7 @@ struct Core::dtDecode Core::decode(const struct dtFetch &dt) { } struct Core::dtExecute Core::execute(const struct dtDecode &dt) { - emit instruction_executed(dt.inst); + emit instruction_executed(dt.inst, dt.inst_addr); bool discard; // Handle conditional move (we have to change regwrite signal if conditional is not met) @@ -242,7 +242,7 @@ struct Core::dtExecute Core::execute(const struct dtDecode &dt) { } struct Core::dtMemory Core::memory(const struct dtExecute &dt) { - emit instruction_memory(dt.inst); + emit instruction_memory(dt.inst, dt.inst_addr); std::uint32_t towrite_val = dt.alu_val; std::uint32_t mem_addr = dt.alu_val; bool memread = dt.memread; @@ -283,7 +283,7 @@ struct Core::dtMemory Core::memory(const struct dtExecute &dt) { } void Core::writeback(const struct dtMemory &dt) { - emit instruction_writeback(dt.inst); + emit instruction_writeback(dt.inst, dt.inst_addr); emit writeback_value(dt.towrite_val); emit writeback_regw_value(dt.regwrite); emit writeback_regw_num_value(dt.rwrite); @@ -293,7 +293,7 @@ void Core::writeback(const struct dtMemory &dt) { void Core::handle_pc(const struct dtDecode &dt) { bool branch = false; - emit instruction_program_counter(dt.inst); + emit instruction_program_counter(dt.inst, dt.inst_addr); if (dt.jump) { if (!dt.bjr_req_rs) { @@ -573,7 +573,7 @@ bool StopExceptionHandler::handle_exception(Core *core, Registers *regs, excause, (unsigned long)inst_addr, (unsigned long)next_addr, (unsigned long)regs->read_pc(), (unsigned long)mem_ref_addr); #else - (void)excause; (void)inst_addr; (void)next_addr; (void)mem_ref_addr; + (void)excause; (void)inst_addr; (void)next_addr; (void)mem_ref_addr; (void)regs; #endif emit core->stop_on_exception_reached(); return true; diff --git a/qtmips_machine/core.h b/qtmips_machine/core.h index a41d98b..9645d5c 100644 --- a/qtmips_machine/core.h +++ b/qtmips_machine/core.h @@ -86,12 +86,12 @@ public: }; signals: - void instruction_fetched(const machine::Instruction &inst); - void instruction_decoded(const machine::Instruction &inst); - void instruction_executed(const machine::Instruction &inst); - void instruction_memory(const machine::Instruction &inst); - void instruction_writeback(const machine::Instruction &inst); - void instruction_program_counter(const machine::Instruction &inst); + void instruction_fetched(const machine::Instruction &inst, std::uint32_t inst_addr); + void instruction_decoded(const machine::Instruction &inst, std::uint32_t inst_addr); + void instruction_executed(const machine::Instruction &inst, std::uint32_t inst_addr); + void instruction_memory(const machine::Instruction &inst, std::uint32_t inst_addr); + void instruction_writeback(const machine::Instruction &inst, std::uint32_t inst_addr); + void instruction_program_counter(const machine::Instruction &inst, std::uint32_t inst_addr); void fetch_jump_reg_value(std::uint32_t); void fetch_jump_value(std::uint32_t); |