Clock event put, get, and wait
See original GitHub issueI found that my simulation was hanging when I called queue.put on a queue with maxlen=1. I also hung awaiting Event.wait()
I’ve fixed the problem by creating versions of the queue and event that loop on a clock-based event so that control goes back to the simulator. Now you pass uvm_root().run_test()
the clock as well as the test name. This gets stored in ConfigDB() and can be used anywhere in the testbench.
Clock-based blocking
Here is the event:
class UVMEvent(Event):
def __init__(self, name, clock):
super().__init__(name=name)
self.trigger = Timer(10, units="step")
async def wait(self):
while True:
await self.trigger
if self.is_set:
return self.fired
else:
continue
And here are the put
and get
:
async def put(self, item):
while True:
await self.trigger
try:
self.put_nowait(item)
break
except QueueFull:
continue
async def get(self):
while True:
await self.trigger
try:
item = self.get_nowait()
print("GOT:", item)
return item
except QueueEmpty:
continue
Do you think this a generalizable feature in cocotb?
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
pygame.time — pygame v2.1.4 documentation
repeatedly create an event on the event queue. pygame.time.Clock ... Most platforms have a limited time resolution of around 10 milliseconds.
Read more >How to wait some time in pygame? - Stack Overflow
If you just wait for some time, you can use pygame.time.wait or ... while run: for event in pygame.event.get(): if event.type == pygame....
Read more >Descriptions of Wait Events - Database - Oracle Help Center
A session has issued a statement ALTER SYSTEM SET DISPATCHER = string and is waiting for the dispatchers to get started. Wait Time:...
Read more >Define a Wait for Time or Event for an Automation Process ...
Wait for Time: Step that waits for a defined amount of time before the process continues to the next step. Wait from: Select...
Read more >How to use Wait On and Wait Until in VHDL - VHDLwhiz
We learned that signals have a broader scope than variables, ... The Wait Until statement will pause until an event causes the condition...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There is no inherit problem with a task calling
await q.put()
on aQueue
withmaxlen = 1
. The calling task will suspend until there is room inq
, which can only happen if another task callsawait q.get()
orq.get_nowait()
.I don’t see value in adding extra
Timer
triggers or waiting on clock edges inside these coroutines, as they are already waiting on someEvent
to be triggered. If your simulation is not progressing, there is some other underlying issue.I think there’s a misunderstanding here. Control is returned to the simulator simply when there are no coroutines left to run, right? The scheduler loop is roughly:
await
ingawait
s and control returns to the simulatorThe only thing that makes “real” triggers special is that they start the chain of events. Any type of trigger can end a chain of events.
If you end up in a situation where the only events waiting to fire are “virtual”, your testbench has a deadlock and is itself the problem; no change to your dut can ever wake it.
If you end up in a situation where your coroutines wake each other up forever, then your testbench has an infinite loop in which no time passes and is itself the problem; no simulator events will ever be able to fire.