From 3d101b9749820d366619ed311b187d94fc63baa4 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 17 Jul 2023 11:14:17 +0200 Subject: [PATCH] integration/export: When csr_base is specified, make CSR regions definition relative to it. Useful for PCIe based systems when internal CSR base is automatically added by the logic. --- litex/soc/integration/export.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/litex/soc/integration/export.py b/litex/soc/integration/export.py index ecd474669..3a00b88f7 100644 --- a/litex/soc/integration/export.py +++ b/litex/soc/integration/export.py @@ -257,13 +257,14 @@ def get_csr_header(regions, constants, csr_base=None, with_csr_base_define=True, r += "#ifndef CSR_ACCESSORS_DEFINED\n" r += "#include \n" r += "#endif /* ! CSR_ACCESSORS_DEFINED */\n" - csr_base = csr_base if csr_base is not None else regions[next(iter(regions))].origin + _csr_base = regions[next(iter(regions))].origin + csr_base = csr_base if csr_base is not None else _csr_base if with_csr_base_define: - r += "#ifndef CSR_BASE\n" + r += "\n#ifndef CSR_BASE\n" r += f"#define CSR_BASE {hex(csr_base)}L\n" r += "#endif\n" for name, region in regions.items(): - origin = region.origin - csr_base + origin = region.origin - _csr_base r += "\n/* "+name+" */\n" r += f"#define CSR_{name.upper()}_BASE {_get_csr_addr(csr_base, origin, with_csr_base_define)}\n" if not isinstance(region.obj, Memory):