Search code examples
pythonsimulationcocotb

Cocotb coroutine never called


I just started using cocotb and I have a problem with a small piece of code that should use a coroutine.

import cocotb
from cocotb.triggers import Timer

@cocotb.coroutine
def test(dut):
    dut.a <= 1
    dut.b <= 2
    cocotb.log.info('test')
    yield Timer(1, unit='ns')

@cocotb.test()
def add_corner(dut):
    dut.uop <= 0b0
    dut.src <= 0b01
    test(dut)
    yield Timer(1, units='ns')
    dut._log.info('done')

The simulation is created and runs through but the coroutine is never called. Neither the log message nor the assignments are executed.

I use python 3.8 and I tested a few of the examples contained in the repo. The axi_slave test works fine so I assume my setup is working.

Does anybody have a guess on what could cause the problem?


Solution

  • You need to yield your coroutine, not directly call it.