NMSIS-Core  Version 1.2.0
NMSIS-Core support for Nuclei processor-based devices
Signed 16-bit Multiply 32-bit Add/Subtract Instructions

Signed 16-bit Multiply 32-bit Add/Subtract Instructions. More...

Functions

__STATIC_FORCEINLINE long __RV_KMABB (long t, unsigned long a, unsigned long b)
 KMABB (SIMD Saturating Signed Multiply Bottom Halfs & Add) More...
 
__STATIC_FORCEINLINE long __RV_KMABT (long t, unsigned long a, unsigned long b)
 KMABT (SIMD Saturating Signed Multiply Bottom & Top Halfs & Add) More...
 
__STATIC_FORCEINLINE long __RV_KMATT (long t, unsigned long a, unsigned long b)
 KMATT (SIMD Saturating Signed Multiply Top Halfs & Add) More...
 
__STATIC_FORCEINLINE long __RV_KMADA (long t, unsigned long a, unsigned long b)
 KMADA (SIMD Saturating Signed Multiply Two Halfs and Two Adds) More...
 
__STATIC_FORCEINLINE long __RV_KMAXDA (long t, unsigned long a, unsigned long b)
 KMAXDA (SIMD Saturating Signed Crossed Multiply Two Halfs and Two Adds) More...
 
__STATIC_FORCEINLINE long __RV_KMADS (long t, unsigned long a, unsigned long b)
 KMADS (SIMD Saturating Signed Multiply Two Halfs & Subtract & Add) More...
 
__STATIC_FORCEINLINE long __RV_KMADRS (long t, unsigned long a, unsigned long b)
 KMADRS (SIMD Saturating Signed Multiply Two Halfs & Reverse Subtract & Add) More...
 
__STATIC_FORCEINLINE long __RV_KMAXDS (long t, unsigned long a, unsigned long b)
 KMAXDS (SIMD Saturating Signed Crossed Multiply Two Halfs & Subtract & Add) More...
 
__STATIC_FORCEINLINE long __RV_KMDA (unsigned long a, unsigned long b)
 KMDA (SIMD Signed Multiply Two Halfs and Add) More...
 
__STATIC_FORCEINLINE long __RV_KMXDA (unsigned long a, unsigned long b)
 KMXDA (SIMD Signed Crossed Multiply Two Halfs and Add) More...
 
__STATIC_FORCEINLINE long __RV_KMSDA (long t, unsigned long a, unsigned long b)
 KMSDA (SIMD Saturating Signed Multiply Two Halfs & Add & Subtract) More...
 
__STATIC_FORCEINLINE long __RV_KMSXDA (long t, unsigned long a, unsigned long b)
 KMSXDA (SIMD Saturating Signed Crossed Multiply Two Halfs & Add & Subtract) More...
 
__STATIC_FORCEINLINE long __RV_SMBB16 (unsigned long a, unsigned long b)
 SMBB16 (SIMD Signed Multiply Bottom Half & Bottom Half) More...
 
__STATIC_FORCEINLINE long __RV_SMBT16 (unsigned long a, unsigned long b)
 SMBT16 (SIMD Signed Multiply Bottom Half & Top Half) More...
 
__STATIC_FORCEINLINE long __RV_SMTT16 (unsigned long a, unsigned long b)
 SMTT16 (SIMD Signed Multiply Top Half & Top Half) More...
 
__STATIC_FORCEINLINE long __RV_SMDS (unsigned long a, unsigned long b)
 SMDS (SIMD Signed Multiply Two Halfs and Subtract) More...
 
__STATIC_FORCEINLINE long __RV_SMDRS (unsigned long a, unsigned long b)
 SMDRS (SIMD Signed Multiply Two Halfs and Reverse Subtract) More...
 
__STATIC_FORCEINLINE long __RV_SMXDS (unsigned long a, unsigned long b)
 SMXDS (SIMD Signed Crossed Multiply Two Halfs and Subtract) More...
 

Detailed Description

Signed 16-bit Multiply 32-bit Add/Subtract Instructions.

there are 18 Signed 16-bit Multiply 32-bit Add/Subtract Instructions

Function Documentation

◆ __RV_KMABB()

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

