mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
Fixed issue #10 (2)
This commit is contained in:
parent
840c858791
commit
77de13ac66
@ -2009,6 +2009,8 @@ class _AnnotateTypesVisitor(ast.NodeVisitor, _ConversionMixin):
|
||||
for a in node.args:
|
||||
if isinstance(a, ast.Str):
|
||||
a.vhd = vhd_unsigned(a.vhd.size)
|
||||
elif isinstance(a.vhd, vhd_signed):
|
||||
a.vhd = vhd_unsigned(a.vhd.size)
|
||||
s += a.vhd.size
|
||||
node.vhd = vhd_unsigned(s)
|
||||
elif f is bool:
|
||||
|
24
myhdl/test/bugs/test_issue_10.py
Normal file
24
myhdl/test/bugs/test_issue_10.py
Normal file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/python2.7-32
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import myhdl
|
||||
|
||||
def unsigned(width, value=0, cls=myhdl.intbv):
|
||||
"""Create an unsigned signal based on a bitvector with the
|
||||
specified width and initial value.
|
||||
"""
|
||||
return myhdl.Signal(cls(value, 0, 2**width))
|
||||
|
||||
def signed(width, value=0, cls=myhdl.intbv):
|
||||
"""Create an signed signal based on a bitvector with the
|
||||
specified width and initial value.
|
||||
"""
|
||||
return myhdl.Signal(cls(value, -2**(width-1), 2**(width-1)))
|
||||
|
||||
a = unsigned(4, 8)
|
||||
b = signed(28, -3)
|
||||
|
||||
#print "%08X" % myhdl.concat(a, b)
|
||||
#print hex(myhdl.concat(a, b))
|
||||
def test_issue_10():
|
||||
assert myhdl.concat(a, b) == 0x8ffffffd
|
40
myhdl/test/bugs/test_issue_10_1.py
Normal file
40
myhdl/test/bugs/test_issue_10_1.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python2.7-32
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Failed VHDL code example
|
||||
"""
|
||||
|
||||
from myhdl import *
|
||||
from myhdl.conversion import verify
|
||||
|
||||
def unsigned(width, value=0, cls=intbv):
|
||||
"""Create an unsigned signal based on a bitvector with the
|
||||
specified width and initial value.
|
||||
"""
|
||||
return Signal(cls(value, 0, 2**width))
|
||||
|
||||
def signed(width, value=0, cls=intbv):
|
||||
"""Create an signed signal based on a bitvector with the
|
||||
specified width and initial value.
|
||||
"""
|
||||
return Signal(cls(value, -2**(width-1), 2**(width-1)))
|
||||
|
||||
|
||||
flags = unsigned(4)
|
||||
position = signed(28)
|
||||
|
||||
def Logic(flags, position):
|
||||
|
||||
conc = unsigned(32)
|
||||
|
||||
@instance
|
||||
def doit():
|
||||
flags.next = 4
|
||||
position.next = 28
|
||||
yield delay(10)
|
||||
conc.next = concat(flags, position)
|
||||
yield delay(10)
|
||||
print conc
|
||||
return doit
|
||||
|
||||
def test_issue_10_1():
|
||||
assert verify(Logic, flags, position) == 0
|
Loading…
x
Reference in New Issue
Block a user