NMSIS-Core  Version 1.2.0
NMSIS-Core support for Nuclei processor-based devices
(RV64 Only) 32-bit Parallel Multiply & Add Instructions

(RV64 Only) 32-bit Parallel Multiply & Add Instructions More...

Functions

__STATIC_FORCEINLINE long __RV_KMADA32 (long t, unsigned long a, unsigned long b)
 KMADA32 (Saturating Signed Multiply Two Words and Two Adds) More...
 
__STATIC_FORCEINLINE long __RV_KMAXDA32 (long t, unsigned long a, unsigned long b)
 KMAXDA32 (Saturating Signed Crossed Multiply Two Words and Two Adds) More...
 
__STATIC_FORCEINLINE long __RV_KMDA32 (unsigned long a, unsigned long b)
 KMDA32 (Signed Multiply Two Words and Add) More...
 
__STATIC_FORCEINLINE long __RV_KMXDA32 (unsigned long a, unsigned long b)
 KMXDA32 (Signed Crossed Multiply Two Words and Add) More...
 
__STATIC_FORCEINLINE long __RV_KMADS32 (long t, unsigned long a, unsigned long b)
 KMADS32 (Saturating Signed Multiply Two Words & Subtract & Add) More...
 
__STATIC_FORCEINLINE long __RV_KMADRS32 (long t, unsigned long a, unsigned long b)
 KMADRS32 (Saturating Signed Multiply Two Words & Reverse Subtract & Add) More...
 
__STATIC_FORCEINLINE long __RV_KMAXDS32 (long t, unsigned long a, unsigned long b)
 KMAXDS32 (Saturating Signed Crossed Multiply Two Words & Subtract & Add) More...
 
__STATIC_FORCEINLINE long __RV_KMSDA32 (long t, unsigned long a, unsigned long b)
 KMSDA32 (Saturating Signed Multiply Two Words & Add & Subtract) More...
 
__STATIC_FORCEINLINE long __RV_KMSXDA32 (long t, unsigned long a, unsigned long b)
 KMSXDA32 (Saturating Signed Crossed Multiply Two Words & Add & Subtract) More...
 
__STATIC_FORCEINLINE long __RV_SMDS32 (unsigned long a, unsigned long b)
 SMDS32 (Signed Multiply Two Words and Subtract) More...
 
__STATIC_FORCEINLINE long __RV_SMDRS32 (unsigned long a, unsigned long b)
 SMDRS32 (Signed Multiply Two Words and Reverse Subtract) More...
 
__STATIC_FORCEINLINE long __RV_SMXDS32 (unsigned long a, unsigned long b)
 SMXDS32 (Signed Crossed Multiply Two Words and Subtract) More...
 

Detailed Description

(RV64 Only) 32-bit Parallel Multiply & Add Instructions

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

Function Documentation

◆ __RV_KMADA32()

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

KMADA32 (Saturating Signed Multiply Two Words and Two Adds)

Type: DSP (RV64 Only)

Syntax:

KMADA32 Rd, Rs1, Rs2
KMAXDA32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from 32-bit data in two registers; and then adds the two 64-bit results and 64-bit data in a third register together. The addition result may be saturated.

  • KMADA32: rd + top*top + bottom*bottom
  • KMAXDA32: rd + top*bottom + bottom*top

Description:
For the KMADA32 instruction, it multiplies the bottom 32-bit element in Rs1 with the bottom 32- bit element in Rs2 and then adds the result to the result of multiplying the top 32-bit element in Rs1 with the top 32-bit element in Rs2. It is actually an alias of the KMAR64 instruction. For the KMAXDA32 instruction, it multiplies the top 32-bit element in Rs1 with the bottom 32-bit element in Rs2 and then adds the result to the result of multiplying the bottom 32-bit element in Rs1 with the top 32-bit element in Rs2. The 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 64-bit result is written to Rd. The 32-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

res = Rd + (Rs1.W[1] * Rs2.w[1]) + (Rs1.W[0] * Rs2.W[0]); // KMADA32
res = Rd + (Rs1.W[1] * Rs2.W[0]) + (Rs1.W[0] * Rs2.W[1]); // KMAXDA32
if (res > (2^63)-1) {
res = (2^63)-1;
OV = 1;
} else if (res < -2^63) {
res = -2^63;
OV = 1;
}
Rd = res;
Parameters
[in]tlong type of value stored in t
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 14854 of file core_feature_dsp.h.

