add mtmsrd instruction and unit test
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 13 Jul 2020 18:07:08 +0000 (19:07 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 13 Jul 2020 18:07:08 +0000 (19:07 +0100)
libreriscv
src/soc/fu/trap/main_stage.py
src/soc/fu/trap/test/test_pipe_caller.py

index a0ed154f4604d296ffc77e0489c4c0f2e23c94dc..12e9237b896ad233cb18946b34dab17d976f415c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a0ed154f4604d296ffc77e0489c4c0f2e23c94dc
+Subproject commit 12e9237b896ad233cb18946b34dab17d976f415c
index 769ae86386da336f04abdfe7a0477cf3339c9c61..2444d7d543fefc49611689ff570d7362a321fcab 100644 (file)
@@ -175,8 +175,13 @@ class TrapMainStage(PipeModBase):
                 with m.Else():
                     # Architecture says to leave out bits 3 (HV), 51 (ME)
                     # and 63 (LE) (IBM bit numbering)
-                    for stt, end in [(1,12), (13, 60), (61, 64)]:
-                        comb += msr_o.data[stt:end].eq(a_i[stt:end])
+                    with m.If(op.insn_type == MicrOp.OP_MTMSRD):
+                        for stt, end in [(1,12), (13, 60), (61, 64)]:
+                            comb += msr_o.data[stt:end].eq(a_i[stt:end])
+                    with m.Else():
+                        # mtmsr - 32-bit, only room for bottom 32 LSB flags
+                        for stt, end in [(1,12), (13, 32)]:
+                            comb += msr_o.data[stt:end].eq(a_i[stt:end])
                     msr_check_pr(m, msr_o.data)
                 comb += msr_o.ok.eq(1)
 
index 44fbba6aff3ac75a4ec98ca25f834c334a087787..279bac26ce8fbde54969f7c1997e552cf661f767 100644 (file)
@@ -120,10 +120,23 @@ class TrapTestCase(FHDLTestCase):
         initial_regs[1] = 0xffffffffffffffff
         self.run_tst_program(Program(lst, bigendian), initial_regs)
 
+    def test_4_mtmsrd_0(self):
+        lst = ["mtmsrd 1,0"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0xffffffffffffffff
+        self.run_tst_program(Program(lst, bigendian), initial_regs)
+
+    def test_5_mtmsrd_1(self):
+        lst = ["mtmsrd 1,1"]
+        initial_regs = [0] * 32
+        initial_regs[1] = 0xffffffffffffffff
+        self.run_tst_program(Program(lst, bigendian), initial_regs)
+
     def test_999_illegal(self):
         # ok, um this is a bit of a cheat: use an instruction we know
         # is not implemented by either ISACaller or the core
-        lst = ["tbegin."]
+        lst = ["tbegin.",
+               "mtmsr 1,1"] # should not get executed
         initial_regs = [0] * 32
         self.run_tst_program(Program(lst, bigendian), initial_regs)