1
\$\begingroup\$

I've recently started diving deeper into DSP and have come across the term 'fixed point number'. The idea of a fixed point number is simple enough and makes since to me, however, I'm somewhat curious as to how fixed point operations are carried out.

Are fixed point operations carried out by processors with instructions to perform fixed point operations? Or is there usually a dedicated chip?

Thanks!

\$\endgroup\$
  • 3
    \$\begingroup\$ Fixed point operations are basically the same as integer operations except that for divide/multiply, the result needs to be shifted. \$\endgroup\$ – mkeith Aug 16 '16 at 2:53
5
\$\begingroup\$

Fixed point operations are carried out as integer operations, possibly with bit shifts to get things lined up. No special hardware is required to use fixed point math, certainly not an ASIC unless you're trying to do something very specialized. The whole point of fixed point is to get some of the benefits of floating point math without the performance penalty, especially on CPUs that do not support hardware floating point math.

\$\endgroup\$
  • \$\begingroup\$ I would also add that fixed point is used on microprocessors, specialized DSP processors, FPGAs, and ASICs for signal processing operations. Fixed point requires much less hardware to perform arithmetic operations than floating point. For this reason, it is cheaper and often uses less power. \$\endgroup\$ – Chris Hansen Aug 16 '16 at 4:43
2
\$\begingroup\$

I was using fixed point back in the Intel 386 days when processors didn't have floating point hardware. It's a very effective way of using integer units to represent numbers with fractional parts, ideal for low-accuracy 3D and audio processing.

Let's do it in base 10. Suppose we have a fixed arithmetic unit capable of handling 2x four decimal digit inputs multiplying to eight, and you want to compute 4.2 * 3.14 (\$\pi\$ rounded). We move the decimal point two spaces to the right, and our operands are now 0420 and 0314. Do the multiply, to get 00131880. Shift the decimal point back four spaces to the left to get 13.188.

It's exactly the same in binary: if you can operate on 32-bit numbers, then you can do fixed point with a shift of the binary point by 8 or 16 bits. Every time you do a multiply you end up incorporating the shift from both arguments, so you need to shift the result back. Bitshifts are fast.

Addition and subtraction are transparent and don't require extra bitshifts.

(Don't do division, division is hard)

\$\endgroup\$
0
\$\begingroup\$

Fixed point on normal processors works perfectly well, provided (a) the existing word widths (typically 8,16,32,64 bits) satisfy your needs, and either (b) your programming language supports it directly or (c) you keep track of the binary point yourself.

If you need custom word lengths, the compiler (if it supports fixed point) will use the next largest type (or return an error if there is no suitable type)

Option (b) - a language which supports fixed point - is by far the easiest way.

The code it generates just uses the integer instructions, which can be more efficient than floating point instructions (and especially, much faster than FP emulation on CPUs without an FPU), and keeps track of the point, shifting where necessary.

Alternatively, you can implement your own hardware on FPGA, there is no need for ASIC. VHDL-2008 incorporates synthesisable fixed and floating point packages.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.