From 2dc4f2bb0a44245979fbf884c00f2a0dd2484428 Mon Sep 17 00:00:00 2001 From: Anderson Ignacio da Silva Date: Fri, 1 Nov 2024 19:30:24 +0000 Subject: [PATCH] Added start method Signed-off-by: Anderson Ignacio da Silva --- README.md | 1 + cocotbext/waves/waves.py | 9 +++++++-- tests/test_gen_ahb_waves.py | 4 +++- tests/test_gen_ahb_waves_ram.py | 4 +++- tests/test_gen_ahb_waves_trigger.py | 4 +++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4fcfdbe..391be2e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ waves.add_signal( ], group="MISO", ) +waves.start() ... ... diff --git a/cocotbext/waves/waves.py b/cocotbext/waves/waves.py index 992a936..7b1970f 100644 --- a/cocotbext/waves/waves.py +++ b/cocotbext/waves/waves.py @@ -4,7 +4,7 @@ # License : MIT license # Author : Anderson I. da Silva (aignacio) # Date : 25.10.2024 -# Last Modified Date: 31.10.2024 +# Last Modified Date: 01.11.2024 import cocotb import wavedrom import json @@ -56,6 +56,7 @@ def __init__( self.head = {"text": name, "tick": 0, "every": 1} self.foot = {"text": "Generated by cocotbext-waves", "tick": 0, "every": 1} + self._start = False self.close = False self.hscale = hscale self.debug = debug @@ -65,7 +66,6 @@ def __init__( self.color_idx = 3 # Start color for multi-bit signal self.add_signal(clk, color=None, is_clock=True, is_posedge_clock=is_posedge) - self.mon = cocotb.start_soon(self._monitor()) self.log = logging.getLogger(f"cocotb.waves.{name}") self.log.info(f"Waveform / Wavedrom - ({name})") @@ -150,6 +150,11 @@ def add_signal( for item in sig_list: self.waves["signal"].append(item) + def start(self): + if self._start is False: + self.mon = cocotb.start_soon(self._monitor()) + self._start = True + async def _monitor(self): while True: if self.is_posedge is True: diff --git a/tests/test_gen_ahb_waves.py b/tests/test_gen_ahb_waves.py index 22d1844..0f7c26c 100644 --- a/tests/test_gen_ahb_waves.py +++ b/tests/test_gen_ahb_waves.py @@ -4,7 +4,7 @@ # License : MIT license # Author : Anderson I. da Silva (aignacio) # Date : 25.10.2024 -# Last Modified Date: 31.10.2024 +# Last Modified Date: 01.11.2024 import cocotb import os import random @@ -80,6 +80,8 @@ async def run_test(dut, bp_fn=None, pip_mode=False): ] ) + waves.start() + await setup_dut(dut, cfg.RST_CYCLES) ahb_master = AHBMaster(AHBBus.from_entity(dut), dut.hclk, dut.hresetn, def_val="Z") diff --git a/tests/test_gen_ahb_waves_ram.py b/tests/test_gen_ahb_waves_ram.py index 5e95a82..449417c 100644 --- a/tests/test_gen_ahb_waves_ram.py +++ b/tests/test_gen_ahb_waves_ram.py @@ -4,7 +4,7 @@ # License : MIT license # Author : Anderson I. da Silva (aignacio) # Date : 25.10.2024 -# Last Modified Date: 31.10.2024 +# Last Modified Date: 01.11.2024 import cocotb import os import random @@ -67,6 +67,8 @@ async def run_test(dut): group="MISO", ) + waves.start() + await setup_dut(dut, cfg.RST_CYCLES) ahb_lite_sram = AHBLiteSlaveRAM( diff --git a/tests/test_gen_ahb_waves_trigger.py b/tests/test_gen_ahb_waves_trigger.py index 8f3ed9b..8349f58 100644 --- a/tests/test_gen_ahb_waves_trigger.py +++ b/tests/test_gen_ahb_waves_trigger.py @@ -4,7 +4,7 @@ # License : MIT license # Author : Anderson I. da Silva (aignacio) # Date : 25.10.2024 -# Last Modified Date: 31.10.2024 +# Last Modified Date: 01.11.2024 import cocotb import os import random @@ -65,6 +65,8 @@ async def run_test(dut): ) waves.add_trigger(dut.hresetn, 1) + waves.start() + await setup_dut(dut, cfg.RST_CYCLES) ahb_master = AHBMaster(AHBBus.from_entity(dut), dut.hclk, dut.hresetn, def_val="Z")