From 330144021b0273409f3fa91e9a24ffff14685ae7 Mon Sep 17 00:00:00 2001 From: Franck Jullien Date: Thu, 6 Jan 2022 09:55:53 +0100 Subject: [PATCH] soc: raise an error if adding a SoCRegion with incoherent cache configuration --- litex/soc/integration/soc.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/litex/soc/integration/soc.py b/litex/soc/integration/soc.py index 07ee6485d..a77b1e582 100644 --- a/litex/soc/integration/soc.py +++ b/litex/soc/integration/soc.py @@ -197,17 +197,24 @@ class SoCBusHandler(Module): self.regions[name] = region # Else add Region. else: - # If Region is an IO Region is not cached. - if not region.cached: - if not self.check_region_is_io(region): - self.logger.error("{} Region {}: {}.".format( - colorer(name), - colorer("not in IO region", color="red"), + if self.check_region_is_io(region): + # If Region is an IO Region it is not cached. + if region.cached: + self.logger.error("{} {}".format( + colorer(name + " Region in IO region, it can't be cached:", color="red"), + str(region))) + self.logger.error(self) + raise SoCError() + else: + # If Region is not an IO Region it is cached. + if not region.cached: + self.logger.error("{} {}".format( + colorer(name + " Region not in IO region, it must be cached:", color="red"), str(region))) self.logger.error(self) raise SoCError() self.regions[name] = region - # Check for overlab with others IO regions. + # Check for overlap with others IO regions. overlap = self.check_regions_overlap(self.regions) if overlap is not None: self.logger.error("Region {} between {} and {}:".format(