forked from M-Labs/artiq
1
0
Fork 0

time_to_cycles: round instead of flooring

This commit is contained in:
Sebastien Bourdeauducq 2014-10-13 18:35:05 +08:00
parent 0158de5ac9
commit 7c4450a963
2 changed files with 2 additions and 2 deletions

View File

@ -347,7 +347,7 @@ def time_to_cycles(time, core=None):
""" """
if core is None: if core is None:
raise ValueError("Core device must be specified for time conversion") raise ValueError("Core device must be specified for time conversion")
return int64(time.amount//core.runtime_env.ref_period) return round64(time.amount//core.runtime_env.ref_period)
def cycles_to_time(cycles, core=None): def cycles_to_time(cycles, core=None):

View File

@ -11,7 +11,7 @@ def _time_to_cycles(ref_period, node):
right=value_to_ast(ref_period)), right=value_to_ast(ref_period)),
node) node)
return ast.copy_location( return ast.copy_location(
ast.Call(func=ast.Name("int64", ast.Load()), ast.Call(func=ast.Name("round64", ast.Load()),
args=[divided], args=[divided],
keywords=[], starargs=[], kwargs=[]), keywords=[], starargs=[], kwargs=[]),
divided) divided)