Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 82b470891fe1
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a01e328b4a0c
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 21, 2015

  1. compiler.iodelay: fold MUToS and SToMU.

    whitequark committed Nov 21, 2015
    Copy the full SHA
    5cd12ff View commit details
  2. Copy the full SHA
    a01e328 View commit details
Showing with 15 additions and 2 deletions.
  1. +12 −0 artiq/compiler/iodelay.py
  2. +3 −2 artiq/compiler/transforms/interleaver.py
12 changes: 12 additions & 0 deletions artiq/compiler/iodelay.py
Original file line number Diff line number Diff line change
@@ -106,13 +106,25 @@ def __str__(self):
def eval(self, env):
return self.operand.eval(env) * self.ref_period

def fold(self, vars=None):
if isinstance(self.operand, Const):
return Const(self.operand.value * self.ref_period)
else:
return super().fold(vars)

class SToMU(Conv):
def __str__(self):
return "s->mu({})".format(self.operand)

def eval(self, env):
return self.operand.eval(env) / self.ref_period

def fold(self, vars=None):
if isinstance(self.operand, Const):
return Const(self.operand.value / self.ref_period)
else:
return super().fold(vars)

class BinOp(Expr):
def __init__(self, lhs, rhs):
self.lhs, self.rhs = lhs, rhs
5 changes: 3 additions & 2 deletions artiq/compiler/transforms/interleaver.py
Original file line number Diff line number Diff line change
@@ -65,8 +65,9 @@ def iodelay_of_block(block):
terminator = block.terminator()
if isinstance(terminator, ir.Delay):
# We should be able to fold everything without free variables.
assert iodelay.is_const(terminator.expr)
return terminator.expr.value
folded_expr = terminator.expr.fold()
assert iodelay.is_const(folded_expr)
return folded_expr.value
else:
return 0