Skip to content

Commit

Permalink
Fix #114
Browse files Browse the repository at this point in the history
  • Loading branch information
jandecaluwe committed Sep 18, 2015
1 parent 97f9b34 commit 68ac94c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions myhdl/conversion/_toVHDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,14 @@ def visit_BoolOp(self, node):
self.write(")")

def visit_UnaryOp(self, node):
# in python3 a negative Num is represented as an USub of a positive Num
# Fix: restore python2 behavior by a shortcut: invert value of Num, inherit
# vhdl type from UnaryOp node, and visit the modified operand
if isinstance(node.op, ast.USub) and isinstance(node.operand, ast.Num):
node.operand.n = -node.operand.n
node.operand.vhd = node.vhd
self.visit(node.operand)
return
pre, suf = self.inferCast(node.vhd, node.vhdOri)
self.write(pre)
self.write("(")
Expand Down

0 comments on commit 68ac94c

Please sign in to comment.