From b9d821cb5409a545431d7b34d8df0ad493c26a46 Mon Sep 17 00:00:00 2001 From: Jon Nordby Date: Sat, 26 Apr 2025 18:13:37 +0200 Subject: cocotb: Try to test a CIC filter --- cocotb_try/test_cic.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cocotb_try/test_cic.py (limited to 'cocotb_try/test_cic.py') diff --git a/cocotb_try/test_cic.py b/cocotb_try/test_cic.py new file mode 100644 index 0000000..3a4e385 --- /dev/null +++ b/cocotb_try/test_cic.py @@ -0,0 +1,32 @@ + +# https://docs.cocotb.org/en/stable/quickstart.html +# test_my_design.py (extended) + +import cocotb +from cocotb.triggers import FallingEdge, Timer + + +async def generate_clock(dut): + """Generate clock pulses.""" + + for cycle in range(10): + dut.clk.value = 0 + await Timer(1, units="ns") + dut.clk.value = 1 + await Timer(1, units="ns") + + +@cocotb.test() +async def my_second_test(dut): + """Try accessing the design.""" + + await cocotb.start(generate_clock(dut)) # run the clock "in the background" + + await Timer(5, units="ns") # wait a bit + await FallingEdge(dut.clk) # wait for falling edge/"negedge" + + dut._log.info("my_signal_1 is %s", dut.my_signal_1.value) + assert dut.my_signal_2.value[0] == 0, "my_signal_2[0] is not 0!" + + + -- cgit v1.2.3