From d33f4440e25dfef6aad971d483670ed21411492d Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Wed, 30 Jan 2019 22:47:52 +0100 Subject: Do not replace rt by forward if instruction in T_R or store. Signed-off-by: Pavel Pisa --- qtmips_machine/core.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'qtmips_machine') diff --git a/qtmips_machine/core.cpp b/qtmips_machine/core.cpp index 17f2ccc..a2cc74b 100644 --- a/qtmips_machine/core.cpp +++ b/qtmips_machine/core.cpp @@ -377,7 +377,7 @@ void CorePipelined::do_step() { #define HAZARD(STAGE) ( \ (STAGE).regwrite && (STAGE).rwrite != 0 && \ ((STAGE).rwrite == dt_d.inst.rs() || ( \ - (dt_d.inst.type() == Instruction::T_R || (STAGE).inst.is_store()) && \ + (dt_d.inst.type() == Instruction::T_R || dt_d.inst.is_store()) && \ (STAGE).rwrite == dt_d.inst.rt()) \ )) // Note: We make exception with $0 as that has no effect and is used in nop instruction @@ -389,7 +389,8 @@ void CorePipelined::do_step() { dt_d.val_rs = dt_m.towrite_val; dt_d.ff_rs = FORWARD_FROM_M; } - if (dt_m.rwrite == dt_d.inst.rt()) { + if ((dt_d.inst.type() == Instruction::T_R || dt_d.inst.is_store()) && + (dt_m.rwrite == dt_d.inst.rt())) { dt_d.val_rt = dt_m.towrite_val; dt_d.ff_rt = FORWARD_FROM_M; } @@ -407,7 +408,8 @@ void CorePipelined::do_step() { dt_d.val_rs = dt_e.alu_val; dt_d.ff_rs = FORWARD_FROM_W; } - if (dt_e.rwrite == dt_d.inst.rt()) { + if ((dt_d.inst.type() == Instruction::T_R || dt_d.inst.is_store()) && + (dt_e.rwrite == dt_d.inst.rt())) { dt_d.val_rt = dt_e.alu_val; dt_d.ff_rt = FORWARD_FROM_W; } -- cgit v1.2.3