mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
soc/alloc_region: Ensure allocated Region is aligned on size.
This commit is contained in:
parent
694878a35a
commit
88d302d4db
1 changed files with 5 additions and 1 deletions
|
@ -233,13 +233,17 @@ class SoCBusHandler(Module):
|
|||
for _, search_region in search_regions.items():
|
||||
origin = search_region.origin
|
||||
while (origin + size) < (search_region.origin + search_region.size_pow2):
|
||||
# Align Origin on Size.
|
||||
if (origin%size):
|
||||
origin += (origin - origin%size)
|
||||
continue
|
||||
# Create a Candidate.
|
||||
candidate = SoCRegion(origin=origin, size=size, cached=cached)
|
||||
overlap = False
|
||||
# Check Candidate does not overlap with allocated existing regions.
|
||||
for _, allocated in self.regions.items():
|
||||
if self.check_regions_overlap({"0": allocated, "1": candidate}) is not None:
|
||||
origin = allocated.origin + allocated.size_pow2
|
||||
origin += size
|
||||
overlap = True
|
||||
break
|
||||
if not overlap:
|
||||
|
|
Loading…
Reference in a new issue