P32A 001000 |
rt |
rs |
rd |
x |
0100101 |
101 |
6 |
5 |
5 |
5 |
1 |
7 |
3 |
PRECRQ_RS.PH.W rd, rs, rt |
DSP |
Precision Reduce Fractional Words to Halfwords With Rounding and Saturation |
Precision Reduce Fractional Words to Halfwords With Rounding and Saturation
Reduce the precision of two fractional words to produce two fractional halfword values, with rounding and saturation.
rd = truncQ15SatRound(rs31..0) || truncQ15SatRound(rt31..0)
The two Q31 fractional word values in each of registers rs and rt are used to create two Q15 fractional halfword values that are written to the two halfword elements in destination register rd. The fractional word from the rs register is used to create the left-most Q15 fractional halfword result in rd, and the fractional word from the rt register is used to create the right-most halfword value.
Each input Q31 fractional value is rounded and saturated before being truncated to create the Q15 fractional halfword result. First, the value 0x00008000 is added to the input Q31 value to round even, creating an interim rounded result.
If this addition causes overflow, the interim rounded result is saturated to the maximum Q31 value (0x7FFFFFFF hexadecimal). Then, the 16 least-significant bits of the interim rounded and saturated result are discarded and the 16 most-significant bits are written to the destination register in the appropriate position.
If either of the rounding operations results in overflow and saturation, a 1 is written to bit 22 in the DSPControl register within the ouflag field.
No data-dependent exceptions are possible.
The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.
ValidateAccessToDSPResources() tempB15..0 = trunc16Sat16Round( GPR[rs]31..0 ) tempA15..0 = trunc16Sat16Round( GPR[rt]31..0 ) GPR[rd]31..0 = tempB15..0 || tempA15..0 function trunc16Sat16Round( a31..0 ) temp32..0 = ( a31 || a31..0 ) + 0x00008000 if ( temp32 != temp31 ) then temp32..0 = 0 || 0x7FFFFFFF DSPControlouflag:22 = 1 endif return temp31..16 endfunction trunc16Sat16Round
Reserved Instruction, DSP Disabled