From 39b4ca4a9309b51cdd710d2fa7b6a0284d58160c Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Fri, 26 May 2023 16:45:46 -0700 Subject: [PATCH] Fix logging when using from_entity Signed-off-by: Alex Forencich --- cocotbext/axi/axi_master.py | 10 ++++++++-- cocotbext/axi/axi_slave.py | 10 ++++++++-- cocotbext/axi/axil_master.py | 10 ++++++++-- cocotbext/axi/axil_slave.py | 10 ++++++++-- cocotbext/axi/axis.py | 5 ++++- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/cocotbext/axi/axi_master.py b/cocotbext/axi/axi_master.py index bfaec1b..7120de1 100644 --- a/cocotbext/axi/axi_master.py +++ b/cocotbext/axi/axi_master.py @@ -198,7 +198,10 @@ class AxiMasterWrite(Region, Reset): self.bus = bus self.clock = clock self.reset = reset - self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}.{bus.aw._name}") + if bus.aw._name: + self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}.{bus.aw._name}") + else: + self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}") self.log.info("AXI master (write)") self.log.info("cocotbext-axi version %s", __version__) @@ -637,7 +640,10 @@ class AxiMasterRead(Region, Reset): self.bus = bus self.clock = clock self.reset = reset - self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}.{bus.ar._name}") + if bus.ar._name: + self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}.{bus.ar._name}") + else: + self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}") self.log.info("AXI master (read)") self.log.info("cocotbext-axi version %s", __version__) diff --git a/cocotbext/axi/axi_slave.py b/cocotbext/axi/axi_slave.py index 3b8105c..959fa4b 100644 --- a/cocotbext/axi/axi_slave.py +++ b/cocotbext/axi/axi_slave.py @@ -38,7 +38,10 @@ class AxiSlaveWrite(Reset): self.clock = clock self.reset = reset self.target = target - self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}.{bus.aw._name}") + if bus.aw._name: + self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}.{bus.aw._name}") + else: + self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}") self.log.info("AXI slave model (write)") self.log.info("cocotbext-axi version %s", __version__) @@ -206,7 +209,10 @@ class AxiSlaveRead(Reset): self.clock = clock self.reset = reset self.target = target - self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}.{bus.ar._name}") + if bus.ar._name: + self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}.{bus.ar._name}") + else: + self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}") self.log.info("AXI slave model (read)") self.log.info("cocotbext-axi version %s", __version__) diff --git a/cocotbext/axi/axil_master.py b/cocotbext/axi/axil_master.py index 1106177..eaef0da 100644 --- a/cocotbext/axi/axil_master.py +++ b/cocotbext/axi/axil_master.py @@ -88,7 +88,10 @@ class AxiLiteMasterWrite(Region, Reset): self.bus = bus self.clock = clock self.reset = reset - self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}.{bus.aw._name}") + if bus.aw._name: + self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}.{bus.aw._name}") + else: + self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}") self.log.info("AXI lite master (write)") self.log.info("cocotbext-axi version %s", __version__) @@ -345,7 +348,10 @@ class AxiLiteMasterRead(Region, Reset): self.bus = bus self.clock = clock self.reset = reset - self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}.{bus.ar._name}") + if bus.ar._name: + self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}.{bus.ar._name}") + else: + self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}") self.log.info("AXI lite master (read)") self.log.info("cocotbext-axi version %s", __version__) diff --git a/cocotbext/axi/axil_slave.py b/cocotbext/axi/axil_slave.py index 4ad0a23..9d159bd 100644 --- a/cocotbext/axi/axil_slave.py +++ b/cocotbext/axi/axil_slave.py @@ -38,7 +38,10 @@ class AxiLiteSlaveWrite(Reset): self.clock = clock self.reset = reset self.target = target - self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}.{bus.aw._name}") + if bus.aw._name: + self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}.{bus.aw._name}") + else: + self.log = logging.getLogger(f"cocotb.{bus.aw._entity._name}") self.log.info("AXI lite slave model (write)") self.log.info("cocotbext-axi version %s", __version__) @@ -161,7 +164,10 @@ class AxiLiteSlaveRead(Reset): self.clock = clock self.reset = reset self.target = target - self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}.{bus.ar._name}") + if bus.ar._name: + self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}.{bus.ar._name}") + else: + self.log = logging.getLogger(f"cocotb.{bus.ar._entity._name}") self.log.info("AXI lite slave model (read)") self.log.info("cocotbext-axi version %s", __version__) diff --git a/cocotbext/axi/axis.py b/cocotbext/axi/axis.py index aa83d1d..25a141e 100644 --- a/cocotbext/axi/axis.py +++ b/cocotbext/axi/axis.py @@ -266,7 +266,10 @@ class AxiStreamBase(Reset): self.bus = bus self.clock = clock self.reset = reset - self.log = logging.getLogger(f"cocotb.{bus._entity._name}.{bus._name}") + if bus._name: + self.log = logging.getLogger(f"cocotb.{bus._entity._name}.{bus._name}") + else: + self.log = logging.getLogger(f"cocotb.{bus._entity._name}") self.log.info("AXI stream %s", self._type) self.log.info("cocotbext-axi version %s", __version__)