14855 {
14856  __ASM volatile("kmada32 %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
14857  return t;
14858 }

References __ASM.

◆ __RV_KMADRS32()

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

KMADRS32 (Saturating Signed Multiply Two Words & Reverse Subtract & Add)

Type: DSP (RV64 Only)

Syntax:

KMADS32 Rd, Rs1, Rs2
KMADRS32 Rd, Rs1, Rs2
KMAXDS32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from 32-bit elements in two registers; and then perform a subtraction operation between the two 64-bit results. Then add the subtraction result to 64-bit data in a third register. The addition result may be saturated.

  • KMADS32: rd + (top*top - bottom*bottom)
  • KMADRS32: rd + (bottom*bottom - top*top)
  • KMAXDS32: rd + (top*bottom - bottom*top)

Description:
For the KMADS32 instruction, it multiplies the bottom 32-bit element in Rs1 with the bottom 32-bit element in Rs2 and then subtracts the result from the result of multiplying the top 32-bit element in Rs1 with the top 32-bit element in Rs2. For the KMADRS32 instruction, it multiplies the top 32-bit element in Rs1 with the top 32-bit element in Rs2 and then subtracts the result from the result of multiplying the bottom 32-bit element in Rs1 with the bottom 32-bit element in Rs2. For the KMAXDS32 instruction, it multiplies the bottom 32-bit element in Rs1 with the top 32-bit element in Rs2 and then subtracts the result from the result of multiplying the top 32-bit element in Rs1 with the bottom 32-bit element in Rs2. The subtraction result is then 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 64-bit 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[1] * Rs2.W[1]) - (Rs1.W[0] * Rs2.W[0]); // KMADS32
res = Rd + (Rs1.W[0] * Rs2.W[0]) - (Rs1.W[1] * Rs2.W[1]); // KMADRS32
res = Rd + (Rs1.W[1] * Rs2.W[0]) - (Rs1.W[0] * Rs2.W[1]); // KMAXDS32
if (res > (2^63)-1) {
res = (2^63)-1;
OV = 1;
} else if (res < -2^63) {
res = -2^63;
OV = 1;
}
Rd = res;
Parameters
[in]tlong type of value stored in t
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 15142 of file core_feature_dsp.h.

15143 {
15144  __ASM volatile("kmadrs32 %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
15145  return t;
15146 }

References __ASM.

◆ __RV_KMADS32()

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

KMADS32 (Saturating Signed Multiply Two Words & Subtract & Add)

Type: DSP (RV64 Only)

Syntax:

KMADS32 Rd, Rs1, Rs2
KMADRS32 Rd, Rs1, Rs2
KMAXDS32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from 32-bit elements in two registers; and then perform a subtraction operation between the two 64-bit results. Then add the subtraction result to 64-bit data in a third register. The addition result may be saturated.

  • KMADS32: rd + (top*top - bottom*bottom)
  • KMADRS32: rd + (bottom*bottom - top*top)
  • KMAXDS32: rd + (top*bottom - bottom*top)

Description:
For the KMADS32 instruction, it multiplies the bottom 32-bit element in Rs1 with the bottom 32-bit element in Rs2 and then subtracts the result from the result of multiplying the top 32-bit element in Rs1 with the top 32-bit element in Rs2. For the KMADRS32 instruction, it multiplies the top 32-bit element in Rs1 with the top 32-bit element in Rs2 and then subtracts the result from the result of multiplying the bottom 32-bit element in Rs1 with the bottom 32-bit element in Rs2. For the KMAXDS32 instruction, it multiplies the bottom 32-bit element in Rs1 with the top 32-bit element in Rs2 and then subtracts the result from the result of multiplying the top 32-bit element in Rs1 with the bottom 32-bit element in Rs2. The subtraction result is then 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 64-bit 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[1] * Rs2.W[1]) - (Rs1.W[0] * Rs2.W[0]); // KMADS32
res = Rd + (Rs1.W[0] * Rs2.W[0]) - (Rs1.W[1] * Rs2.W[1]); // KMADRS32
res = Rd + (Rs1.W[1] * Rs2.W[0]) - (Rs1.W[0] * Rs2.W[1]); // KMAXDS32
if (res > (2^63)-1) {
res = (2^63)-1;
OV = 1;
} else if (res < -2^63) {
res = -2^63;
OV = 1;
}
Rd = res;
Parameters
[in]tlong type of value stored in t
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 15078 of file core_feature_dsp.h.

