LDSTException now passing bits of SRR1 around to the Trap Pipeline
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 25 Jan 2022 00:42:44 +0000 (00:42 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 25 Jan 2022 00:42:44 +0000 (00:42 +0000)
the actual (former) value of SRR1 is not what is supposed to be used:
the use of the variable "srr1" is a moniker from microwatt

src/soc/fu/ldst/loadstore.py
src/soc/fu/trap/main_stage.py
src/soc/fu/trap/trap_input_record.py

index d0beddedbf6d4571d24dfdff0045a9deb59ef077..2b883d0d529c1ce77bf2001668de9058cdcc28fe 100644 (file)
@@ -412,6 +412,12 @@ class LoadStore1(PortInterfaceBase):
         comb += exc.perm_error.eq(m_in.perm_error)
         comb += exc.rc_error.eq(m_in.rc_error)
         comb += exc.segment_fault.eq(m_in.segerr)
+        # conditions for 0x400 trap need these in SRR1
+        with m.If(exception & ~exc.alignment & exc.instr_fault):
+            comb += exc.srr1[14].eq(exc.invalid)      # 47-33
+            comb += exc.srr1[12].eq(exc.perm_error)   # 47-35
+            comb += exc.srr1[3].eq(exc.badtree)       # 47-44
+            comb += exc.srr1[2].eq(exc.rc_error)      # 47-45
 
         # TODO, connect dcache wb_in/wb_out to "standard" nmigen Wishbone bus
         comb += dbus.adr.eq(dcache.bus.adr)
index 9eb85887d14db0d472426ed6a1c78fbb6a42b492..f0da82b9d24200f64dc3927cc524bc89a9e2e80d 100644 (file)
@@ -67,7 +67,9 @@ class TrapMainStage(PipeModBase):
         msr_i = op.msr
         svstate_i = op.svstate
 
-        srr1_i = self.i.srr1
+        exc = LDSTException("trapexc")
+        comb += exc.eq(op.ldst_exc)
+        srr1_i = exc.srr1 # new SRR1 bits come from exception
         nia_o = self.o.nia
         svsrr0_o, srr0_o, srr1_o = self.o.svsrr0, self.o.srr0, self.o.srr1
 
index 521ab590be1461051ea4ae9f4b265d00cd54ec82..107bc0f4c7e8d5f5f0275f7062c0681cf531eb2c 100644 (file)
@@ -20,7 +20,7 @@ class CompTrapOpSubset(CompOpSubsetBase):
                   ('is_32bit', 1),
                   ('traptype', TT.size), # see trap main_stage.py, PowerDecoder2
                   ('trapaddr', 13),
-                  ('ldst_exc', len(LDSTException._exc_types)),
+                  ('ldst_exc', LDSTException.length), # blech
                   ]
 
         super().__init__(layout, name=name)