Motorola ColdFire MCF5281 User Manual page 113

Motorola microcontroller user's manual
Table of Contents

Advertisement

• Execution of a MAC (or MSAC) instruction with 32-bit operands. 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
The round-to-nearest-even technique is also known as convergent rounding.
3.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 EMAC's save/restore process. 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;
int macsr;
} macState;
MOTOROLA
then Result = R0.U + 1
else if lsb of R0.U = 0
then Result = R0.U
else Result = R0.U + 1
Chapter 3. Enhanced Multiply-Accumulate Unit (EMAC)
Memory Map/Register Set
/* R0.L = 0x8000 */
3-9

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfire mcf5282

Table of Contents