Round (dalu), Description, Operation assembler syntax – Freescale Semiconductor StarCore SC140 User Manual
Page 673

RND
SC140 DSP Core Reference Manual
A-359
RND
Round (DALU)
RND
Description
Two types of rounding can be used: convergent rounding (round to the nearest even number) or two’s
complement rounding. The type of rounding is selected by the rounding mode bit (RM) in SR. The default
mode is convergent rounding (SR[3] = 0).
In both rounding modes, a rounding constant (RC) is first added to the source data. The value of the
rounding constant added is determined by the scaling mode bits S0 and S1 in SR. A 1 is positioned in the
rounding constant aligned with the MSB of the scaled LP. The rounding constant weight is actually equal
to half the weight of the scaled HP’s LSB.
For two’s complement rounding, the scaled LP bits are then truncated. Numbers with an original value of
1/2 in the scaled LP are rounded up, resulting in a small positive bias.
If convergent rounding is used, the result of the addition is tested. If all the bits of the result to the right of
(including the rounding position) are cleared, then the bit to the left of the rounding position is cleared in
the result, ensuring that the result is even. An even result eliminates the two’s complement bias where 1/2
is always rounded up.
See
Section 2.2.2.6, “Rounding Modes,”
on page 2-21 for more detailed information.
The following table shows the rounding position (LP MSB) and rounding constant (RC) as determined by
the scaling mode bits:
Operation
Assembler Syntax
Rnd(Da)
→ Dn
RND Da,Dn
RND Da,Dn
Rounds the 40-bit value in the source data register (Da) and stores the result in the destination data register
(Dn). In the round function, the contribution of the least significant bits is rounded into the HP of the
destination data register by adding a rounding constant RC to the LS bits of the source data register. The
boundary between the LP and HP is determined by the scaling mode bits S0 and S1 in SR. The LSBs of the
result are cleared. The number of LSBs cleared is determined by the scaling mode bits in SR. All bits to the
right of (including the rounding position) are cleared in the result.
Rounding
Rounding Constant
(RC) Bits
S1
S0
Scaling Mode
Position
39–17
16
15
14
13–0
0
0
No Scaling
15
0 . . . 0
0
1
0
0 . . . 0
0
1
Scale Down
16
0 . . . 0
1
0
0
0 . . . 0
1
0
Scale Up
14
0 . . . 0
0
0
1
0 . . . 0