|
15 | 15 | from litex_boards.platforms import sqrl_xcu1525 |
16 | 16 |
|
17 | 17 | from litex.soc.cores.clock import * |
| 18 | +from litex.soc.integration.soc import SoCIORegion |
18 | 19 | from litex.soc.integration.soc_core import * |
19 | 20 | from litex.soc.integration.builder import * |
20 | 21 | from litex.soc.cores.led import LedChaser |
|
39 | 40 | 2: 0xc0000000, |
40 | 41 | 3: 0x1_0000_0000, |
41 | 42 | } |
| 43 | +DDRAM_CSR_ORIGIN = 0x20000000 |
| 44 | +DDRAM_DEBUG_ORIGIN = 0x20010000 |
42 | 45 |
|
43 | 46 | def parse_qsfp_port(port): |
44 | 47 | if port not in QSFP_PORTS: |
@@ -81,6 +84,14 @@ def parse_ddram_channels(channels): |
81 | 84 | def ddram_window_end(origins): |
82 | 85 | return max(origin + DDRAM_CHANNEL_SIZE for origin in origins.values()) |
83 | 86 |
|
| 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 | + |
84 | 95 | # CRG ---------------------------------------------------------------------------------------------- |
85 | 96 |
|
86 | 97 | class _CRG(LiteXModule): |
@@ -159,6 +170,15 @@ def __init__(self, sys_clk_freq=125e6, ddram_channel=0, |
159 | 170 |
|
160 | 171 | # SoCCore ---------------------------------------------------------------------------------- |
161 | 172 | 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)) |
162 | 182 |
|
163 | 183 | # DDR4 SDRAM ------------------------------------------------------------------------------- |
164 | 184 | if not self.integrated_main_ram_size: |
|
0 commit comments