saturation

Branchless Saturating Integer Arithmetic

This project is maintained by paulhuggett

A Simple Mixer

To show how useful a saturating addition function can be, we can look at a simple DSP signal mixer. This takes two input signals and combines them to produce a single output. It’s common for DSP systems to use fixed-point integers to represent amplitudes. The choices made in the formatting of these values imposes a strict limit on the range of number that can be represented. The hypothetical system described here can reproduce values in the range [-1.0, 1.0].

The first two charts below show two input sinusoids. You can experiment with changing the frequency, amplitude, and phase of each. The next three charts show the result of mixing the two input signals.

It should be clear that neither saturating nor modulo addition will be able to produce the desired output — there will be distortion of some kind regardless of our choice — but that using saturating arithmetic yields a waveform that is much closer to the ideal.

Input 1
Input 2
Desired Output
Actual Output: Saturating Addition
Actual Output: Modulo Addition

Compare the results when using saturating addition or modulo addition to the desired output. Saturating addition has produced output which is much closer to the ideal output.