1
0
forked from M-Labs/artiq
artiq/artiq/devices/core.py

28 lines
991 B
Python
Raw Normal View History

from artiq.compiler.inline import inline
2014-08-18 23:06:34 +08:00
from artiq.compiler.lower_units import lower_units
2014-06-21 06:19:56 +08:00
from artiq.compiler.fold_constants import fold_constants
2014-06-21 21:06:15 +08:00
from artiq.compiler.unroll_loops import unroll_loops
2014-06-23 00:52:37 +08:00
from artiq.compiler.interleave import interleave
2014-07-16 01:22:11 +08:00
from artiq.compiler.lower_time import lower_time
from artiq.compiler.ir import get_runtime_binary
2014-05-31 00:20:13 +08:00
class Core:
def __init__(self, core_com, runtime_env=None):
if runtime_env is None:
runtime_env = core_com.get_runtime_env()
self.runtime_env = runtime_env
self.core_com = core_com
def run(self, k_function, k_args, k_kwargs):
funcdef, rpc_map = inline(self, k_function, k_args, k_kwargs)
2014-08-18 23:06:34 +08:00
lower_units(funcdef, self.runtime_env.ref_period)
fold_constants(funcdef)
unroll_loops(funcdef, 50)
interleave(funcdef)
lower_time(funcdef, getattr(self.runtime_env, "initial_time", 0))
fold_constants(funcdef)
2014-06-17 04:56:08 +08:00
binary = get_runtime_binary(self.runtime_env, funcdef)
self.core_com.run(binary)
2014-07-08 01:14:23 +08:00
self.core_com.serve(rpc_map)