[vhdl-200x-ft] Fixed point sizing problem

From: David Bishop <dbishop_at_.....>
Date: Thu Feb 24 2005 - 09:18:50 PST
I was running some boundary test on the fixed point packages, and
I came up with some sizing problems.
   -- sfixed(a downto b) * sfixed(c downto d) = sfixed(a+c   downto b+d)

Suppose we have:
x := sfixed (3 downto -3) := "1000.000" -- -8
Then "x*x" the maximum result would be "6 downto -6", or "0111111.111111"
which is 61.9, not 62.

We need to add one more bit here.  New rule would be:
   -- sfixed(a downto b) * sfixed(c downto d) = sfixed(a+c+1 downto b+d)

Next, what if we do the following:
   -- sfixed(a downto b) / sfixed(c downto d) = sfixed(a-d   downto b-c)
x := sfixed (3 downto -3) := "1000.000" -- -8
y := sfixed (3 downto -3) := "1111.111" -- -0.125
Then x / y the maximum result would be "6 downto -6", or "0111111.111111"
which is 61.9, not 62.

We need to add one more bit here.  New rule would be:
   -- sfixed(a downto b) / sfixed(c downto d) = sfixed(a-d+1 downto b-c)
(the minimum bounds still work)

Why didn't I see this before you ask?
I was doing the following:
x := "1000000"; -- -8
mulres := x * x;
mulrest := to_sfixed (64, mulrest'high, mulrest'low);
BOTH of these saturated to "0111111.111111", so the compare worked.


-- 
David W. Bishop dbishop@vhdl.org       All standard disclaimers apply.
Received on Thu Feb 24 09:18:58 2005

This archive was generated by hypermail 2.1.8 : Thu Feb 24 2005 - 09:19:56 PST