Correct, thanks for the bug report, and for entering it in BitBucket.
This is solved in development.
On 08/09/2014 10:17 AM, Thomas Heller wrote:
> I expected myhdl.concat to return a bit-wise concatenation of the arguments.
> However, when I use concat(unsigned, signed) this is not the case.
> The following program prints '7FFFFFFD' instead of '8FFFFFFD':
>
> <code>
> #!/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)
> </code>
>
> Is this correct? Changing (in myhdl 0.8, module _concat.py) this line
> gives the result that I expected:
>
> --- _concat.py~ Mon Aug 4 12:20:26 2014
> +++ _concat.py Sat Aug 9 10:15:05 2014
> @@ -65,7 +65,7 @@
> if not w:
> raise TypeError, "concat: arg on pos %d should have
> length" % (i+1)
> width += w
> - val = val*(2**w) + v
> + val = val*(2**w) | (v % 2**len(v))
>
> if basewidth:
> return intbv(val, _nrbits=basewidth + width)
>
>
> Thomas
>
>
> ------------------------------------------------------------------------------
>
--
Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com
Python as a HDL: http://www.myhdl.org
VHDL development, the modern way: http://www.sigasi.com
World-class digital design: http://www.easics.com
|