soc/SoCBusHandler: Add get_address_width method to get address_width depending bus standard.

This fixes SDCard/SATA build with and AXI/AXI-Lite Bus.
This commit is contained in:
Florent Kermarrec 2022-07-21 12:50:10 +02:00
parent 7acb6d468d
commit e3a536ab5f
1 changed files with 23 additions and 8 deletions

View File

@ -440,6 +440,21 @@ class SoCBusHandler(Module):
colorer(name, color="underline"), colorer(name, color="underline"),
colorer("added", color="green"))) colorer("added", color="green")))
def get_address_width(self, standard):
standard_from = self.standard
standard_to = standard
# AXI or AXI-Lite SoC Bus and Wishbone requested:
if standard_from in ["axi", "axi-lite"] and standard_to in ["wishbone"]:
address_shift = log2_int(self.data_width//8)
return self.address_width - address_shift
# Wishbone SoC Bus and AXI, AXI-Lite requested:
if standard_from in ["wishbone"] and standard_to in ["axi", "axi-lite"]:
address_shift = log2_int(self.data_width//8)
return self.address_width + address_shift
# Else just return address_width:
return self.address_width
# Str ------------------------------------------------------------------------------------------ # Str ------------------------------------------------------------------------------------------
def __str__(self): def __str__(self):
r = "{}-bit {} Bus, {}GiB Address Space.\n".format( r = "{}-bit {} Bus, {}GiB Address Space.\n".format(
@ -1038,7 +1053,7 @@ class SoC(Module):
name = "SoCDMABusHandler", name = "SoCDMABusHandler",
standard = "wishbone", standard = "wishbone",
data_width = self.bus.data_width, data_width = self.bus.data_width,
address_width = self.bus.address_width, address_width = self.bus.get_address_width(standard="wishbone"),
bursting = self.bus.bursting bursting = self.bus.bursting
) )
dma_bus = wishbone.Interface(data_width=self.bus.data_width) dma_bus = wishbone.Interface(data_width=self.bus.data_width)
@ -1789,7 +1804,7 @@ class LiteXSoC(SoC):
# Block2Mem DMA. # Block2Mem DMA.
if "read" in mode: if "read" in mode:
bus = wishbone.Interface(data_width=self.bus.data_width, adr_width=self.bus.address_width) bus = wishbone.Interface(data_width=self.bus.data_width, adr_width=self.bus.get_address_width(standard="wishbone"))
self.submodules.sdblock2mem = SDBlock2MemDMA(bus=bus, endianness=self.cpu.endianness) self.submodules.sdblock2mem = SDBlock2MemDMA(bus=bus, endianness=self.cpu.endianness)
self.comb += self.sdcore.source.connect(self.sdblock2mem.sink) self.comb += self.sdcore.source.connect(self.sdblock2mem.sink)
dma_bus = self.bus if not hasattr(self, "dma_bus") else self.dma_bus dma_bus = self.bus if not hasattr(self, "dma_bus") else self.dma_bus
@ -1797,7 +1812,7 @@ class LiteXSoC(SoC):
# Mem2Block DMA. # Mem2Block DMA.
if "write" in mode: if "write" in mode:
bus = wishbone.Interface(data_width=self.bus.data_width, adr_width=self.bus.address_width) bus = wishbone.Interface(data_width=self.bus.data_width, adr_width=self.bus.get_address_width(standard="wishbone"))
self.submodules.sdmem2block = SDMem2BlockDMA(bus=bus, endianness=self.cpu.endianness) self.submodules.sdmem2block = SDMem2BlockDMA(bus=bus, endianness=self.cpu.endianness)
self.comb += self.sdmem2block.source.connect(self.sdcore.sink) self.comb += self.sdmem2block.source.connect(self.sdcore.sink)
dma_bus = self.bus if not hasattr(self, "dma_bus") else self.dma_bus dma_bus = self.bus if not hasattr(self, "dma_bus") else self.dma_bus
@ -1861,7 +1876,7 @@ class LiteXSoC(SoC):
# Sector2Mem DMA. # Sector2Mem DMA.
if "read" in mode: if "read" in mode:
bus = wishbone.Interface(data_width=self.bus.data_width, adr_width=self.bus.address_width) bus = wishbone.Interface(data_width=self.bus.data_width, adr_width=self.bus.get_address_width(standard="wishbone"))
self.submodules.sata_sector2mem = LiteSATASector2MemDMA( self.submodules.sata_sector2mem = LiteSATASector2MemDMA(
port = self.sata_crossbar.get_port(), port = self.sata_crossbar.get_port(),
bus = bus, bus = bus,
@ -1871,7 +1886,7 @@ class LiteXSoC(SoC):
# Mem2Sector DMA. # Mem2Sector DMA.
if "write" in mode: if "write" in mode:
bus = wishbone.Interface(data_width=self.bus.data_width, adr_width=self.bus.address_width) bus = wishbone.Interface(data_width=self.bus.data_width, adr_width=self.bus.get_address_width(standard="wishbone"))
self.submodules.sata_mem2sector = LiteSATAMem2SectorDMA( self.submodules.sata_mem2sector = LiteSATAMem2SectorDMA(
bus = bus, bus = bus,
port = self.sata_crossbar.get_port(), port = self.sata_crossbar.get_port(),