TRAP = (63 - 46) # 1 if exception is "trap" type
ADR = (63 - 47) # 0 if SRR0 = address of instruction causing exception
+# see traptype (and trap main_stage.py)
+
+class TT:
+ FP = 1<<0
+ PRIV = 1<<1
+ TRAP = 1<<2
+ ADDR = 1<<3
+ ILLEG = 1<<4
from soc.consts import MSR
from soc.regfile.regfiles import FastRegs
+from soc.consts import TT
-# see traptype (and trap main_stage.py)
-
-TT_FP = 1<<0
-TT_PRIV = 1<<1
-TT_TRAP = 1<<2
-TT_ADDR = 1<<3
-TT_ILLEG = 1<<4
def decode_spr_num(spr):
return Cat(spr[5:10], spr[0:5])
# TODO: get msr, then can do privileged instruction
with m.If(instr_is_priv(m, op.internal_op, e.do.insn) & msr[MSR.PR]):
# privileged instruction trap
- self.trap(m, TT_PRIV, 0x700)
+ self.trap(m, TT.PRIV, 0x700)
# illegal instruction must redirect to trap. this is done by
# *overwriting* the decoded instruction and starting again.
# just with different trapaddr and traptype)
with m.Elif(op.internal_op == MicrOp.OP_ILLEGAL):
# illegal instruction trap
- self.trap(m, TT_ILLEG, 0x700)
+ self.trap(m, TT.ILLEG, 0x700)
# trap: (note e.insn_type so this includes OP_ILLEGAL) set up fast regs
# Note: OP_SC could actually be modified to just be a trap
from soc.decoder.power_fields import DecodeFields
from soc.decoder.power_fieldsn import SignalBitRange
-from soc.decoder.power_decoder2 import (TT_FP, TT_PRIV, TT_TRAP, TT_ADDR,
- TT_ILLEG)
-from soc.consts import MSR, PI
+from soc.consts import MSR, PI, TT
def msr_copy(msr_o, msr_i, zero_me=True):
with m.If(traptype == 0):
# say trap occurred (see 3.0B Book III 7.5.9)
comb += srr1_o.data[PI.TRAP].eq(1)
- with m.If(traptype & TT_PRIV):
+ with m.If(traptype & TT.PRIV):
comb += srr1_o.data[PI.PRIV].eq(1)
- with m.If(traptype & TT_FP):
+ with m.If(traptype & TT.FP):
comb += srr1_o.data[PI.FP].eq(1)
- with m.If(traptype & TT_ADDR):
+ with m.If(traptype & TT.ADDR):
comb += srr1_o.data[PI.ADR].eq(1)
- with m.If(traptype & TT_ILLEG):
+ with m.If(traptype & TT.ILLEG):
comb += srr1_o.data[PI.ILLEG].eq(1)
# move to MSR