-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC #66: Simulation time #66
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it looks good. I left some minor bikeshedding comments.
- `.GHz(frequency: numbers.Real)` | ||
- The argument will be scaled according to the SI prefix on the method and the `duration` or reciprocal of `frequency` then used to calculate the closest integer femtosecond representation. | ||
|
||
To convert it back to a number, the following properties are available: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we provide a convenience wrappers over time getters, to request the period rounded to int? If we specify time, then usually we know which unit is needed to get the exact int value. In such cases there will be always needed explicit cast which will produce boilerplate.
So I would like to propose to add:
.iseconds
-> int.imiliseconds
-> int- and so on
(of course the above function names are some example, which should probably by changed for something better)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that as valuable due to how rare reading simulation time is expected to be.
[guide-level-explanation]: #guide-level-explanation | ||
|
||
A new type `amaranth.sim.Period` is introduced. | ||
It is immutable, has no public constructor and is instead constructed through the following classmethods: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if classmethod constructors should have such short names and the time getters the longer one. Usually the construction is more seldom than accessing. So maybe we can have constructors something like .make_s(duration)
, .make_ms(duration)
... and the access functions as .get_s()
, .get_ms()
,...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in this case though. You will almost never use accessors. You should keep that in mind when evaluating the API design.
Something that I realized is that this class would also be really convenient for specifying frequencies of clocks.
|
…g with clock constraints.
## Prior art | ||
[prior-art]: #prior-art | ||
|
||
None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think CXXRTL using time as an 128-bit number of femtoseconds is prior art.
Rendered.