from nmutil.iocontrol import RecordObject
from soc.decoder.power_enums import MicrOp, CryIn, Function, SPR, LDSTMode
from soc.consts import TT
+from soc.experiment.mem_types import LDSTException
class Data(Record):
self.oe = Data(1, "oe")
self.input_carry = Signal(CryIn, reset_less=True)
self.traptype = Signal(TT.size, reset_less=True) # trap main_stage.py
+ self.ldst_exc = LDSTException("exc")
self.trapaddr = Signal(13, reset_less=True)
self.read_cr_whole = Data(8, "cr_rd") # CR full read mask
self.write_cr_whole = Data(8, "cr_wr") # CR full write mask
#srr1(63 - 35) <= exc.perm_error; -- noexec fault
#srr1(63 - 44) <= exc.badtree;
#srr1(63 - 45) <= exc.rc_error;
- self.trap(m, TT.MEMEXC, 0x400)
+ self.trap(m, TT.MEMEXC, 0x400, exc)
with m.Else():
with m.If(exc.segment_fault):
self.trap(m, TT.MEMEXC, 0x380)
return m
- def trap(self, m, traptype, trapaddr):
+ def trap(self, m, traptype, trapaddr, exc=None):
"""trap: this basically "rewrites" the decoded instruction as a trap
"""
comb = m.d.comb
comb += self.do_copy("fn_unit", Function.TRAP, True)
comb += self.do_copy("trapaddr", trapaddr >> 4, True) # bottom 4 bits
comb += self.do_copy("traptype", traptype, True) # request type
+ comb += self.do_copy("ldst_exc", exc, True) # request type
comb += self.do_copy("msr", self.state.msr, True) # copy of MSR "state"
comb += self.do_copy("cia", self.state.pc, True) # copy of PC "state"
# https://bugs.libre-soc.org/show_bug.cgi?id=465
class LDSTException(RecordObject):
- _exc_types = ['alignment', 'instr_fault', 'invalid', 'badtree',
+ _exc_types = ['happened', 'alignment', 'instr_fault', 'invalid', 'badtree',
'perm_error', 'rc_error', 'segment_fault',]
def __init__(self, name=None):
RecordObject.__init__(self, name=name)
- self.happened = Signal()
for f in self._exc_types:
setattr(self, f, Signal())
('is_32bit', 1),
('traptype', TT.size), # see trap main_stage.py, PowerDecoder2
('trapaddr', 13),
+ ('ldst_exc', len(LDSTException._exc_types)),
]
- # add LDST field exception types
- #for f in LDSTException._exc_types:
- # layout.append((f, 1))
-
super().__init__(layout, name=name)