From 2a50a8021ab95a685dbebd0567c08dd3713e6934 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 5 Mar 2018 09:59:06 +0100 Subject: [PATCH] soc/integration/soc_core: improve error message for missing csrs --- litex/soc/integration/soc_core.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/litex/soc/integration/soc_core.py b/litex/soc/integration/soc_core.py index aec3a8de1..5198e5c9a 100644 --- a/litex/soc/integration/soc_core.py +++ b/litex/soc/integration/soc_core.py @@ -258,15 +258,12 @@ class SoCCore(Module): try: return self.csr_map[name] except KeyError as e: - raise RuntimeError("""\ -Unable to find {} in your SoC's csr address map. - -Check {}.csr_map in {} - -Found {} in the csr_map""".format( - name, self.__class__.__name__, inspect.getfile(self.__class__), - ", ".join(self.csr_map.keys())) - ) from e + msg = "Undefined \"{}\" CSR.\n".format(name) + msg += "Avalaible CSRs in {} ({}):\n".format( + self.__class__.__name__, inspect.getfile(self.__class__)) + for k in sorted(self.csr_map.keys()): + msg += "- {}\n".format(k) + raise RuntimeError(msg) except ValueError: return None