STDA045 November   2026 MSPM0G1505 , MSPM0G1506 , MSPM0G1507 , MSPM0G1518 , MSPM0G1519 , MSPM0G3505 , MSPM0G3506 , MSPM0G3507 , MSPM0G3518 , MSPM0G3519

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
  5. 2ED25519PH Algorithm Introduction
  6. 3MSPM0G Math Accelerator (MATHACL)
    1. 3.1 MATHACL Module
    2. 3.2 Multiply-Accumulate (MAC) Operation
  7. 4Accelerate the ED25519PH Algorithm by Using MATHACL
    1. 4.1 Loop Unrolled Implementation
      1. 4.1.1 Non-MATHACL Optimization
      2. 4.1.2 MATHACL Optimization
    2. 4.2 Loop Rolled Implementation
      1. 4.2.1 Non-MATHACL Optimization
      2. 4.2.2 MATHACL Optimization
    3. 4.3 Benchmark
  8. 5Summary
  9. 6References

MATHACL Optimization

The same operation can be performed using MATHACL to get the h[0] result:

MATHACL->RES2 = 0;
MATHACL->RES1 = 0;
MATHACL->OP2 = g0;
MATHACL->OP1 = f0;
MATHACL->OP2 = g9_19;
MATHACL->OP1 = f1_2;
MATHACL->OP2 = g8_19;
MATHACL->OP1 = f2;
MATHACL->OP2 = g7_19;
MATHACL->OP1 = f3_2;
MATHACL->OP2 = g6_19;
MATHACL->OP1 = f4;
MATHACL->OP2 = g5_19;
MATHACL->OP1 = f5_2;
MATHACL->OP2 = g4_19;
MATHACL->OP1 = f6;
MATHACL->OP2 = g3_19;
MATHACL->OP1 = f7_2;
MATHACL->OP2 = g2_19;
MATHACL->OP1 = f8;
MATHACL->OP2 = g1_19;
MATHACL->OP1 = f9_2;
__asm__ __volatile__ ("nop");
hvect[0] = ((uint64)(MATHACL->RES2)<<32) + MATHACL->RES1;

After accumulation, carries are propagated through alternating 26-bit and 25-bit limbs. The final carry from the highest limb is wrapped into limb 0 and multiplied by 19, maintaining a valid field element.

Based on a MAC operation in the MATHACL module in MSPM0G devices, the program must continuously input the 32-bit operation data into OP1 and OP2 to directly get the MAC results from the RES register, which is an obvious improvement to 32-bit multiplication efficiency.