Esempio n. 1
0
def issue_588_coroutine_list(dut):
    """ Yield a list of triggers and coroutines."""

    # Record simulation time.
    current_time = utils.get_sim_time("ns")

    # Yield a list, containing a RisingEdge trigger and a coroutine.
    yield [sample_coroutine(dut), triggers.Timer(100, "ns")]

    # Make sure that only 5 ns passed, because the sample coroutine
    # terminated first.
    new_time = utils.get_sim_time("ns")
    if int(new_time - current_time) != 5:
        raise result.TestFailure("Did not yield coroutine in list.")
Esempio n. 2
0
async def issue_588_coroutine_list(dut):
    """ Yield a list of triggers and coroutines."""

    # Record simulation time.
    current_time = utils.get_sim_time("ns")

    # Yield a list, containing a RisingEdge trigger and a coroutine.
    coro = cocotb.fork(sample_coroutine(dut))
    await triggers.First(coro, triggers.Timer(100, "ns"))
    coro.kill()

    # Make sure that only 5 ns passed, because the sample coroutine
    # terminated first.
    new_time = utils.get_sim_time("ns")
    assert int(new_time - current_time) == 5, "Did not yield coroutine in list."
Esempio n. 3
0
def sample_coroutine(dut):
    """ Very simple coroutine that waits 5 ns."""
    yield triggers.Timer(5, "ns")
    dut._log.info("Sample coroutine yielded.")
Esempio n. 4
0
def Timer(*args, **kwargs):
    assert cocotb_wrapper.using_cocotb()
    return cocotb_triggers.Timer(*args, **kwargs)