32-Bit Hardware Multiplier Operation
9-12
32-Bit Hardware Multiplier
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 register(s) is not modified when MPYSAT = 1.
When the result is accessed using software, the value is automatically
adjusted providing 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 non-saturated result.
With 16x16 operations the saturation mode only applies to the least significant
32 bits, i.e. the result registers RES0 and RES1. Using the saturation mode
in MAC or MACS operations that mix 16x16 operations with 32x32, 16x32 or
32x16 operations will lead to unpredictable results.
With 32x32, 16x32, and 32x16 operations the saturated result can only be
calculated when RES3 is ready. In non-5xx devices, reading RES0 to RES2
prior to the complete result being ready will deliver the nonsaturated results,
independent of the MPYSAT bit setting.
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
Table 9−6. Result Availability in Saturation Mode (MPYSAT = 1)
Operation
Result ready in MCLK cycles
after
(OP1 x OP2)
RES0
RES1
RES2
RES3
MPYC Bit
8/16 x 8/16
3
3
N/A
N/A
3
OP2 written
24/32 x 8/16
7
7
7
7
7
OP2 written
8/16 x 24/32
7
7
7
7
7
OP2L written
4
4
4
4
4
OP2H written
24/32 x 24/32
11
11
11
11
11
OP2L written
6
6
6
6
6
OP2H written
Summary of Contents for MSP430x4xx Family
Page 1: ...MSP430x4xx Family 2007 Mixed Signal Products User s Guide SLAU056G ...
Page 2: ......
Page 6: ...vi ...
Page 114: ...3 76 RISC 16 Bit CPU ...
Page 304: ...5 20 FLL Clock Module ...
Page 340: ...7 8 Supply Voltage Supervisor ...
Page 348: ...8 8 16 Bit Hardware Multiplier ...
Page 372: ...9 24 32 Bit Hardware Multiplier ...
Page 400: ...10 28 DMA Controller ...
Page 428: ...13 10 Basic Timer1 ...
Page 466: ...15 24 Timer_A ...
Page 522: ...17 30 USART Peripheral Interface UART Mode ...
Page 544: ...18 22 USART Peripheral Interface SPI Mode ...
Page 672: ...23 12 Comparator_A ...
Page 692: ...24 20 LCD Controller ...
Page 746: ...26 28 ADC12 ...