2014-06-17 03:33:59 +08:00
|
|
|
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
|
2014-07-06 04:47:54 +08:00
|
|
|
from artiq.compiler.ir import get_runtime_binary
|
2014-05-31 00:20:13 +08:00
|
|
|
|
|
|
|
class Core:
|
2014-07-16 01:20:13 +08:00
|
|
|
def __init__(self, core_com, runtime_env=None):
|
|
|
|
if runtime_env is None:
|
|
|
|
runtime_env = core_com.get_runtime_env()
|
2014-07-06 04:47:54 +08:00
|
|
|
self.runtime_env = runtime_env
|
|
|
|
self.core_com = core_com
|
|
|
|
|
2014-06-17 03:33:59 +08:00
|
|
|
def run(self, k_function, k_args, k_kwargs):
|
2014-08-18 21:37:30 +08:00
|
|
|
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)
|
2014-08-18 21:37:30 +08:00
|
|
|
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
|
|
|
|
2014-08-18 21:37:30 +08:00
|
|
|
binary = get_runtime_binary(self.runtime_env, funcdef)
|
2014-07-06 04:47:54 +08:00
|
|
|
self.core_com.run(binary)
|
2014-07-08 01:14:23 +08:00
|
|
|
self.core_com.serve(rpc_map)
|