Skip to content

Commit

Permalink
Fix race condition in dff_cocotb test
Browse files Browse the repository at this point in the history
There is no constraint on tb.stop() action with regards to all other
coroutines waiting for clock rising edge. This may lead to mismatching
transactions and expectations being sent to Scoreboard and the following
error:

AssertionError: Received a transaction but wasn't expecting anything

Waiting on ReadOnly trigger ensures that all other coroutines have
performed their actions before the testbetch is stopped.
  • Loading branch information
p12tic authored and ktbarrett committed Sep 5, 2024
1 parent dfc4613 commit cf1e834
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/dff/tests/dff_cocotb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import cocotb
from cocotb.clock import Clock
from cocotb.triggers import RisingEdge
from cocotb.triggers import ReadOnly, RisingEdge
from cocotb.binary import BinaryValue
from cocotb.regression import TestFactory

Expand Down Expand Up @@ -149,6 +149,8 @@ async def run_test(dut):

# Stop generation of input data. One more clock cycle is needed to capture
# the resulting output of the DUT.

await ReadOnly()
tb.stop()
await clkedge

Expand Down

0 comments on commit cf1e834

Please sign in to comment.