From 0985a53df2210f97973da1d91e73f0fa37f6a44c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 6 Oct 2014 23:26:21 +0800 Subject: [PATCH] language/core: add time_to_cycles and cycles_to_time --- artiq/language/core.py | 20 +++++++++++++++++++- artiq/transforms/inline.py | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/artiq/language/core.py b/artiq/language/core.py index 8909cf7d9..bd8ecdb62 100644 --- a/artiq/language/core.py +++ b/artiq/language/core.py @@ -232,6 +232,8 @@ class _DummyTimeManager: take_time = _not_implemented get_time = _not_implemented set_time = _not_implemented + time_to_cycles = _not_implemented + cycles_to_time = _not_implemented _time_manager = _DummyTimeManager() @@ -265,7 +267,9 @@ def set_syscall_manager(syscall_manager): # 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: @@ -319,6 +323,20 @@ def at(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): """Invokes a service of the runtime. diff --git a/artiq/transforms/inline.py b/artiq/transforms/inline.py index 6a846cfaa..ed9fab890 100644 --- a/artiq/transforms/inline.py +++ b/artiq/transforms/inline.py @@ -104,6 +104,7 @@ class _ReferenceManager: _embeddable_calls = ( core_language.delay, core_language.at, core_language.now, + core_language.time_to_cycles, core_language.cycles_to_time, core_language.syscall, range, int, float, round, core_language.int64, core_language.round64, core_language.array,