6 rounding modes, Rounding modes -21, Rounding position in relation to scaling mode -21 – Freescale Semiconductor StarCore SC140 User Manual

Page 53: 2 unsigned comparison, 1 convergent rounding

Advertising
background image

DALU

SC140 DSP Core Reference Manual

2-21

2.2.2.5.2 Unsigned Comparison

When performing an unsigned comparison, the condition code computation is different from signed
comparisons. The most significant bit of the unsigned operand has a positive weight, while in signed
representation it has a negative weight. Special instructions are implemented to support unsigned
comparison such as CMPHI (compare greater).

2.2.2.6 Rounding Modes

The SC140 DALU performs rounding of the full register to single precision if requested in the instruction.
The high portion of the register is rounded according to the contents of the low portion of the register.
Then the low portion is cleared. The boundary between the low portion and the high portion is determined
by the scaling mode bits (S0 and S1) in the SR. Two types of rounding are implemented, convergent
rounding and two’s complement rounding. The type of rounding is selected by the rounding mode (RM)
bit in the SR.

Table 2-13 shows the boundary between the high portion and the low portion depending on scaling. The
scaling adjustment is disabled if arithmetic saturation mode is selected.

2.2.2.6.1 Convergent Rounding

Convergent rounding (also called round-to-nearest even number) is the default rounding mode. It is
selected when the rounding mode (RM) bit in the SR is cleared. The traditional rounding method rounds up
any value greater than one-half, and rounds down any value less than one-half. However, the question
arises as to which way one-half should be rounded. If it is always rounded one way, the results are
eventually biased in that direction. Convergent rounding, however, removes the bias by rounding down if
the high portion is even (LSB = 0) and rounding up if the high portion is odd (LSB = 1).

For no scaling, the higher portion (HP) of the register is bits 39:16; the low portion (LP) is bits 15:0. The
HP is incremented by one bit if the LP was > 1/2, or if the LP = 1/2 and bit 16 was 1 (odd). The HP is left
alone if the LP was <1/2, or if LP = 1/2 and bit 16 was 0 (even). After rounding, the LP is cleared. If
scaling down is selected, the HP is bits 39:17 and the LP is bits 16:0. If scaling up is selected, the HP is bits
39:15 and the LP is bits 14:0.

Table 2-13. Rounding Position in Relation to Scaling Mode

S1

S0

Scaling Mode

High Portion

Low Portion

0

0

No Scaling

39–16

15–0

0

1

Scale Down

39–17

16–0

1

0

Scale Up

39–15

14–0

Advertising