Skip to content

Commit

Permalink
soc_core: remove 256MB mem_map limitation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
enjoy-digital committed Jun 28, 2019
1 parent b65968c commit 740629b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions litex/soc/integration/soc_core.py
Expand Up @@ -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)
Expand Down Expand Up @@ -397,9 +398,13 @@ def add_wb_master(self, wbm):
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):
Expand Down

0 comments on commit 740629b

Please sign in to comment.