forked from M-Labs/artiq
1
0
Fork 0

devices/core: compile to machine code and run on hardware

This commit is contained in:
Sebastien Bourdeauducq 2014-07-05 22:47:54 +02:00
parent 5570d45acb
commit 1aac985f10
1 changed files with 7 additions and 14 deletions

View File

@ -1,26 +1,19 @@
from operator import itemgetter
from artiq.compiler.inline import inline from artiq.compiler.inline import inline
from artiq.compiler.fold_constants import fold_constants from artiq.compiler.fold_constants import fold_constants
from artiq.compiler.unroll_loops import unroll_loops from artiq.compiler.unroll_loops import unroll_loops
from artiq.compiler.interleave import interleave from artiq.compiler.interleave import interleave
from artiq.compiler.unparse import Unparser from artiq.compiler.ir import get_runtime_binary
class Core: class Core:
def __init__(self, runtime_env, core_com):
self.runtime_env = runtime_env
self.core_com = core_com
def run(self, k_function, k_args, k_kwargs): def run(self, k_function, k_args, k_kwargs):
stmts, rpc_map = inline(self, k_function, k_args, k_kwargs) stmts, rpc_map = inline(self, k_function, k_args, k_kwargs)
fold_constants(stmts) fold_constants(stmts)
unroll_loops(stmts, 50) unroll_loops(stmts, 50)
interleave(stmts) interleave(stmts)
print("=========================") binary = get_runtime_binary(self.runtime_env, stmts)
print(" Inlined") self.core_com.run(binary)
print("=========================")
Unparser(stmts)
print("")
print("=========================")
print(" RPC map")
print("=========================")
for rpc_func, rpc_num in sorted(rpc_map.items(), key=itemgetter(1)):
print("{:3} -> {}".format(rpc_num, str(rpc_func)))