示例#1
0
def test_multiple_externals(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    value = yield external(return_two)(dut)
    dut._log.info("First one completed")
    assert value == 2

    value = yield external(return_two)(dut)
    dut._log.info("Second one completed")
    assert value == 2
示例#2
0
def test_ext_call_return(dut):
    """Test ability to yeild on an external non cocotb coroutine decorated
    function"""
    mon = cocotb.scheduler.queue(clock_monitor(dut))
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())
    value = yield external(test_ext_function)(dut)
    dut._log.info("Value was %d" % value)
示例#3
0
def test_ext_call_return(dut):
    """Test ability to yeild on an external non cocotb coroutine decorated
    function"""
    mon = cocotb.scheduler.queue(clock_monitor(dut))
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())
    value = yield external(test_ext_function)(dut)
    dut._log.info("Value was %d" % value)
示例#4
0
def test_external_from_readonly(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    yield ReadOnly()
    dut._log.info("In readonly")
    value = yield external(return_two)(dut)
    assert value == 2
示例#5
0
def test_ext_call_return(dut):
    """Test ability to yield on an external non cocotb coroutine decorated
    function"""
    mon = cocotb.scheduler.queue(clock_monitor(dut))
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())
    value = yield external(return_two)(dut)
    assert value == 2
def test_external_and_continue(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    value = yield external(test_ext_function_access)(dut)

    yield Timer(10, "ns")
    yield RisingEdge(dut.clk)
示例#7
0
def test_external_and_continue(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    value = yield external(test_ext_function_access)(dut)

    yield Timer(10, "ns")
    yield RisingEdge(dut.clk)
示例#8
0
def test_external_and_continue(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    value = yield external(calls_cocotb_function)(dut)
    assert value == 2

    yield Timer(10, "ns")
    yield RisingEdge(dut.clk)
示例#9
0
def test_time_in_external_yield(dut):
    """Test that an external function calling back into a cocotb function
    takes the expected amount of time"""
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())
    yield Timer(10, 'ns')
    for n in range(5):
        for i in range(20):
            yield RisingEdge(dut.clk)
            time = get_sim_time()
            expected_after = time + 100 * n
            yield external(wait_cycles_wrapper)(dut, n)
            time_after = get_sim_time()
            if expected_after != time_after:
                raise TestFailure("Wrong time elapsed in external call")
示例#10
0
def test_time_in_external(dut):
    """Test that the simulation time does no advance if the wrapped external
    routine does not its self yield"""
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())
    yield Timer(10, 'ns')
    time = get_sim_time('ns')
    dut._log.info("Time at start of test = %d" % time)
    for i in range(1000):
        dut._log.info("Loop call %d" % i)
        yield external(test_print_sim_time)(dut, time)

    time_now = get_sim_time('ns')
    yield Timer(10, 'ns')

    if time != time_now:
        raise TestFailure("Time has elapsed over external call")
def test_time_in_external(dut):
    """Test that the simulation time does not advance if the wrapped external
    routine does not itself yield"""
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())
    yield Timer(10, 'ns')
    time = get_sim_time('ns')
    dut._log.info("Time at start of test = %d" % time)
    for i in range(100):
        dut._log.info("Loop call %d" % i)
        yield external(test_print_sim_time)(dut, time)

    time_now = get_sim_time('ns')
    yield Timer(10, 'ns')

    if time != time_now:
        raise TestFailure("Time has elapsed over external call")
def test_external_that_yields(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    value = yield external(test_ext_function_access)(dut)
示例#13
0
def ztest_ext_exit_error(dut):
    """Test that a premature exit of the sim at it's request still results in
    the clean close down of the sim world"""
    yield external(test_ext_function)(dut)
    yield Timer(1000)
示例#14
0
def test_multiple_externals(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())
    value = yield external(test_ext_function)(dut)
    dut._log.info("First one completed")
    value = yield external(test_ext_function)(dut)
    dut._log.info("Second one completed")
示例#15
0
def test_external_from_readonly(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    yield ReadOnly()
    dut._log.info("In readonly")
    value = yield external(test_ext_function_access)(dut)
示例#16
0
def test_external_that_yields(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    value = yield external(calls_cocotb_function)(dut)
    assert value == 2
示例#17
0
def run_external(dut):
    value = yield external(calls_cocotb_function)(dut)
    raise ReturnValue(value)
示例#18
0
def test_external_from_readonly(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    yield ReadOnly()
    dut._log.info("In readonly")
    value = yield external(test_ext_function_access)(dut)
示例#19
0
def test_ext_exit_error(dut):
    """Test that a premature exit of the sim at its request still results in
    the clean close down of the sim world"""
    yield external(return_two)(dut)
    yield Timer(1000)
示例#20
0
def test_ext_call_nreturn(dut):
    """Test ability to yield on an external non cocotb coroutine decorated
    function"""
    mon = cocotb.scheduler.queue(clock_monitor(dut))
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())
    yield external(test_ext_function)(dut)
def run_external(dut):
    value = yield external(test_ext_function_access)(dut)
    raise ReturnValue(value)
示例#22
0
def test_external_that_yields(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    value = yield external(test_ext_function_access)(dut)
示例#23
0
def test_multiple_externals(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())
    value = yield external(test_ext_function)(dut)
    dut._log.info("First one completed")
    value = yield external(test_ext_function)(dut)
    dut._log.info("Second one completed")
示例#24
0
def run_external(dut):
    value = yield external(test_ext_function_access)(dut)
    raise ReturnValue(value)
示例#25
0
def ztest_ext_exit_error(dut):
    """Test that a premature exit of the sim at it's request still results in
    the clean close down of the sim world"""
    yield external(test_ext_function)(dut)
    yield Timer(1000)
示例#26
0
def run_external(dut):
    value = yield external(calls_cocotb_function)(dut)
    return value