15079 {
15080  __ASM volatile("kmads32 %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
15081  return t;
15082 }

References __ASM.

◆ __RV_KMAXDA32()

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

KMAXDA32 (Saturating Signed Crossed Multiply Two Words and Two Adds)

Type: DSP (RV64 Only)

Syntax:

KMADA32 Rd, Rs1, Rs2
KMAXDA32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from 32-bit data in two registers; and then adds the two 64-bit results and 64-bit data in a third register together. The addition result may be saturated.

  • KMADA32: rd + top*top + bottom*bottom
  • KMAXDA32: rd + top*bottom + bottom*top

Description:
For the KMADA32 instruction, it multiplies the bottom 32-bit element in Rs1 with the bottom 32- bit element in Rs2 and then adds the result to the result of multiplying the top 32-bit element in Rs1 with the top 32-bit element in Rs2. It is actually an alias of the KMAR64 instruction. For the KMAXDA32 instruction, it multiplies the top 32-bit element in Rs1 with the bottom 32-bit element in Rs2 and then adds the result to the result of multiplying the bottom 32-bit element in Rs1 with the top 32-bit element in Rs2. The 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 64-bit result is written to Rd. The 32-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

res = Rd + (Rs1.W[1] * Rs2.w[1]) + (Rs1.W[0] * Rs2.W[0]); // KMADA32
res = Rd + (Rs1.W[1] * Rs2.W[0]) + (Rs1.W[0] * Rs2.W[1]); // KMAXDA32
if (res > (2^63)-1) {
res = (2^63)-1;
OV = 1;
} else if (res < -2^63) {
res = -2^63;
OV = 1;
}
Rd = res;
Parameters
[in]tlong type of value stored in t
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 14910 of file core_feature_dsp.h.

14911 {
14912  __ASM volatile("kmaxda32 %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
14913  return t;
14914 }

References __ASM.

◆ __RV_KMAXDS32()

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

KMAXDS32 (Saturating Signed Crossed Multiply Two Words & Subtract & Add)

Type: DSP (RV64 Only)

Syntax:

KMADS32 Rd, Rs1, Rs2
KMADRS32 Rd, Rs1, Rs2
KMAXDS32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from 32-bit elements in two registers; and then perform a subtraction operation between the two 64-bit results. Then add the subtraction result to 64-bit data in a third register. The addition result may be saturated.

  • KMADS32: rd + (top*top - bottom*bottom)
  • KMADRS32: rd + (bottom*bottom - top*top)
  • KMAXDS32: rd + (top*bottom - bottom*top)

Description:
For the KMADS32 instruction, it multiplies the bottom 32-bit element in Rs1 with the bottom 32-bit element in Rs2 and then subtracts the result from the result of multiplying the top 32-bit element in Rs1 with the top 32-bit element in Rs2. For the KMADRS32 instruction, it multiplies the top 32-bit element in Rs1 with the top 32-bit element in Rs2 and then subtracts the result from the result of multiplying the bottom 32-bit element in Rs1 with the bottom 32-bit element in Rs2. For the KMAXDS32 instruction, it multiplies the bottom 32-bit element in Rs1 with the top 32-bit element in Rs2 and then subtracts the result from the result of multiplying the top 32-bit element in Rs1 with the bottom 32-bit element in Rs2. The subtraction result is then 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 64-bit 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[1] * Rs2.W[1]) - (Rs1.W[0] * Rs2.W[0]); // KMADS32
res = Rd + (Rs1.W[0] * Rs2.W[0]) - (Rs1.W[1] * Rs2.W[1]); // KMADRS32
res = Rd + (Rs1.W[1] * Rs2.W[0]) - (Rs1.W[0] * Rs2.W[1]); // KMAXDS32
if (res > (2^63)-1) {
res = (2^63)-1;
OV = 1;
} else if (res < -2^63) {
res = -2^63;
OV = 1;
}
Rd = res;
Parameters
[in]tlong type of value stored in t
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 15206 of file core_feature_dsp.h.

15207 {
15208  __ASM volatile("kmaxds32 %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
15209  return t;
15210 }

References __ASM.

◆ __RV_KMDA32()

__STATIC_FORCEINLINE long __RV_KMDA32 ( unsigned long  a,
unsigned long  b 
)

KMDA32 (Signed Multiply Two Words and Add)

Type: DSP (RV64 Only)

Syntax:

KMDA32 Rd, Rs1, Rs2
KMXDA32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from the 32-bit element of two registers; and then adds the two 64-bit results together. The addition result may be saturated.

  • KMDA32: top*top + bottom*bottom
  • KMXDA32: top*bottom + bottom*top

Description:
For the KMDA32 instruction, it multiplies the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2 and then adds the result to the result of multiplying the top 32-bit element of Rs1 with the top 32-bit element of Rs2. For the KMXDA32 instruction, it multiplies the bottom 32-bit element of Rs1 with the top 32-bit element of Rs2 and then adds the result to the result of multiplying the top 32-bit element of Rs1 with the bottom 32-bit element of Rs2. The addition result is checked for saturation. If saturation happens, the result is saturated to 2^63-1. The final result is written to Rd. The 32-bit contents are treated as signed integers.

Operations:

if ((Rs1 != 0x8000000080000000) or (Rs2 != 0x8000000080000000)) {
Rd = (Rs1.W[1] * Rs2.W[1]) + (Rs1.W[0] * Rs2.W[0]); // KMDA32
Rd = (Rs1.W[1] * Rs2.W[0]) + (Rs1.W[0] * Rs2.W[1]); // KMXDA32
} else {
Rd = 0x7fffffffffffffff;
OV = 1;
}
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 14961 of file core_feature_dsp.h.

14962 {
14963  long result;
14964  __ASM volatile("kmda32 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
14965  return result;
14966 }

References __ASM.

◆ __RV_KMSDA32()

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

KMSDA32 (Saturating Signed Multiply Two Words & Add & Subtract)

Type: DSP (RV64 Only)

Syntax:

KMSDA32 Rd, Rs1, Rs2
KMSXDA32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from the 32-bit element of two registers; and then subtracts the two 64-bit results from a third register. The subtraction result may be saturated.

  • KMSDA: rd - top*top - bottom*bottom
  • KMSXDA: rd - top*bottom - bottom*top

Description:
For the KMSDA32 instruction, it multiplies the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2 and multiplies the top 32-bit element of Rs1 with the top 32-bit element of Rs2. For the KMSXDA32 instruction, it multiplies the bottom 32-bit element of Rs1 with the top 32-bit element of Rs2 and multiplies the top 32-bit element of Rs1 with the bottom 32-bit element of Rs2. The two 64-bit multiplication results are then subtracted from the content of Rd. If the subtraction 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 are treated as signed integers.

Operations:

res = Rd - (Rs1.W[1] * Rs2.W[1]) - (Rs1.W[0] * Rs2.W[0]); // KMSDA32
res = Rd - (Rs1.W[1] * Rs2.W[0]) - (Rs1.W[0] * Rs2.W[1]); // KMSXDA32
if (res > (2^63)-1) {
res = (2^63)-1;
OV = 1;
} else if (res < -2^63) {
res = -2^63;
OV = 1;
}
Rd = res;
Parameters
[in]tlong type of value stored in t
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 15261 of file core_feature_dsp.h.

15262 {
15263  __ASM volatile("kmsda32 %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
15264  return t;
15265 }

References __ASM.

◆ __RV_KMSXDA32()

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

KMSXDA32 (Saturating Signed Crossed Multiply Two Words & Add & Subtract)

Type: DSP (RV64 Only)

Syntax:

KMSDA32 Rd, Rs1, Rs2
KMSXDA32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from the 32-bit element of two registers; and then subtracts the two 64-bit results from a third register. The subtraction result may be saturated.

  • KMSDA: rd - top*top - bottom*bottom
  • KMSXDA: rd - top*bottom - bottom*top

Description:
For the KMSDA32 instruction, it multiplies the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2 and multiplies the top 32-bit element of Rs1 with the top 32-bit element of Rs2. For the KMSXDA32 instruction, it multiplies the bottom 32-bit element of Rs1 with the top 32-bit element of Rs2 and multiplies the top 32-bit element of Rs1 with the bottom 32-bit element of Rs2. The two 64-bit multiplication results are then subtracted from the content of Rd. If the subtraction 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 are treated as signed integers.

Operations:

res = Rd - (Rs1.W[1] * Rs2.W[1]) - (Rs1.W[0] * Rs2.W[0]); // KMSDA32
res = Rd - (Rs1.W[1] * Rs2.W[0]) - (Rs1.W[0] * Rs2.W[1]); // KMSXDA32
if (res > (2^63)-1) {
res = (2^63)-1;
OV = 1;
} else if (res < -2^63) {
res = -2^63;
OV = 1;
}
Rd = res;
Parameters
[in]tlong type of value stored in t
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 15316 of file core_feature_dsp.h.

15317 {
15318  __ASM volatile("kmsxda32 %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
15319  return t;
15320 }

References __ASM.

◆ __RV_KMXDA32()

__STATIC_FORCEINLINE long __RV_KMXDA32 ( unsigned long  a,
unsigned long  b 
)

KMXDA32 (Signed Crossed Multiply Two Words and Add)

Type: DSP (RV64 Only)

Syntax:

KMDA32 Rd, Rs1, Rs2
KMXDA32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from the 32-bit element of two registers; and then adds the two 64-bit results together. The addition result may be saturated.

  • KMDA32: top*top + bottom*bottom
  • KMXDA32: top*bottom + bottom*top

Description:
For the KMDA32 instruction, it multiplies the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2 and then adds the result to the result of multiplying the top 32-bit element of Rs1 with the top 32-bit element of Rs2. For the KMXDA32 instruction, it multiplies the bottom 32-bit element of Rs1 with the top 32-bit element of Rs2 and then adds the result to the result of multiplying the top 32-bit element of Rs1 with the bottom 32-bit element of Rs2. The addition result is checked for saturation. If saturation happens, the result is saturated to 2^63-1. The final result is written to Rd. The 32-bit contents are treated as signed integers.

Operations:

if ((Rs1 != 0x8000000080000000) or (Rs2 != 0x8000000080000000)) {
Rd = (Rs1.W[1] * Rs2.W[1]) + (Rs1.W[0] * Rs2.W[0]); // KMDA32
Rd = (Rs1.W[1] * Rs2.W[0]) + (Rs1.W[0] * Rs2.W[1]); // KMXDA32
} else {
Rd = 0x7fffffffffffffff;
OV = 1;
}
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 15013 of file core_feature_dsp.h.

15014 {
15015  long result;
15016  __ASM volatile("kmxda32 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
15017  return result;
15018 }

References __ASM.

◆ __RV_SMDRS32()

__STATIC_FORCEINLINE long __RV_SMDRS32 ( unsigned long  a,
unsigned long  b 
)

SMDRS32 (Signed Multiply Two Words and Reverse Subtract)

Type: DSP (RV64 Only)

Syntax:

SMDS32 Rd, Rs1, Rs2
SMDRS32 Rd, Rs1, Rs2
SMXDS32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from the l 32-bit element of two registers; and then perform a subtraction operation between the two 64-bit results.

  • SMDS32: top*top - bottom*bottom
  • SMDRS32: bottom*bottom - top*top
  • SMXDS32: top*bottom - bottom*top

Description:
For the SMDS32 instruction, it multiplies the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2 and then subtracts the result from the result of multiplying the top 32-bit element of Rs1 with the top 32-bit element of Rs2. For the SMDRS32 instruction, it multiplies the top 32-bit element of Rs1 with the top 32-bit element of Rs2 and then subtracts the result from the result of multiplying the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2. For the SMXDS32 instruction, it multiplies the bottom 32-bit element of Rs1 with the top 32-bit element of Rs2 and then subtracts the result from the result of multiplying the top 32-bit element of Rs1 with the bottom 32-bit element of Rs2. The subtraction result is written to Rd. The 32-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

Rt = (Rs1.W[1] * Rs2.W[1]) - (Rs1.W[0] * Rs2.W[0]); // SMDS32
Rt = (Rs1.W[0] * Rs2.W[0]) - (Rs1.W[1] * Rs2.W[1]); // SMDRS32
Rt = (Rs1.W[1] * Rs2.W[0]) - (Rs1.W[0] * Rs2.W[1]); // SMXDS32
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 16543 of file core_feature_dsp.h.

16544 {
16545  long result;
16546  __ASM volatile("smdrs32 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
16547  return result;
16548 }

References __ASM.

◆ __RV_SMDS32()

__STATIC_FORCEINLINE long __RV_SMDS32 ( unsigned long  a,
unsigned long  b 
)

SMDS32 (Signed Multiply Two Words and Subtract)

Type: DSP (RV64 Only)

Syntax:

SMDS32 Rd, Rs1, Rs2
SMDRS32 Rd, Rs1, Rs2
SMXDS32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from the l 32-bit element of two registers; and then perform a subtraction operation between the two 64-bit results.

  • SMDS32: top*top - bottom*bottom
  • SMDRS32: bottom*bottom - top*top
  • SMXDS32: top*bottom - bottom*top

Description:
For the SMDS32 instruction, it multiplies the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2 and then subtracts the result from the result of multiplying the top 32-bit element of Rs1 with the top 32-bit element of Rs2. For the SMDRS32 instruction, it multiplies the top 32-bit element of Rs1 with the top 32-bit element of Rs2 and then subtracts the result from the result of multiplying the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2. For the SMXDS32 instruction, it multiplies the bottom 32-bit element of Rs1 with the top 32-bit element of Rs2 and then subtracts the result from the result of multiplying the top 32-bit element of Rs1 with the bottom 32-bit element of Rs2. The subtraction result is written to Rd. The 32-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

Rt = (Rs1.W[1] * Rs2.W[1]) - (Rs1.W[0] * Rs2.W[0]); // SMDS32
Rt = (Rs1.W[0] * Rs2.W[0]) - (Rs1.W[1] * Rs2.W[1]); // SMDRS32
Rt = (Rs1.W[1] * Rs2.W[0]) - (Rs1.W[0] * Rs2.W[1]); // SMXDS32
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 16490 of file core_feature_dsp.h.

16491 {
16492  long result;
16493  __ASM volatile("smds32 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
16494  return result;
16495 }

References __ASM.

◆ __RV_SMXDS32()

__STATIC_FORCEINLINE long __RV_SMXDS32 ( unsigned long  a,
unsigned long  b 
)

SMXDS32 (Signed Crossed Multiply Two Words and Subtract)

Type: DSP (RV64 Only)

Syntax:

SMDS32 Rd, Rs1, Rs2
SMDRS32 Rd, Rs1, Rs2
SMXDS32 Rd, Rs1, Rs2

Purpose:
Do two signed 32-bit multiplications from the l 32-bit element of two registers; and then perform a subtraction operation between the two 64-bit results.

  • SMDS32: top*top - bottom*bottom
  • SMDRS32: bottom*bottom - top*top
  • SMXDS32: top*bottom - bottom*top

Description:
For the SMDS32 instruction, it multiplies the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2 and then subtracts the result from the result of multiplying the top 32-bit element of Rs1 with the top 32-bit element of Rs2. For the SMDRS32 instruction, it multiplies the top 32-bit element of Rs1 with the top 32-bit element of Rs2 and then subtracts the result from the result of multiplying the bottom 32-bit element of Rs1 with the bottom 32-bit element of Rs2. For the SMXDS32 instruction, it multiplies the bottom 32-bit element of Rs1 with the top 32-bit element of Rs2 and then subtracts the result from the result of multiplying the top 32-bit element of Rs1 with the bottom 32-bit element of Rs2. The subtraction result is written to Rd. The 32-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

Rt = (Rs1.W[1] * Rs2.W[1]) - (Rs1.W[0] * Rs2.W[0]); // SMDS32
Rt = (Rs1.W[0] * Rs2.W[0]) - (Rs1.W[1] * Rs2.W[1]); // SMDRS32
Rt = (Rs1.W[1] * Rs2.W[0]) - (Rs1.W[0] * Rs2.W[1]); // SMXDS32
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in long type

Definition at line 16596 of file core_feature_dsp.h.

16597 {
16598  long result;
16599  __ASM volatile("smxds32 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
16600  return result;
16601 }

References __ASM.

__ASM
#define __ASM
Pass information from the compiler to the assembler.
Definition: nmsis_gcc.h:55