From 05030990b28ef4faef3f49b19c50cec3fb5c18c5 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 21 May 2024 10:17:13 +0200 Subject: [PATCH] soc/integration/export: Add LITEX_CSR_ACCESS_FUNCTIONS/LITEX_CSR_FIELDS_ACCESS_FUNCTIONS defines to allow user to disable access functions. -DLITEX_CSR_ACCESS_FUNCTIONS=0 to disable CSR access functions. -DLITEX_CSR_FIELDS_ACCESS_FUNCTIONS=0 to disable CSR access functions. User can also avoid access function generation on get_csr_header call with: - with_access_functions=False - with_fields_access_functions=False --- litex/soc/integration/export.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/litex/soc/integration/export.py b/litex/soc/integration/export.py index 675522ff9..3bea515da 100644 --- a/litex/soc/integration/export.py +++ b/litex/soc/integration/export.py @@ -412,17 +412,31 @@ def get_csr_header(regions, constants, csr_base=None, with_csr_base_define=True, if with_access_functions: r += "\n" r += generated_separator("//", "CSR Registers Access Functions.") + r += "\n" + r += "#ifndef LITEX_CSR_ACCESS_FUNCTIONS\n" + r += "#define LITEX_CSR_ACCESS_FUNCTIONS 1\n" + r += "#endif\n" + r += "\n" + r += "#if LITEX_CSR_ACCESS_FUNCTIONS\n" for name, region in regions.items(): origin = region.origin - _csr_base r += _generate_csr_region_access_functions_c(name, region, origin, alignment, csr_base, with_csr_base_define) + r += "#endif /* LITEX_CSR_ACCESS_FUNCTIONS */\n" # CSR Registers Field Access Functions. if with_fields_access_functions: r += "\n" r += generated_separator("//", "CSR Registers Field Access Functions.") + r += "\n" + r += "#ifndef LITEX_CSR_FIELDS_ACCESS_FUNCTIONS\n" + r += "#define LITEX_CSR_FIELDS_ACCESS_FUNCTIONS 1\n" + r += "#endif\n" + r += "\n" + r += "#if LITEX_CSR_FIELDS_ACCESS_FUNCTIONS\n" for name, region in regions.items(): origin = region.origin - _csr_base r += _generate_csr_fields_access_functions_c(name, region, origin, alignment, csr_base, with_csr_base_define) + r += "#endif /* LITEX_CSR_FIELDS_ACCESS_FUNCTIONS */\n" r += "\n#endif /* ! __GENERATED_CSR_H */\n" return r