Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from fork to start_soon #62

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/axi_lite_slave/tests/test_axi_lite_slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def setup_dut(dut):
cocotb.fork(Clock(dut.clk, CLK_PERIOD_NS, units='ns').start())
cocotb.start_soon(Clock(dut.clk, CLK_PERIOD_NS, units='ns').start())


# Write to address 0 and verify that value got through
Expand Down
2 changes: 1 addition & 1 deletion examples/dff/tests/dff_cocotb.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def stop(self):
async def run_test(dut):
"""Setup testbench and run a test."""

cocotb.fork(Clock(dut.c, 10, 'us').start(start_high=False))
cocotb.start_soon(Clock(dut.c, 10, 'us').start(start_high=False))

tb = DFF_TB(dut, init_val=BinaryValue(0))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def reset(dut, duration=10):
async def initial_hal_test(dut, debug=True):
"""Example of using the software HAL against cosim testbench"""

cocotb.fork(Clock(dut.clk, 5, units='ns').start())
cocotb.start_soon(Clock(dut.clk, 5, units='ns').start())
await reset(dut)

# Create the avalon master and direct our HAL calls to that
Expand Down
8 changes: 4 additions & 4 deletions examples/endian_swapper/tests/test_endian_swapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __init__(self, dut, debug=False):

self.csr = AvalonMaster(dut, "csr", dut.clk)

