From: Luke Kenneth Casson Leighton Date: Fri, 30 Dec 2022 13:41:49 +0000 (+0000) Subject: add rollover mem test, store "rolls over" a 64-bit boundary X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=245194ee2937392c922828024757fed399f31b43;p=openpower-isa.git add rollover mem test, store "rolls over" a 64-bit boundary --- diff --git a/src/openpower/decoder/isa/mem.py b/src/openpower/decoder/isa/mem.py index 23e2c07e..8b3e0563 100644 --- a/src/openpower/decoder/isa/mem.py +++ b/src/openpower/decoder/isa/mem.py @@ -147,10 +147,20 @@ class Mem: if swap: v = swap_order(v, width) # not misaligned: pass through to Mem._st but we've swapped already - if remainder & (width - 1) == 0: + misaligned = remainder & (width - 1) + if misaligned == 0: return self._st(addr, v, width, swap=False) shifter, mask = self._get_shifter_mask(width, remainder) - print ("mask", hex(shifter), hex(mask)) + # split into two halves. lower first + maxmask = (1 << (self.bytes_per_word)*8) - 1 + val1 = ((v << shifter) & maxmask) >> shifter + self._st(addr+misaligned, val1, + width=width-misaligned, swap=False) + # now upper + val2 = v >> ((width-misaligned)*8) + print ("v, val2", hex(v), hex(val2)) + self._st(addr+self.bytes_per_word, val2, + width=width-misaligned, swap=False) def __call__(self, addr, sz): val = self.ld(addr.value, sz, swap=False) diff --git a/src/openpower/decoder/isa/test_mem.py b/src/openpower/decoder/isa/test_mem.py index b7734449..9a5423af 100644 --- a/src/openpower/decoder/isa/test_mem.py +++ b/src/openpower/decoder/isa/test_mem.py @@ -16,13 +16,13 @@ class TestMem(unittest.TestCase): log ("dict", d) self.assertEqual(d, [(0, 0x1234567800000000)]) - def test_mem_misalign_st(self): + def test_mem_misalign_st_rollover(self): m = Mem(row_bytes=8, initial_mem={}, misaligned_ok=True) - m.st(4, 0x912345678, width=8, swap=False) + m.st(6, 0x912345678, width=8, swap=False) d = m.dump() log ("dict", d) - self.assertEqual(d, [(0, 0x1234567800000000), - 8, 0x0000000000000009]) + self.assertEqual(d, [(0, 0x5678000000000000), + (8, 0x0000000000091234)]) if __name__ == '__main__':