Basically, I want to do bit slicing on a signed integer sfixN (having bits N-1 (sign) down to 0). E.g., I want to grab bit N-1, put it in OR gate, etc.) If you try to blindly use the Extract Bits block with signed integers, the output integers are signed, so you can't get single bits.
My solution was to use a convert block with input fixdt(1, N, 0) and output fixdt(0, N, 0), (since these are integers, setting Input and output to have equal RWW or SI give the same result). This works as expected – non-negative numbers are passed through and a negative number x, comes out as x + 2^N. However, this is always flagged as an overflow.
Is this the best way to extract bits from signed numbers? If so, is there a way to turn off warnings for just this block? If not, I'd love to know the right way.
Thanks, Dara
PS: I searched and found http://www.mathworks.com/matlabcentral/answers/98131-how-do-i-convert-an-unsigned-integer-to-a-signed-integer-without-causing-an-overflow-or-using-typeca which isn't quite the same as my question I don't think.
Best Answer