integration/soc: review/simplify changes for standalone cores.
- do the CSR alignment update only if CPU is not CPUNone. - revert PointToPoint interconnect when 1 master and 1 slave since this will break others use cases and will prevent mapping slave to a specific location. It's probably better to let the synthesis tools optimize the 1:1 mapping directly. - add with_soc_interconnect parameter to add_sdram that defaults to True. When set to False, only the LiteDRAMCore will be instantiated and interconnect with the SoC will not be added.
This commit is contained in:
parent
0d5eb13359
commit
3a6dd95d6f
|
@ -781,15 +781,9 @@ class SoC(Module):
|
||||||
for n, (origin, size) in enumerate(self.cpu.io_regions.items()):
|
for n, (origin, size) in enumerate(self.cpu.io_regions.items()):
|
||||||
self.bus.add_region("io{}".format(n), SoCIORegion(origin=origin, size=size, cached=False))
|
self.bus.add_region("io{}".format(n), SoCIORegion(origin=origin, size=size, cached=False))
|
||||||
self.mem_map.update(self.cpu.mem_map) # FIXME
|
self.mem_map.update(self.cpu.mem_map) # FIXME
|
||||||
|
|
||||||
# We don't want the CSR alignemnt reduced from 64-bit to 32-bit on
|
|
||||||
# a standalone system with a 64-bit WB and no CPU.
|
|
||||||
# Should we instead only update alignment if the CPU is *bigger*
|
|
||||||
# than the CSR ?
|
|
||||||
if name != "None":
|
|
||||||
self.csr.update_alignment(self.cpu.data_width)
|
|
||||||
# Add Bus Masters/CSR/IRQs
|
# Add Bus Masters/CSR/IRQs
|
||||||
if not isinstance(self.cpu, cpu.CPUNone):
|
if not isinstance(self.cpu, cpu.CPUNone):
|
||||||
|
self.csr.update_alignment(self.cpu.data_width)
|
||||||
if reset_address is None:
|
if reset_address is None:
|
||||||
reset_address = self.mem_map["rom"]
|
reset_address = self.mem_map["rom"]
|
||||||
self.cpu.set_reset_address(reset_address)
|
self.cpu.set_reset_address(reset_address)
|
||||||
|
@ -830,14 +824,7 @@ class SoC(Module):
|
||||||
# SoC Bus Interconnect ---------------------------------------------------------------------
|
# SoC Bus Interconnect ---------------------------------------------------------------------
|
||||||
bus_masters = self.bus.masters.values()
|
bus_masters = self.bus.masters.values()
|
||||||
bus_slaves = [(self.bus.regions[n].decoder(self.bus), 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()]
|
||||||
# One master and one slave, use a point to point interconnect, this is useful for
|
if len(bus_masters) and len(bus_slaves):
|
||||||
# generating standalone components such as LiteDRAM whose external control
|
|
||||||
# interface is a wishbone.
|
|
||||||
if len(bus_masters) == 1 and len(bus_slaves) == 1:
|
|
||||||
self.submodules.bus_interconnect = wishbone.InterconnectPointToPoint(
|
|
||||||
master = list(bus_masters)[0],
|
|
||||||
slave = list(self.bus.slaves.values())[0])
|
|
||||||
elif len(bus_masters) and len(bus_slaves):
|
|
||||||
self.submodules.bus_interconnect = wishbone.InterconnectShared(
|
self.submodules.bus_interconnect = wishbone.InterconnectShared(
|
||||||
masters = bus_masters,
|
masters = bus_masters,
|
||||||
slaves = bus_slaves,
|
slaves = bus_slaves,
|
||||||
|
@ -1010,7 +997,7 @@ class LiteXSoC(SoC):
|
||||||
self.bus.add_master(name="uartbone", master=self.uartbone.wishbone)
|
self.bus.add_master(name="uartbone", master=self.uartbone.wishbone)
|
||||||
|
|
||||||
# Add SDRAM ------------------------------------------------------------------------------------
|
# Add SDRAM ------------------------------------------------------------------------------------
|
||||||
def add_sdram(self, name, phy, module, origin, size=None,
|
def add_sdram(self, name, phy, module, origin, size=None, with_soc_interconnect=True,
|
||||||
l2_cache_size = 8192,
|
l2_cache_size = 8192,
|
||||||
l2_cache_min_data_width = 128,
|
l2_cache_min_data_width = 128,
|
||||||
l2_cache_reverse = True,
|
l2_cache_reverse = True,
|
||||||
|
@ -1032,6 +1019,8 @@ class LiteXSoC(SoC):
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.csr.add("sdram")
|
self.csr.add("sdram")
|
||||||
|
|
||||||
|
if not with_soc_interconnect: return
|
||||||
|
|
||||||
# Compute/Check SDRAM size
|
# Compute/Check SDRAM size
|
||||||
sdram_size = 2**(module.geom_settings.bankbits +
|
sdram_size = 2**(module.geom_settings.bankbits +
|
||||||
module.geom_settings.rowbits +
|
module.geom_settings.rowbits +
|
||||||
|
@ -1040,7 +1029,6 @@ class LiteXSoC(SoC):
|
||||||
sdram_size = min(sdram_size, size)
|
sdram_size = min(sdram_size, size)
|
||||||
|
|
||||||
# Add SDRAM region
|
# Add SDRAM region
|
||||||
if self.cpu_type is not None:
|
|
||||||
self.bus.add_region("main_ram", SoCRegion(origin=origin, size=sdram_size))
|
self.bus.add_region("main_ram", SoCRegion(origin=origin, size=sdram_size))
|
||||||
|
|
||||||
# SoC [<--> L2 Cache] <--> LiteDRAM --------------------------------------------------------
|
# SoC [<--> L2 Cache] <--> LiteDRAM --------------------------------------------------------
|
||||||
|
@ -1092,7 +1080,7 @@ class LiteXSoC(SoC):
|
||||||
# Else raise Error.
|
# Else raise Error.
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
elif self.cpu_type is not None:
|
else:
|
||||||
# When CPU has no direct memory interface, create a Wishbone Slave interface to LiteDRAM.
|
# When CPU has no direct memory interface, create a Wishbone Slave interface to LiteDRAM.
|
||||||
|
|
||||||
# Request a LiteDRAM native port.
|
# Request a LiteDRAM native port.
|
||||||
|
|
|
@ -184,10 +184,8 @@ class SoCCore(LiteXSoC):
|
||||||
if with_timer:
|
if with_timer:
|
||||||
self.add_timer(name="timer0")
|
self.add_timer(name="timer0")
|
||||||
|
|
||||||
# Add CSR bridge. Potentially override CSR base
|
# Add CSR bridge
|
||||||
if csr_base is not None:
|
self.add_csr_bridge(self.mem_map["csr"] if csr_base is None else csr_base)
|
||||||
self.mem_map["csr"] = csr_base;
|
|
||||||
self.add_csr_bridge(self.mem_map["csr"])
|
|
||||||
|
|
||||||
# Methods --------------------------------------------------------------------------------------
|
# Methods --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,14 @@ from litex.soc.interconnect import csr_bus, wishbone
|
||||||
|
|
||||||
class WB2CSR(Module):
|
class WB2CSR(Module):
|
||||||
def __init__(self, bus_wishbone=None, bus_csr=None):
|
def __init__(self, bus_wishbone=None, bus_csr=None):
|
||||||
if bus_csr is None:
|
|
||||||
bus_csr = csr_bus.Interface()
|
|
||||||
self.csr = bus_csr
|
self.csr = bus_csr
|
||||||
if bus_wishbone is None:
|
if self.csr is None:
|
||||||
bus_wishbone = wishbone.Interface(adr_width=bus_csr.address_width)
|
# If no CSR bus provided, create it with default parameters.
|
||||||
|
self.csr = csr_bus.Interface()
|
||||||
self.wishbone = bus_wishbone
|
self.wishbone = bus_wishbone
|
||||||
|
if self.wishbone is None:
|
||||||
|
# If no Wishbone bus provided, create it with default parameters.
|
||||||
|
self.wishbone = wishbone.Interface()
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue