You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is immutable, has no public constructor and is instead constructed through the following classmethods:
26
-
-`.s(duration: numbers.Real)`
27
-
-`.ms(duration: numbers.Real)`
28
-
-`.us(duration: numbers.Real)`
29
-
-`.ns(duration: numbers.Real)`
30
-
-`.ps(duration: numbers.Real)`
31
-
-`.fs(duration: numbers.Real)`
32
-
-`.Hz(frequency: numbers.Real)`
33
-
-`.kHz(frequency: numbers.Real)`
34
-
-`.MHz(frequency: numbers.Real)`
35
-
-`.GHz(frequency: numbers.Real)`
36
-
- 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.
25
+
It is immutable and has a constructor accepting at most one named argument, giving the following valid forms of construction:
26
+
-`Period()`
27
+
- Constructs a zero period.
28
+
-`Period(seconds: numbers.Real)`
29
+
-`Period(milliseconds: numbers.Real)`
30
+
-`Period(microseconds: numbers.Real)`
31
+
-`Period(nanoseconds: numbers.Real)`
32
+
-`Period(picoseconds: numbers.Real)`
33
+
-`Period(femtoseconds: numbers.Real)`
34
+
- The argument will be scaled according to its SI prefix and used to calculate the closest integer femtosecond representation.
35
+
-`Period(hertz: numbers.Real)`
36
+
-`Period(kilohertz: numbers.Real)`
37
+
-`Period(megahertz: numbers.Real)`
38
+
-`Period(gigahertz: numbers.Real)`
39
+
- The argument will be scaled according to its SI prefix and its reciprocal used to calculate the closest integer femtosecond representation.
40
+
A value of zero will raise `ZeroDivisionError`.
37
41
38
42
To convert it back to a number, the following properties are available:
39
43
-`.seconds -> fractions.Fraction`
@@ -120,6 +124,9 @@ Consequently, `Platform.default_clk_frequency()` is also deprecated and replaced
120
124
121
125
-`.elapsed_time()` is only available from within a testbench/process, where it is well defined.
122
126
127
+
- Instead of named constructor arguments, we could use a classmethod for each SI prefix.
128
+
This was proposed in an earlier revision of this RFC.
129
+
123
130
## Prior art
124
131
[prior-art]: #prior-art
125
132
@@ -130,10 +137,12 @@ None.
130
137
131
138
- With the scope of `Period` extended beyond simulation, where do we put it?
132
139
133
-
- The usual bikeshedding.
134
-
- Case, e.g. `.MHz` vs `.mhz`.
140
+
- Should we use shorter argument/property names like `MHz` instead of (or an alias in addition to) `megahertz`?
141
+
142
+
- Should we disallow passing a negative frequency or accessing a frequency property on a negative period?
135
143
136
-
- Should `Period` also have properties to return the reciprocal frequency?
144
+
- We could allow passing multiple constructor arguments and add them together -- should we?
145
+
- Probably not. Limited usefulness for durations and nonsensical for frequencies.
0 commit comments