OP_RFID needs to read SRR0/1, OP_SC needs to write
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 5 Jul 2020 10:52:09 +0000 (11:52 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 5 Jul 2020 10:52:09 +0000 (11:52 +0100)
src/soc/decoder/power_decoder2.py

index 812bf72e812f2491bb5c5adbc38eb9c1b700a512..220b0e68e8d446ddaec9ffd8e8b785da78482186 100644 (file)
@@ -639,7 +639,9 @@ class PowerDecode2(Elaboratable):
             comb += e.traptype.eq(TT_ILLEG) # request illegal instruction
 
         # trap: (note e.insn_type so this includes OP_ILLEGAL) set up fast regs
-        with m.If(e.insn_type == InternalOp.OP_TRAP):
+        # Note: OP_SC could actually be modified to just be a trap
+        with m.If((e.insn_type == InternalOp.OP_TRAP) |
+                  (e.insn_type == InternalOp.OP_SC)):
             # TRAP write fast1 = SRR0
             comb += e.write_fast1.data.eq(FastRegs.SRR0) # constant: SRR0
             comb += e.write_fast1.ok.eq(1)
@@ -647,6 +649,16 @@ class PowerDecode2(Elaboratable):
             comb += e.write_fast2.data.eq(FastRegs.SRR1) # constant: SRR1
             comb += e.write_fast2.ok.eq(1)
 
+        # RFID: needs to read SRR0/1
+        with m.If(e.insn_type == InternalOp.OP_RFID):
+            # TRAP read fast1 = SRR0
+            comb += e.read_fast1.data.eq(FastRegs.SRR0) # constant: SRR0
+            comb += e.read_fast1.ok.eq(1)
+            # TRAP read fast2 = SRR1
+            comb += e.read_fast2.data.eq(FastRegs.SRR1) # constant: SRR1
+            comb += e.read_fast2.ok.eq(1)
+
+
         return m
 
         # TODO: get msr, then can do privileged instruction