Skip to content

Commit

Permalink
soc/integration/soc: Fix CSRBridge Bus Width conversion
Browse files Browse the repository at this point in the history
Wishbone2CSR and AXILite2CSR bridges are incapable for performing
bus width conversion, which means it's Bus slave port must have same
width as CSRs.

Use CSR width to create slave bus to allow width adaptar to be inserted
by add_slave. Also add relevant assertion.

Signed-off-by: Jiaxun Yang <[email protected]>
  • Loading branch information
FlyGoat committed Dec 17, 2024
1 parent d05b661 commit 7615c91
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions litex/soc/integration/soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,13 +1138,14 @@ def add_csr_bridge(self, name="csr", origin=None, register=False):
}[self.bus.standard]
csr_bridge_name = f"{name}_bridge"
self.check_if_exists(csr_bridge_name)
data_width = self.csr.data_width
csr_bridge = csr_bridge_cls(
bus_bridge_cls(
address_width = self.bus.address_width,
data_width = self.bus.data_width),
data_width = data_width),
bus_csr = csr_bus.Interface(
address_width = self.csr.address_width,
data_width = self.csr.data_width),
data_width = data_width),
register = register)
self.logger.info("CSR Bridge {} {}.".format(
colorer(name, color="underline"),
Expand Down
2 changes: 2 additions & 0 deletions litex/soc/interconnect/axi/axi_lite_to_csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def __init__(self, axi_lite=None, bus_csr=None, register=False):
self.axi_lite = axi_lite
self.csr = bus_csr

assert axi_lite.data_width == bus_csr.data_width

fsm, comb = axi_lite_to_simple(
axi_lite = self.axi_lite,
port_adr = self.csr.adr,
Expand Down
2 changes: 2 additions & 0 deletions litex/soc/interconnect/wishbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ def __init__(self, bus_wishbone=None, bus_csr=None, register=True):
# If no Wishbone bus provided, create it with default parameters.
self.wishbone = Interface()

assert self.wishbone.data_width == self.csr.data_width

# # #

wishbone_adr_shift = {
Expand Down

0 comments on commit 7615c91

Please sign in to comment.