From: Tim 'mithro' Ansell Date: Sun, 4 Mar 2018 00:02:44 +0000 (-0800) Subject: Improving error message when csr name is not found. X-Git-Tag: 24jan2021_ls180~1723^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5ef34500f7b0c49369505c88eaf5c6a116f51efd;p=litex.git Improving error message when csr name is not found. Before; ``` "/usr/local/lib/python3.5/dist-packages/litex-0.1-py3.5.egg/litex/soc/integration/soc_core.py", line 258, in get_csr_dev_address return self.csr_map[name] KeyError: 'core' ``` Now; ``` Traceback (most recent call last): File "XXXX/github/enjoy-digital/litex/litex/soc/integration/soc_core.py", line 259, in get_csr_dev_address return self.csr_map[name] KeyError: 'ddrphy' The above exception was the direct cause of the following exception: Traceback (most recent call last): ... File "XXXX/github/enjoy-digital/litex/litex/soc/interconnect/csr_bus.py", line 199, in scan mapaddr = self.address_map(name, None) File "XXXX/github/enjoy-digital/litex/litex/soc/integration/soc_core.py", line 269, in get_csr_dev_address ) from e RuntimeError: Unable to find ddrphy in your SoC's csr address map. Check BaseSoC.csr_map in XXXX/github/enjoy-digital/litex/litex/boards/targets/arty.py Found l2_cache, timer0, ddrphy2, buttons, sdram, identifier_mem, uart, uart_phy, leds, crg in the csr_map ``` --- diff --git a/litex/soc/integration/soc_core.py b/litex/soc/integration/soc_core.py index 7f6dd75a..aec3a8de 100644 --- a/litex/soc/integration/soc_core.py +++ b/litex/soc/integration/soc_core.py @@ -1,3 +1,4 @@ +import inspect from operator import itemgetter from migen import * @@ -256,6 +257,16 @@ class SoCCore(Module): name = name + "_" + memory.name_override 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 except ValueError: return None