From 740629ba53944fc04fca79e433508a67cfe0f02f Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Thu, 27 Jun 2019 23:07:26 +0200 Subject: [PATCH] soc_core: remove 256MB mem_map limitation mem_map was limited to 8 256MB for simplicity but has become an issue for complex SoCs. Default mem_map size is still 256MB (retro-compatibility) but size can now be specified. --- litex/soc/integration/soc_core.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/litex/soc/integration/soc_core.py b/litex/soc/integration/soc_core.py index 46f31d5b4..8f703ec83 100644 --- a/litex/soc/integration/soc_core.py +++ b/litex/soc/integration/soc_core.py @@ -93,8 +93,9 @@ def get_mem_data(filename_or_regions, endianness="big", mem_size=None): i += 1 return data -def mem_decoder(address, start=26, end=29): - return lambda a: a[start:end] == ((address >> (start+2)) & (2**(end-start))-1) +def mem_decoder(address, size=0x10000000): + address &= ~0x80000000 + return lambda a: (a[:-1] >= address//4) & (a[:-1] < (address + size)//4) def csr_map_update(csr_map, csr_peripherals): csr_map.update(dict((n, v) @@ -397,9 +398,13 @@ class SoCCore(Module): raise FinalizeError self._wb_masters.append(wbm) - def add_wb_slave(self, address_decoder, interface): + def add_wb_slave(self, address_or_address_decoder, interface, size=None): if self.finalized: raise FinalizeError + if size is not None: + address_decoder = mem_decoder(address_or_address_decoder, size) + else: + address_decoder = address_or_address_decoder self._wb_slaves.append((address_decoder, interface)) def add_csr_master(self, csrm):