MPY32 Operation
280
SLAU367P – October 2012 – Revised April 2020
Copyright © 2012–2020, Texas Instruments Incorporated
32-Bit Hardware Multiplier (MPY32)
NOTE:
Saturation in fractional mode
In case of multiplying –1.0 × –1.0 in fractional mode, the result of +1.0 is out of range, thus,
the saturated result gives the most positive result.
When using multiply-and-accumulate operations, the accumulated values are saturated as if
MPYFRAC = 0; only during read accesses to the result registers the values are saturated
taking the fractional mode into account. This provides additional dynamic range during the
calculation and only the end result is then saturated if needed.
The following example illustrates a special case showing the saturation function in fractional mode. It also
uses the 8-bit functionality of the MPY32 module.
; Turn on fractional and saturation mode,
; clear all other bits in MPY32CTL0:
MOV
#MPYFRAC,&MPY32CTL0
;Pre-load result registers to demonstrate overflow
MOV
#0,&RES3
;
MOV
#0,&RES2
;
MOV
#07FFFh,&RES1
;
MOV
#0FA60h,&RES0
;
MOV.B
#050h,&MACS_B
; 8-bit signed MAC operation
MOV.B
#012h,&OP2_B
; Start 16x16 bit operation
MOV
&RES0,R6
; R6 = 0FFFFh
MOV
&RES1,R7
; R7 = 07FFFh
The result is saturated because already the result not converted into a fractional number shows an
overflow. The multiplication of the two positive numbers 00050h and 00012h gives 005A0h. 005A0h added
to 07FFF FA60h results in 8000 059Fh, without MPYC being set. Because the MSB of the unmodified
result RES1 is 1 and MPYC = 0, the result is saturated according
NOTE:
Validity of saturated result
The saturated result is valid only if the registers RES0 to RES3, the size of OP1 and OP2,
and MPYC are not modified.
If the saturation mode is used with a preloaded result, user software must ensure that MPYC
in the MPY32CTL0 register is loaded with the sign bit of the written result; otherwise, the
saturation mode erroneously saturates the result.
5.2.5 Putting It All Together
shows the complete multiplication flow, depending on the various selectable modes for the
MPY32 module.