NMSIS-Core  Version 1.5.0
NMSIS-Core support for Nuclei processor-based devices

SIMD 16-bit Add/Subtract Instructions. More...

Functions

__STATIC_FORCEINLINE unsigned long __RV_ADD16 (unsigned long a, unsigned long b)
 ADD16 (SIMD 16-bit Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_CRAS16 (unsigned long a, unsigned long b)
 CRAS16 (SIMD 16-bit Cross Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_CRSA16 (unsigned long a, unsigned long b)
 CRSA16 (SIMD 16-bit Cross Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_KADD16 (unsigned long a, unsigned long b)
 KADD16 (SIMD 16-bit Signed Saturating Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_KCRAS16 (unsigned long a, unsigned long b)
 KCRAS16 (SIMD 16-bit Signed Saturating Cross Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_KCRSA16 (unsigned long a, unsigned long b)
 KCRSA16 (SIMD 16-bit Signed Saturating Cross Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_KSTAS16 (unsigned long a, unsigned long b)
 KSTAS16 (SIMD 16-bit Signed Saturating Straight Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_KSTSA16 (unsigned long a, unsigned long b)
 KSTSA16 (SIMD 16-bit Signed Saturating Straight Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_KSUB16 (unsigned long a, unsigned long b)
 KSUB16 (SIMD 16-bit Signed Saturating Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_RADD16 (unsigned long a, unsigned long b)
 RADD16 (SIMD 16-bit Signed Halving Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_RCRAS16 (unsigned long a, unsigned long b)
 RCRAS16 (SIMD 16-bit Signed Halving Cross Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_RCRSA16 (unsigned long a, unsigned long b)
 RCRSA16 (SIMD 16-bit Signed Halving Cross Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_RSTAS16 (unsigned long a, unsigned long b)
 RSTAS16 (SIMD 16-bit Signed Halving Straight Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_RSTSA16 (unsigned long a, unsigned long b)
 RSTSA16 (SIMD 16-bit Signed Halving Straight Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_RSUB16 (unsigned long a, unsigned long b)
 RSUB16 (SIMD 16-bit Signed Halving Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_STAS16 (unsigned long a, unsigned long b)
 STAS16 (SIMD 16-bit Straight Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_STSA16 (unsigned long a, unsigned long b)
 STSA16 (SIMD 16-bit Straight Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_SUB16 (unsigned long a, unsigned long b)
 SUB16 (SIMD 16-bit Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_UKADD16 (unsigned long a, unsigned long b)
 UKADD16 (SIMD 16-bit Unsigned Saturating Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_UKCRAS16 (unsigned long a, unsigned long b)
 UKCRAS16 (SIMD 16-bit Unsigned Saturating Cross Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_UKCRSA16 (unsigned long a, unsigned long b)
 UKCRSA16 (SIMD 16-bit Unsigned Saturating Cross Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_UKSTAS16 (unsigned long a, unsigned long b)
 UKSTAS16 (SIMD 16-bit Unsigned Saturating Straight Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_UKSTSA16 (unsigned long a, unsigned long b)
 UKSTSA16 (SIMD 16-bit Unsigned Saturating Straight Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_UKSUB16 (unsigned long a, unsigned long b)
 UKSUB16 (SIMD 16-bit Unsigned Saturating Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_URADD16 (unsigned long a, unsigned long b)
 URADD16 (SIMD 16-bit Unsigned Halving Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_URCRAS16 (unsigned long a, unsigned long b)
 URCRAS16 (SIMD 16-bit Unsigned Halving Cross Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_URCRSA16 (unsigned long a, unsigned long b)
 URCRSA16 (SIMD 16-bit Unsigned Halving Cross Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_URSTAS16 (unsigned long a, unsigned long b)
 URSTAS16 (SIMD 16-bit Unsigned Halving Straight Addition & Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long __RV_URSTSA16 (unsigned long a, unsigned long b)
 URSTSA16 (SIMD 16-bit Unsigned Halving Straight Subtraction & Addition) More...
 
__STATIC_FORCEINLINE unsigned long __RV_URSUB16 (unsigned long a, unsigned long b)
 URSUB16 (SIMD 16-bit Unsigned Halving Subtraction) More...
 

Detailed Description

SIMD 16-bit Add/Subtract Instructions.

Based on the combination of the types of the two 16-bit arithmetic operations, the SIMD 16-bit add/subtract instructions can be classified into 6 main categories: Addition (two 16-bit addition), Subtraction (two 16-bit subtraction), Crossed Add & Sub (one addition and one subtraction), and Crossed Sub & Add (one subtraction and one addition), Straight Add & Sub (one addition and one subtraction), and Straight Sub & Add (one subtraction and one addition). Based on the way of how an overflow condition is handled, the SIMD 16-bit add/subtract instructions can be classified into 5 groups: Wrap-around (dropping overflow), Signed Halving (keeping overflow by dropping 1 LSB bit), Unsigned Halving, Signed Saturation (clipping overflow), and Unsigned Saturation. Together, there are 30 SIMD 16-bit add/subtract instructions.

Function Documentation

◆ __RV_ADD16()

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

ADD16 (SIMD 16-bit Addition)

Type: SIMD

Syntax:

ADD16 Rd, Rs1, Rs2

Purpose:
Do 16-bit integer element additions simultaneously.

Description:
This instruction adds the 16-bit integer elements in Rs1 with the 16-bit integer elements in Rs2, and then writes the 16-bit element results to Rd.

Note:
This instruction can be used for either signed or unsigned addition.

Operations:

Rd.H[x] = Rs1.H[x] + Rs2.H[x];
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 494 of file core_feature_dsp.h.

495 {
496  unsigned long result;
497  __ASM volatile("add16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
498  return result;
499 }
#define __ASM
Pass information from the compiler to the assembler.
Definition: nmsis_gcc.h:55

References __ASM.

◆ __RV_CRAS16()

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

CRAS16 (SIMD 16-bit Cross Addition & Subtraction)

Type: SIMD

Syntax:

CRAS16 Rd, Rs1, Rs2

Purpose:
Do 16-bit integer element addition and 16-bit integer element subtraction in a 32-bit chunk simultaneously. Operands are from crossed positions in 32-bit chunks.

Description:
This instruction adds the 16-bit integer element in [31:16] of 32-bit chunks in Rs1 with the 16-bit integer element in [15:0] of 32-bit chunks in Rs2, and writes the result to [31:16] of 32-bit chunks in Rd; at the same time, it subtracts the 16-bit integer element in [31:16] of 32-bit chunks in Rs2 from the 16-bit integer element in [15:0] of 32-bit chunks, and writes the result to [15:0] of 32- bit chunks in Rd.

Note:
This instruction can be used for either signed or unsigned operations.

Operations:

Rd.W[x][31:16] = Rs1.W[x][31:16] + Rs2.W[x][15:0];
Rd.W[x][15:0] = Rs1.W[x][15:0] - Rs2.W[x][31:16];
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 unsigned long type

Definition at line 1286 of file core_feature_dsp.h.

1287 {
1288  unsigned long result;
1289  __ASM volatile("cras16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
1290  return result;
1291 }

References __ASM.

◆ __RV_CRSA16()

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

CRSA16 (SIMD 16-bit Cross Subtraction & Addition)

Type: SIMD

Syntax:

CRSA16 Rd, Rs1, Rs2

Purpose:
Do 16-bit integer element subtraction and 16-bit integer element addition in a 32-bit chunk simultaneously. Operands are from crossed positions in 32-bit chunks.

Description:
This instruction subtracts the 16-bit integer element in [15:0] of 32-bit chunks in Rs2 from the 16-bit integer element in [31:16] of 32-bit chunks in Rs1, and writes the result to [31:16] of 32-bit chunks in Rd; at the same time, it adds the 16-bit integer element in [31:16] of 32-bit chunks in Rs2 with the 16-bit integer element in [15:0] of 32-bit chunks in Rs1, and writes the result to [15:0] of 32-bit chunks in Rd.

Note:
This instruction can be used for either signed or unsigned operations.

Operations:

Rd.W[x][31:16] = Rs1.W[x][31:16] - Rs2.W[x][15:0];
Rd.W[x][15:0] = Rs1.W[x][15:0] + Rs2.W[x][31:16];
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 unsigned long type

Definition at line 1332 of file core_feature_dsp.h.

1333 {
1334  unsigned long result;
1335  __ASM volatile("crsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
1336  return result;
1337 }

References __ASM.

◆ __RV_KADD16()

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

KADD16 (SIMD 16-bit Signed Saturating Addition)

Type: SIMD

Syntax:

KADD16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element saturating additions simultaneously.

Description:
This instruction adds the 16-bit signed integer elements in Rs1 with the 16-bit signed integer elements in Rs2. If any of the results are beyond the Q15 number range (-2^15 <= Q15 <= 2^15-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to Rd.

Operations:

res[x] = Rs1.H[x] + Rs2.H[x];
if (res[x] > 32767) {
res[x] = 32767;
OV = 1;
} else if (res[x] < -32768) {
res[x] = -32768;
OV = 1;
}
Rd.H[x] = res[x];
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 1604 of file core_feature_dsp.h.

1605 {
1606  unsigned long result;
1607  __ASM volatile("kadd16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
1608  return result;
1609 }

References __ASM.

◆ __RV_KCRAS16()

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

KCRAS16 (SIMD 16-bit Signed Saturating Cross Addition & Subtraction)

Type: SIMD

Syntax:

KCRAS16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element saturating addition and 16-bit signed integer element saturating subtraction in a 32-bit chunk simultaneously. Operands are from crossed positions in 32- bit chunks.

Description:
This instruction adds the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs1 with the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs2; at the same time, it subtracts the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs2 from the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs1. If any of the results are beyond the Q15 number range (-2^15 <= Q15 <= 2^15-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32-bit chunks in Rd for addition and [15:0] of 32-bit chunks in Rd for subtraction.

Operations:

res1 = Rs1.W[x][31:16] + Rs2.W[x][15:0];
res2 = Rs1.W[x][15:0] - Rs2.W[x][31:16];
for (res in [res1, res2]) {
if (res > (2^15)-1) {
res = (2^15)-1;
OV = 1;
} else if (res < -2^15) {
res = -2^15;
OV = 1;
}
}
Rd.W[x][31:16] = res1;
Rd.W[x][15:0] = res2;
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 unsigned long type

Definition at line 1822 of file core_feature_dsp.h.

1823 {
1824  unsigned long result;
1825  __ASM volatile("kcras16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
1826  return result;
1827 }

References __ASM.

◆ __RV_KCRSA16()

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

KCRSA16 (SIMD 16-bit Signed Saturating Cross Subtraction & Addition)

Type: SIMD

Syntax:

KCRSA16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element saturating subtraction and 16-bit signed integer element saturating addition in a 32-bit chunk simultaneously. Operands are from crossed positions in 32-bit chunks.

Description:
This instruction subtracts the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs2 from the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs1; at the same time, it adds the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs2 with the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs1. If any of the results are beyond the Q15 number range (-2^15 <= Q15 <= 2^15-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32-bit chunks in Rd for subtraction and [15:0] of 32-bit chunks in Rd for addition.

Operations:

res1 = Rs1.W[x][31:16] - Rs2.W[x][15:0];
res2 = Rs1.W[x][15:0] + Rs2.W[x][31:16];
for (res in [res1, res2]) {
if (res > (2^15)-1) {
res = (2^15)-1;
OV = 1;
} else if (res < -2^15) {
res = -2^15;
OV = 1;
}
}
Rd.W[x][31:16] = res1;
Rd.W[x][15:0] = res2;
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 unsigned long type

Definition at line 1879 of file core_feature_dsp.h.

1880 {
1881  unsigned long result;
1882  __ASM volatile("kcrsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
1883  return result;
1884 }

References __ASM.

◆ __RV_KSTAS16()

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

KSTAS16 (SIMD 16-bit Signed Saturating Straight Addition & Subtraction)

Type: SIMD

Syntax:

KSTAS16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element saturating addition and 16-bit signed integer element saturating subtraction in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks.

Description:
This instruction adds the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs1 with the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs2; at the same time, it subtracts the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs2 from the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs1. If any of the results are beyond the Q15 number range (-2^15 <= Q15 <= 2^15-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32-bit chunks in Rd for addition and [15:0] of 32-bit chunks in Rd for subtraction.

Operations:

res1 = Rs1.W[x][31:16] + Rs2.W[x][31:16];
res2 = Rs1.W[x][15:0] - Rs2.W[x][15:0];
for (res in [res1, res2]) {
if (res > (2^15)-1) {
res = (2^15)-1;
OV = 1;
} else if (res < -2^15) {
res = -2^15;
OV = 1;
}
}
Rd.W[x][31:16] = res1;
Rd.W[x][15:0] = res2;
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 unsigned long type

Definition at line 5282 of file core_feature_dsp.h.

5283 {
5284  unsigned long result;
5285  __ASM volatile("kstas16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
5286  return result;
5287 }

References __ASM.

◆ __RV_KSTSA16()

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

KSTSA16 (SIMD 16-bit Signed Saturating Straight Subtraction & Addition)

Type: SIMD

Syntax:

KSTSA16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element saturating subtraction and 16-bit signed integer element saturating addition in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks.

Description:
This instruction subtracts the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs2 from the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs1; at the same time, it adds the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs2 with the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs1. If any of the results are beyond the Q15 number range (-2^15 <= Q15 <= 2^15-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32-bit chunks in Rd for subtraction and [15:0] of 32-bit chunks in Rd for addition.

Operations:

res1 = Rs1.W[x][31:16] - Rs2.W[x][31:16];
res2 = Rs1.W[x][15:0] + Rs2.W[x][15:0];
for (res in [res1, res2]) {
if (res > (2^15)-1) {
res = (2^15)-1;
OV = 1;
} else if (res < -2^15) {
res = -2^15;
OV = 1;
}
}
Rd.W[x][31:16] = res1;
Rd.W[x][15:0] = res2;
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 unsigned long type

Definition at line 5339 of file core_feature_dsp.h.

5340 {
5341  unsigned long result;
5342  __ASM volatile("kstsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
5343  return result;
5344 }

References __ASM.

◆ __RV_KSUB16()

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

KSUB16 (SIMD 16-bit Signed Saturating Subtraction)

Type: SIMD

Syntax:

KSUB16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer elements saturating subtractions simultaneously.

Description:
This instruction subtracts the 16-bit signed integer elements in Rs2 from the 16-bit signed integer elements in Rs1. If any of the results are beyond the Q15 number range (-2^15 <= Q15 <= 2^15-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to Rd.

Operations:

res[x] = Rs1.H[x] - Rs2.H[x];
if (res[x] > (2^15)-1) {
res[x] = (2^15)-1;
OV = 1;
} else if (res[x] < -2^15) {
res[x] = -2^15;
OV = 1;
}
Rd.H[x] = res[x];
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 5434 of file core_feature_dsp.h.

5435 {
5436  unsigned long result;
5437  __ASM volatile("ksub16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
5438  return result;
5439 }

References __ASM.

◆ __RV_RADD16()

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

RADD16 (SIMD 16-bit Signed Halving Addition)

Type: SIMD

Syntax:

RADD16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element additions simultaneously. The results are halved to avoid overflow or saturation.

Description:
This instruction adds the 16-bit signed integer elements in Rs1 with the 16-bit signed integer elements in Rs2. The results are first arithmetically right-shifted by 1 bit and then written to Rd.

Examples:

* Rs1 = 0x7FFF, Rs2 = 0x7FFF, Rd = 0x7FFF
* Rs1 = 0x8000, Rs2 = 0x8000, Rd = 0x8000
* Rs1 = 0x4000, Rs2 = 0x8000, Rd = 0xE000

Operations:

Rd.H[x] = (Rs1.H[x] + Rs2.H[x]) s>> 1; for RV32: x=1...0, for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 6352 of file core_feature_dsp.h.

6353 {
6354  unsigned long result;
6355  __ASM volatile("radd16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
6356  return result;
6357 }

References __ASM.

◆ __RV_RCRAS16()

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

RCRAS16 (SIMD 16-bit Signed Halving Cross Addition & Subtraction)

Type: SIMD

Syntax:

RCRAS16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element addition and 16-bit signed integer element subtraction in a 32-bit chunk simultaneously. Operands are from crossed positions in 32-bit chunks. The results are halved to avoid overflow or saturation.

Description:
This instruction adds the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs1 with the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs2, and subtracts the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs2 from the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs1. The element results are first arithmetically right-shifted by 1 bit and then written to [31:16] of 32-bit chunks in Rd and [15:0] of 32-bit chunks in Rd.

Examples:

Please see `RADD16` and `RSUB16` instructions.

Operations:

Rd.W[x][31:16] = (Rs1.W[x][31:16] + Rs2.W[x][15:0]) s>> 1;
Rd.W[x][15:0] = (Rs1.W[x][15:0] - Rs2.W[x][31:16]) s>> 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 unsigned long type

Definition at line 6502 of file core_feature_dsp.h.

6503 {
6504  unsigned long result;
6505  __ASM volatile("rcras16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
6506  return result;
6507 }

References __ASM.

◆ __RV_RCRSA16()

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

RCRSA16 (SIMD 16-bit Signed Halving Cross Subtraction & Addition)

Type: SIMD

Syntax:

RCRSA16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element subtraction and 16-bit signed integer element addition in a 32-bit chunk simultaneously. Operands are from crossed positions in 32-bit chunks. The results are halved to avoid overflow or saturation.

Description:
This instruction subtracts the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs2 from the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs1, and adds the 16-bit signed element integer in [15:0] of 32-bit chunks in Rs1 with the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs2. The two results are first arithmetically right-shifted by 1 bit and then written to [31:16] of 32-bit chunks in Rd and [15:0] of 32-bit chunks in Rd.

Examples:

Please see `RADD16` and `RSUB16` instructions.

Operations:

Rd.W[x][31:16] = (Rs1.W[x][31:16] - Rs2.W[x][15:0]) s>> 1;
Rd.W[x][15:0] = (Rs1.W[x][15:0] + Rs2.W[x][31:16]) s>> 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 unsigned long type

Definition at line 6551 of file core_feature_dsp.h.

6552 {
6553  unsigned long result;
6554  __ASM volatile("rcrsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
6555  return result;
6556 }

References __ASM.

◆ __RV_RSTAS16()

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

RSTAS16 (SIMD 16-bit Signed Halving Straight Addition & Subtraction)

Type: SIMD

Syntax:

RSTAS16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element addition and 16-bit signed integer element subtraction in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks. The results are halved to avoid overflow or saturation.

Description:
This instruction adds the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs1 with the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs2, and subtracts the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs2 from the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs1. The element results are first arithmetically right-shifted by 1 bit and then written to [31:16] of 32-bit chunks in Rd and [15:0] of 32-bit chunks in Rd.

Examples:

Please see `RADD16` and `RSUB16` instructions.

Operations:

Rd.W[x][31:16] = (Rs1.W[x][31:16] + Rs2.W[x][31:16]) s>> 1;
Rd.W[x][15:0] = (Rs1.W[x][15:0] - Rs2.W[x][15:0]) s>> 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 unsigned long type

Definition at line 6627 of file core_feature_dsp.h.

6628 {
6629  unsigned long result;
6630  __ASM volatile("rstas16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
6631  return result;
6632 }

References __ASM.

◆ __RV_RSTSA16()

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

RSTSA16 (SIMD 16-bit Signed Halving Straight Subtraction & Addition)

Type: SIMD

Syntax:

RSTSA16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element subtraction and 16-bit signed integer element addition in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks. The results are halved to avoid overflow or saturation.

Description:
This instruction subtracts the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs2 from the 16-bit signed integer element in [31:16] of 32-bit chunks in Rs1, and adds the 16-bit signed element integer in [15:0] of 32-bit chunks in Rs1 with the 16-bit signed integer element in [15:0] of 32-bit chunks in Rs2. The two results are first arithmetically right-shifted by 1 bit and then written to [31:16] of 32-bit chunks in Rd and [15:0] of 32-bit chunks in Rd.

Examples:

Please see `RADD16` and `RSUB16` instructions.

Operations:

Rd.W[x][31:16] = (Rs1.W[x][31:16] - Rs2.W[x][31:16]) s>> 1;
Rd.W[x][15:0] = (Rs1.W[x][15:0] + Rs2.W[x][15:0]) s>> 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 unsigned long type

Definition at line 6676 of file core_feature_dsp.h.

6677 {
6678  unsigned long result;
6679  __ASM volatile("rstsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
6680  return result;
6681 }

References __ASM.

◆ __RV_RSUB16()

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

RSUB16 (SIMD 16-bit Signed Halving Subtraction)

Type: SIMD

Syntax:

RSUB16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer element subtractions simultaneously. The results are halved to avoid overflow or saturation.

Description:
This instruction subtracts the 16-bit signed integer elements in Rs2 from the 16-bit signed integer elements in Rs1. The results are first arithmetically right-shifted by 1 bit and then written to Rd.

Examples:

* Ra = 0x7FFF, Rb = 0x8000, Rt = 0x7FFF
* Ra = 0x8000, Rb = 0x7FFF, Rt = 0x8000
* Ra = 0x8000, Rb = 0x4000, Rt = 0xA000

Operations:

Rd.H[x] = (Rs1.H[x] - Rs2.H[x]) s>> 1;
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 6770 of file core_feature_dsp.h.

6771 {
6772  unsigned long result;
6773  __ASM volatile("rsub16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
6774  return result;
6775 }

References __ASM.

◆ __RV_STAS16()

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

STAS16 (SIMD 16-bit Straight Addition & Subtraction)

Type: SIMD

Syntax:

STAS16 Rd, Rs1, Rs2

Purpose:
Do 16-bit integer element addition and 16-bit integer element subtraction in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks.

Description:
This instruction adds the 16-bit integer element in [31:16] of 32-bit chunks in Rs1 with the 16-bit integer element in [31:16] of 32-bit chunks in Rs2, and writes the result to [31:16] of 32-bit chunks in Rd; at the same time, it subtracts the 16-bit integer element in [15:0] of 32-bit chunks in Rs2 from the 16-bit integer element in [15:0] of 32-bit chunks, and writes the result to [15:0] of 32- bit chunks in Rd.

Note:
This instruction can be used for either signed or unsigned operations.

Operations:

Rd.W[x][31:16] = Rs1.W[x][31:16] + Rs2.W[x][31:16];
Rd.W[x][15:0] = Rs1.W[x][15:0] - Rs2.W[x][15:0];
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 unsigned long type

Definition at line 10585 of file core_feature_dsp.h.

10586 {
10587  unsigned long result;
10588  __ASM volatile("stas16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
10589  return result;
10590 }

References __ASM.

◆ __RV_STSA16()

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

STSA16 (SIMD 16-bit Straight Subtraction & Addition)

Type: SIMD

Syntax:

STSA16 Rd, Rs1, Rs2

Purpose:
Do 16-bit integer element subtraction and 16-bit integer element addition in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks.

Description:
This instruction subtracts the 16-bit integer element in [31:16] of 32-bit chunks in Rs2 from the 16-bit integer element in [31:16] of 32-bit chunks in Rs1, and writes the result to [31:16] of 32-bit chunks in Rd; at the same time, it adds the 16-bit integer element in [15:0] of 32-bit chunks in Rs2 with the 16-bit integer element in [15:0] of 32-bit chunks in Rs1, and writes the result to [15:0] of 32-bit chunks in Rd.

Note:
This instruction can be used for either signed or unsigned operations.

Operations:

Rd.W[x][31:16] = Rs1.W[x][31:16] - Rs2.W[x][31:16];
Rd.W[x][15:0] = Rs1.W[x][15:0] + Rs2.W[x][15:0];
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 unsigned long type

Definition at line 10631 of file core_feature_dsp.h.

10632 {
10633  unsigned long result;
10634  __ASM volatile("stsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
10635  return result;
10636 }

References __ASM.

◆ __RV_SUB16()

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

SUB16 (SIMD 16-bit Subtraction)

Type: SIMD

Syntax:

SUB16 Rd, Rs1, Rs2

Purpose:
Do 16-bit integer element subtractions simultaneously.

Description:
This instruction subtracts the 16-bit integer elements in Rs2 from the 16-bit integer elements in Rs1, and then writes the result to Rd.

Note:
This instruction can be used for either signed or unsigned subtraction.

Operations:

Rd.H[x] = Rs1.H[x] - Rs2.H[x];
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 10713 of file core_feature_dsp.h.

10714 {
10715  unsigned long result;
10716  __ASM volatile("sub16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
10717  return result;
10718 }

References __ASM.

◆ __RV_UKADD16()

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

UKADD16 (SIMD 16-bit Unsigned Saturating Addition)

Type: SIMD

Syntax:

UKADD16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer element saturating additions simultaneously.

Description:
This instruction adds the 16-bit unsigned integer elements in Rs1 with the 16-bit unsigned integer elements in Rs2. If any of the results are beyond the 16-bit unsigned number range (0 <= RES <= 2^16-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to Rd.

Operations:

res[x] = Rs1.H[x] + Rs2.H[x];
if (res[x] > (2^16)-1) {
res[x] = (2^16)-1;
OV = 1;
}
Rd.H[x] = res[x];
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 11466 of file core_feature_dsp.h.

11467 {
11468  unsigned long result;
11469  __ASM volatile("ukadd16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
11470  return result;
11471 }

References __ASM.

◆ __RV_UKCRAS16()

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

UKCRAS16 (SIMD 16-bit Unsigned Saturating Cross Addition & Subtraction)

Type: SIMD

Syntax:

UKCRAS16 Rd, Rs1, Rs2

Purpose:
Do one 16-bit unsigned integer element saturating addition and one 16-bit unsigned integer element saturating subtraction in a 32-bit chunk simultaneously. Operands are from crossed positions in 32-bit chunks.

Description:
This instruction adds the 16-bit unsigned integer element in [31:16] of 32-bit chunks in Rs1 with the 16-bit unsigned integer element in [15:0] of 32-bit chunks in Rs2; at the same time, it subtracts the 16-bit unsigned integer element in [31:16] of 32-bit chunks in Rs2 from the 16-bit unsigned integer element in [15:0] of 32-bit chunks in Rs1. If any of the results are beyond the 16-bit unsigned number range (0 <= RES <= 2^16-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32-bit chunks in Rd for addition and [15:0] of 32-bit chunks in Rd for subtraction.

Operations:

res1 = Rs1.W[x][31:16] + Rs2.W[x][15:0];
res2 = Rs1.W[x][15:0] - Rs2.W[x][31:16];
if (res1 > (2^16)-1) {
res1 = (2^16)-1;
OV = 1;
}
if (res2 < 0) {
res2 = 0;
OV = 1;
}
Rd.W[x][31:16] = res1;
Rd.W[x][15:0] = res2;
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 unsigned long type

Definition at line 11669 of file core_feature_dsp.h.

11670 {
11671  unsigned long result;
11672  __ASM volatile("ukcras16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
11673  return result;
11674 }

References __ASM.

◆ __RV_UKCRSA16()

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

UKCRSA16 (SIMD 16-bit Unsigned Saturating Cross Subtraction & Addition)

Type: SIMD

Syntax:

UKCRSA16 Rd, Rs1, Rs2

Purpose:
Do one 16-bit unsigned integer element saturating subtraction and one 16-bit unsigned integer element saturating addition in a 32-bit chunk simultaneously. Operands are from crossed positions in 32-bit chunks.

Description:
This instruction subtracts the 16-bit unsigned integer element in [15:0] of 32-bit chunks in Rs2 from the 16-bit unsigned integer element in [31:16] of 32-bit chunks in Rs1; at the same time, it adds the 16-bit unsigned integer element in [31:16] of 32-bit chunks in Rs2 with the 16- bit unsigned integer element in [15:0] of 32-bit chunks in Rs1. If any of the results are beyond the 16-bit unsigned number range (0 <= RES <= 2^16-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32-bit chunks in Rd for subtraction and [15:0] of 32-bit chunks in Rd for addition.

Operations:

res1 = Rs1.W[x][31:16] - Rs2.W[x][15:0];
res2 = Rs1.W[x][15:0] + Rs2.W[x][31:16];
if (res1 < 0) {
res1 = 0;
OV = 1;
} else if (res2 > (2^16)-1) {
res2 = (2^16)-1;
OV = 1;
}
Rd.W[x][31:16] = res1;
Rd.W[x][15:0] = res2;
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 unsigned long type

Definition at line 11724 of file core_feature_dsp.h.

11725 {
11726  unsigned long result;
11727  __ASM volatile("ukcrsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
11728  return result;
11729 }

References __ASM.

◆ __RV_UKSTAS16()

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

UKSTAS16 (SIMD 16-bit Unsigned Saturating Straight Addition & Subtraction)

Type: SIMD

Syntax:

UKSTAS16 Rd, Rs1, Rs2

Purpose:
Do one 16-bit unsigned integer element saturating addition and one 16-bit unsigned integer element saturating subtraction in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks.

Description:
This instruction adds the 16-bit unsigned integer element in [31:16] of 32-bit chunks in Rs1 with the 16-bit unsigned integer element in [31:16] of 32-bit chunks in Rs2; at the same time, it subtracts the 16-bit unsigned integer element in [15:0] of 32-bit chunks in Rs2 from the 16-bit unsigned integer element in [15:0] of 32-bit chunks in Rs1. If any of the results are beyond the 16-bit unsigned number range (0 <= RES <= 2^16-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32-bit chunks in Rd for addition and [15:0] of 32-bit chunks in Rd for subtraction.

Operations:

res1 = Rs1.W[x][31:16] + Rs2.W[x][31:16];
res2 = Rs1.W[x][15:0] - Rs2.W[x][15:0];
if (res1 > (2^16)-1) {
res1 = (2^16)-1;
OV = 1;
}
if (res2 < 0) {
res2 = 0;
OV = 1;
}
Rd.W[x][31:16] = res1;
Rd.W[x][15:0] = res2;
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 unsigned long type

Definition at line 11909 of file core_feature_dsp.h.

11910 {
11911  unsigned long result;
11912  __ASM volatile("ukstas16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
11913  return result;
11914 }

References __ASM.

◆ __RV_UKSTSA16()

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

UKSTSA16 (SIMD 16-bit Unsigned Saturating Straight Subtraction & Addition)

Type: SIMD

Syntax:

UKSTSA16 Rd, Rs1, Rs2

Purpose:
Do one 16-bit unsigned integer element saturating subtraction and one 16-bit unsigned integer element saturating addition in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks.

Description:
This instruction subtracts the 16-bit unsigned integer element in [31:16] of 32-bit chunks in Rs2 from the 16-bit unsigned integer element in [31:16] of 32-bit chunks in Rs1; at the same time, it adds the 16-bit unsigned integer element in [15:0] of 32-bit chunks in Rs2 with the 16- bit unsigned integer element in [15:0] of 32-bit chunks in Rs1. If any of the results are beyond the 16-bit unsigned number range (0 <= RES <= 2^16-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32-bit chunks in Rd for subtraction and [15:0] of 32-bit chunks in Rd for addition.

Operations:

res1 = Rs1.W[x][31:16] - Rs2.W[x][31:16];
res2 = Rs1.W[x][15:0] + Rs2.W[x][15:0];
if (res1 < 0) {
res1 = 0;
OV = 1;
} else if (res2 > (2^16)-1) {
res2 = (2^16)-1;
OV = 1;
}
Rd.W[x][31:16] = res1;
Rd.W[x][15:0] = res2;
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 unsigned long type

Definition at line 11964 of file core_feature_dsp.h.

11965 {
11966  unsigned long result;
11967  __ASM volatile("ukstsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
11968  return result;
11969 }

References __ASM.

◆ __RV_UKSUB16()

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

UKSUB16 (SIMD 16-bit Unsigned Saturating Subtraction)

Type: SIMD

Syntax:

UKSUB16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer elements saturating subtractions simultaneously.

Description:
This instruction subtracts the 16-bit unsigned integer elements in Rs2 from the 16-bit unsigned integer elements in Rs1. If any of the results are beyond the 16-bit unsigned number range (0 <= RES <= 2^16-1), they are saturated to the range and the OV bit is set to 1. The saturated results are written to Rd.

Operations:

res[x] = Rs1.H[x] - Rs2.H[x];
if (res[x] < 0) {
res[x] = 0;
OV = 1;
}
Rd.H[x] = res[x];
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 12054 of file core_feature_dsp.h.

12055 {
12056  unsigned long result;
12057  __ASM volatile("uksub16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
12058  return result;
12059 }

References __ASM.

◆ __RV_URADD16()

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

URADD16 (SIMD 16-bit Unsigned Halving Addition)

Type: SIMD

Syntax:

URADD16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer element additions simultaneously. The results are halved to avoid overflow or saturation.

Description:
This instruction adds the 16-bit unsigned integer elements in Rs1 with the 16-bit unsigned integer elements in Rs2. The results are first logically right-shifted by 1 bit and then written to Rd.

Examples:

* Ra = 0x7FFF, Rb = 0x7FFF Rt = 0x7FFF
* Ra = 0x8000, Rb = 0x8000 Rt = 0x8000
* Ra = 0x4000, Rb = 0x8000 Rt = 0x6000

Operations:

Rd.H[x] = (Rs1.H[x] + Rs2.H[x]) u>> 1;
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 12945 of file core_feature_dsp.h.

12946 {
12947  unsigned long result;
12948  __ASM volatile("uradd16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
12949  return result;
12950 }

References __ASM.

◆ __RV_URCRAS16()

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

URCRAS16 (SIMD 16-bit Unsigned Halving Cross Addition & Subtraction)

Type: SIMD

Syntax:

URCRAS16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer element addition and 16-bit unsigned integer element subtraction in a 32-bit chunk simultaneously. Operands are from crossed positions in 32-bit chunks. The results are halved to avoid overflow or saturation.

Description:
This instruction adds the 16-bit unsigned integer in [31:16] of 32-bit chunks in Rs1 with the 16-bit unsigned integer in [15:0] of 32-bit chunks in Rs2, and subtracts the 16-bit unsigned integer in [31:16] of 32-bit chunks in Rs2 from the 16-bit unsigned integer in [15:0] of 32-bit chunks in Rs1. The element results are first logically right-shifted by 1 bit and then written to [31:16] of 32- bit chunks in Rd and [15:0] of 32-bit chunks in Rd.

Examples:

Please see `URADD16` and `URSUB16` instructions.

Operations:

Rd.W[x][31:16] = (Rs1.W[x][31:16] + Rs2.W[x][15:0]) u>> 1;
Rd.W[x][15:0] = (Rs1.W[x][15:0] - Rs2.W[x][31:16]) u>> 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 unsigned long type

Definition at line 13094 of file core_feature_dsp.h.

13095 {
13096  unsigned long result;
13097  __ASM volatile("urcras16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
13098  return result;
13099 }

References __ASM.

◆ __RV_URCRSA16()

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

URCRSA16 (SIMD 16-bit Unsigned Halving Cross Subtraction & Addition)

Type: SIMD

Syntax:

URCRSA16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer element subtraction and 16-bit unsigned integer element addition in a 32-bit chunk simultaneously. Operands are from crossed positions in 32-bit chunks. The results are halved to avoid overflow or saturation.

Description:
This instruction subtracts the 16-bit unsigned integer in [15:0] of 32-bit chunks in Rs2 from the 16-bit unsigned integer in [31:16] of 32-bit chunks in Rs1, and adds the 16-bit unsigned integer in [15:0] of 32-bit chunks in Rs1 with the 16-bit unsigned integer in [31:16] of 32-bit chunks in Rs2. The two results are first logically right-shifted by 1 bit and then written to [31:16] of 32-bit chunks in Rd and [15:0] of 32-bit chunks in Rd.

Examples:

Please see `URADD16` and `URSUB16` instructions.

Operations:

Rd.W[x][31:16] = (Rs1.W[x][31:16] - Rs2.W[x][15:0]) u>> 1;
Rd.W[x][15:0] = (Rs1.W[x][15:0] + Rs2.W[x][31:16]) u>> 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 unsigned long type

Definition at line 13143 of file core_feature_dsp.h.

13144 {
13145  unsigned long result;
13146  __ASM volatile("urcrsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
13147  return result;
13148 }

References __ASM.

◆ __RV_URSTAS16()

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

URSTAS16 (SIMD 16-bit Unsigned Halving Straight Addition & Subtraction)

Type: SIMD

Syntax:

URSTAS16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer element addition and 16-bit unsigned integer element subtraction in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks. The results are halved to avoid overflow or saturation.

Description:
This instruction adds the 16-bit unsigned integer in [31:16] of 32-bit chunks in Rs1 with the 16-bit unsigned integer in [31:16] of 32-bit chunks in Rs2, and subtracts the 16-bit unsigned integer in [15:0] of 32-bit chunks in Rs2 from the 16-bit unsigned integer in [15:0] of 32-bit chunks in Rs1. The element results are first logically right-shifted by 1 bit and then written to [31:16] of 32- bit chunks in Rd and [15:0] of 32-bit chunks in Rd.

Examples:

Please see `URADD16` and `URSUB16` instructions.

Operations:

Rd.W[x][31:16] = (Rs1.W[x][31:16] + Rs2.W[x][31:16]) u>> 1;
Rd.W[x][15:0] = (Rs1.W[x][15:0] - Rs2.W[x][15:0]) u>> 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 unsigned long type

Definition at line 13192 of file core_feature_dsp.h.

13193 {
13194  unsigned long result;
13195  __ASM volatile("urstas16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
13196  return result;
13197 }

References __ASM.

◆ __RV_URSTSA16()

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

URSTSA16 (SIMD 16-bit Unsigned Halving Straight Subtraction & Addition)

Type: SIMD

Syntax:

URCRSA16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer element subtraction and 16-bit unsigned integer element addition in a 32-bit chunk simultaneously. Operands are from corresponding positions in 32-bit chunks. The results are halved to avoid overflow or saturation.

Description:
This instruction subtracts the 16-bit unsigned integer in [31:16] of 32-bit chunks in Rs2 from the 16-bit unsigned integer in [31:16] of 32-bit chunks in Rs1, and adds the 16-bit unsigned integer in [15:0] of 32-bit chunks in Rs1 with the 16-bit unsigned integer in [15:0] of 32-bit chunks in Rs2. The two results are first logically right-shifted by 1 bit and then written to [31:16] of 32-bit chunks in Rd and [15:0] of 32-bit chunks in Rd.

Examples:

Please see `URADD16` and `URSUB16` instructions.

Operations:

Rd.W[x][31:16] = (Rs1.W[x][31:16] - Rs2.W[x][31:16]) u>> 1;
Rd.W[x][15:0] = (Rs1.W[x][15:0] + Rs2.W[x][15:0]) u>> 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 unsigned long type

Definition at line 13241 of file core_feature_dsp.h.

13242 {
13243  unsigned long result;
13244  __ASM volatile("urstsa16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
13245  return result;
13246 }

References __ASM.

◆ __RV_URSUB16()

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

URSUB16 (SIMD 16-bit Unsigned Halving Subtraction)

Type: SIMD

Syntax:

URSUB16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer element subtractions simultaneously. The results are halved to avoid overflow or saturation.

Description:
This instruction subtracts the 16-bit unsigned integer elements in Rs2 from the 16-bit unsigned integer elements in Rs1. The results are first logically right-shifted by 1 bit and then written to Rd.

Examples:

* Ra = 0x7FFF, Rb = 0x8000 Rt = 0xFFFF
* Ra = 0x8000, Rb = 0x7FFF Rt = 0x0000
* Ra = 0x8000, Rb = 0x4000 Rt = 0x2000

Operations:

Rd.H[x] = (Rs1.H[x] - Rs2.H[x]) u>> 1;
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
[in]bunsigned long type of value stored in b
Returns
value stored in unsigned long type

Definition at line 13335 of file core_feature_dsp.h.

13336 {
13337  unsigned long result;
13338  __ASM volatile("ursub16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
13339  return result;
13340 }

References __ASM.