cocotb.fork(stream_out_config_setter(dut, self.stream_out,
cocotb.start_soon(stream_out_config_setter(dut, self.stream_out,
self.stream_in))

# Create a scoreboard on the stream_out bus
Expand Down Expand Up @@ -197,15 +197,15 @@ async def reset(self, duration=20):
async def run_test(dut, data_in=None, config_coroutine=None, idle_inserter=None,
backpressure_inserter=None):

cocotb.fork(Clock(dut.clk, 10, units='ns').start())
cocotb.start_soon(Clock(dut.clk, 10, units='ns').start())
tb = EndianSwapperTB(dut)

await tb.reset()
dut.stream_out_ready <= 1

# Start off any optional coroutines
if config_coroutine is not None:
cocotb.fork(config_coroutine(tb.csr))
cocotb.start_soon(config_coroutine(tb.csr))
if idle_inserter is not None:
tb.stream_in.set_valid_generator(idle_inserter())
if backpressure_inserter is not None:
Expand Down Expand Up @@ -260,7 +260,7 @@ async def wavedrom_test(dut):
"""
Generate a JSON wavedrom diagram of a trace and save it to wavedrom.json
"""
cocotb.fork(Clock(dut.clk, 10, units='ns').start())
cocotb.start_soon(Clock(dut.clk, 10, units='ns').start())
await RisingEdge(dut.clk)
tb = EndianSwapperTB(dut)
await tb.reset()
Expand Down
4 changes: 2 additions & 2 deletions examples/mean/tests/test_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def value_test(dut, nums):
dut._log.info('Detected DATA_WIDTH = %d, BUS_WIDTH = %d' %
(DATA_WIDTH, BUS_WIDTH))

cocotb.fork(Clock(dut.clk, CLK_PERIOD_NS, units='ns').start())
cocotb.start_soon(Clock(dut.clk, CLK_PERIOD_NS, units='ns').start())

dut.rst <= 1
for i in range(BUS_WIDTH):
Expand Down Expand Up @@ -102,7 +102,7 @@ async def mean_randomised_test(dut):
dut._log.info('Detected DATA_WIDTH = %d, BUS_WIDTH = %d' %
(DATA_WIDTH, BUS_WIDTH))

cocotb.fork(Clock(dut.clk, CLK_PERIOD_NS, units='ns').start())
cocotb.start_soon(Clock(dut.clk, CLK_PERIOD_NS, units='ns').start())

dut.rst <= 1
for i in range(BUS_WIDTH):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_version(version_file):
packages=find_packages("src"),
package_dir={"": "src"},
install_requires=[
"cocotb>=1.5.0.dev,<2.0"
"cocotb>=1.6.0,<=2.0.0.dev"
],
python_requires='>=3.5'
)
2 changes: 1 addition & 1 deletion src/cocotb_bus/drivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def start(self, generator: Iterable[Tuple[int, int]] = None) -> None:

bit_driver.start((1, i % 5) for i in itertools.count())
"""
self._cr = cocotb.fork(self._cr_twiddler(generator=generator))
self._cr = cocotb.start_soon(self._cr_twiddler(generator=generator))

def stop(self):
"""Stop generating data."""
Expand Down
6 changes: 3 additions & 3 deletions src/cocotb_bus/drivers/amba.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ async def write(
write_data = self._send_write_data(address, value, burst, size,
data_latency, byte_enable, sync)

await Combine(cocotb.fork(write_address), cocotb.fork(write_data))
await Combine(cocotb.start_soon(write_address), cocotb.fork(write_data))

async with self.write_response_busy:
# Wait for the response
Expand Down Expand Up @@ -597,8 +597,8 @@ def __init__(self, entity, name, clock, memory, callback=None, event=None,
self.read_address_busy = Lock("%s_rabusy" % name)
self.write_data_busy = Lock("%s_wbusy" % name)

cocotb.fork(self._read_data())
cocotb.fork(self._write_data())
cocotb.start_soon(self._read_data())
cocotb.start_soon(self._write_data())

def _size_to_bytes_in_beat(self, AxSIZE):
if AxSIZE < 7:
Expand Down
2 changes: 1 addition & 1 deletion src/cocotb_bus/drivers/avalon.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def __init__(self, entity, name, clock, readlatency_min=1,
self._readlatency_min = readlatency_min
self._readlatency_max = readlatency_max
self._responses = []
self._coro = cocotb.fork(self._respond())
self._coro = cocotb.start_soon(self._respond())

if hasattr(self.bus, "readdatavalid"):
self.bus.readdatavalid.setimmediatevalue(0)
Expand Down
3 changes: 2 additions & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

# Do not fail on DeprecationWarning caused by virtualenv, which might come from
# the distutils or site modules.
export PYTHONWARNINGS = error,ignore::DeprecationWarning:distutils,ignore::DeprecationWarning:site
# Do not fail on DeprecationWarning caused by attrs dropping 3.6 support
export PYTHONWARNINGS = error,ignore::DeprecationWarning:distutils,ignore::DeprecationWarning:site,ignore::DeprecationWarning:attr

REGRESSIONS := $(shell ls test_cases/)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cases/test_array_buses/test_array_buses.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def add_expected(self, transaction):
@cocotb.test(expect_error=AttributeError if cocotb.SIM_NAME.lower().startswith('ghdl') else ())
async def test_array_buses(dut):
clock = Clock(dut.clk, 10, units="ns")
cocotb.fork(clock.start())
cocotb.start_soon(clock.start())
clkedge = RisingEdge(dut.clk)
in_data_0 = TestDriver(dut, "in", dut.clk, array_idx=0)
in_data_1 = TestDriver(dut, "in", dut.clk, array_idx=1)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cases/test_avalon/test_avalon.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, dut, avlproperties={}):
self.dut = dut
# Launch clock
dut.reset.value = 1
clk_gen = cocotb.fork(Clock(dut.clk, 10).start())
clk_gen = cocotb.start_soon(Clock(dut.clk, 10).start())

# Bytes aligned memory
self.memdict = {value: value for value in range(0x1000)}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cases/test_avalon_stream/test_avalon_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, dut):

async def initialise(self):
self.dut.reset.value = 0
cocotb.fork(Clock(self.dut.clk, 10).start())
cocotb.start_soon(Clock(self.dut.clk, 10).start())
for _ in range(3):
await self.clkedge
self.dut.reset.value = 1
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cases/test_axi4/test_axi4.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def compare_read_values(expected_values, read_values, burst, burst_length,


async def setup_dut(dut):
cocotb.fork(Clock(dut.clk, *CLK_PERIOD).start())
cocotb.start_soon(Clock(dut.clk, *CLK_PERIOD).start())
dut.rstn.value = 0
await ClockCycles(dut.clk, 2)
dut.rstn.value = 1
Expand Down Expand Up @@ -416,11 +416,11 @@ async def test_simultaneous(dut, sync, num=5):

await Combine(*writers)

readers = [cocotb.fork(axim.read(address, sync=sync))
readers = [cocotb.start_soon(axim.read(address, sync=sync))
for address in addresses]

dummy_addrs = [base_address + (num + i) * data_width for i in range(num)]
dummy_writers = [cocotb.fork(axim.write(address, value, sync=sync))
dummy_writers = [cocotb.start_soon(axim.write(address, value, sync=sync))
for address, value in zip(dummy_addrs, write_values)]

read_values = []
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cases/test_case_insensitive/case_insensitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def add_expected(self, transaction):
@cocotb.test()
async def test_case_insensitive(dut):
clock = Clock(dut.clk, 10, units="ns")
cocotb.fork(clock.start())
cocotb.start_soon(clock.start())
clkedge = RisingEdge(dut.clk)
in_data = TestDriver(dut, "in", dut.clk)
out_data = TestMonitor(dut, "in", dut.clk)
Expand Down
Loading