print(f"expected {expected:x}, actual: {alu_out:x}")
dut.assertEqual(expected, alu_out, msg)
+ def check_msr(dut, res, sim_o, msg):
+ if 'msr' in res:
+ expected = sim_o['msr']
+ alu_out = res['msr']
+ print(f"expected {expected:x}, actual: {alu_out:x}")
+ dut.assertEqual(expected, alu_out, msg)
+
def check_nia(dut, res, sim_o, msg):
if 'nia' in res:
expected = sim_o['nia']
# MSR was in srr1
comb += msr_copy(msr_o.data, srr1_i, zero_me=False) # don't zero
msr_check_pr(m, msr_o.data)
+
+ # hypervisor stuff
+ comb += msr_o.data[MSR.HV].eq(msr_i[MSR.HV] & srr1_i[MSR.HV])
+ comb += msr_o.data[MSR.ME].eq((msr_i[MSR.HV] & srr1_i[MSR.HV]) |
+ (~msr_i[MSR.HV] & srr1_i[MSR.HV]))
+ # don't understand but it's in the spec
+ with m.If((msr_i[63-31:63-29] != Const(0b010, 3)) |
+ (srr1_i[63-31:63-29] != Const(0b000, 3))):
+ comb += msr_o.data[63-31:63-29].eq(srr1_i[63-31:63-29])
+ with m.Else():
+ comb += msr_o.data[63-31:63-29].eq(msr_i[63-31:63-29])
comb += msr_o.ok.eq(1)
# OP_SC
ALUHelpers.check_fast_spr1(self, res, sim_o, code)
ALUHelpers.check_fast_spr2(self, res, sim_o, code)
ALUHelpers.check_nia(self, res, sim_o, code)
+ ALUHelpers.check_msr(self, res, sim_o, code)
if __name__ == "__main__":