Open Scafir opened 1 year ago
I'm assuming that version 0.2.3 is the cocotb-test
version, not cocotb
.
That being said, this is a bug.
Module handles are of type GpiObjHdl
type, but not GpiSignalObjHdl
, which gpi_register_value_change_callback()
assumes and does a static_cast
to:
There is no checking for this difference either in GPI or in Python.
@Scafir Thanks for your great bug report. Would you be interested in attempting a fix in a pull request?
Hi @imphil , I am willing to try. A few questions: It seems that the type check can either happen in cocotb/triggers.py#L386 or GpiCommon.cpp#L519. It seems to me that the first one would be the best place to do that. Should I also implement it in GpiCommon? My todo list would be as follow:
Does this looks good to you?
I don't think there's any need to document that objects can throw TypeError
s, because that's true of pretty much everything if you use it incorrectly.
Dupe of #1887. Could be solved with #2774. IMO RisingEdge
, Edge
, and FallingEdge
have no business being free functions, but oh well.
Description
If one awaits a trigger with dut as the signal (e.g:
await RisingEdge(dut)
), then the error produced is incomprehensible:This makes a relatively simple user mistake seem like an internal bug. This behavior is partly due to dut having an attribute
_handle
, thus not producing the "usual" error due to a typo:AttributeError: 'XXX' object has no attribute '_handle'
Expected Behavior
A more understandable error should be raised (TypeError if signal is not of type
cocotb.handle.ModifiableObject
?)How to reproduce?
Context