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.

Fundamental concept of time required

See original GitHub issue

Cocotb should have a fundamental concept of time. Currently the Timer() trigger is expressed in simulation time units, however the user has no knowledge of that this is.

We should query the simulator (in VPI we call vpi_get_time with vpiTimeUnit and vpiTimePrecision properties and a NULL handle).

Cocotb can then store the fundamental unit and precision and scale appropriately. In my test I can then specify for example a 6.4ns period clock without needing to know the time precision of the simulator.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
lukedarnellcommented, Mar 7, 2016

I have an implementation that adds convenience functions into cocotb to allow you to easily specify delays in time units.

I’ve currently got something like this:


from cocotb.time import s,ms,us,ns,ps,fs

@cocotb.coroutine
def time_example():
    # Wait 10 seconds
    yield Timer(s(10))
    # Wait 16 milli seconds
    yield Timer(ms(16))
    # Wait 100 micro seconds
    yield Timer(us(100))
    # Wait 5 nano seconds
    yield Timer(ns(5))
    # Wait 2 pico seconds
    yield Timer(ps(2))
    # Wait 1 femto second
    yield Timer(fs(1))

I’m not in love with the syntax of the function calls to generate the simulation time counts. But I’m not sure how else we’d get these numbers. The SystemVerilog time unit syntax would be ideal. e.g

initial begin
    #10s;
    #16ms;
    #2fs;
end

But I’m not sure how’d you achieve something similar in python.

0reactions
ktbarrettcommented, Apr 23, 2020

Added sim time with units as a concept to Timer, Clock, and get_sim_time in #474. with_timeout and test timeouts were added in #1119.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Time - Wikipedia
Time in physics is operationally defined as "what a clock reads". The physical nature of time is addressed by general relativity with respect...
Read more >
The Illusion of Time: What's Real? - Space.com
At the deepest foundations of nature, time is not a primitive, irreducible element or concept required to construct reality. The idea that time ......
Read more >
Time | Internet Encyclopedia of Philosophy
The fundamental theories of physical science—namely relativity theory, quantum theory and the big bang theory—imply that time exists. They imply it ...
Read more >
About time - Mathematical Association of America
The time that is measured by a clock is itself produced by that clock. The clock's time is independent of the flow of...
Read more >
Time is Fundamental? - Physics Forums
At a deeper level, in which space disappears but time persists, a universal meaning can be given to the concept of now. If...
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