MPY32 Operation
278
SLAU367P – October 2012 – Revised April 2020
Copyright © 2012–2020, Texas Instruments Incorporated
32-Bit Hardware Multiplier (MPY32)
The MPYC bit is not affected by the fractional mode. It always reads the carry of the nonfractional result.
; Example using
; Fractional 16x16 multiplication
BIS
#MPYFRAC,&MPY32CTL0
; Turn on fractional mode
MOV
&FRACT1,&MPYS
; Load 1st operand as Q15
MOV
&FRACT2,&OP2
; Load 2nd operand as Q15
MOV
&RES1,&PROD
; Save result as Q15
BIC
#MPYFRAC,&MPY32CTL0
; Back to normal mode
Table 5-5. Result Availability in Fractional Mode (MPYFRAC = 1, MPYSAT = 0)
Operation
(OP1 × OP2)
Result Ready in MCLK Cycles
After
RES0
RES1
RES2
RES3
MPYC Bit
8/16 × 8/16
3
3
4
4
3
OP2 written
24/32 × 8/16
3
5
6
7
7
OP2 written
8/16 × 24/32
3
5
6
7
7
OP2L written
N/A
3
4
4
4
OP2H written
24/32 × 24/32
3
8
10
11
11
OP2L written
N/A
3
5
6
6
OP2H written
5.2.4.2
Saturation Mode
The multiplier prevents overflow and underflow of signed operations in saturation mode. The saturation
mode is enabled with MPYSAT = 1 in register MPY32CTL0. If an overflow occurs, the result is set to the
most-positive value available. If an underflow occurs, the result is set to the most-negative value available.
This is useful to reduce mathematical artifacts in control systems on overflow and underflow conditions.
The saturation mode should only be enabled when required and disabled after use.
The actual content of the result registers is not modified when MPYSAT = 1. When the result is accessed
using software, the value is automatically adjusted to provide the most-positive or most-negative result
when an overflow or underflow has occurred. The adjusted result is also used for successive multiply-and-
accumulate operations. This allows user software to switch between reading the saturated and the
nonsaturated result.
With 16×16 operations, the saturation mode only applies to the least significant 32 bits; that is, the result
registers RES0 and RES1. Using the saturation mode in MAC or MACS operations that mix 16×16
operations with 32×32, 16×32, or 32×16 operations leads to unpredictable results.
With 32×32, 16×32, and 32×16 operations, the saturated result can only be calculated when RES3 is
ready.
Enabling the saturation mode does not affect the content of the SUMEXT register nor the content of the
MPYC bit.
; Example using
; Fractional 16x16 multiply accumulate with Saturation
; Turn on fractional and saturation mode:
BIS
#MPYFRAC,&MPY32CTL0
MOV
&A1,&MPYS
; Load A1 for 1st term
MOV
&K1,&OP2
; Load K1 to get A1*K1
MOV
&A2,&MACS
; Load A2 for 2nd term
MOV
&K2,&OP2
; Load K2 to get A2*K2
MOV
&RES1,&PROD
; Save A1*K1+A2*K2 as result
BIC
#MPYFRAC,&MPY32CTL0
; turn back to normal