Re: [myhdl-list] Slicing an unsigned intbv to a signed one
Brought to you by:
jandecaluwe
|
From: Jan D. <ja...@ja...> - 2008-06-20 08:26:59
|
Günter Dannoritzer wrote:
> Now that brings me back to think about the idea of an extra function
> based on concat() that is convertible with toVerilog/VHDL. That would
> not add extra code to intbv, but would allow to create an intbv instance
> with bit slices and allow to manipulate the sign.
I would prefer to add a new method to intbv instead of a function in the
myhdl namespace. Adding a new function always feels a bit like a "defeat"
to me - when possible I prefer methods to keep namespaces clean and tie
operators to their type.
"concat" is a function because it has to work on several different types.
> So what about having a function like:
>
> concatSigned(sign, slice1, [slice2, ...[sliceN]..])
>
> It will return an intbv by concatenating the slice(s) and setting the
> sign based on the specified sign.
With the intbv.signed() method, this could be done as follows:
concat(....).signed()
Jan
--
Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com
Kaboutermansstraat 97, B-3000 Leuven, Belgium
From Python to silicon:
http://myhdl.jandecaluwe.com
|