From 9c1a8936424486eeab239baa78635b41c2407c93 Mon Sep 17 00:00:00 2001 From: Pavel Benacek Date: Fri, 15 Apr 2022 15:52:01 +0200 Subject: [PATCH] Case insensitive signal connection for optional signals. --- src/cocotb_bus/bus.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cocotb_bus/bus.py b/src/cocotb_bus/bus.py index 01c60a7c..f887df97 100644 --- a/src/cocotb_bus/bus.py +++ b/src/cocotb_bus/bus.py @@ -67,9 +67,9 @@ def __init__(self, entity, name, signals, optional_signals=[], bus_separator="_" signame = name + bus_separator + sig_name else: signame = sig_name - + # Signal matching on optional attributes needs to be also case insensitive self._entity._log.debug("Signal name {}".format(signame)) - if hasattr(entity, signame): + if self._caseInsensGetattr(entity, signame) is not None: self._add_signal(attr_name, signame, array_idx, case_insensitive) else: self._entity._log.debug("Ignoring optional missing signal " @@ -79,6 +79,7 @@ def _caseInsensGetattr(self, obj, attr): for a in dir(obj): if a.casefold() == attr.casefold(): return getattr(obj, a) + return None def _add_signal(self, attr_name, signame, array_idx=None, case_insensitive=True): self._entity._log.debug("Signal name {}, idx {}".format(signame, array_idx))