Merge pull request #1540 from sensille/soc_odd_regions

soc: allow regions that are not a power of 2
This commit is contained in:
enjoy-digital 2023-02-24 10:30:47 +01:00 committed by GitHub
commit 93632465a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -252,12 +252,13 @@ class SoCBusHandler(LiteXModule):
search_regions = {"main": SoCRegion(origin=0x00000000, size=2**self.address_width-1)} search_regions = {"main": SoCRegion(origin=0x00000000, size=2**self.address_width-1)}
# Iterate on Search_Regions to find a Candidate. # Iterate on Search_Regions to find a Candidate.
size_pow2 = 2**log2_int(size, False)
for _, search_region in search_regions.items(): for _, search_region in search_regions.items():
origin = search_region.origin origin = search_region.origin
while (origin + size) < (search_region.origin + search_region.size_pow2): while (origin + size) < (search_region.origin + search_region.size_pow2):
# Align Origin on Size. # Align Origin on Size.
if (origin%size): if (origin%size_pow2):
origin += (size - origin%size) origin += (size_pow2 - origin%size_pow2)
continue continue
# Create a Candidate. # Create a Candidate.
candidate = SoCRegion(origin=origin, size=size, cached=cached) candidate = SoCRegion(origin=origin, size=size, cached=cached)