whoops missed out branch_taken logic from fetch_action
[rv32.git] / cpu.py
diff --git a/cpu.py b/cpu.py
index 7150968bda422e1cac82a9f29341b360e8731ef0..5206b34d8347896905d3581de3159eb71cf96f76 100644 (file)
--- a/cpu.py
+++ b/cpu.py
@@ -224,11 +224,15 @@ class Fetch:
 
         # branch -> misaligned=error, otherwise jump
         i = i.Elif((dc.act & DA.branch) != 0,
-                If(misaligned_jump_target,
-                    self.action.eq(FA.error_trap)
-                ).Else(
-                    self.action.eq(FA.jump)
-                )
+                If(branch_taken,
+                    If(misaligned_jump_target,
+                        self.action.eq(FA.error_trap)
+                    ).Else(
+                        self.action.eq(FA.jump)
+                    )
+                 ).Else(
+                        self.action.eq(FA.default)
+                 )
               )
 
         # jal/jalr -> misaligned=error, otherwise jump