Blog‎ > ‎

### Saturation Arithmetic

posted Apr 29, 2018, 10:56 PM by MUHAMMAD MUN`IM AHMAD ZABIDI   [ updated Apr 29, 2018, 11:06 PM ]
 Take a sinewave normalized to 1 in 16 bits. By the way, this is how a sinewave looks like in Q15 format. Assume the signal is passed through an amplifier has a gain of 2. The resulting numbers would overflow and alias. That would be totally wrong in terms of signal amplification since it no longer has any resemblance of the original wave. That is where saturation arithmetic comes. Saturation arithmetic simply clips the positive values to 32767 (largest value in 16-bits) and negative values to -32768 (minimum value in -32768). Multiplying each value in the original sinewave by 2 gives the following result: The last waveform was generated by Python. The others may generated by commenting and modifying the code as appropriate. ```import numpy as np import matplotlib.pyplot as plot time = np.arange(0, 10, 0.01); amplitude = 65536*np.sin(time) clipped = np.clip(amplitude, -32768, 32767) #aliased = np.where(amplitude>32767,amplitude-65536,amplitude) #aliased2 = np.where(aliased<-32768,aliased+65536,aliased) print (clipped) # Plot a sine wave using time and amplitude obtained for the sine wave plot.plot(time, clipped) plot.grid(True, which='both') plot.axhline(y=0, color='k') plot.show() ```
Comments