mirror of https://github.com/m-labs/artiq.git
parent
03a69ec5b7
commit
6155f65366
|
@ -162,15 +162,9 @@ def obj_sequential():
|
|||
def fn_watchdog():
|
||||
return types.TBuiltinFunction("watchdog")
|
||||
|
||||
def fn_now():
|
||||
return types.TBuiltinFunction("now")
|
||||
|
||||
def fn_delay():
|
||||
return types.TBuiltinFunction("delay")
|
||||
|
||||
def fn_at():
|
||||
return types.TBuiltinFunction("at")
|
||||
|
||||
def fn_now_mu():
|
||||
return types.TBuiltinFunction("now_mu")
|
||||
|
||||
|
|
|
@ -38,9 +38,7 @@ def globals():
|
|||
"watchdog": builtins.fn_watchdog(),
|
||||
|
||||
# ARTIQ time management functions
|
||||
"now": builtins.fn_now(),
|
||||
"delay": builtins.fn_delay(),
|
||||
"at": builtins.fn_at(),
|
||||
"now_mu": builtins.fn_now_mu(),
|
||||
"delay_mu": builtins.fn_delay_mu(),
|
||||
"at_mu": builtins.fn_at_mu(),
|
||||
|
|
|
@ -1692,19 +1692,12 @@ class ARTIQIRGenerator(algorithm.Visitor):
|
|||
self.polymorphic_print([self.visit(arg) for arg in args],
|
||||
separator=" ", suffix="\n\x1D", as_rtio=True)
|
||||
return ir.Constant(None, builtins.TNone())
|
||||
elif types.is_builtin(typ, "now"):
|
||||
if len(node.args) == 0 and len(node.keywords) == 0:
|
||||
now_mu = self.append(ir.Builtin("now_mu", [], builtins.TInt64()))
|
||||
now_mu_float = self.append(ir.Coerce(now_mu, builtins.TFloat()))
|
||||
return self.append(ir.Arith(ast.Mult(loc=None), now_mu_float, self.ref_period))
|
||||
else:
|
||||
assert False
|
||||
elif types.is_builtin(typ, "delay") or types.is_builtin(typ, "at"):
|
||||
elif types.is_builtin(typ, "delay"):
|
||||
if len(node.args) == 1 and len(node.keywords) == 0:
|
||||
arg = self.visit(node.args[0])
|
||||
arg_mu_float = self.append(ir.Arith(ast.Div(loc=None), arg, self.ref_period))
|
||||
arg_mu = self.append(ir.Coerce(arg_mu_float, builtins.TInt64()))
|
||||
return self.append(ir.Builtin(typ.name + "_mu", [arg_mu], builtins.TNone()))
|
||||
return self.append(ir.Builtin("delay_mu", [arg_mu], builtins.TNone()))
|
||||
else:
|
||||
assert False
|
||||
elif types.is_builtin(typ, "now_mu") or types.is_builtin(typ, "delay_mu") \
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
# RUN: %python -m artiq.compiler.testbench.jit %s
|
||||
# REQUIRES: time
|
||||
|
||||
assert now() == 0.0
|
||||
assert now_mu() == 0
|
||||
delay(100.0)
|
||||
assert now() == 100.0
|
||||
at(12345.0)
|
||||
assert now() == 12345.0
|
||||
|
||||
assert now_mu() == 100000000
|
||||
at_mu(12345000000)
|
||||
assert now_mu() == 12345000000
|
||||
|
|
Loading…
Reference in New Issue