mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 03:38:25 +08:00
compiler.iodelay: fold MUToS and SToMU.
This commit is contained in:
parent
82b470891f
commit
5cd12ffd28
@ -106,6 +106,12 @@ class MUToS(Conv):
|
|||||||
def eval(self, env):
|
def eval(self, env):
|
||||||
return self.operand.eval(env) * self.ref_period
|
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):
|
class SToMU(Conv):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "s->mu({})".format(self.operand)
|
return "s->mu({})".format(self.operand)
|
||||||
@ -113,6 +119,12 @@ class SToMU(Conv):
|
|||||||
def eval(self, env):
|
def eval(self, env):
|
||||||
return self.operand.eval(env) / self.ref_period
|
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):
|
class BinOp(Expr):
|
||||||
def __init__(self, lhs, rhs):
|
def __init__(self, lhs, rhs):
|
||||||
self.lhs, self.rhs = lhs, rhs
|
self.lhs, self.rhs = lhs, rhs
|
||||||
|
Loading…
Reference in New Issue
Block a user