From 63c764d45c991cfe4bffd56a9be0fd2c93a70a7f Mon Sep 17 00:00:00 2001 From: Jean THOMAS Date: Mon, 8 Jun 2020 13:23:48 +0200 Subject: [PATCH] Throw exception if two CSR have the same name --- lambdasoc/periph/base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lambdasoc/periph/base.py b/lambdasoc/periph/base.py index 8789ee3..84c3452 100644 --- a/lambdasoc/periph/base.py +++ b/lambdasoc/periph/base.py @@ -253,6 +253,8 @@ class CSRBank: name = name or tracer.get_var_name(depth=2 + src_loc_at).lstrip("_") elem_name = "{}_{}".format(self._name_prefix, name) + if any(elem.name == elem_name for (elem, _, _) in self._csr_regs): + raise Exception("CSR \"{}\" has already been defined".format(elem_name)) elem = csr.Element(width, access, name=elem_name) self._csr_regs.append((elem, addr, alignment)) return elem -- 2.30.2