From 2d5cf5ecb0642cdf6f34b0dd2871272e7702c912 Mon Sep 17 00:00:00 2001
From: Roberto Hexsel <roberto@inf.ufpr.br>
Date: Sat, 14 May 2016 21:02:31 -0300
Subject: [PATCH] SC-nop-branch forwarding was fixed, with thanks to Rafael
 Soares

---
 cMIPS/tests/ll_sc.expected | 3 +++
 cMIPS/vhdl/core.vhd        | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/cMIPS/tests/ll_sc.expected b/cMIPS/tests/ll_sc.expected
index 76864aa..d8b37d0 100644
--- a/cMIPS/tests/ll_sc.expected
+++ b/cMIPS/tests/ll_sc.expected
@@ -22,6 +22,9 @@ ffffffff
 ffffffff
 ok
 
+55555555
+ok
+
 ok
 
 ok
diff --git a/cMIPS/vhdl/core.vhd b/cMIPS/vhdl/core.vhd
index 0bddb10..9b8ea27 100644
--- a/cMIPS/vhdl/core.vhd
+++ b/cMIPS/vhdl/core.vhd
@@ -988,6 +988,9 @@ begin
       elsif MM_is_MFC0 then          -- non-LW
         eq_fwd_A <= MM_cop0_val;
         rs_stall := FALSE;
+      elsif MM_is_SC then
+        eq_fwd_A <= x"00000000";
+        rs_stall := FALSE;         
       else
         eq_fwd_A <= MM_result;
         rs_stall := FALSE;
@@ -1013,6 +1016,9 @@ begin
       elsif MM_is_MFC0 then          -- non-LW
         eq_fwd_B <= MM_cop0_val;
         rt_stall := FALSE;
+      elsif MM_is_SC then
+        eq_fwd_B <= x"00000000";
+        rs_stall := FALSE;         
       else
         eq_fwd_B <= MM_result;
         rt_stall := FALSE;
-- 
GitLab