1. Field of the Invention
This invention relates to the field of data processing systems. More particularly, this invention relates to saturating shift mechanisms within data processing systems.
2. Description of the Prior Art
It is known to provide data processing program instructions which specify shift operations to be performed upon input data values. As a refinement to such mechanisms it is known to combine a saturating function with a shift whereby if the shifted output value is outside of the range of values which can be represented by the bits available within the output data value, then a saturated value is instead returned at the appropriate limiting extreme of the range of values which may be represented. This type of behavior is particularly useful in digital signal processing operations.
Viewed from one aspect the present invention provides apparatus for performing a saturating shift operation upon an input data value to generate an output data value, said apparatus comprising:
The present technique recognizes that the requirement to saturate the output can be identified from the input data value and the shift amount and that it is not necessary to wait until the shifted or rotated value has been generated to make this determination. Performing this evaluation earlier eases timing considerations and thus enables faster operation.
In preferred embodiments of the invention, the shifting is performed by a data value rotating circuit and accordingly a mask value is used to generate the output data value from the rotated data value. Rotation can be considered to be a subset of shifting in general. The mask circuit thus provided can be re-used to perform any required saturation without requiring additional circuitry in the data path. The complexity of performing this saturation determination is effectively transferred into the control plane rather than in the data plane of operation.
In preferred embodiments of the invention, the mask value is also operable to control sign extending if required.
It will be appreciated that the detection of whether or not saturation is required may be performed directly from the input data value or alternatively may be performed from partially shifted or rotated version of the input data value partway through its shifting or rotation. Allowing such control to be made from a partially processed result can enable the shifting or rotation to be commenced prior to the signals being available to control how the input data value is to be evaluated to determine whether or not saturation is required.
In preferred embodiments, improved speed is achieved when the masking circuit comprises a combinatorial logic array.
Whilst the shifting operations may be ones in which data width is maintained, preferred embodiments of the invention are well suited to situations in which shifting results in a simultaneous data width narrowing. This type of behavior is particularly useful in digital signal processing situations where multiply-accumulate sequences have been performed and then the final result needs to be normalized back down to the normal data width.
When such data width reduction takes place, it is preferred to determine whether or not saturation should be required prior to the data width reduction being performed since this simplifies implementation.
The mask values that are applied could take a variety of different forms and may be calculated in a variety of different ways (e.g. from an appropriate combinatorial logic or through lookups from input control signals). In preferred embodiments the mask values have a thermometer coded type of arrangement in which they are formed of at least one of a run of binary ones and a run of binary zeros separating the portion to be maintained and the portion to be masked out. These mask values can be used in their direct form or alternatively as their complement if required and can be reused to give saturated results.
The shifter of the present technique is preferably controllable to either support saturating or non-saturating operation by adjusting control signals to change the mask generation. Similarly, both signed and unsigned variant behavior can be achieved by adjustment of the mask signals to be responsive to the sign of the input data.
Viewed from another aspect the present invention provides a method of performing a saturating shift operation upon an input data value to generate an output data value, said method comprising the steps of:
The above, and other objects, features and advantages of this invention will be apparent from the following detailed description of illustrative embodiments which is to be read in connection with the accompanying drawings.
The mask to be used, either a saturating mask or a non-saturating mask is selected by unit 8 and then applied by a combinatorial logic array 10 to generate an output data value.
A mode signal is also input to the mask generating mechanisms 4, 6 and serves to selectively switch between such saturating and non-saturating modes of operation and signed and un-signed data representations within the input data word. Sign extension can be accommodated by appropriate selection of a mask to be applied by the combinatorial logic, either in a single stage or in a multi-stage masking operation. Within a scaler embodiment, the data width may also be narrowed by appropriate masking and control if desired. Within a SIMD embodiment the data width of each data element may be narrowed by appropriate masking and control, e.g. two registers input and one register output. Saturation detection is performed before narrowing. The saturation detection may be responsive to a partially rotated/shifted version of the input data value rather than the unaltered data value if desired.
A significant feature of the circuit of
Viewed in another way, the AND gates 14 make sure that no 1s from the rotation are passed through to the final result when we staurate to MAX −ve. The OR gates 16 make sure there is always a 1 in the result when we staurate to MAX +ve, regardless of the rotation value. The XOR gate 17 inverts the most significant bit when we have a signed saturate.
As an example of mask values that may be used in the example of
s = Signed & Data[3]
a = (D[3] & Saturate & ˜Signed) | (˜D[3] & D[2] & Saturate & Signed)
b = (|(D[3:2]) & Saturate & ˜Signed) | (˜D[3] & (|D[2:1]) & Saturate & Signed)
c = (|(D[3:1]) & Saturate & ˜Signed) | (˜D[3] & (|D[2:0]) & Saturate & Signed)
d = (|(D[3:0]) & Saturate & ˜Signed) | (˜D[3] & (|D[2:0]) & Saturate & Signed)
X = Signed & Saturate & (a | b | c| d)
Although illustrative embodiments of the invention have been described in detail herein with reference to the accompanying drawings, it is to be understood that the invention is not limited to those precise embodiments, and that various changes and modifications can be effected therein by one skilled in the art without departing from the scope and spirit of the invention as defined by the appended claims.