From: Luke Kenneth Casson Leighton Date: Wed, 22 Sep 2021 15:48:45 +0000 (+0100) Subject: split out function which processes initial test memory values in Mem class X-Git-Tag: sv_maxu_works-initial~851 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a57d6918b4621a2deff7c6cab70a1828f25db56e;p=openpower-isa.git split out function which processes initial test memory values in Mem class --- diff --git a/src/openpower/decoder/isa/mem.py b/src/openpower/decoder/isa/mem.py index adaa84b4..c41e436e 100644 --- a/src/openpower/decoder/isa/mem.py +++ b/src/openpower/decoder/isa/mem.py @@ -31,6 +31,27 @@ def swap_order(x, nbytes): class MemException(Exception): pass +def process_mem(initial_mem, row_bytes=8): + res = {} + # different types of memory data structures recognised (for convenience) + if isinstance(initial_mem, list): + initial_mem = (0, initial_mem) + if isinstance(initial_mem, tuple): + startaddr, mem = initial_mem + initial_mem = {} + for i, val in enumerate(mem): + initial_mem[startaddr + row_bytes*i] = (val, row_bytes) + + for addr, val in initial_mem.items(): + if isinstance(val, tuple): + (val, width) = val + else: + width = row_bytes # assume same width + #val = swap_order(val, width) + res[addr] = (val, width) + + return res + class Mem: @@ -44,20 +65,7 @@ class Mem: if not initial_mem: return - # different types of memory data structures recognised (for convenience) - if isinstance(initial_mem, list): - initial_mem = (0, initial_mem) - if isinstance(initial_mem, tuple): - startaddr, mem = initial_mem - initial_mem = {} - for i, val in enumerate(mem): - initial_mem[startaddr + row_bytes*i] = (val, row_bytes) - - for addr, val in initial_mem.items(): - if isinstance(val, tuple): - (val, width) = val - else: - width = row_bytes # assume same width + for addr, (val, width) in process_mem(initial_mem, row_bytes).items(): #val = swap_order(val, width) self.st(addr, val, width, swap=False)