Merge pull request #1485 from Icenowy/64bit-systembus-csr-fix

soc/interconnect/csr: Fix CSR on 64-bit SoC bus width
This commit is contained in:
enjoy-digital 2022-11-03 21:27:19 +01:00 committed by GitHub
commit eb2e9a371d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -1199,8 +1199,7 @@ class SoC(LiteXModule):
address_width = self.csr.address_width, address_width = self.csr.address_width,
alignment = self.csr.alignment, alignment = self.csr.alignment,
paging = self.csr.paging, paging = self.csr.paging,
ordering = self.csr.ordering, ordering = self.csr.ordering)
soc_bus_data_width = self.bus.data_width)
if len(self.csr.masters): if len(self.csr.masters):
self.csr_interconnect = csr_bus.InterconnectShared( self.csr_interconnect = csr_bus.InterconnectShared(
masters = list(self.csr.masters.values()), masters = list(self.csr.masters.values()),

View File

@ -86,11 +86,11 @@ class InterconnectShared(Module):
# CSR SRAM ----------------------------------------------------------------------------------------- # CSR SRAM -----------------------------------------------------------------------------------------
class SRAM(Module): class SRAM(Module):
def __init__(self, mem_or_size, address, read_only=None, init=None, bus=None, paging=0x800, soc_bus_data_width=32): def __init__(self, mem_or_size, address, read_only=None, init=None, bus=None, paging=0x800):
if bus is None: if bus is None:
bus = Interface() bus = Interface()
self.bus = bus self.bus = bus
aligned_paging = paging//(soc_bus_data_width//8) aligned_paging = paging//4
data_width = len(self.bus.dat_w) data_width = len(self.bus.dat_w)
if isinstance(mem_or_size, Memory): if isinstance(mem_or_size, Memory):
mem = mem_or_size mem = mem_or_size
@ -165,11 +165,11 @@ class SRAM(Module):
# CSR Bank ----------------------------------------------------------------------------------------- # CSR Bank -----------------------------------------------------------------------------------------
class CSRBank(csr.GenericBank): class CSRBank(csr.GenericBank):
def __init__(self, description, address=0, bus=None, paging=0x800, ordering="big", soc_bus_data_width=32): def __init__(self, description, address=0, bus=None, paging=0x800, ordering="big"):
if bus is None: if bus is None:
bus = Interface() bus = Interface()
self.bus = bus self.bus = bus
aligned_paging = paging//(soc_bus_data_width//8) aligned_paging = paging//4
# # # # # #
@ -205,12 +205,11 @@ class CSRBank(csr.GenericBank):
# address_map is called exactly once for each object at each call to # address_map is called exactly once for each object at each call to
# scan(), so it can have side effects. # scan(), so it can have side effects.
class CSRBankArray(Module): class CSRBankArray(Module):
def __init__(self, source, address_map, *ifargs, paging=0x800, ordering="big", soc_bus_data_width=32, **ifkwargs): def __init__(self, source, address_map, *ifargs, paging=0x800, ordering="big", **ifkwargs):
self.source = source self.source = source
self.address_map = address_map self.address_map = address_map
self.paging = paging self.paging = paging
self.ordering = ordering self.ordering = ordering
self.soc_bus_data_width = soc_bus_data_width
self.scan(ifargs, ifkwargs) self.scan(ifargs, ifkwargs)
def scan(self, ifargs, ifkwargs): def scan(self, ifargs, ifkwargs):
@ -272,8 +271,7 @@ class CSRBankArray(Module):
rmap = CSRBank(csrs, mapaddr, rmap = CSRBank(csrs, mapaddr,
bus = bank_bus, bus = bank_bus,
paging = self.paging, paging = self.paging,
ordering = self.ordering, ordering = self.ordering)
soc_bus_data_width = self.soc_bus_data_width)
self.submodules += rmap self.submodules += rmap
self.banks.append((name, csrs, mapaddr, rmap)) self.banks.append((name, csrs, mapaddr, rmap))