2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-19 00:16:29 +08:00

compiler.iodelay: fold and eval SToMU to an int, not float.

This commit is contained in:
whitequark 2015-11-24 00:19:33 +08:00
parent 178ff74da2
commit abb36b42be

View File

@ -114,12 +114,12 @@ class SToMU(Conv):
return "s->mu({})".format(self.operand) return "s->mu({})".format(self.operand)
def eval(self, env): def eval(self, env):
return self.operand.eval(env) / self.ref_period return int(self.operand.eval(env) / self.ref_period)
def fold(self, vars=None): def fold(self, vars=None):
operand = self.operand.fold(vars) operand = self.operand.fold(vars)
if isinstance(operand, Const): if isinstance(operand, Const):
return Const(operand.value / self.ref_period) return Const(int(operand.value / self.ref_period))
else: else:
return SToMU(operand, ref_period=self.ref_period) return SToMU(operand, ref_period=self.ref_period)