Skip to content

Commit c4ceaa0

Browse files
committed
targets: avoid XCU1525 quad DDR CSR overlap
When a selected 1GiB DDRAM window covers the CPU default CSR/debug area, relocate those apertures to a small uncached IO window below main RAM. This preserves the requested ddram2/ddram3 map while keeping single-channel builds at the legacy CSR base.
1 parent 6860172 commit c4ceaa0

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

litex_boards/targets/sqrl_xcu1525.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from litex_boards.platforms import sqrl_xcu1525
1616

1717
from litex.soc.cores.clock import *
18+
from litex.soc.integration.soc import SoCIORegion
1819
from litex.soc.integration.soc_core import *
1920
from litex.soc.integration.builder import *
2021
from litex.soc.cores.led import LedChaser
@@ -39,6 +40,8 @@
3940
2: 0xc0000000,
4041
3: 0x1_0000_0000,
4142
}
43+
DDRAM_CSR_ORIGIN = 0x20000000
44+
DDRAM_DEBUG_ORIGIN = 0x20010000
4245

4346
def parse_qsfp_port(port):
4447
if port not in QSFP_PORTS:
@@ -81,6 +84,14 @@ def parse_ddram_channels(channels):
8184
def ddram_window_end(origins):
8285
return max(origin + DDRAM_CHANNEL_SIZE for origin in origins.values())
8386

87+
def ddram_windows_overlap(origins, origin, size):
88+
if origin is None:
89+
return False
90+
return any(
91+
(origin < ddram_origin + DDRAM_CHANNEL_SIZE) and (origin + size > ddram_origin)
92+
for ddram_origin in origins.values()
93+
)
94+
8495
# CRG ----------------------------------------------------------------------------------------------
8596

8697
class _CRG(LiteXModule):
@@ -159,6 +170,15 @@ def __init__(self, sys_clk_freq=125e6, ddram_channel=0,
159170

160171
# SoCCore ----------------------------------------------------------------------------------
161172
SoCCore.__init__(self, platform, sys_clk_freq, ident="LiteX SoC on XCU1525", **kwargs)
173+
relocated_io = False
174+
if ddram_windows_overlap(ddram_origins, self.mem_map.get("csr"), 2**(self.csr.address_width + 2)):
175+
self.mem_map["csr"] = DDRAM_CSR_ORIGIN
176+
relocated_io = True
177+
if ddram_windows_overlap(ddram_origins, self.mem_map.get("vexriscv_debug"), 0x100):
178+
self.mem_map["vexriscv_debug"] = DDRAM_DEBUG_ORIGIN
179+
relocated_io = True
180+
if relocated_io:
181+
self.bus.add_region("csr_io", SoCIORegion(origin=DDRAM_CSR_ORIGIN, size=0x20000))
162182

163183
# DDR4 SDRAM -------------------------------------------------------------------------------
164184
if not self.integrated_main_ram_size:

0 commit comments

Comments
 (0)