示例#1
0
def test_yield_list(dut):
    """Example of yielding on a list of triggers"""
    clock = dut.clk
    cocotb.scheduler.add(clock_gen(clock))
    yield [Timer(1000), Timer(2000)]

    yield Timer(10000)
示例#2
0
async def test_coroutine_kill(dut):
    """Test that killing a coroutine causes pending routine continue"""
    global test_flag
    clk_gen = cocotb.scheduler.add(clock_gen(dut.clk))
    await Timer(100, "ns")
    clk_gen_two = cocotb.fork(clock_yield(clk_gen))
    await Timer(100, "ns")
    clk_gen.kill()
    assert not test_flag
    await Timer(1000, "ns")
    assert test_flag
示例#3
0
def test_coroutine_kill(dut):
    """Test that killing a coroutine causes pending routine continue"""
    global test_flag
    clk_gen = cocotb.scheduler.add(clock_gen(dut.clk))
    yield Timer(100)
    clk_gen_two = cocotb.fork(clock_yield(clk_gen))
    yield Timer(100)
    clk_gen.kill()
    if test_flag is not False:
        raise TestFailure
    yield Timer(1000)
    if test_flag is not True:
        raise TestFailure
示例#4
0
def test_coroutine_syntax_error(dut):
    """Syntax error in a coroutine that we yield"""
    yield clock_gen(dut.clk)
    yield syntax_error()
示例#5
0
def test_fork_syntax_error(dut):
    """Syntax error in a coroutine that we fork"""
    yield clock_gen(dut.clk)
    cocotb.fork(syntax_error())
    yield clock_gen(dut.clk)
示例#6
0
def test_fork_error(dut):
    """Error in a coroutine that we fork"""
    yield clock_gen(dut.clk)
    cocotb.fork(erroring_coro())
    yield clock_gen(dut.clk)
示例#7
0
def test_coroutine_error(dut):
    """Error in a coroutine that we yield"""
    yield clock_gen(dut.clk)
    with assert_raises(NameError):
        yield erroring_coro()
示例#8
0
def test_syntax_error(dut):
    """Syntax error in the test"""
    yield clock_gen(dut.clk)
    fail