diff --git a/.gitignore b/.gitignore index 387b4fc9..267af9a0 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ myhdl/**/*.vhd # Pycharm ide junk .idea/ +/.pytest_cache/ diff --git a/myhdl/conversion/_toVHDL.py b/myhdl/conversion/_toVHDL.py index b1697e17..e3aec5c4 100644 --- a/myhdl/conversion/_toVHDL.py +++ b/myhdl/conversion/_toVHDL.py @@ -1251,7 +1251,6 @@ class _ConvertVisitor(ast.NodeVisitor, _ConversionMixin): self.write("to_signed(%s, %s)" % (n, node.vhd.size)) else: self.write('signed\'("%s")' % tobin(n, node.vhd.size)) - else: if n < 0: self.write("(") @@ -2295,18 +2294,18 @@ class _AnnotateTypesVisitor(ast.NodeVisitor, _ConversionMixin): if sys.version_info >= (3, 8, 0): def visit_Constant(self, node): - if node.value in (True, False, None): - # NameConstant - node.vhd = inferVhdlObj(node.value) - elif isinstance(node.value, str): - # Str - node.vhd = vhd_string() - elif isinstance(node.value, int): + if isinstance(node.value, int): # Num if node.value < 0: node.vhd = vhd_int() else: node.vhd = vhd_nat() + elif node.value in (True, False, None): + # NameConstant + node.vhd = inferVhdlObj(node.value) + elif isinstance(node.value, str): + # Str + node.vhd = vhd_string() node.vhdOri = copy(node.vhd) else: