class FPSCRState(SelectableInt):
- def __init__(self, value=0):
+ def __init__(self, value=0, *, auto_update_summary_bits=True):
self.__do_update_summary_bits = False
SelectableInt.__init__(self, value, 64)
self.fsi = {}
fs = tuple(offs)
v = FieldSelectableInt(self, fs)
self.fsi[field] = v
- self.__update_summary_bits()
+ if auto_update_summary_bits:
+ self.__update_summary_bits()
@property
def value(self):
from openpower.decoder.power_enums import XER_bits
from openpower.decoder.isa.radixmmu import RADIX
from openpower.util import log
+from openpower.fpscr import FPSCRState
import os
import sys
from copy import deepcopy
# fpscr
if self.fpscr is not None and s2.fpscr is not None:
- self.dut.assertEqual(
- self.fpscr, s2.fpscr, "fpscr mismatch (%s != %s) %s" %
- (self.state_type, s2.state_type, repr(self.code)))
+ if self.fpscr != s2.fpscr:
+ # use FPSCRState.fsi since that's much easier to read than a
+ # decimal integer and since unittest has fancy dict diffs.
+
+ # use auto_update_summary_bits=False since HDL might
+ # mis-compute those summary bits and we want to show the
+ # actual bits, not the corrected bits
+ fpscr1 = FPSCRState(self.fpscr, auto_update_summary_bits=False)
+ fpscr2 = FPSCRState(s2.fpscr, auto_update_summary_bits=False)
+ # FieldSelectableInt.__repr__ is too long
+ fpscr1 = {k: hex(int(v)) for k, v in fpscr1.fsi.items()}
+ fpscr2 = {k: hex(int(v)) for k, v in fpscr2.fsi.items()}
+ old_max_diff = self.dut.maxDiff
+ self.dut.maxDiff = None # show full diff
+ try:
+ self.dut.assertEqual(
+ fpscr1, fpscr2, "fpscr mismatch (%s != %s) %s\n" %
+ (self.state_type, s2.state_type, repr(self.code)))
+ finally:
+ self.dut.maxDiff = old_max_diff
def compare_mem(self, s2):
# copy dics to preserve state mem then pad empty locs since