question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditional waiting on events : API discussion

See original GitHub issue

Based on https://github.com/cocotb/cocotb/pull/1250 (by @Fatsie) proposals and discussion in https://github.com/cocotb/cocotb/issues/1682

We have discussed a bit internally on https://github.com/cocotb/cocotb/pull/1250 and concluded is a that it is a good idea but:

  • function names have to be clear
  • we can gain performance if we implement this in a slightly different way

For performance reasons the function should include as input:

  • synchronization trigger (clock and edge)
  • sensitivity list (signals to observe)
  • condition for trigger

We would like to make API to replace such example:

    while True:
        await RisingEdge(clk)
        if condition():
            do_something()

with something like:

await OnCondition(clk, signals, condition)

Implementation of the waiting part could be initially somewhere along the lines (from @eric-wieser ) :

async def OnCondition(clk, signals, condition)
    while True:
        await RisingEdge(clk)
        if condition():
            break
        await First(*[Edge(hdl) for hdl in signals])
  • We should support signals, vectors and buses?
  • Should we use ReadOnly()?
  • FallingEdge of clk

This way we minimize the number of triggers/callbacks that will improve performance and may become the recommended way to wait for the signal. In the future, such a trigger can be moved to GPI/C++.

Considering those points we should agree on API before implementation. Proposals are welcome. https://github.com/cocotb/cocotb/pull/1250 can be a starting point.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
themperekcommented, Apr 23, 2020

@chiraag It is interesting but can you move your findings to new issues? It does not look to me it belongs here. Also would be good to say what simulator and version you are using.

0reactions
cmarqucommented, Jan 12, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Wait until a condition is true? - javascript - Stack Overflow
Ideally the user would see a 'Waiting for location' message periodically until the location was obtained, then the form would submit. However, I'm...
Read more >
Use the Wait Until API Event Activity to Drive Real-Time ...
Configure the Wait Until API Event activity to hold contacts until an event, such as a purchase or loan application, occurs before moving...
Read more >
Event driven architecture conditional logic
"processing" events, checks its event-sourced database of registered events then generates another event if it's registered or doesn't if it's ...
Read more >
Using Condition Variables (Multithreaded Programming Guide)
h> pthread_cond_t cv ; pthread_mutex_t mp ; int ret ; /* wait on condition variable */ ret = pthread_cond_wait(& cv , & mp...
Read more >
Events vs. Condition Variables - narkive
Anyone have a link to a discussion of such? And is this question OK in ... for other waiting threads to properly coordinate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found