soc/SoCRegion/Decoder: pass bus to decoder and remove mask on origin
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 10 Feb 2020 18:34:18 +0000 (19:34 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 10 Feb 2020 18:34:18 +0000 (19:34 +0100)
litex/soc/integration/soc.py

index 3cb2df8b0e95cd4bd4a54aa2da0961164bae7212..39784e074100f414e2e5b566513052b8e5e581aa 100755 (executable)
@@ -62,18 +62,17 @@ class SoCRegion:
         self.mode      = mode
         self.cached    = cached
 
-    def decoder(self):
+    def decoder(self, bus):
         origin = self.origin
         size   = self.size
-        origin &= ~0x80000000
         size   = 2**log2_int(size, False)
         if (origin & (size - 1)) != 0:
             self.logger.error("Origin needs to be aligned on size:")
             self.logger.error(self)
             raise
-        origin >>= 2 # bytes to words aligned
-        size   >>= 2 # bytes to words aligned
-        return lambda a: (a[log2_int(size):-1] == (origin >> log2_int(size)))
+        origin >>= int(log2(bus.data_width//8)) # bytes to words aligned
+        size   >>= int(log2(bus.data_width//8)) # bytes to words aligned
+        return lambda a: (a[log2_int(size):] == (origin >> log2_int(size)))
 
     def __str__(self):
         r = ""
@@ -772,7 +771,7 @@ class SoC(Module):
 
         # SoC Bus Interconnect ---------------------------------------------------------------------
         bus_masters = self.bus.masters.values()
-        bus_slaves  = [(self.bus.regions[n].decoder(), s) for n, s in self.bus.slaves.items()]
+        bus_slaves  = [(self.bus.regions[n].decoder(self.bus), s) for n, s in self.bus.slaves.items()]
         if len(bus_masters) and len(bus_slaves):
             self.submodules.bus_interconnect = wishbone.InterconnectShared(
                 masters        = bus_masters,