tidyup
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 24 Nov 2018 01:34:30 +0000 (01:34 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 24 Nov 2018 01:34:30 +0000 (01:34 +0000)
cpu_decoder.py

index 3f91824316dfbb6d1f4dae702a14230145418d9b..995a04c1a4d9db41cb7d58912b142d38f9519d64 100644 (file)
@@ -186,14 +186,14 @@ class CPUDecoder(Module):
         # fence
         c[F3.fence] = \
             If((self.immediate[8:12] == immz) & (self.rs1 == regz) & \
-                                                   (self.rd == regz),
+                                                (self.rd == regz),
                 self.decode_action.eq(DA.fence)
             ).Else(
                 self.decode_action.eq(DA.trap_illegal_instruction))
         # fence.i
         c[F3.fence_i] = \
             If((self.immediate[0:12] == immz) & (self.rs1 == regz) & \
-                                                    (self.rd == regz),
+                                                (self.rd == regz),
                 self.decode_action.eq(DA.fence_i)
             ).Else(
                 self.decode_action.eq(DA.trap_illegal_instruction))
@@ -210,11 +210,11 @@ class CPUDecoder(Module):
         regz = Constant(0, 5)
         # ebreak
         c[F3.ecall_ebreak] = \
-            If((self.immediate != ~b1) | (self.rs1 != regz) | \
-                                                   (self.rd != regz),
-                self.decode_action.eq(DA.trap_illegal_instruction)
+            If((self.immediate == ~b1) ^ (self.rs1 == regz) & \
+                                         (self.rd == regz),
+                self.decode_action.eq(DA.trap_ecall_ebreak)
             ).Else(
-                self.decode_action.eq(DA.trap_ecall_ebreak))
+                self.decode_action.eq(DA.trap_illegal_instruction))
         # csrs
         for op in [ F3.csrrw, F3.csrrs, F3.csrrc,
                     F3.csrrwi, F3.csrrsi, F3.csrrci]: