soc_core: round memory regions size/length to next power of 2 (if not already a power of 2)
This commit is contained in:
parent
556d2c7c0f
commit
1cfb36e1e4
|
@ -98,6 +98,7 @@ def get_mem_data(filename_or_regions, endianness="big", mem_size=None):
|
||||||
|
|
||||||
def mem_decoder(address, size=0x10000000):
|
def mem_decoder(address, size=0x10000000):
|
||||||
address &= ~0x80000000
|
address &= ~0x80000000
|
||||||
|
size = 2**log2_int(size, False)
|
||||||
assert (address & (size - 1)) == 0
|
assert (address & (size - 1)) == 0
|
||||||
address >>= 2 # bytes to words aligned
|
address >>= 2 # bytes to words aligned
|
||||||
size >>= 2 # bytes to words aligned
|
size >>= 2 # bytes to words aligned
|
||||||
|
@ -431,6 +432,7 @@ class SoCCore(Module):
|
||||||
def in_this_region(addr):
|
def in_this_region(addr):
|
||||||
return addr >= origin and addr < origin + length
|
return addr >= origin and addr < origin + length
|
||||||
for n, o, l in self._memory_regions:
|
for n, o, l in self._memory_regions:
|
||||||
|
l = 2**log2_int(l, False)
|
||||||
if n == name or in_this_region(o) or in_this_region(o+l-1):
|
if n == name or in_this_region(o) or in_this_region(o+l-1):
|
||||||
raise ValueError("Memory region conflict between {} and {}".format(n, name))
|
raise ValueError("Memory region conflict between {} and {}".format(n, name))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue