comb += self.fast_out.data.eq(FastRegs.SRR1)
comb += self.fast_out.ok.eq(1)
with m.Case(SPR.XER.value):
+ comb += self.fast_out.data.eq(FastRegs.XER)
+ comb += self.fast_out.ok.eq(1)
pass # do nothing
# : map to internal SPR numbers
# XXX TODO: dec and tb not to go through mapping.
comb += self.fast_out.data.eq(FastRegs.SRR1)
comb += self.fast_out.ok.eq(1)
with m.Case(SPR.XER.value):
+ comb += self.fast_out.data.eq(FastRegs.XER)
+ comb += self.fast_out.ok.eq(1)
pass # do nothing
# : map to internal SPR numbers
# XXX TODO: dec and tb not to go through mapping.
with m.Case(MicrOp.OP_MTSPR):
with m.Switch(spr):
# fast SPRs first
- with m.Case(SPR.CTR, SPR.LR, SPR.TAR, SPR.SRR0, SPR.SRR1):
+ with m.Case(SPR.CTR, SPR.LR, SPR.TAR, SPR.SRR0,
+ SPR.SRR1, SPR.XER):
comb += fast1_o.data.eq(a_i)
comb += fast1_o.ok.eq(1)
- # XER is constructed
- with m.Case(SPR.XER):
- # sticky
- comb += so_o.data.eq(a_i[63-XER_bits['SO']])
- comb += so_o.ok.eq(1)
- # overflow
- comb += ov_o.data[0].eq(a_i[63-XER_bits['OV']])
- comb += ov_o.data[1].eq(a_i[63-XER_bits['OV32']])
- comb += ov_o.ok.eq(1)
- # carry
- comb += ca_o.data[0].eq(a_i[63-XER_bits['CA']])
- comb += ca_o.data[1].eq(a_i[63-XER_bits['CA32']])
- comb += ca_o.ok.eq(1)
+ # XER is constructed
+ with m.If(spr == SPR.XER):
+ # sticky
+ comb += so_o.data.eq(a_i[63-XER_bits['SO']])
+ comb += so_o.ok.eq(1)
+ # overflow
+ comb += ov_o.data[0].eq(a_i[63-XER_bits['OV']])
+ comb += ov_o.data[1].eq(a_i[63-XER_bits['OV32']])
+ comb += ov_o.ok.eq(1)
+ # carry
+ comb += ca_o.data[0].eq(a_i[63-XER_bits['CA']])
+ comb += ca_o.data[1].eq(a_i[63-XER_bits['CA32']])
+ comb += ca_o.ok.eq(1)
# slow SPRs TODO
# move from SPRs
comb += o.ok.eq(1)
with m.Switch(spr):
# fast SPRs first
- with m.Case(SPR.CTR, SPR.LR, SPR.TAR, SPR.SRR0, SPR.SRR1):
+ with m.Case(SPR.CTR, SPR.LR, SPR.TAR, SPR.SRR0, SPR.SRR1,
+ SPR.XER):
comb += o.data.eq(fast1_i)
- # XER is constructed
- with m.Case(SPR.XER):
- # sticky
- comb += o[63-XER_bits['SO']].eq(so_i)
- # overflow
- comb += o[63-XER_bits['OV']].eq(ov_i[0])
- comb += o[63-XER_bits['OV32']].eq(ov_i[1])
- # carry
- comb += o[63-XER_bits['CA']].eq(ca_i[0])
- comb += o[63-XER_bits['CA32']].eq(ca_i[1])
+ with m.If(spr == SPR.XER):
+ # bits 0:31 and 35:43 are treated as reserved
+ # and return 0s when read using mfxer
+ comb += o[32:64].eq(0) # MBS0 bits 0-31
+ comb += o[63-43:64-35].eq(0) # MSB0 bits 35-43
+ # sticky
+ comb += o[63-XER_bits['SO']].eq(so_i)
+ # overflow
+ comb += o[63-XER_bits['OV']].eq(ov_i[0])
+ comb += o[63-XER_bits['OV32']].eq(ov_i[1])
+ # carry
+ comb += o[63-XER_bits['CA']].eq(ca_i[0])
+ comb += o[63-XER_bits['CA32']].eq(ca_i[1])
# slow SPRs TODO
comb += self.o.ctx.eq(self.i.ctx)
class FastRegs(RegFileMem): #RegFileArray):
"""FastRegs
- FAST regfile - CTR, LR, TAR, SRR1, SRR2
+ FAST regfile - CTR, LR, TAR, SRR1, SRR2, XER
- * QTY 5of 64-bit registers
+ * QTY 6of 64-bit registers
* 2R1W
* Array-based unary-indexed (not binary-indexed)
* write-through capability (read on same cycle as write)
TAR = 2
SRR0 = 3
SRR1 = 4
+ XER = 5 # non-XER bits
def __init__(self):
- super().__init__(64, 5)
+ super().__init__(64, 6)
self.w_ports = {'fast1': self.write_port("dest1"),
}
self.r_ports = {'fast1': self.read_port("src1"),