language/core: add time_to_cycles and cycles_to_time

This commit is contained in:
Sebastien Bourdeauducq 2014-10-06 23:26:21 +08:00
parent 9caaaeb414
commit 0985a53df2
2 changed files with 20 additions and 1 deletions

View File

@ -232,6 +232,8 @@ class _DummyTimeManager:
take_time = _not_implemented take_time = _not_implemented
get_time = _not_implemented get_time = _not_implemented
set_time = _not_implemented set_time = _not_implemented
time_to_cycles = _not_implemented
cycles_to_time = _not_implemented
_time_manager = _DummyTimeManager() _time_manager = _DummyTimeManager()
@ -265,7 +267,9 @@ def set_syscall_manager(syscall_manager):
# global namespace for kernels # global namespace for kernels
kernel_globals = "sequential", "parallel", "delay", "now", "at", "syscall" kernel_globals = ("sequential", "parallel",
"delay", "now", "at", "time_to_cycles", "cycles_to_time",
"syscall")
class _Sequential: class _Sequential:
@ -319,6 +323,20 @@ def at(time):
_time_manager.set_time(time) _time_manager.set_time(time)
def time_to_cycles(time):
"""Converts time to the corresponding number of RTIO cycles.
"""
return _time_manager.time_to_cycles(time)
def cycles_to_time(cycles):
"""Converts RTIO cycles to the corresponding time.
"""
return _time_manager.cycles_to_time(cycles)
def syscall(*args): def syscall(*args):
"""Invokes a service of the runtime. """Invokes a service of the runtime.

View File

@ -104,6 +104,7 @@ class _ReferenceManager:
_embeddable_calls = ( _embeddable_calls = (
core_language.delay, core_language.at, core_language.now, core_language.delay, core_language.at, core_language.now,
core_language.time_to_cycles, core_language.cycles_to_time,
core_language.syscall, core_language.syscall,
range, int, float, round, range, int, float, round,
core_language.int64, core_language.round64, core_language.array, core_language.int64, core_language.round64, core_language.array,