compiler/devices: set initial time

This commit is contained in:
Sebastien Bourdeauducq 2014-07-21 13:22:07 -06:00
parent cdda1beea8
commit 8769066e89
4 changed files with 5 additions and 4 deletions

View File

@ -33,10 +33,10 @@ class _TimeLowerer(ast.NodeTransformer):
else:
return node
def lower_time(stmts, ref_period):
def lower_time(stmts, ref_period, initial_time):
transformer = _TimeLowerer(ref_period)
new_stmts = [transformer.visit(stmt) for stmt in stmts]
new_stmts.insert(0, ast.copy_location(
ast.Assign(targets=[ast.Name("now", ast.Store())], value=ast.Num(0)),
ast.Assign(targets=[ast.Name("now", ast.Store())], value=ast.Num(initial_time)),
stmts[0]))
stmts[:] = new_stmts

View File

@ -17,7 +17,8 @@ class Core:
fold_constants(stmts)
unroll_loops(stmts, 50)
interleave(stmts)
lower_time(stmts, self.runtime_env.ref_period)
lower_time(stmts, self.runtime_env.ref_period,
getattr(self.runtime_env, "initial_time", 0))
fold_constants(stmts)
binary = get_runtime_binary(self.runtime_env, stmts)

View File

@ -49,6 +49,7 @@ class LinkInterface:
class Environment(LinkInterface):
def __init__(self, ref_period):
self.ref_period = ref_period
self.initial_time = 8000
def emit_object(self):
tm = lt.TargetMachine.new(triple="or1k", cpu="generic")

View File

@ -7,7 +7,6 @@ class TTLTest(MPO):
@kernel
def run(self):
delay(10*us)
i = 0
while i < 100000:
with parallel: