5-10
ColdFire CF4e Core User’s Manual
For More Information On This Product,
Go to: www.freescale.com
Memory Map/Register Set
A store accumulator instruction is executed (MOV.L ACCx,Rx). The lsbs of the
48-bit accumulator logic are used to round the resulting 16- or 32-bit value. If
MACSR[S/U] = 0, the low-order 8 bits are used to round the resulting 32-bit
fraction. If MACSR[S/U] = 1, the low-order 24 bits are used to round the resulting
16-bit fraction.
A MAC (or MSAC) instruction with 32-bit operands is executed. If MACSR[R/T]
is zero, multiplying two 32-bit numbers creates a 64-bit product that is truncated to
the upper 40-bits; otherwise, it is rounded using round-to-nearest (even) method.
To understand the round-to-nearest-even method, consider the following example involving
the rounding of a 32-bit number, R0, to a 16-bit number. Using this method, the 32-bit
number is rounded to the closest 16-bit number possible. Let the high-order 16 bits of R0
be named R0.U and the low-order 16 bits be R0.L.
If R0.L is less than 0x8000, the result is truncated to the value of R0.U.
If R0.L is greater than 0x8000, the upper word is incremented (rounded up).
If R0.L is 0x8000, R0 is half-way between two 16-bit numbers. In this case,
rounding is based on the lsb of R0.U, so the result is always even (lsb = 0).
— If the lsb of R0.U = 1 and R0.L = 0x8000, the number is rounded up.
— If the lsb of R0.U = 0 and R0.L =0x8000, the number is rounded down.
This method minimizes rounding bias and creates as statistically correct an answer
as possible.
The rounding algorithm is summarized in the following pseudocode:
if R0.L < 0x8000
then Result = R0.U
else if R0.L > 0x8000
then Result = R0.U + 1
else if LSB of R0.U = 0
then Result = R0.U
else Result = R0.U + 1
/* R0.L = 0x8000 */
The round-to-nearest-even technique is also known as convergent rounding.
5.4.1.1.2 Saving and Restoring the EMAC Programming Model
The presence of rounding logic in the output datapath of the EMAC requires that special
care be taken during the save and restore of the EMAC programming model. In particular,
any result rounding modes must be disabled during the save/restore process so the exact
bit-wise contents of the EMAC registers are accessed. Consider the following memory
structure containing the EMAC programming model:
struct macState {
int acc0;
int acc1;
int acc2;
int acc3;
int accext01;
int accext02;
int mask;
F
Freescale Semiconductor, Inc.
n
.