mirror of https://github.com/m-labs/artiq.git
compiler.iodelay: always fully fold SToMU and MUToS.
This commit is contained in:
parent
f3da227e2d
commit
02f2763ea8
|
@ -95,10 +95,6 @@ class Conv(Expr):
|
||||||
def free_vars(self):
|
def free_vars(self):
|
||||||
return self.operand.free_vars()
|
return self.operand.free_vars()
|
||||||
|
|
||||||
def fold(self, vars=None):
|
|
||||||
return self.__class__(self.operand.fold(vars),
|
|
||||||
ref_period=self.ref_period)
|
|
||||||
|
|
||||||
class MUToS(Conv):
|
class MUToS(Conv):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "mu->s({})".format(self.operand)
|
return "mu->s({})".format(self.operand)
|
||||||
|
@ -107,10 +103,11 @@ class MUToS(Conv):
|
||||||
return self.operand.eval(env) * self.ref_period
|
return self.operand.eval(env) * self.ref_period
|
||||||
|
|
||||||
def fold(self, vars=None):
|
def fold(self, vars=None):
|
||||||
if isinstance(self.operand, Const):
|
operand = self.operand.fold(vars)
|
||||||
return Const(self.operand.value * self.ref_period)
|
if isinstance(operand, Const):
|
||||||
|
return Const(operand.value * self.ref_period)
|
||||||
else:
|
else:
|
||||||
return super().fold(vars)
|
return MUToS(operand, ref_period=self.ref_period)
|
||||||
|
|
||||||
class SToMU(Conv):
|
class SToMU(Conv):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -120,10 +117,11 @@ class SToMU(Conv):
|
||||||
return self.operand.eval(env) / self.ref_period
|
return self.operand.eval(env) / self.ref_period
|
||||||
|
|
||||||
def fold(self, vars=None):
|
def fold(self, vars=None):
|
||||||
if isinstance(self.operand, Const):
|
operand = self.operand.fold(vars)
|
||||||
return Const(self.operand.value / self.ref_period)
|
if isinstance(operand, Const):
|
||||||
|
return Const(operand.value / self.ref_period)
|
||||||
else:
|
else:
|
||||||
return super().fold(vars)
|
return SToMU(operand, ref_period=self.ref_period)
|
||||||
|
|
||||||
class BinOp(Expr):
|
class BinOp(Expr):
|
||||||
def __init__(self, lhs, rhs):
|
def __init__(self, lhs, rhs):
|
||||||
|
|
Loading…
Reference in New Issue