예제 #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
예제 #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)
예제 #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")
예제 #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")
예제 #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)
예제 #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)
예제 #21
0
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