Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 6
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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 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")
Ejemplo n.º 11
0
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")
Ejemplo n.º 12
0
def test_external_that_yields(dut):
    clk_gen = cocotb.fork(Clock(dut.clk, 100).start())

    value = yield external(test_ext_function_access)(dut)
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 17
0
def run_external(dut):
    value = yield external(calls_cocotb_function)(dut)
    raise ReturnValue(value)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 21
0
def run_external(dut):
    value = yield external(test_ext_function_access)(dut)
    raise ReturnValue(value)
Ejemplo n.º 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)
Ejemplo n.º 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")
Ejemplo n.º 24
0
def run_external(dut):
    value = yield external(test_ext_function_access)(dut)
    raise ReturnValue(value)
Ejemplo n.º 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)
Ejemplo n.º 26
0
def run_external(dut):
    value = yield external(calls_cocotb_function)(dut)
    return value