From bc2b7995f5a076bbf33b8fc7d1d935d6c6f8c6cb Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 14 Dec 2020 10:51:37 +0100 Subject: [PATCH] integration/export/get_csr_header: don't generate replace/write fields access functions when CSR is read only. --- litex/soc/integration/export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litex/soc/integration/export.py b/litex/soc/integration/export.py index e13d66229..3b8916507 100644 --- a/litex/soc/integration/export.py +++ b/litex/soc/integration/export.py @@ -237,7 +237,7 @@ def get_csr_header(regions, constants, csr_base=None, with_access_functions=True r += "\tuint32_t word = " + reg_name + "_read();\n" r += "\treturn " + field_name + "_extract(word);\n" r += "}\n" - if (reg_name + "_write") in r: + if not getattr(csr, "read_only", False): r += "static inline uint32_t " + field_name + "_replace(uint32_t oldword, uint32_t plain_value) {\n" r += "\tuint32_t mask = ((1 << " + size + ")-1);\n" r += "\treturn (oldword & (~(mask << " + offset + "))) | (mask & plain_value)<< " + offset + " ;\n}\n"