Hardware for "A div B" with A and B fixed point

217 Views Asked by At

I need a way to compute how many times a fixed point number B is contained into a fixed point number A. Something like integer division but on non-integer operands. I need to design an hardware block for this operation. My first guess is to use division as shift and subtract and stop when I reach the fractional part but maybe you know better ways to find it.

1

There are 1 best solutions below

0
On

If I understand you correctly you want the integer part of the fractional division, i.e.

C = floor(A / B)

Now, fractional division is not any different than integer division, besides adjusting the decimal point, if you represent A = a * 2^-n and B = b * 2^-m you get

C = floor(A / B) = floor((a / b) * 2^(-n-m))

So you can use the division algorithm for integers (which is essentially shift and subtract) unchanged and ignore (round down) the least significant n+m bits, or more efficiently just stop iterating once you've reached the decimal point.