KMABB (SIMD Saturating Signed Multiply Bottom Halfs & Add)

Type: SIMD

Syntax:

KMABB Rd, Rs1, Rs2
KMABT Rd, Rs1, Rs2
KMATT Rd, Rs1, Rs2

Purpose:
Multiply the signed 16-bit content of 32-bit elements in a register with the 16-bit content of 32-bit elements in another register and add the result to the content of 32-bit elements in the third register. The addition result may be saturated and is written to the third register.

  • KMABB: rd.W[x] + bottom*bottom (per 32-bit element)
  • KMABT rd.W[x] + bottom*top (per 32-bit element)
  • KMATT rd.W[x] + top*top (per 32-bit element)

Description:
For the KMABB instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2. For the KMABT instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. For the KMATT instruction, it multiplies the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. The multiplication result is added to the content of 32-bit elements in Rd. If the addition result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to

  1. The results after saturation are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

res[x] = Rd.W[x] + (Rs1.W[x].H[0] * Rs2.W[x].H[0]); // KMABB
res[x] = Rd.W[x] + (Rs1.W[x].H[0] * Rs2.W[x].H[1]); // KMABT
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[1]); // KMATT
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 2705 of file core_feature_dsp.h.

2706 {
2707  __ASM volatile("kmabb %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
2708  return t;
2709 }

References __ASM.

◆ __RV_KMABT()

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

KMABT (SIMD Saturating Signed Multiply Bottom & Top Halfs & Add)

Type: SIMD

Syntax:

KMABB Rd, Rs1, Rs2
KMABT Rd, Rs1, Rs2
KMATT Rd, Rs1, Rs2

Purpose:
Multiply the signed 16-bit content of 32-bit elements in a register with the 16-bit content of 32-bit elements in another register and add the result to the content of 32-bit elements in the third register. The addition result may be saturated and is written to the third register.

  • KMABB: rd.W[x] + bottom*bottom (per 32-bit element)
  • KMABT rd.W[x] + bottom*top (per 32-bit element)
  • KMATT rd.W[x] + top*top (per 32-bit element)

Description:
For the KMABB instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2. For the KMABT instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. For the KMATT instruction, it multiplies the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. The multiplication result is added to the content of 32-bit elements in Rd. If the addition result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to

  1. The results after saturation are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

res[x] = Rd.W[x] + (Rs1.W[x].H[0] * Rs2.W[x].H[0]); // KMABB
res[x] = Rd.W[x] + (Rs1.W[x].H[0] * Rs2.W[x].H[1]); // KMABT
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[1]); // KMATT
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 2768 of file core_feature_dsp.h.

