from litex.soc.cores.identifier import Identifier
from litex.soc.cores.timer import Timer
+
from litex.soc.interconnect.csr import *
+from litex.soc.interconnect import csr_bus
from litex.soc.interconnect import wishbone
+from litex.soc.interconnect import wishbone2csr
# TODO:
# - replace raise with exit on logging error.
colorer(alignment, color="red"),
colorer(", ".join(str(x) for x in self.supported_alignment), color="green")))
raise
+ if data_width > alignment:
+ self.logger.error("Alignment ({}) should be >= data_width ({})".format(
+ colorer(alignment, color="red"),
+ colorer(data_width, color="red")))
+ raise
# Check Paging
if paging not in self.supported_paging:
self.csr.add(name, use_loc_if_exists=True)
self.irq.add(name, use_loc_if_exists=True)
+ def add_csr_bridge(self, origin):
+ self.submodules.csr_bridge = wishbone2csr.WB2CSR(
+ bus_csr = csr_bus.Interface(
+ address_width = self.csr.address_width,
+ data_width = self.csr.data_width))
+ csr_size = 2**(self.csr.address_width + 2)
+ self.bus.add_slave("csr", self.csr_bridge.wishbone, SoCRegion(origin=origin, size=csr_size))
+
# SoC finalization -----------------------------------------------------------------------------
def do_finalize(self):
self.logger.info(colorer("-"*80, color="bright"))
self.csr_data_width = csr_data_width
self.csr_address_width = csr_address_width
+ self.csr_alignment = csr_alignment
self.with_wishbone = with_wishbone
self.wishbone_timeout_cycles = wishbone_timeout_cycles
# Add Wishbone to CSR bridge
self.config["CSR_DATA_WIDTH"] = csr_data_width
self.config["CSR_ALIGNMENT"] = csr_alignment
- assert csr_data_width <= csr_alignment
- self.csr_data_width = csr_data_width
- self.csr_alignment = csr_alignment
if with_wishbone:
- self.submodules.wishbone2csr = wishbone2csr.WB2CSR(
- bus_csr=csr_bus.Interface(
- address_width = csr_address_width,
- data_width = csr_data_width))
- self.add_csr_master(self.wishbone2csr.csr)
- self.register_mem("csr", self.soc_mem_map["csr"], self.wishbone2csr.wishbone, 2**(csr_address_width + 2))
+ self.add_csr_bridge(self.soc_mem_map["csr"])
+ self.add_csr_master(self.csr_bridge.csr) # FIXME
# Methods --------------------------------------------------------------------------------------