Merge pull request #68 from mithro/improve-csr-missing-error-message

Improving error message when csr name is not found.
This commit is contained in:
enjoy-digital 2018-03-05 08:38:25 +01:00 committed by GitHub
commit c02b127ef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import inspect
from operator import itemgetter from operator import itemgetter
from migen import * from migen import *
@ -256,6 +257,16 @@ class SoCCore(Module):
name = name + "_" + memory.name_override name = name + "_" + memory.name_override
try: try:
return self.csr_map[name] 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: except ValueError:
return None return None