A saturation-capable arithmetic logic unit (ALU) includes a
general-purpose comparator coupled to receive a data value and a
saturation threshold value during a saturation operation. Using the
general-purpose comparator of the ALU for saturation minimizes circuit
area without adversely affecting microprocessor performance. In an
unsigned saturation operation, the data value is replaced with the
threshold value when the data value is greater than the threshold value.
In a signed saturation operation, positive data values are compared with
an upper threshold value and negative data values are compared with a
lower threshold value. In this manner, the data value need only be
compared to either the upper or lower threshold value, rather than both.
If the data value falls outside the bounds set by the upper and lower
threshold values, the data value is replaced with the nearest threshold
value.