2769 {
2770  __ASM volatile("kmabt %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
2771  return t;
2772 }

References __ASM.

◆ __RV_KMADA()

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

KMADA (SIMD Saturating Signed Multiply Two Halfs and Two Adds)

Type: SIMD

Syntax:

KMADA Rd, Rs1, Rs2
KMAXDA Rd, Rs1, Rs2

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

  • KMADA: rd.W[x] + top*top + bottom*bottom (per 32-bit element)
  • KMAXDA: rd.W[x] + top*bottom + bottom*top (per 32-bit element)

Description:
For the `KMADA instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2 and then adds the result to the result of multiplying the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. For the KMAXDA instruction, it multiplies the top 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2 and then adds the result to the result of multiplying the bottom 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. The result is added to the content of 32-bit elements in Rd. If the addition result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to 1. The 32-bit results after saturation are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

// KMADA
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[1]) + (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
// KMAXDA
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[0]) + (Rs1.W[x].H[0] * Rs2.W[x].H[1]);
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 2895 of file core_feature_dsp.h.

2896 {
2897  __ASM volatile("kmada %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
2898  return t;
2899 }

References __ASM.

◆ __RV_KMADRS()

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

KMADRS (SIMD Saturating Signed Multiply Two Halfs & Reverse Subtract & Add)

Type: SIMD

Syntax:

KMADS Rd, Rs1, Rs2
KMADRS Rd, Rs1, Rs2
KMAXDS Rd, Rs1, Rs2

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

  • KMADS: rd.W[x] + (top*top - bottom*bottom) (per 32-bit element)
  • KMADRS: rd.W[x] + (bottom*bottom - top*top) (per 32-bit element)
  • KMAXDS: rd.W[x] + (top*bottom - bottom*top) (per 32-bit element)

Description:
For the KMADS instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. For the KMADRS instruction, it multiplies the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2 and then subtracts the result from the result of multiplying the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32- bit elements in Rs2. For the KMAXDS instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2. The subtraction result is then added to the content of the corresponding 32-bit elements in Rd. If the addition result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to 1. The 32-bit results after saturation are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

// KMADS
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[1]) - (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
// KMADRS
res[x] = Rd.W[x] + (Rs1.W[x].H[0] * Rs2.W[x].H[0]) - (Rs1.W[x].H[1] * Rs2.W[x].H[1]);
// KMAXDS
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[0]) - (Rs1.W[x].H[0] * Rs2.W[x].H[1]);
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 3103 of file core_feature_dsp.h.

3104 {
3105  __ASM volatile("kmadrs %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
3106  return t;
3107 }

References __ASM.

◆ __RV_KMADS()

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

KMADS (SIMD Saturating Signed Multiply Two Halfs & Subtract & Add)

Type: SIMD

Syntax:

KMADS Rd, Rs1, Rs2
KMADRS Rd, Rs1, Rs2
KMAXDS Rd, Rs1, Rs2

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

  • KMADS: rd.W[x] + (top*top - bottom*bottom) (per 32-bit element)
  • KMADRS: rd.W[x] + (bottom*bottom - top*top) (per 32-bit element)
  • KMAXDS: rd.W[x] + (top*bottom - bottom*top) (per 32-bit element)

Description:
For the KMADS instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. For the KMADRS instruction, it multiplies the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2 and then subtracts the result from the result of multiplying the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32- bit elements in Rs2. For the KMAXDS instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2. The subtraction result is then added to the content of the corresponding 32-bit elements in Rd. If the addition result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to 1. The 32-bit results after saturation are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

// KMADS
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[1]) - (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
// KMADRS
res[x] = Rd.W[x] + (Rs1.W[x].H[0] * Rs2.W[x].H[0]) - (Rs1.W[x].H[1] * Rs2.W[x].H[1]);
// KMAXDS
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[0]) - (Rs1.W[x].H[0] * Rs2.W[x].H[1]);
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 3031 of file core_feature_dsp.h.

3032 {
3033  __ASM volatile("kmads %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
3034  return t;
3035 }

References __ASM.

◆ __RV_KMATT()

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

KMATT (SIMD Saturating Signed Multiply Top Halfs & Add)

Type: SIMD

Syntax:

KMABB Rd, Rs1, Rs2
KMABT Rd, Rs1, Rs2
KMATT Rd, Rs1, Rs2

Purpose:
Multiply the signed 16-bit content of 32-bit elements in a register with the 16-bit content of 32-bit elements in another register and add the result to the content of 32-bit elements in the third register. The addition result may be saturated and is written to the third register.

  • KMABB: rd.W[x] + bottom*bottom (per 32-bit element)
  • KMABT rd.W[x] + bottom*top (per 32-bit element)
  • KMATT rd.W[x] + top*top (per 32-bit element)

Description:
For the KMABB instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2. For the KMABT instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. For the KMATT instruction, it multiplies the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. The multiplication result is added to the content of 32-bit elements in Rd. If the addition result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to

  1. The results after saturation are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

res[x] = Rd.W[x] + (Rs1.W[x].H[0] * Rs2.W[x].H[0]); // KMABB
res[x] = Rd.W[x] + (Rs1.W[x].H[0] * Rs2.W[x].H[1]); // KMABT
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[1]); // KMATT
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 2831 of file core_feature_dsp.h.

2832 {
2833  __ASM volatile("kmatt %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
2834  return t;
2835 }

References __ASM.

◆ __RV_KMAXDA()

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

KMAXDA (SIMD Saturating Signed Crossed Multiply Two Halfs and Two Adds)

Type: SIMD

Syntax:

KMADA Rd, Rs1, Rs2
KMAXDA Rd, Rs1, Rs2

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

  • KMADA: rd.W[x] + top*top + bottom*bottom (per 32-bit element)
  • KMAXDA: rd.W[x] + top*bottom + bottom*top (per 32-bit element)

Description:
For the `KMADA instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2 and then adds the result to the result of multiplying the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. For the KMAXDA instruction, it multiplies the top 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2 and then adds the result to the result of multiplying the bottom 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. The result is added to the content of 32-bit elements in Rd. If the addition result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to 1. The 32-bit results after saturation are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

// KMADA
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[1]) + (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
// KMAXDA
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[0]) + (Rs1.W[x].H[0] * Rs2.W[x].H[1]);
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 2959 of file core_feature_dsp.h.

