SLAU846B June 2023 – November 2024 MSPM0G1105 , MSPM0G1106 , MSPM0G1107 , MSPM0G1505 , MSPM0G1506 , MSPM0G1507 , MSPM0G1519 , MSPM0G3105 , MSPM0G3105-Q1 , MSPM0G3106 , MSPM0G3106-Q1 , MSPM0G3107 , MSPM0G3107-Q1 , MSPM0G3505 , MSPM0G3505-Q1 , MSPM0G3506 , MSPM0G3506-Q1 , MSPM0G3507 , MSPM0G3507-Q1 , MSPM0G3519
The Multiply32 (MPY32) function returns the results of multiplying two 32-bit numbers with the 32-bit result in RES1.
The MPY32 function can perform the data types shown in Table 6-21.
Data type (Multiplicand and Multiplier) | Data type (Product) | Condition |
---|---|---|
Uint32_t | Uint32_t | Product is < 232 - 1 |
Int32_t | Int32_t | Product is > -231 and < 231 - 1 |
SQm.n | SQm.n | Product is not outside the range representable in the chosen data format |
UQm.n | UQm.n |
Table 6-22 shows the operands and descriptions for the MPY32 function.
Register (Bit Field) | Value | Description |
---|---|---|
OP1 | User value | Multiplicand |
OP2 | User value | Multiplier |
CTL.FUNC | 6h | MPY32 |
CTL.QVAL | User value | Number of fractional bits (unsigned or signed number data type only) |
CTL.OPTYPE | 0h = unsigned operands 1h = signed operands | Operand sign |
RES1 | 32-bit product | Product |
Signed integer (int32_t) calculations requires 1 cycles to compute results in RES1 from an OP2 write. Examples of MPY32 for int32_t are in Table 6-13.
Multiplicand | Multiplier | Product |
---|---|---|
15 (0x0000000F) | 2 (0x00000002) | 30 (0x0000001E) |
-15 (0xFFFFFFF1) | 2 (0x00000002) | -30 (0xFFFFFFE2) |
15 (0x0000000F) | -2 (0xFFFFFFFE) | -30 (0xFFFFFFE2) |
-15 (0xFFFFFFF1) | -2 (0xFFFFFFFE) | 30 (0x0000001E) |
Signed number (SQm.n) calculations requires n cycles to compute results in RES1 from an OP2 write, where n is the number of fractional bits. Examples of MPY32 for SQ15.16 are in Table 6-14.
Multiplicand | Multiplier | Product |
---|---|---|
1.5 (0x00018000) | 2.5 (0x00028000) | 3.75 (0x0003C000) |
-1.5 (0xFFFE8000) | 2.5 (0x00028000) | -3.75 (0xFFFCC000) |
1.5 (0x00018000) | -2.5 (0xFFFD8000) | -3.75 (0xFFFCC000) |
-1.5 (0xFFFE8000) | -2.5 (0xFFFD8000) | 3.75 (0x0003C000) |
Status, Errors, and Overflow
If the result of the operation is more than 32 bits, STAT.OVF is set to indicate that an overflow has occurred. It will remain set until cleared by writing setting CLR_OVF = 1 in the CLR register.
For signed operation, if result saturation is enabled (CTL.SATEN = 1), in the case of an overflow, the STAT.OVF bit is set and the result saturates to the maximum positive result (0x7FFFFFFF).
For unsigned operation, if result saturation is enabled (CTL.SATEN = 1) in the case of an overflow, the result will be saturated to the maximum positive result (0xFFFFFFFF).
Configuration
To perform an MPY32: