soc/get_mem_data: add direct support for regions
We now support passing filename (offset=0), json file and regions
This commit is contained in:
parent
0714816f31
commit
fbb24720f0
|
@ -77,8 +77,12 @@ def mem_decoder(address, start=26, end=29):
|
|||
return lambda a: a[start:end] == ((address >> (start+2)) & (2**(end-start))-1)
|
||||
|
||||
|
||||
def get_mem_data(filename, endianness="big", mem_size=None):
|
||||
def get_mem_data(filename_or_regions, endianness="big", mem_size=None):
|
||||
# create memory regions
|
||||
if isinstance(filename_or_regions, dict):
|
||||
regions = filename_or_regions
|
||||
else:
|
||||
filename = filename_or_regions
|
||||
_, ext = os.path.splitext(filename)
|
||||
if ext == ".json":
|
||||
f = open(filename, "r")
|
||||
|
|
Loading…
Reference in New Issue