Fix logging when using from_entity

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich
2023-05-26 16:45:46 -07:00
parent f70731a8d8
commit 39b4ca4a93
5 changed files with 36 additions and 9 deletions

View File

@@ -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__)

View File

@@ -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__)

View File

@@ -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__)

View File

@@ -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__)

View File

@@ -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__)