On Mon, 26 Oct 2009 01:17:59 -0700, thunder wrote:
> Hi
>
> I have a question regarding Fixed point Arithmetic addition.
>
> For example, i have two fixed point numbers:
>
> a = unsigned Q7.8 format (7-bit integer, 8 bit factional). b = unsigned
> Q7.8 format ( " " ).
>
> Now a + b = c, where c is an unsigned Q8.8 result.
>
> Qs: How do I transform c into d, where d is a unsigned Q7.9 result ??
>
> The way i have tried to approach it is as follows:
>
> Integer part
> ----------------
> The way i have thought about the integer part is to say that if bit [15]
> of the result c is a '1', then bits[14:8] of d is b"111_1111",
> otherwise d[14:8] = c[14:8].
>
> Is is correct ??
>
> Fractional Part
> ----------------------
>
> The way i have thought about the fractional part is that for d, i want
> one extra fractional bit to increase the fractional preciion.
>
> The obvious way to me seems to be to add an extra bit at the LSB end: ie
> d[8:0 = c[7:0] & 1'b0.
>
> Is this correct?
Rather than answer that, I'm just going to point out that there's not a
1:1 mapping between Q8.8 and Q7.9 types. So for a good part of the range
of your Q8.8 type you can only approximate the value in Q7.9. So the
question becomes not "is this correct?" but "is this right for my
application?" -- and you know what your application is.
Me, I'd append a zero to the end and I'd saturate to +/- full range (or
to +63.etc and -63.etc -- allowing the b100000... into a signed twos
compliment type gives you a tiny corner case that attracts a huge amount
of nasty bugs).
--
www.wescottdesign.com