soc: improve memory region conflict check

This commit is contained in:
Sebastien Bourdeauducq 2015-04-01 15:14:02 +08:00
parent 980791e2b8
commit 5113301130
1 changed files with 4 additions and 4 deletions

View File

@ -133,13 +133,13 @@ class SoC(Module):
raise FinalizeError raise FinalizeError
self._wb_slaves.append((address_decoder, interface)) self._wb_slaves.append((address_decoder, interface))
def check_memory_region(self, name, origin): def add_memory_region(self, name, origin, length):
def in_this_region(addr):
return addr >= origin and addr < origin + length
for n, o, l in self.memory_regions: for n, o, l in self.memory_regions:
if n == name or o == origin: 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))
def add_memory_region(self, name, origin, length):
self.check_memory_region(name, origin)
self.memory_regions.append((name, origin, length)) self.memory_regions.append((name, origin, length))
def register_mem(self, name, address, interface, size=None): def register_mem(self, name, address, interface, size=None):