SIMD 16bit Add/Subtract InstructionsΒΆ

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

group
NMSIS_Core_DSP_Intrinsic_SIMD_16B_ADDSUB
SIMD 16bit Add/Subtract Instructions.
Based on the combination of the types of the two 16bit arithmetic operations, the SIMD 16bit add/subtract instructions can be classified into 6 main categories: Addition (two 16bit addition), Subtraction (two 16bit 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 16bit add/subtract instructions can be classified into 5 groups: Wraparound (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 16bit add/subtract instructions.
Functions

__STATIC_FORCEINLINE unsigned long __RV_ADD16(unsigned long a, unsigned long b)
ADD16 (SIMD 16bit Addition)
Type: SIMD
Syntax:
ADD16 Rd, Rs1, Rs2
Purpose:
Do 16bit integer element additions simultaneously.
Description:
This instruction adds the 16bit integer elements in Rs1 with the 16bit integer elements in Rs2, and then writes the 16bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_CRAS16(unsigned long a, unsigned long b)
CRAS16 (SIMD 16bit Cross Addition & Subtraction)
Type: SIMD
Syntax:
CRAS16 Rd, Rs1, Rs2
Purpose:
Do 16bit integer element addition and 16bit integer element subtraction in a 32bit chunk simultaneously. Operands are from crossed positions in 32bit chunks.
Description:
This instruction adds the 16bit integer element in [31:16] of 32bit chunks in Rs1 with the 16bit integer element in [15:0] of 32bit chunks in Rs2, and writes the result to [31:16] of 32bit chunks in Rd; at the same time, it subtracts the 16bit integer element in [31:16] of 32bit chunks in Rs2 from the 16bit integer element in [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_CRSA16(unsigned long a, unsigned long b)
CRSA16 (SIMD 16bit Cross Subtraction & Addition)
Type: SIMD
Syntax:
CRSA16 Rd, Rs1, Rs2
Purpose:
Do 16bit integer element subtraction and 16bit integer element addition in a 32bit chunk simultaneously. Operands are from crossed positions in 32bit chunks.
Description:
This instruction subtracts the 16bit integer element in [15:0] of 32bit chunks in Rs2 from the 16bit integer element in [31:16] of 32bit chunks in Rs1, and writes the result to [31:16] of 32bit chunks in Rd; at the same time, it adds the 16bit integer element in [31:16] of 32bit chunks in Rs2 with the 16bit integer element in [15:0] of 32bit chunks in Rs1, and writes the result to [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_KADD16(unsigned long a, unsigned long b)
KADD16 (SIMD 16bit Signed Saturating Addition)
Type: SIMD
Syntax:
KADD16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element saturating additions simultaneously.
Description:
This instruction adds the 16bit signed integer elements in Rs1 with the 16bit signed integer elements in Rs2. If any of the results are beyond the Q15 number range (2^15 <= Q15 <= 2^151), 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_KCRAS16(unsigned long a, unsigned long b)
KCRAS16 (SIMD 16bit Signed Saturating Cross Addition & Subtraction)
Type: SIMD
Syntax:
KCRAS16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element saturating addition and 16bit signed integer element saturating subtraction in a 32bit chunk simultaneously. Operands are from crossed positions in 32 bit chunks.
Description:
This instruction adds the 16bit signed integer element in [31:16] of 32bit chunks in Rs1 with the 16bit signed integer element in [15:0] of 32bit chunks in Rs2; at the same time, it subtracts the 16bit signed integer element in [31:16] of 32bit chunks in Rs2 from the 16bit signed integer element in [15:0] of 32bit chunks in Rs1. If any of the results are beyond the Q15 number range (2^15 <= Q15 <= 2^151), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32bit chunks in Rd for addition and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_KCRSA16(unsigned long a, unsigned long b)
KCRSA16 (SIMD 16bit Signed Saturating Cross Subtraction & Addition)
Type: SIMD
Syntax:
KCRSA16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element saturating subtraction and 16bit signed integer element saturating addition in a 32bit chunk simultaneously. Operands are from crossed positions in 32bit chunks.
Description:
This instruction subtracts the 16bit signed integer element in [15:0] of 32bit chunks in Rs2 from the 16bit signed integer element in [31:16] of 32bit chunks in Rs1; at the same time, it adds the 16bit signed integer element in [31:16] of 32bit chunks in Rs2 with the 16bit signed integer element in [15:0] of 32bit chunks in Rs1. If any of the results are beyond the Q15 number range (2^15 <= Q15 <= 2^151), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32bit chunks in Rd for subtraction and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_KSTAS16(unsigned long a, unsigned long b)
KSTAS16 (SIMD 16bit Signed Saturating Straight Addition & Subtraction)
Type: SIMD
Syntax:
KSTAS16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element saturating addition and 16bit signed integer element saturating subtraction in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks.
Description:
This instruction adds the 16bit signed integer element in [31:16] of 32bit chunks in Rs1 with the 16bit signed integer element in [31:16] of 32bit chunks in Rs2; at the same time, it subtracts the 16bit signed integer element in [15:0] of 32bit chunks in Rs2 from the 16bit signed integer element in [15:0] of 32bit chunks in Rs1. If any of the results are beyond the Q15 number range (2^15 <= Q15 <= 2^151), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32bit chunks in Rd for addition and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_KSTSA16(unsigned long a, unsigned long b)
KSTSA16 (SIMD 16bit Signed Saturating Straight Subtraction & Addition)
Type: SIMD
Syntax:
KSTSA16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element saturating subtraction and 16bit signed integer element saturating addition in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks.
Description:
This instruction subtracts the 16bit signed integer element in [31:16] of 32bit chunks in Rs2 from the 16bit signed integer element in [31:16] of 32bit chunks in Rs1; at the same time, it adds the 16bit signed integer element in [15:0] of 32bit chunks in Rs2 with the 16bit signed integer element in [15:0] of 32bit chunks in Rs1. If any of the results are beyond the Q15 number range (2^15 <= Q15 <= 2^151), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32bit chunks in Rd for subtraction and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_KSUB16(unsigned long a, unsigned long b)
KSUB16 (SIMD 16bit Signed Saturating Subtraction)
Type: SIMD
Syntax:
KSUB16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer elements saturating subtractions simultaneously.
Description:
This instruction subtracts the 16bit signed integer elements in Rs2 from the 16bit signed integer elements in Rs1. If any of the results are beyond the Q15 number range (2^15 <= Q15 <= 2^151), 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_RADD16(unsigned long a, unsigned long b)
RADD16 (SIMD 16bit Signed Halving Addition)
Type: SIMD
Syntax:
RADD16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element additions simultaneously. The results are halved to avoid overflow or saturation.
Description:
This instruction adds the 16bit signed integer elements in Rs1 with the 16bit signed integer elements in Rs2. The results are first arithmetically rightshifted 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_RCRAS16(unsigned long a, unsigned long b)
RCRAS16 (SIMD 16bit Signed Halving Cross Addition & Subtraction)
Type: SIMD
Syntax:
RCRAS16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element addition and 16bit signed integer element subtraction in a 32bit chunk simultaneously. Operands are from crossed positions in 32bit chunks. The results are halved to avoid overflow or saturation.
Description:
This instruction adds the 16bit signed integer element in [31:16] of 32bit chunks in Rs1 with the 16bit signed integer element in [15:0] of 32bit chunks in Rs2, and subtracts the 16bit signed integer element in [31:16] of 32bit chunks in Rs2 from the 16bit signed integer element in [15:0] of 32bit chunks in Rs1. The element results are first arithmetically rightshifted by 1 bit and then written to [31:16] of 32bit chunks in Rd and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_RCRSA16(unsigned long a, unsigned long b)
RCRSA16 (SIMD 16bit Signed Halving Cross Subtraction & Addition)
Type: SIMD
Syntax:
RCRSA16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element subtraction and 16bit signed integer element addition in a 32bit chunk simultaneously. Operands are from crossed positions in 32bit chunks. The results are halved to avoid overflow or saturation.
Description:
This instruction subtracts the 16bit signed integer element in [15:0] of 32bit chunks in Rs2 from the 16bit signed integer element in [31:16] of 32bit chunks in Rs1, and adds the 16bit signed element integer in [15:0] of 32bit chunks in Rs1 with the 16bit signed integer element in [31:16] of 32bit chunks in Rs2. The two results are first arithmetically rightshifted by 1 bit and then written to [31:16] of 32bit chunks in Rd and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_RSTAS16(unsigned long a, unsigned long b)
RSTAS16 (SIMD 16bit Signed Halving Straight Addition & Subtraction)
Type: SIMD
Syntax:
RSTAS16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element addition and 16bit signed integer element subtraction in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks. The results are halved to avoid overflow or saturation.
Description:
This instruction adds the 16bit signed integer element in [31:16] of 32bit chunks in Rs1 with the 16bit signed integer element in [31:16] of 32bit chunks in Rs2, and subtracts the 16bit signed integer element in [15:0] of 32bit chunks in Rs2 from the 16bit signed integer element in [15:0] of 32bit chunks in Rs1. The element results are first arithmetically rightshifted by 1 bit and then written to [31:16] of 32bit chunks in Rd and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_RSTSA16(unsigned long a, unsigned long b)
RSTSA16 (SIMD 16bit Signed Halving Straight Subtraction & Addition)
Type: SIMD
Syntax:
RSTSA16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element subtraction and 16bit signed integer element addition in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks. The results are halved to avoid overflow or saturation.
Description:
This instruction subtracts the 16bit signed integer element in [31:16] of 32bit chunks in Rs2 from the 16bit signed integer element in [31:16] of 32bit chunks in Rs1, and adds the 16bit signed element integer in [15:0] of 32bit chunks in Rs1 with the 16bit signed integer element in [15:0] of 32bit chunks in Rs2. The two results are first arithmetically rightshifted by 1 bit and then written to [31:16] of 32bit chunks in Rd and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_RSUB16(unsigned long a, unsigned long b)
RSUB16 (SIMD 16bit Signed Halving Subtraction)
Type: SIMD
Syntax:
RSUB16 Rd, Rs1, Rs2
Purpose:
Do 16bit signed integer element subtractions simultaneously. The results are halved to avoid overflow or saturation.
Description:
This instruction subtracts the 16bit signed integer elements in Rs2 from the 16bit signed integer elements in Rs1. The results are first arithmetically rightshifted 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_STAS16(unsigned long a, unsigned long b)
STAS16 (SIMD 16bit Straight Addition & Subtraction)
Type: SIMD
Syntax:
STAS16 Rd, Rs1, Rs2
Purpose:
Do 16bit integer element addition and 16bit integer element subtraction in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks.
Description:
This instruction adds the 16bit integer element in [31:16] of 32bit chunks in Rs1 with the 16bit integer element in [31:16] of 32bit chunks in Rs2, and writes the result to [31:16] of 32bit chunks in Rd; at the same time, it subtracts the 16bit integer element in [15:0] of 32bit chunks in Rs2 from the 16bit integer element in [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_STSA16(unsigned long a, unsigned long b)
STSA16 (SIMD 16bit Straight Subtraction & Addition)
Type: SIMD
Syntax:
STSA16 Rd, Rs1, Rs2
Purpose:
Do 16bit integer element subtraction and 16bit integer element addition in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks.
Description:
This instruction subtracts the 16bit integer element in [31:16] of 32bit chunks in Rs2 from the 16bit integer element in [31:16] of 32bit chunks in Rs1, and writes the result to [31:16] of 32bit chunks in Rd; at the same time, it adds the 16bit integer element in [15:0] of 32bit chunks in Rs2 with the 16bit integer element in [15:0] of 32bit chunks in Rs1, and writes the result to [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_SUB16(unsigned long a, unsigned long b)
SUB16 (SIMD 16bit Subtraction)
Type: SIMD
Syntax:
SUB16 Rd, Rs1, Rs2
Purpose:
Do 16bit integer element subtractions simultaneously.
Description:
This instruction subtracts the 16bit integer elements in Rs2 from the 16bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_UKADD16(unsigned long a, unsigned long b)
UKADD16 (SIMD 16bit Unsigned Saturating Addition)
Type: SIMD
Syntax:
UKADD16 Rd, Rs1, Rs2
Purpose:
Do 16bit unsigned integer element saturating additions simultaneously.
Description:
This instruction adds the 16bit unsigned integer elements in Rs1 with the 16bit unsigned integer elements in Rs2. If any of the results are beyond the 16bit unsigned number range (0 <= RES <= 2^161), 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_UKCRAS16(unsigned long a, unsigned long b)
UKCRAS16 (SIMD 16bit Unsigned Saturating Cross Addition & Subtraction)
Type: SIMD
Syntax:
UKCRAS16 Rd, Rs1, Rs2
Purpose:
Do one 16bit unsigned integer element saturating addition and one 16bit unsigned integer element saturating subtraction in a 32bit chunk simultaneously. Operands are from crossed positions in 32bit chunks.
Description:
This instruction adds the 16bit unsigned integer element in [31:16] of 32bit chunks in Rs1 with the 16bit unsigned integer element in [15:0] of 32bit chunks in Rs2; at the same time, it subtracts the 16bit unsigned integer element in [31:16] of 32bit chunks in Rs2 from the 16bit unsigned integer element in [15:0] of 32bit chunks in Rs1. If any of the results are beyond the 16bit unsigned number range (0 <= RES <= 2^161), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32bit chunks in Rd for addition and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_UKCRSA16(unsigned long a, unsigned long b)
UKCRSA16 (SIMD 16bit Unsigned Saturating Cross Subtraction & Addition)
Type: SIMD
Syntax:
UKCRSA16 Rd, Rs1, Rs2
Purpose:
Do one 16bit unsigned integer element saturating subtraction and one 16bit unsigned integer element saturating addition in a 32bit chunk simultaneously. Operands are from crossed positions in 32bit chunks.
Description:
This instruction subtracts the 16bit unsigned integer element in [15:0] of 32bit chunks in Rs2 from the 16bit unsigned integer element in [31:16] of 32bit chunks in Rs1; at the same time, it adds the 16bit unsigned integer element in [31:16] of 32bit chunks in Rs2 with the 16 bit unsigned integer element in [15:0] of 32bit chunks in Rs1. If any of the results are beyond the 16bit unsigned number range (0 <= RES <= 2^161), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32bit chunks in Rd for subtraction and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_UKSTAS16(unsigned long a, unsigned long b)
UKSTAS16 (SIMD 16bit Unsigned Saturating Straight Addition & Subtraction)
Type: SIMD
Syntax:
UKSTAS16 Rd, Rs1, Rs2
Purpose:
Do one 16bit unsigned integer element saturating addition and one 16bit unsigned integer element saturating subtraction in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks.
Description:
This instruction adds the 16bit unsigned integer element in [31:16] of 32bit chunks in Rs1 with the 16bit unsigned integer element in [31:16] of 32bit chunks in Rs2; at the same time, it subtracts the 16bit unsigned integer element in [15:0] of 32bit chunks in Rs2 from the 16bit unsigned integer element in [15:0] of 32bit chunks in Rs1. If any of the results are beyond the 16bit unsigned number range (0 <= RES <= 2^161), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32bit chunks in Rd for addition and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_UKSTSA16(unsigned long a, unsigned long b)
UKSTSA16 (SIMD 16bit Unsigned Saturating Straight Subtraction & Addition)
Type: SIMD
Syntax:
UKSTSA16 Rd, Rs1, Rs2
Purpose:
Do one 16bit unsigned integer element saturating subtraction and one 16bit unsigned integer element saturating addition in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks.
Description:
This instruction subtracts the 16bit unsigned integer element in [31:16] of 32bit chunks in Rs2 from the 16bit unsigned integer element in [31:16] of 32bit chunks in Rs1; at the same time, it adds the 16bit unsigned integer element in [15:0] of 32bit chunks in Rs2 with the 16 bit unsigned integer element in [15:0] of 32bit chunks in Rs1. If any of the results are beyond the 16bit unsigned number range (0 <= RES <= 2^161), they are saturated to the range and the OV bit is set to 1. The saturated results are written to [31:16] of 32bit chunks in Rd for subtraction and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_UKSUB16(unsigned long a, unsigned long b)
UKSUB16 (SIMD 16bit Unsigned Saturating Subtraction)
Type: SIMD
Syntax:
UKSUB16 Rd, Rs1, Rs2
Purpose:
Do 16bit unsigned integer elements saturating subtractions simultaneously.
Description:
This instruction subtracts the 16bit unsigned integer elements in Rs2 from the 16bit unsigned integer elements in Rs1. If any of the results are beyond the 16bit unsigned number range (0 <= RES <= 2^161), 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_URADD16(unsigned long a, unsigned long b)
URADD16 (SIMD 16bit Unsigned Halving Addition)
Type: SIMD
Syntax:
URADD16 Rd, Rs1, Rs2
Purpose:
Do 16bit unsigned integer element additions simultaneously. The results are halved to avoid overflow or saturation.
Description:
This instruction adds the 16bit unsigned integer elements in Rs1 with the 16bit unsigned integer elements in Rs2. The results are first logically rightshifted 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_URCRAS16(unsigned long a, unsigned long b)
URCRAS16 (SIMD 16bit Unsigned Halving Cross Addition & Subtraction)
Type: SIMD
Syntax:
URCRAS16 Rd, Rs1, Rs2
Purpose:
Do 16bit unsigned integer element addition and 16bit unsigned integer element subtraction in a 32bit chunk simultaneously. Operands are from crossed positions in 32bit chunks. The results are halved to avoid overflow or saturation.
Description:
This instruction adds the 16bit unsigned integer in [31:16] of 32bit chunks in Rs1 with the 16bit unsigned integer in [15:0] of 32bit chunks in Rs2, and subtracts the 16bit unsigned integer in [31:16] of 32bit chunks in Rs2 from the 16bit unsigned integer in [15:0] of 32bit chunks in Rs1. The element results are first logically rightshifted by 1 bit and then written to [31:16] of 32 bit chunks in Rd and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_URCRSA16(unsigned long a, unsigned long b)
URCRSA16 (SIMD 16bit Unsigned Halving Cross Subtraction & Addition)
Type: SIMD
Syntax:
URCRSA16 Rd, Rs1, Rs2
Purpose:
Do 16bit unsigned integer element subtraction and 16bit unsigned integer element addition in a 32bit chunk simultaneously. Operands are from crossed positions in 32bit chunks. The results are halved to avoid overflow or saturation.
Description:
This instruction subtracts the 16bit unsigned integer in [15:0] of 32bit chunks in Rs2 from the 16bit unsigned integer in [31:16] of 32bit chunks in Rs1, and adds the 16bit unsigned integer in [15:0] of 32bit chunks in Rs1 with the 16bit unsigned integer in [31:16] of 32bit chunks in Rs2. The two results are first logically rightshifted by 1 bit and then written to [31:16] of 32bit chunks in Rd and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_URSTAS16(unsigned long a, unsigned long b)
URSTAS16 (SIMD 16bit Unsigned Halving Straight Addition & Subtraction)
Type: SIMD
Syntax:
URSTAS16 Rd, Rs1, Rs2
Purpose:
Do 16bit unsigned integer element addition and 16bit unsigned integer element subtraction in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks. The results are halved to avoid overflow or saturation.
Description:
This instruction adds the 16bit unsigned integer in [31:16] of 32bit chunks in Rs1 with the 16bit unsigned integer in [31:16] of 32bit chunks in Rs2, and subtracts the 16bit unsigned integer in [15:0] of 32bit chunks in Rs2 from the 16bit unsigned integer in [15:0] of 32bit chunks in Rs1. The element results are first logically rightshifted by 1 bit and then written to [31:16] of 32 bit chunks in Rd and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_URSTSA16(unsigned long a, unsigned long b)
URSTSA16 (SIMD 16bit Unsigned Halving Straight Subtraction & Addition)
Type: SIMD
Syntax:
URCRSA16 Rd, Rs1, Rs2
Purpose:
Do 16bit unsigned integer element subtraction and 16bit unsigned integer element addition in a 32bit chunk simultaneously. Operands are from corresponding positions in 32bit chunks. The results are halved to avoid overflow or saturation.
Description:
This instruction subtracts the 16bit unsigned integer in [31:16] of 32bit chunks in Rs2 from the 16bit unsigned integer in [31:16] of 32bit chunks in Rs1, and adds the 16bit unsigned integer in [15:0] of 32bit chunks in Rs1 with the 16bit unsigned integer in [15:0] of 32bit chunks in Rs2. The two results are first logically rightshifted by 1 bit and then written to [31:16] of 32bit chunks in Rd and [15:0] of 32bit 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b

__STATIC_FORCEINLINE unsigned long __RV_URSUB16(unsigned long a, unsigned long b)
URSUB16 (SIMD 16bit Unsigned Halving Subtraction)
Type: SIMD
Syntax:
URSUB16 Rd, Rs1, Rs2
Purpose:
Do 16bit unsigned integer element subtractions simultaneously. The results are halved to avoid overflow or saturation.
Description:
This instruction subtracts the 16bit unsigned integer elements in Rs2 from the 16bit unsigned integer elements in Rs1. The results are first logically rightshifted 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
 Return
value stored in unsigned long type
 Parameters
[in] a
: unsigned long type of value stored in a[in] b
: unsigned long type of value stored in b
