From: Florent Kermarrec Date: Fri, 3 May 2019 11:24:06 +0000 (+0200) Subject: soc/get_mem_data: add direct support for regions X-Git-Tag: 24jan2021_ls180~1242 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fbb24720f07d27b3a55c9dcf1a6645fab881884c;p=litex.git soc/get_mem_data: add direct support for regions We now support passing filename (offset=0), json file and regions --- diff --git a/litex/soc/integration/soc_core.py b/litex/soc/integration/soc_core.py index 33623733..6a69bd30 100644 --- a/litex/soc/integration/soc_core.py +++ b/litex/soc/integration/soc_core.py @@ -77,15 +77,19 @@ 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 - _, ext = os.path.splitext(filename) - if ext == ".json": - f = open(filename, "r") - regions = json.load(f) - f.close() + if isinstance(filename_or_regions, dict): + regions = filename_or_regions else: - regions = {filename: "0x00000000"} + filename = filename_or_regions + _, ext = os.path.splitext(filename) + if ext == ".json": + f = open(filename, "r") + regions = json.load(f) + f.close() + else: + regions = {filename: "0x00000000"} # determine data_size data_size = 0