cocotb: Unexpected behavior with simple dff example - unexpected triggering at time==0
From: https://github.com/cocotb/cocotb/pull/1529#pullrequestreview-387867775
# test_dff.py
import random
import cocotb
from cocotb.clock import Clock
from cocotb.triggers import FallingEdge
@cocotb.test()
async def test_dff_simple(dut):
""" Test that d propagates to q """
clock = Clock(dut.clk, 10, units="us") # Create a 10us period clock on port clk
cocotb.fork(clock.start()) # Start the clock
for i in range(10):
await RisingEdge(dut.clk) # Synchronize ourselves with the clock
val = random.randint(0, 1)
dut.d <= val # Assign the random value val to the input port d
await FallingEdge(dut.clk)
assert dut.q == val, "output q was incorrect on the {}th cycle".format(i)
6000.00ns ERROR cocotb.regression regression.py:396 in _score_test Test Failed: test_dff_simple (result was ValueError)
Traceback (most recent call last):
File "/examples/dff_simple/test_dff.py", line 20, in test_dff_simple
assert dut.q == val, "output was incorrect on the {}th cycle".format(i)
File "/cocotb/handle.py", line 409, in __eq__
return self.value == other
File "/cocotb/binary.py", line 439, in __eq__
return self.value == other
File "/cocotb/binary.py", line 296, in value
return self.integer
File "/cocotb/binary.py", line 287, in integer
return self._convert_from[self.binaryRepresentation](self._str)
File "/cocotb/binary.py", line 193, in _convert_from_unsigned
return int(resolve(x), 2)
File "/cocotb/binary.py", line 45, in resolve
raise ValueError("Unable to resolve to binary >%s<" % string)
ValueError: Unable to resolve to binary >z<
6000.00ns ERROR cocotb.regression regression.py:227 in tear_down Failed 1 out of 1 tests (0 skipped)
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 19 (19 by maintainers)
There is also “The Facts and Fallacies of Verilog Event Scheduling: Is the IEEE 1364 Standard Right or Wrong?”: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.611.4282&rep=rep1&type=pdf