soc/integration/soc_sdram: round port.data_width/l2_size to nearest power of 2 when it's not the case

With ECC configurations, native port data_width is not necessarily a power of 2.
This commit is contained in:
Florent Kermarrec 2019-01-22 09:08:35 +01:00
parent 871b958f85
commit 7e0dd37616
1 changed files with 5 additions and 1 deletions

View File

@ -1,3 +1,5 @@
from math import log2
from migen import * from migen import *
from migen.genlib.record import * from migen.genlib.record import *
@ -76,7 +78,9 @@ class SoCSDRAM(SoCCore):
if self.l2_size: if self.l2_size:
port = self.sdram.crossbar.get_port() port = self.sdram.crossbar.get_port()
l2_cache = wishbone.Cache(self.l2_size//4, self._wb_sdram, wishbone.Interface(port.dw)) port.data_width = 2**int(log2(port.data_width)) # Round to nearest power of 2
l2_size = 2**int(log2(self.l2_size)) # Round to nearest power of 2
l2_cache = wishbone.Cache(l2_size//4, self._wb_sdram, wishbone.Interface(port.data_width))
# XXX Vivado ->2018.2 workaround, Vivado is not able to map correctly our L2 cache. # XXX Vivado ->2018.2 workaround, Vivado is not able to map correctly our L2 cache.
# Issue is reported to Xilinx, Remove this if ever fixed by Xilinx... # Issue is reported to Xilinx, Remove this if ever fixed by Xilinx...
from litex.build.xilinx.vivado import XilinxVivadoToolchain from litex.build.xilinx.vivado import XilinxVivadoToolchain