SLAU846A June 2023 – October 2023 MSPM0G1105 , MSPM0G1106 , MSPM0G1107 , MSPM0G1505 , MSPM0G1506 , MSPM0G1507 , MSPM0G3105 , MSPM0G3105-Q1 , MSPM0G3106 , MSPM0G3106-Q1 , MSPM0G3107 , MSPM0G3107-Q1 , MSPM0G3505 , MSPM0G3505-Q1 , MSPM0G3506 , MSPM0G3506-Q1 , MSPM0G3507 , MSPM0G3507-Q1
Multiply-accumulate (MAC) functions accumulates the results of the product of OP1 and OP2 inside result registers RES1 and RES2 over multiple iterations until the MATHACL is reprogrammed for another function. The MATHACL supports only a 32-bit multiplier and multiplicand operand size, and a 64-bit accumulated result size.
Figure 1-1 shows the operation of the MATHACL in MAC mode.
Internal MAC operation performs the following steps:
The MAC function can perform the following data types of multiply-accumulate shown in Table 5-25.
Data Type (Multiplicand and Multiplier) | Data Type (Product) | Condition |
---|---|---|
Uint32_t | Uint64_t | MAC result is < 264 - 1 |
Int32_t | Int64_t | MAC result is > -263 and < 263 - 1 |
SQm.n | SQ(32+m).n | MAC result is not outside the range representable in the chosen data format |
UQm.n | UQ(32+m).n |
Table 5-26 shows the configuration registers for the MAC function.
Register (Bit Field) | Value | Description |
---|---|---|
OP1 | User value | Multiplicand |
OP2 | User value | Multiplier |
CTL.FUNC | Ah | MAC |
CTL.QVAL | User value | Number of fractional bits (unsigned or signed number data type only) |
CTL.OPTYPE |
0 = unsigned operands 1 = signed operands |
Operand sign |
RES1 | Lower 32 bits of result | Multiply-accumulate result (64-bit) |
RES2 | Upper 32 bits of result |
The final result of the MAC operation can be read after 2 cycles after writing OP2.
Status, Errors, and Overflow
If the result of the operation is more than 64 bits, STAT.OVF is set to indicate that an overflow has occurred. It will remain set until cleared by writing a 1 to CLR.CLR_OVF.
For signed 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 (0x7FFF_FFFF_FFFF_FFFF) and the minimum negative result (0x8000_0000_0000_0000).
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 (0xFFFF_FFFF_FFFF_FFFF).
Configuration
To configure the MAC for operation:
Set QVAL to the number of fractional bits (n) for a signed (SQm.n) or unsigned number (UQm.n)