1 回答
TA贡献1847条经验 获得超7个赞
我有一个协程,它等待一个事件被设置:
@cocotb.coroutine
def wb_RXDR_read(self):
""" waiting util RXDR is read """
if not self._RXDR_read_flag:
while True:
yield self._RXDR_read_event.wait()
break
我想在超时的情况下“屈服”。然后要做到这一点,我这样做了:
RXDR_timeout = Timer(250, units="us")
ret = yield [RXDR_timeout, self.wb_RXDR_read()]
if ret == RXDR_timeout:
self._dut._log.error("Timeout on waiting RXDR to be read")
raise TestError()
但我收到此错误:
2ns ERROR Coroutine i2c_write yielded something the scheduler can't handle
Got type: <type 'list'> repr: [<cocotb.triggers.Timer object at 0x7f2098cb1350>, <cocotb.decorators.RunningCoroutine object at 0x7f2098cb1610>] str: [<cocotb.triggers.Timer object at 0x7f2098cb1350>, <cocotb.decorators.RunningCoroutine object at 0x7f2098cb1610>]
Did you forget to decorate with @cocotb.coroutine?
我的协程用@cocotb.coroutine 装饰。如果我单独屈服它有效:
yield self.wb_RXDR_read() # <- that works
但我不能把它放在一个列表中。是否可以将协程放在一个列表中以像 unix select() 那样阻塞?还是保留给 Trigger 类?
添加回答
举报