integration/soc Add accessible_region to add_memory_buses

Enables CPUs to know which memory addresses are accessible via
the connected memory_bus.
This commit is contained in:
Christian Klarhorst 2022-07-04 12:47:09 +02:00
parent 8eae77a310
commit 46788f2d9c
3 changed files with 12 additions and 5 deletions

6
litex/soc/cores/cpu/naxriscv/core.py Normal file → Executable file
View File

@ -396,7 +396,7 @@ class NaxRiscv(CPU):
) )
soc.bus.add_slave("clint", clintbus, region=soc_region_cls(origin=soc.mem_map.get("clint"), size=0x1_0000, cached=False)) soc.bus.add_slave("clint", clintbus, region=soc_region_cls(origin=soc.mem_map.get("clint"), size=0x1_0000, cached=False))
def add_memory_buses(self, address_width, data_width): def add_memory_buses(self, address_width, data_width, accessible_region):
nax_data_width = 64 nax_data_width = 64
nax_burst_size = 64 nax_burst_size = 64
assert data_width >= nax_data_width # FIXME: Only supporting up-conversion for now. assert data_width >= nax_data_width # FIXME: Only supporting up-conversion for now.
@ -460,6 +460,10 @@ class NaxRiscv(CPU):
i_ram_dbus_rresp = dbus.r.resp, i_ram_dbus_rresp = dbus.r.resp,
i_ram_dbus_rlast = dbus.r.last, i_ram_dbus_rlast = dbus.r.last,
) )
self.scala_args.append('mem-region-origin=0x{accessible_region.origin:x}'
.format(accessible_region=accessible_region))
self.scala_args.append('mem-region-length=0x{accessible_region.size:x}'
.format(accessible_region=accessible_region))
def do_finalize(self): def do_finalize(self):
assert hasattr(self, "reset_address") assert hasattr(self, "reset_address")

View File

@ -430,7 +430,7 @@ class VexRiscvSMP(CPU):
) )
soc.bus.add_slave("clint", clintbus, region=soc_region_cls(origin=soc.mem_map.get("clint"), size=0x1_0000, cached=False)) soc.bus.add_slave("clint", clintbus, region=soc_region_cls(origin=soc.mem_map.get("clint"), size=0x1_0000, cached=False))
def add_memory_buses(self, address_width, data_width): def add_memory_buses(self, address_width, data_width, accessible_region):
VexRiscvSMP.litedram_width = data_width VexRiscvSMP.litedram_width = data_width
from litedram.common import LiteDRAMNativePort from litedram.common import LiteDRAMNativePort

9
litex/soc/integration/soc.py Normal file → Executable file
View File

@ -1460,13 +1460,16 @@ class LiteXSoC(SoC):
sdram_size = min(sdram_size, size) sdram_size = min(sdram_size, size)
# Add SDRAM region. # Add SDRAM region.
self.bus.add_region("main_ram", SoCRegion(origin=self.mem_map.get("main_ram", origin), size=sdram_size)) main_ram_region = SoCRegion(origin=self.mem_map.get("main_ram", origin),
size=sdram_size)
self.bus.add_region("main_ram", main_ram_region)
# Add CPU's direct memory buses (if not already declared) ---------------------------------- # Add CPU's direct memory buses (if not already declared) ----------------------------------
if hasattr(self.cpu, "add_memory_buses"): if hasattr(self.cpu, "add_memory_buses"):
self.cpu.add_memory_buses( self.cpu.add_memory_buses(
address_width = 32, address_width = 32,
data_width = sdram.crossbar.controller.data_width data_width = sdram.crossbar.controller.data_width,
accessible_region = main_ram_region
) )
# Connect CPU's direct memory buses to LiteDRAM -------------------------------------------- # Connect CPU's direct memory buses to LiteDRAM --------------------------------------------