I am implementing (A+B-C-D-E) in fixed-point logic. I am implementing
it as ((A+B)-((C+D)+E)). A, B, C, D, and E are all unsigned, more or
less uniformly distributed over the range [0, MAX), where MAX>>1, and
each also carries several fractional bits. The final result is signed.
I need for the accuracy of the final result to be reasonably close to
±½, but I also need to carry as few bits as possible in the arithmetic
operations to minimize real estate and maximize speed. Is there a
deterministic way to find the minimum number of fractional bits to keep
in A, B, C, D, E, (A+B), (C+D), and ((C+D)+E) at the inputs to the
adders, and whether to round or truncate?
"Greg Berchin" <[email protected]> wrote in message
news:[email protected]..
>I am implementing (A+B-C-D-E) in fixed-point logic. I am implementing
> it as ((A+B)-((C+D)+E)). A, B, C, D, and E are all unsigned, more or
> less uniformly distributed over the range [0, MAX), where MAX>>1, and
> each also carries several fractional bits. The final result is signed.
> I need for the accuracy of the final result to be reasonably close to
> ±½, but I also need to carry as few bits as possible in the arithmetic
> operations to minimize real estate and maximize speed. Is there a
> deterministic way to find the minimum number of fractional bits to keep
> in A, B, C, D, E, (A+B), (C+D), and ((C+D)+E) at the inputs to the
> adders, and whether to round or truncate?
>
> Thanks,
> Greg
If the inputs ABCDE are undeterministic, then either A+B or A+C or whatever
doesn't
matter.
The goal of your "I need for the accuracy of the final result to be
reasonably close to
±½, " is pretty ambiguous.
> "Greg Berchin" <[email protected]> wrote in message
> news:[email protected]..
>>I am implementing (A+B-C-D-E) in fixed-point logic. I am implementing
>> it as ((A+B)-((C+D)+E)). A, B, C, D, and E are all unsigned, more or
>> less uniformly distributed over the range [0, MAX), where MAX>>1, and
>> each also carries several fractional bits. The final result is signed.
>> I need for the accuracy of the final result to be reasonably close to
>> ±½, but I also need to carry as few bits as possible in the arithmetic
>> operations to minimize real estate and maximize speed. Is there a
>> deterministic way to find the minimum number of fractional bits to keep
>> in A, B, C, D, E, (A+B), (C+D), and ((C+D)+E) at the inputs to the
>> adders, and whether to round or truncate?
>>
>> Thanks,
>> Greg
>
> If the inputs ABCDE are undeterministic, then either A+B or A+C or whatever
> doesn't
> matter.
>
> The goal of your "I need for the accuracy of the final result to be
> reasonably close to
> ±½, " is pretty ambiguous.
I'd look at max/mins. A+B has a max of 2*MAX and a min of 0. C+D+E has
a max of 3*MAX and a min of 0. Thus A+B-(C+D+E) has a max of 2*MAX and
a min of -1*3*MAX. You must carry enough bits to cover this range or
you'll lose something (either via saturation or roundoff, depending
on how you scale things).
--
% Randy Yates % "Watching all the days go by...
%% Fuquay-Varina, NC % Who are you and who am I?"
%%% 919-577-9882 % 'Mission (A World Record)',
%%%% <[email protected]> % *A New World Record*, ELO http://home.earthlink.net/~yatescr
Answering my own question; I think I've got it figured out. (Amazing
what a good night's sleep will do after a long week -- including
Saturday -- working on this stuff. Last night I just couldn't get my
head around it.)
Let's say that A, B, C, and D are all truncated to integers. Then each
has a tolerance of +0/-1.
Then (A+B) and (C+D) are each +0/-2.
And (A+B)-(C+D) is +2/-2.
If E is rounded, then it has a tolerance of ±½.
And (A+B)-(C+D)-E is ±2½.
If everything is rounded instead of truncated, the results are the same.
So if I carry two fractional bits, my final result will be
±2.5*0.25 = ±0.625.
Three fractional bit will give me ±2.5*0.125 = ±0.3125.