soc/SoCBusHandler: Add io_regions_check attribute and and disable IO region check with CPUNone.

This commit is contained in:
Florent Kermarrec 2022-01-07 10:47:47 +01:00
parent e0961d7cb1
commit f404877353
1 changed files with 28 additions and 24 deletions

View File

@ -144,14 +144,15 @@ class SoCBusHandler(Module):
raise SoCError() raise SoCError()
# Create Bus # Create Bus
self.standard = standard self.standard = standard
self.data_width = data_width self.data_width = data_width
self.address_width = address_width self.address_width = address_width
self.masters = {} self.masters = {}
self.slaves = {} self.slaves = {}
self.regions = {} self.regions = {}
self.io_regions = {} self.io_regions = {}
self.timeout = timeout self.io_regions_check = True
self.timeout = timeout
self.logger.info("{}-bit {} Bus, {}GiB Address Space.".format( self.logger.info("{}-bit {} Bus, {}GiB Address Space.".format(
colorer(data_width), colorer(standard), colorer(2**address_width/2**30))) colorer(data_width), colorer(standard), colorer(2**address_width/2**30)))
@ -197,22 +198,23 @@ class SoCBusHandler(Module):
self.regions[name] = region self.regions[name] = region
# Else add Region. # Else add Region.
else: else:
if self.check_region_is_io(region): if self.io_regions_check:
# If Region is an IO Region it is not cached. if self.check_region_is_io(region):
if region.cached: # If Region is an IO Region it is not cached.
self.logger.error("{} {}".format( if region.cached:
colorer(name + " Region in IO region, it can't be cached:", color="red"), self.logger.error("{} {}".format(
str(region))) colorer(name + " Region in IO region, it can't be cached:", color="red"),
self.logger.error(self) str(region)))
raise SoCError() self.logger.error(self)
else: raise SoCError()
# If Region is not an IO Region it is cached. else:
if not region.cached: # If Region is not an IO Region it is cached.
self.logger.error("{} {}".format( if not region.cached:
colorer(name + " Region not in IO region, it must be cached:", color="red"), self.logger.error("{} {}".format(
str(region))) colorer(name + " Region not in IO region, it must be cached:", color="red"),
self.logger.error(self) str(region)))
raise SoCError() self.logger.error(self)
raise SoCError()
self.regions[name] = region self.regions[name] = region
# Check for overlap with others IO regions. # Check for overlap with others IO regions.
overlap = self.check_regions_overlap(self.regions) overlap = self.check_regions_overlap(self.regions)
@ -919,6 +921,8 @@ class SoC(Module):
if isinstance(self.cpu, cpu.CPUNone): if isinstance(self.cpu, cpu.CPUNone):
# With CPUNone, give priority to User's mapping. # With CPUNone, give priority to User's mapping.
self.mem_map = {**self.cpu.mem_map, **self.mem_map} self.mem_map = {**self.cpu.mem_map, **self.mem_map}
# With CPUNone, disable IO regions check.
self.bus.io_regions_check = False
else: else:
# Override User's mapping with CPU constrainted mapping (and warn User). # Override User's mapping with CPU constrainted mapping (and warn User).
for n, origin in self.cpu.mem_map.items(): for n, origin in self.cpu.mem_map.items():