(RV64 Only) 32-bit Multiply & Add Instructions

__STATIC_FORCEINLINE long __RV_KMABB32 (long t, unsigned long a, unsigned long b)
__STATIC_FORCEINLINE long __RV_KMABT32 (long t, unsigned long a, unsigned long b)
__STATIC_FORCEINLINE long __RV_KMATT32 (long t, unsigned long a, unsigned long b)
group NMSIS_Core_DSP_Intrinsic_RV64_32B_MULT_ADD

(RV64 Only) 32-bit Multiply & Add Instructions

there are 3 (RV64 Only) 32-bit Multiply & Add Instructions

Functions

__STATIC_FORCEINLINE long __RV_KMABB32 (long t, unsigned long a, unsigned long b)

KMABB32 (Saturating Signed Multiply Bottom Words & Add)

Type: DSP (RV64 Only)

Syntax:

KMABB32 Rd, Rs1, Rs2
KMABT32 Rd, Rs1, Rs2
KMATT32 Rd, Rs1, Rs2

Purpose

:

Multiply the signed 32-bit element in a register with the 32-bit element in another register and add the result to the content of 64-bit data in the third register. The addition result may be saturated and is written to the third register.

  • KMABB32: rd + bottom*bottom

  • KMABT32: rd + bottom*top

  • KMATT32: rd + top*top

Description

:

For the

KMABB32 instruction, it multiplies the bottom 32-bit element in Rs1 with the bottom 32-bit element in Rs2. For the KMABT32 instruction, it multiplies the bottom 32-bit element in Rs1 with the top 32-bit element in Rs2. For the KMATT32 instruction, it multiplies the top 32-bit element in Rs1 with the top 32-bit element in Rs2. The multiplication result is added to the content of 64-bit data in Rd. If the addition result is beyond the Q63 number range (-2^63 <= Q63 <= 2^63-1), it is saturated to the range and the OV bit is set to 1. The result after saturation is written to Rd. The 32-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

res = Rd + (Rs1.W[0] * Rs2.W[0]); // KMABB32
 res = Rd + (Rs1.W[0] * Rs2.W[1]); // KMABT32
 res = Rd + (Rs1.W[1] * Rs2.W[1]); // KMATT32
 if (res > (2^63)-1) {
   res = (2^63)-1;
   OV = 1;
 } else if (res < -2^63) {
   res = -2^63;
   OV = 1;
 }
 Rd = res;
*Exceptions:* None

Parameters
  • t[in] long type of value stored in t

  • a[in] unsigned long type of value stored in a

  • b[in] unsigned long type of value stored in b

Returns

value stored in long type

__STATIC_FORCEINLINE long __RV_KMABT32 (long t, unsigned long a, unsigned long b)

KMABT32 (Saturating Signed Multiply Bottom & Top Words & Add)

Type: DSP (RV64 Only)

Syntax:

KMABB32 Rd, Rs1, Rs2
KMABT32 Rd, Rs1, Rs2
KMATT32 Rd, Rs1, Rs2

Purpose

:

Multiply the signed 32-bit element in a register with the 32-bit element in another register and add the result to the content of 64-bit data in the third register. The addition result may be saturated and is written to the third register.

  • KMABB32: rd + bottom*bottom

  • KMABT32: rd + bottom*top

  • KMATT32: rd + top*top

Description

:

For the

KMABB32 instruction, it multiplies the bottom 32-bit element in Rs1 with the bottom 32-bit element in Rs2. For the KMABT32 instruction, it multiplies the bottom 32-bit element in Rs1 with the top 32-bit element in Rs2. For the KMATT32 instruction, it multiplies the top 32-bit element in Rs1 with the top 32-bit element in Rs2. The multiplication result is added to the content of 64-bit data in Rd. If the addition result is beyond the Q63 number range (-2^63 <= Q63 <= 2^63-1), it is saturated to the range and the OV bit is set to 1. The result after saturation is written to Rd. The 32-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

res = Rd + (Rs1.W[0] * Rs2.W[0]); // KMABB32
 res = Rd + (Rs1.W[0] * Rs2.W[1]); // KMABT32
 res = Rd + (Rs1.W[1] * Rs2.W[1]); // KMATT32
 if (res > (2^63)-1) {
   res = (2^63)-1;
   OV = 1;
 } else if (res < -2^63) {
   res = -2^63;
   OV = 1;
 }
 Rd = res;
*Exceptions:* None

Parameters
  • t[in] long type of value stored in t

  • a[in] unsigned long type of value stored in a

  • b[in] unsigned long type of value stored in b

Returns

value stored in long type

__STATIC_FORCEINLINE long __RV_KMATT32 (long t, unsigned long a, unsigned long b)

KMATT32 (Saturating Signed Multiply Top Words & Add)

Type: DSP (RV64 Only)

Syntax:

KMABB32 Rd, Rs1, Rs2
KMABT32 Rd, Rs1, Rs2
KMATT32 Rd, Rs1, Rs2

Purpose

:

Multiply the signed 32-bit element in a register with the 32-bit element in another register and add the result to the content of 64-bit data in the third register. The addition result may be saturated and is written to the third register.

  • KMABB32: rd + bottom*bottom

  • KMABT32: rd + bottom*top

  • KMATT32: rd + top*top

Description

:

For the

KMABB32 instruction, it multiplies the bottom 32-bit element in Rs1 with the bottom 32-bit element in Rs2. For the KMABT32 instruction, it multiplies the bottom 32-bit element in Rs1 with the top 32-bit element in Rs2. For the KMATT32 instruction, it multiplies the top 32-bit element in Rs1 with the top 32-bit element in Rs2. The multiplication result is added to the content of 64-bit data in Rd. If the addition result is beyond the Q63 number range (-2^63 <= Q63 <= 2^63-1), it is saturated to the range and the OV bit is set to 1. The result after saturation is written to Rd. The 32-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

res = Rd + (Rs1.W[0] * Rs2.W[0]); // KMABB32
 res = Rd + (Rs1.W[0] * Rs2.W[1]); // KMABT32
 res = Rd + (Rs1.W[1] * Rs2.W[1]); // KMATT32
 if (res > (2^63)-1) {
   res = (2^63)-1;
   OV = 1;
 } else if (res < -2^63) {
   res = -2^63;
   OV = 1;
 }
 Rd = res;
*Exceptions:* None

Parameters
  • t[in] long type of value stored in t

  • a[in] unsigned long type of value stored in a

  • b[in] unsigned long type of value stored in b

Returns

value stored in long type