mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
language.core: implement round(value, width) (fixes #203).
This commit is contained in:
parent
25188f0ca9
commit
a250b5da21
@ -10,7 +10,7 @@ from functools import wraps
|
||||
from artiq.coredevice.runtime import source_loader
|
||||
|
||||
|
||||
__all__ = ["host_int", "int",
|
||||
__all__ = ["host_int", "int", "host_round", "round",
|
||||
"kernel", "portable", "syscall",
|
||||
"set_time_manager", "set_watchdog_factory",
|
||||
"ARTIQException",
|
||||
@ -161,6 +161,11 @@ class int:
|
||||
__lt__ = _compareop(host_int.__lt__, "__ge__")
|
||||
__le__ = _compareop(host_int.__le__, "__gt__")
|
||||
|
||||
host_round = round
|
||||
|
||||
def round(value, width=32):
|
||||
return int(host_round(value), width)
|
||||
|
||||
|
||||
_ARTIQEmbeddedInfo = namedtuple("_ARTIQEmbeddedInfo",
|
||||
"core_name function syscall")
|
||||
@ -316,7 +321,7 @@ def seconds_to_mu(seconds, core=None):
|
||||
"""
|
||||
if core is None:
|
||||
raise ValueError("Core device must be specified for time conversion")
|
||||
return round64(seconds//core.ref_period)
|
||||
return round(seconds//core.ref_period, width=64)
|
||||
|
||||
|
||||
def mu_to_seconds(mu, core=None):
|
||||
|
Loading…
Reference in New Issue
Block a user