forked from M-Labs/artiq
1
0
Fork 0

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
1 changed files with 2 additions and 2 deletions

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)