![Freescale Semiconductor ColdFire MCF5211 Reference Manual Download Page 91](http://html1.mh-extra.com/html/freescale-semiconductor/coldfire-mcf5211/coldfire-mcf5211_reference-manual_2330619091.webp)
Multiply-Accumulate Unit (MAC)
MCF5213 ColdFire® Integrated Microcontroller Reference Manual, Rev. 3
Freescale Semiconductor
4-5
4.4.1.1
Fractional Operation Mode
This section describes behavior when the fractional mode is used (MACSR[F/I] is set).
4.4.1.1.1
Rounding
When the processor is in fractional mode, there are two operations during which rounding can occur:
1. The 32-bit accumulator is moved into a general purpose register. If MACSR[S/U] is cleared, the
accumulator is stored as is in the destination register; if it is set, the 32-bit value is rounded to a
16-bit value using the round-to-nearest (even) method. The resulting 16-bit number is stored in the
lower word of the destination register. The upper word is zero-filled. The accumulator value is
unaffected by this rounding procedure.
2. 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 truncated to the upper 32 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 equals 0).
— If the lsb of R0.U equals 1 and R0.L equals 0x8000, the number is rounded up.
— If the lsb of R0.U equals 0 and R0.L equals 0x8000, the number is rounded down.
This method minimizes rounding bias and creates as statistically correct an answer as possible.
Table 4-3. Summary of S/U, F/I, and R/T Control Bits
S/U
F/I
R/T
Operational Modes
0
0
x
Signed, integer
0
1
0
Signed, fractional
Truncate on MAC.L and MSAC.L
No round on accumulator stores
0
1
1
Signed, fractional
Round on MAC.L and MSAC.L
No round on accumulator stores
1
0
x
Unsigned, integer
1
1
0
Signed, fractional
Truncate on MAC.L and MSAC.L
Round-to-16-bits on accumulator stores
1
1
1
Signed, fractional
Round on MAC.L and MSAC.L
Round-to-16-bits on accumulator stores