2960 {
2961  __ASM volatile("kmaxda %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
2962  return t;
2963 }

References __ASM.

◆ __RV_KMAXDS()

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

KMAXDS (SIMD Saturating Signed Crossed Multiply Two Halfs & Subtract & Add)

Type: SIMD

Syntax:

KMADS Rd, Rs1, Rs2
KMADRS Rd, Rs1, Rs2
KMAXDS Rd, Rs1, Rs2

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

  • KMADS: rd.W[x] + (top*top - bottom*bottom) (per 32-bit element)
  • KMADRS: rd.W[x] + (bottom*bottom - top*top) (per 32-bit element)
  • KMAXDS: rd.W[x] + (top*bottom - bottom*top) (per 32-bit element)

Description:
For the KMADS instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2. For the KMADRS instruction, it multiplies the top 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2 and then subtracts the result from the result of multiplying the bottom 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32- bit elements in Rs2. For the KMAXDS instruction, it multiplies the bottom 16-bit content of 32-bit elements in Rs1 with the top 16-bit content of 32-bit elements in Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of 32-bit elements in Rs1 with the bottom 16-bit content of 32-bit elements in Rs2. The subtraction result is then added to the content of the corresponding 32-bit elements in Rd. If the addition result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to 1. The 32-bit results after saturation are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

// KMADS
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[1]) - (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
// KMADRS
res[x] = Rd.W[x] + (Rs1.W[x].H[0] * Rs2.W[x].H[0]) - (Rs1.W[x].H[1] * Rs2.W[x].H[1]);
// KMAXDS
res[x] = Rd.W[x] + (Rs1.W[x].H[1] * Rs2.W[x].H[0]) - (Rs1.W[x].H[0] * Rs2.W[x].H[1]);
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 3175 of file core_feature_dsp.h.

3176 {
3177  __ASM volatile("kmaxds %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
3178  return t;
3179 }

References __ASM.

◆ __RV_KMDA()

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

KMDA (SIMD Signed Multiply Two Halfs and Add)

Type: SIMD

Syntax:

KMDA Rd, Rs1, Rs2
KMXDA Rd, Rs1, Rs2

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

  • KMDA: top*top + bottom*bottom (per 32-bit element)
  • KMXDA: top*bottom + bottom*top (per 32-bit element)

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

Operations:

if Rs1.W[x] != 0x80008000) or (Rs2.W[x] != 0x80008000 { // KMDA Rd.W[x] = Rs1.W[x].H[1] *
Rs2.W[x].H[1]) + (Rs1.W[x].H[0] * Rs2.W[x].H[0]; // KMXDA Rd.W[x] = Rs1.W[x].H[1] * Rs2.W[x].H[0])
+ (Rs1.W[x].H[0] * Rs2.W[x].H[1]; } else { Rd.W[x] = 0x7fffffff; OV = 1; } for RV32: x=0 for RV64:
x=1...0
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 3293 of file core_feature_dsp.h.

3294 {
3295  long result;
3296  __ASM volatile("kmda %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
3297  return result;
3298 }

References __ASM.

◆ __RV_KMSDA()

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

KMSDA (SIMD Saturating Signed Multiply Two Halfs & Add & Subtract)

Type: SIMD

Syntax:

KMSDA Rd, Rs1, Rs2
KMSXDA Rd, Rs1, Rs2

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

  • KMSDA: rd.W[x] - top*top - bottom*bottom (per 32-bit element)
  • KMSXDA: rd.W[x] - top*bottom - bottom*top (per 32-bit element)

Description:
For the KMSDA instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2 and multiplies the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. For the KMSXDA instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2 and multiplies the top 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. The two 32-bit multiplication results are then subtracted from the content of the corresponding 32- bit elements of Rd. If the subtraction result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to 1. The results after saturation are written to Rd. The 16-bit contents are treated as signed integers.

Operations:

// KMSDA
res[x] = Rd.W[x] - (Rs1.W[x].H[1] * Rs2.W[x].H[1]) - (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
// KMSXDA
res[x] = Rd.W[x] - (Rs1.W[x].H[1] * Rs2.W[x].H[0]) - (Rs1.W[x].H[0] * Rs2.W[x].H[1]);
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 4393 of file core_feature_dsp.h.

4394 {
4395  __ASM volatile("kmsda %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
4396  return t;
4397 }

References __ASM.

◆ __RV_KMSXDA()

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

KMSXDA (SIMD Saturating Signed Crossed Multiply Two Halfs & Add & Subtract)

Type: SIMD

Syntax:

KMSDA Rd, Rs1, Rs2
KMSXDA Rd, Rs1, Rs2

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

  • KMSDA: rd.W[x] - top*top - bottom*bottom (per 32-bit element)
  • KMSXDA: rd.W[x] - top*bottom - bottom*top (per 32-bit element)

Description:
For the KMSDA instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2 and multiplies the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. For the KMSXDA instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2 and multiplies the top 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. The two 32-bit multiplication results are then subtracted from the content of the corresponding 32- bit elements of Rd. If the subtraction result is beyond the Q31 number range (-2^31 <= Q31 <= 2^31-1), it is saturated to the range and the OV bit is set to 1. The results after saturation are written to Rd. The 16-bit contents are treated as signed integers.

Operations:

// KMSDA
res[x] = Rd.W[x] - (Rs1.W[x].H[1] * Rs2.W[x].H[1]) - (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
// KMSXDA
res[x] = Rd.W[x] - (Rs1.W[x].H[1] * Rs2.W[x].H[0]) - (Rs1.W[x].H[0] * Rs2.W[x].H[1]);
if (res[x] > (2^31)-1) {
res[x] = (2^31)-1;
OV = 1;
} else if (res[x] < -2^31) {
res[x] = -2^31;
OV = 1;
}
Rd.W[x] = res[x];
for RV32: x=0
for RV64: x=1...0
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 4455 of file core_feature_dsp.h.

4456 {
4457  __ASM volatile("kmsxda %0, %1, %2" : "+r"(t) : "r"(a), "r"(b));
4458  return t;
4459 }

References __ASM.

◆ __RV_KMXDA()

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

KMXDA (SIMD Signed Crossed Multiply Two Halfs and Add)

Type: SIMD

Syntax:

KMDA Rd, Rs1, Rs2
KMXDA Rd, Rs1, Rs2

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

  • KMDA: top*top + bottom*bottom (per 32-bit element)
  • KMXDA: top*bottom + bottom*top (per 32-bit element)

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

Operations:

if Rs1.W[x] != 0x80008000) or (Rs2.W[x] != 0x80008000 { // KMDA Rd.W[x] = Rs1.W[x].H[1] *
Rs2.W[x].H[1]) + (Rs1.W[x].H[0] * Rs2.W[x].H[0]; // KMXDA Rd.W[x] = Rs1.W[x].H[1] * Rs2.W[x].H[0])
+ (Rs1.W[x].H[0] * Rs2.W[x].H[1]; } else { Rd.W[x] = 0x7fffffff; OV = 1; } for RV32: x=0 for RV64:
x=1...0
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 3344 of file core_feature_dsp.h.

3345 {
3346  long result;
3347  __ASM volatile("kmxda %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
3348  return result;
3349 }

References __ASM.

◆ __RV_SMBB16()

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

SMBB16 (SIMD Signed Multiply Bottom Half & Bottom Half)

Type: SIMD

Syntax:

SMBB16 Rd, Rs1, Rs2
SMBT16 Rd, Rs1, Rs2
SMTT16 Rd, Rs1, Rs2

Purpose:
Multiply the signed 16-bit content of the 32-bit elements of a register with the signed 16- bit content of the 32-bit elements of another register and write the result to a third register.

  • SMBB16: W[x].bottom*W[x].bottom
  • SMBT16: W[x].bottom *W[x].top
  • SMTT16: W[x].top * W[x].top

Description:
For the SMBB16 instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. For the SMBT16 instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. For the SMTT16 instruction, it multiplies the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. The multiplication results are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

Rd.W[x] = Rs1.W[x].H[0] * Rs2.W[x].H[0]; // SMBB16
Rd.W[x] = Rs1.W[x].H[0] * Rs2.W[x].H[1]; // SMBT16
Rd.W[x] = Rs1.W[x].H[1] * Rs2.W[x].H[1]; // SMTT16
for RV32: x=0,
for RV64: x=1...0
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 8355 of file core_feature_dsp.h.

8356 {
8357  long result;
8358  __ASM volatile("smbb16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
8359  return result;
8360 }

References __ASM.

◆ __RV_SMBT16()

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

SMBT16 (SIMD Signed Multiply Bottom Half & Top Half)

Type: SIMD

Syntax:

SMBB16 Rd, Rs1, Rs2
SMBT16 Rd, Rs1, Rs2
SMTT16 Rd, Rs1, Rs2

Purpose:
Multiply the signed 16-bit content of the 32-bit elements of a register with the signed 16- bit content of the 32-bit elements of another register and write the result to a third register.

  • SMBB16: W[x].bottom*W[x].bottom
  • SMBT16: W[x].bottom *W[x].top
  • SMTT16: W[x].top * W[x].top

Description:
For the SMBB16 instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. For the SMBT16 instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. For the SMTT16 instruction, it multiplies the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. The multiplication results are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

Rd.W[x] = Rs1.W[x].H[0] * Rs2.W[x].H[0]; // SMBB16
Rd.W[x] = Rs1.W[x].H[0] * Rs2.W[x].H[1]; // SMBT16
Rd.W[x] = Rs1.W[x].H[1] * Rs2.W[x].H[1]; // SMTT16
for RV32: x=0,
for RV64: x=1...0
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 8407 of file core_feature_dsp.h.

8408 {
8409  long result;
8410  __ASM volatile("smbt16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
8411  return result;
8412 }

References __ASM.

◆ __RV_SMDRS()

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

SMDRS (SIMD Signed Multiply Two Halfs and Reverse Subtract)

Type: SIMD

Syntax:

SMDS Rd, Rs1, Rs2
SMDRS Rd, Rs1, Rs2
SMXDS Rd, Rs1, Rs2

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

  • SMDS: top*top - bottom*bottom (per 32-bit element)
  • SMDRS: bottom*bottom - top*top (per 32-bit element)
  • SMXDS: top*bottom - bottom*top (per 32-bit element)

Description:
For the SMDS instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. For the SMDRS instruction, it multiplies the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2 and then subtracts the result from the result of multiplying the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. For the SMXDS instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. The subtraction result is written to the corresponding 32-bit element of Rd. The 16-bit contents of multiplication are treated as signed integers.

Operations:

* SMDS:
Rd.W[x] = (Rs1.W[x].H[1] * Rs2.W[x].H[1]) - (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
* SMDRS:
Rd.W[x] = (Rs1.W[x].H[0] * Rs2.W[x].H[0]) - (Rs1.W[x].H[1] * Rs2.W[x].H[1]);
* SMXDS:
Rd.W[x] = (Rs1.W[x].H[1] * Rs2.W[x].H[0]) - (Rs1.W[x].H[0] * Rs2.W[x].H[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 8577 of file core_feature_dsp.h.

8578 {
8579  long result;
8580  __ASM volatile("smdrs %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
8581  return result;
8582 }

References __ASM.

◆ __RV_SMDS()

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

SMDS (SIMD Signed Multiply Two Halfs and Subtract)

Type: SIMD

Syntax:

SMDS Rd, Rs1, Rs2
SMDRS Rd, Rs1, Rs2
SMXDS Rd, Rs1, Rs2

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

  • SMDS: top*top - bottom*bottom (per 32-bit element)
  • SMDRS: bottom*bottom - top*top (per 32-bit element)
  • SMXDS: top*bottom - bottom*top (per 32-bit element)

Description:
For the SMDS instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. For the SMDRS instruction, it multiplies the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2 and then subtracts the result from the result of multiplying the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. For the SMXDS instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. The subtraction result is written to the corresponding 32-bit element of Rd. The 16-bit contents of multiplication are treated as signed integers.

Operations:

* SMDS:
Rd.W[x] = (Rs1.W[x].H[1] * Rs2.W[x].H[1]) - (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
* SMDRS:
Rd.W[x] = (Rs1.W[x].H[0] * Rs2.W[x].H[0]) - (Rs1.W[x].H[1] * Rs2.W[x].H[1]);
* SMXDS:
Rd.W[x] = (Rs1.W[x].H[1] * Rs2.W[x].H[0]) - (Rs1.W[x].H[0] * Rs2.W[x].H[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 8518 of file core_feature_dsp.h.

8519 {
8520  long result;
8521  __ASM volatile("smds %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
8522  return result;
8523 }

References __ASM.

◆ __RV_SMTT16()

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

SMTT16 (SIMD Signed Multiply Top Half & Top Half)

Type: SIMD

Syntax:

SMBB16 Rd, Rs1, Rs2
SMBT16 Rd, Rs1, Rs2
SMTT16 Rd, Rs1, Rs2

Purpose:
Multiply the signed 16-bit content of the 32-bit elements of a register with the signed 16- bit content of the 32-bit elements of another register and write the result to a third register.

  • SMBB16: W[x].bottom*W[x].bottom
  • SMBT16: W[x].bottom *W[x].top
  • SMTT16: W[x].top * W[x].top

Description:
For the SMBB16 instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. For the SMBT16 instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. For the SMTT16 instruction, it multiplies the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. The multiplication results are written to Rd. The 16-bit contents of Rs1 and Rs2 are treated as signed integers.

Operations:

Rd.W[x] = Rs1.W[x].H[0] * Rs2.W[x].H[0]; // SMBB16
Rd.W[x] = Rs1.W[x].H[0] * Rs2.W[x].H[1]; // SMBT16
Rd.W[x] = Rs1.W[x].H[1] * Rs2.W[x].H[1]; // SMTT16
for RV32: x=0,
for RV64: x=1...0
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 8459 of file core_feature_dsp.h.

8460 {
8461  long result;
8462  __ASM volatile("smtt16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
8463  return result;
8464 }

References __ASM.

◆ __RV_SMXDS()

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

SMXDS (SIMD Signed Crossed Multiply Two Halfs and Subtract)

Type: SIMD

Syntax:

SMDS Rd, Rs1, Rs2
SMDRS Rd, Rs1, Rs2
SMXDS Rd, Rs1, Rs2

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

  • SMDS: top*top - bottom*bottom (per 32-bit element)
  • SMDRS: bottom*bottom - top*top (per 32-bit element)
  • SMXDS: top*bottom - bottom*top (per 32-bit element)

Description:
For the SMDS instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2. For the SMDRS instruction, it multiplies the top 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2 and then subtracts the result from the result of multiplying the bottom 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. For the SMXDS instruction, it multiplies the bottom 16-bit content of the 32-bit elements of Rs1 with the top 16-bit content of the 32-bit elements of Rs2 and then subtracts the result from the result of multiplying the top 16-bit content of the 32-bit elements of Rs1 with the bottom 16-bit content of the 32-bit elements of Rs2. The subtraction result is written to the corresponding 32-bit element of Rd. The 16-bit contents of multiplication are treated as signed integers.

Operations:

* SMDS:
Rd.W[x] = (Rs1.W[x].H[1] * Rs2.W[x].H[1]) - (Rs1.W[x].H[0] * Rs2.W[x].H[0]);
* SMDRS:
Rd.W[x] = (Rs1.W[x].H[0] * Rs2.W[x].H[0]) - (Rs1.W[x].H[1] * Rs2.W[x].H[1]);
* SMXDS:
Rd.W[x] = (Rs1.W[x].H[1] * Rs2.W[x].H[0]) - (Rs1.W[x].H[0] * Rs2.W[x].H[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 8636 of file core_feature_dsp.h.

8637 {
8638  long result;
8639  __ASM volatile("smxds %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
8640  return result;
8641 }

References __ASM.

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