From 2944592201545034216ebd94258503d89b309ab6 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 5 Oct 2014 17:54:22 +0800 Subject: [PATCH] Remove microcycle unit Introducing it complicates things and has no advantage with good rational arithmetic support. --- artiq/__init__.py | 2 +- artiq/language/core.py | 2 +- artiq/language/units.py | 3 --- artiq/transforms/inline.py | 2 +- artiq/transforms/interleave.py | 2 +- artiq/transforms/lower_units.py | 13 +++++-------- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/artiq/__init__.py b/artiq/__init__.py index 866e20e2c..9f7fc4cfa 100644 --- a/artiq/__init__.py +++ b/artiq/__init__.py @@ -1,3 +1,3 @@ from artiq.language.core import * -from artiq.language.units import microcycle, ps, ns, us, ms, s +from artiq.language.units import ps, ns, us, ms, s from artiq.language.units import Hz, kHz, MHz, GHz diff --git a/artiq/language/core.py b/artiq/language/core.py index 1a3fed022..8909cf7d9 100644 --- a/artiq/language/core.py +++ b/artiq/language/core.py @@ -306,7 +306,7 @@ def delay(duration): def now(): - """Retrieves the current RTIO time, in microcycles. + """Retrieves the current RTIO time, in seconds. """ return _time_manager.get_time() diff --git a/artiq/language/units.py b/artiq/language/units.py index b5c1fd882..0584706f1 100644 --- a/artiq/language/units.py +++ b/artiq/language/units.py @@ -157,6 +157,3 @@ def _register_unit(name, prefixes): _register_unit("s", "pnum_") _register_unit("Hz", "_kMG") - -microcycle_unit = Unit("microcycle") -microcycle = Quantity(1, microcycle_unit) diff --git a/artiq/transforms/inline.py b/artiq/transforms/inline.py index ef672c346..9bb9388fb 100644 --- a/artiq/transforms/inline.py +++ b/artiq/transforms/inline.py @@ -49,7 +49,7 @@ class _ReferenceManager: self.use_count[kg] = 1 for name in ("int", "round", "int64", "round64", "float", "array", "range", "Fraction", "Quantity", "EncodedException", - "s_unit", "Hz_unit", "microcycle_unit"): + "s_unit", "Hz_unit"): self.use_count[name] = 1 def new_name(self, base_name): diff --git a/artiq/transforms/interleave.py b/artiq/transforms/interleave.py index d421d902a..917ff0c86 100644 --- a/artiq/transforms/interleave.py +++ b/artiq/transforms/interleave.py @@ -7,7 +7,7 @@ from artiq.transforms.tools import * # -1 statement duration could not be pre-determined # 0 statement has no effect on timeline # >0 statement is a static delay that advances the timeline -# by the given amount (in microcycles) +# by the given amount def _get_duration(stmt): if isinstance(stmt, (ast.Expr, ast.Assign)): return _get_duration(stmt.value) diff --git a/artiq/transforms/lower_units.py b/artiq/transforms/lower_units.py index d195b6f80..c5914c029 100644 --- a/artiq/transforms/lower_units.py +++ b/artiq/transforms/lower_units.py @@ -24,14 +24,11 @@ class _UnitsLowerer(ast.NodeTransformer): self.in_core_time = old_in_core_time elif fn == "Quantity": if self.in_core_time: - if node.args[1].id == "microcycle_units": - node = node.args[0] - else: - node = ast.copy_location( - ast.BinOp(left=node.args[0], - op=ast.Div(), - right=value_to_ast(self.ref_period)), - node) + node = ast.copy_location( + ast.BinOp(left=node.args[0], + op=ast.Div(), + right=value_to_ast(self.ref_period)), + node) else: node = node.args[0] else: