SLAU846B June 2023 – November 2024 MSPM0G1105 , MSPM0G1106 , MSPM0G1107 , MSPM0G1505 , MSPM0G1506 , MSPM0G1507 , MSPM0G3105 , MSPM0G3106 , MSPM0G3107 , MSPM0G3505 , MSPM0G3506 , MSPM0G3507
Square-accumulate (SAC) functions accumulates the results of the square of operand OP2 inside result registers RES1 and RES2 over multiple iterations until the MATHACL is reprogrammed for another function. It is a variation of the MAC function and operation details remain the same.
Write 0 into RES1 and RES2 before starting a SAC operation to get the correct result.
The SAC function can perform the following data types of square-accumulate shown in Table 6-25.
Data Type (Base) | Data Type (Result) | Condition |
---|---|---|
Uint32_t | Uint64_t | SAC result should be < 264 - 1 |
Int32_t | Int64_t | SAC result should be > -263 and < 263 - 1 |
SQm.n | SQ(32+m).n | SAC result should not be outside the range representable in the chosen data format |
UQm.n | UQ(32+m).n |
Table 6-26 shows the configuration registers for the SAC function.
Register (Bit Field) | Value | Description |
---|---|---|
OP1 | User value | Base |
CTL.FUNC | Bh | SAC |
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 | Square-accumulate result (64-bit) |
RES2 | Upper 32 bits of result |
The final result of the SAC 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 SAC for operation: