self.pc = Signal(64) # Program Counter (CIA, NIA)
self.msr = Signal(64) # Machine Status Register (MSR)
self.eint = Signal() # External Interrupt
+ self.dec = Signal(64) # DEC SPR (again, for interrupt generation)
TRAP = 1<<2
ADDR = 1<<3
EINT = 1<<4 # external interrupt
- ILLEG = 1<<5 # currently the max, therefore traptype must be 5 bits
+ DEC = 1<<5 # decrement counter
+ ILLEG = 1<<6 # currently the max, therefore traptype must be 5 bits
# TODO: support for TM_BAD_THING (not included yet in trap main_stage.py)
- size = 6 # MUST update this to contain the full number of Trap Types
+ size = 7 # MUST update this to contain the full number of Trap Types
def elaborate(self, platform):
m = Module()
comb = m.d.comb
+ state = self.state
e_out, op, do_out = self.e, self.dec.op, self.e.do
- msr, cia, ext_irq = self.state.msr, self.state.pc, self.state.eint
+ dec_spr, msr, cia, ext_irq = state.dec, state.msr, state.pc, state.eint
# fill in for a normal instruction (not an exception)
# copy over if non-exception, non-privileged etc. is detected
with m.If(ext_irq & msr[MSR.EE]):
self.trap(m, TT.EINT, 0x500)
+ # decrement counter: TODO 32-bit version (MSR.LPCR)
+ with m.If(dec_spr[63] & msr[MSR.EE]): # v3.0B 6.5.11 p1076
+ self.trap(m, TT.DEC, 0x900) # v3.0B 6.5 p1065
+
# privileged instruction trap
with m.Elif(is_priv_insn & msr[MSR.PR]):
self.trap(m, TT.PRIV, 0x700)