PDA

View Full Version : avoiding division


01-21-2007, 03:33 AM
Hi
I got to implement (A*x + B*y)/(x+y).
A and B can take value from 0 to 255. x and y are non-negative
integer i.e. 0 and above.
(x+y) can be max. of 8.
For example if (x+y) is 7. and x is 2
(A*2 + B*5)/7

Is there any way to avoid division by scaling using left right
shift or somethin...??

thanks,

HT-Lab
01-22-2007, 09:10 AM
<[email protected]> wrote in message
news:[email protected] oups.com...
> Hi
> I got to implement (A*x + B*y)/(x+y).
> A and B can take value from 0 to 255. x and y are non-negative
> integer i.e. 0 and above.
> (x+y) can be max. of 8.
> For example if (x+y) is 7. and x is 2
> (A*2 + B*5)/7
>
> Is there any way to avoid division by scaling using left right
> shift or somethin...??
>
> thanks,

Google for restoring and non-restoring dividers, they only require shift and
addition/subtraction. If you want a faster converging method then google for
Newton-Raphson and Goldschmidt, they do require multiplication.

Hans
www.ht-lab.com

Ben Jones
01-22-2007, 09:50 AM
<[email protected]> wrote in message
news:[email protected] oups.com...
> Hi
> I got to implement (A*x + B*y)/(x+y).
> A and B can take value from 0 to 255. x and y are non-negative
> integer i.e. 0 and above.
> (x+y) can be max. of 8.
> For example if (x+y) is 7. and x is 2
> (A*2 + B*5)/7

So x, y, and x+y are extremely small integers (0-8), about 3/4 bits, right?

Why not simply do a reciprocal lookup for (x+y), which is a ROM with 3-input
address, then multiply?

Or perhaps even better, re-arrange your formula to give:

A * (x/(x+y)) + B * (y/(x+y))

Given x and y you can have a lookup table for (x/(x+y)) and (y/(x+y)), just
6-8 address bits. If you want a multi-cycle resource shared implementation
you only need one multiplier, one adder and one lookup ROM. You'll have to
decide (i.e. work out) what precision you need for the lookup though.

Good luck,

-Ben-