1
\$\begingroup\$

I am developing a core on Spartan 6 which needs to do divisions like 1/6,2/4 etc... so the values are always between 0 and 1. As I dont need the precision of floating point I am want to use a fixed point divider as division is costly. I found some dividers on opencores.org but all of them can computer normal division problems like 4/2,8/4 etc... well but cannot do 1/6 kind of operations. Can anyone point to a suitable divider for my application

Thank You

asked Jan 19, 2013 at 17:11
\$\endgroup\$
9
  • 1
    \$\begingroup\$ Are the divisors constants or do they vary? \$\endgroup\$ Commented Jan 19, 2013 at 17:54
  • 2
    \$\begingroup\$ What kind of bandwidth (results per second) and latency does your application require? I developed a pipelined divider that can deliver a result per clock @150 MHz, but that's because I needed to compute 1024 scale factors during the vertical blanking interval of a HD video stream. If you don't need that kind of bandwidth, there are other approaches that are less resource-intensive. My divider is in VHDL; it could be translated to Verilog (but not for free). \$\endgroup\$ Commented Jan 19, 2013 at 17:56
  • \$\begingroup\$ @JoeHass: If the divisors are constants, you don't need a divider at all; you just multiply by 1/x instead. \$\endgroup\$ Commented Jan 19, 2013 at 17:59
  • \$\begingroup\$ @DaveTweed: Yes, that's exactly why I asked. I've learned never to take anything for granted on stackexchange. \$\endgroup\$ Commented Jan 19, 2013 at 18:01
  • 1
    \$\begingroup\$ Actually, even if the divisors vary, computing 1/x is a very viable approach if you don't need a result per clock. The Newton-Rhapson method just needs one multiplier to compute 1/x in a few clocks, and then one more multiply gets you your quotient. There are many commercial computers throughout history that have used exactly this method. \$\endgroup\$ Commented Jan 19, 2013 at 18:12

1 Answer 1

3
\$\begingroup\$

You say that you have found dividers that do "normal" division. Fixed-point division is normal division, except that the dividend must be scaled up (shifted left). Shift the dividend to the left 8 places (multiply by 256), then do a normal division. The fixed-point fractional result is equal to the integer result from the division, divided by 256. So, if you want to calculate 1/6 you will actually divide (1*256)/6, which is 42. The real result is therefore 42/256 = 0.1640625, which is reasonably close to the true value of 0.1666... We would normally say that this result is a fixed-point number with 8 bits to the right of the decimal point. If you want greater precision, use a larger scale factor.

answered Jan 22, 2013 at 19:39
\$\endgroup\$
4
  • \$\begingroup\$ My problem is if I do 1/4 with this divider I am getting zero as answer. Following your method if I do 256/4 I get 64. Again if I do 64/256 I would get zero because any division with numerator less than denominator is resulting in zero. What to do ? :( \$\endgroup\$ Commented Feb 19, 2013 at 0:01
  • \$\begingroup\$ You have to scale the dividend up. If you want to do integer division and have the result represent a fraction, you have to multiply the dividend by some power of 2 beforehand. \$\endgroup\$ Commented Feb 20, 2013 at 2:55
  • \$\begingroup\$ A bit of example code would help me a lot. I tried and tried but had no success at all. Please help me \$\endgroup\$ Commented Mar 7, 2013 at 21:21
  • \$\begingroup\$ If you are doing integer divisions then it is impossible to get a result that is not an integer. The key concept is how you interpret that integer. In your example above you would not try to divide 64/256, you would just recognize that the result is a fraction multiplied by the integer 256. \$\endgroup\$ Commented Mar 19, 2013 at 21:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.