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

SIMD 16-bit Miscellaneous Instructions. More...

Macros

#define __RV_SCLIP16(a, b)
 SCLIP16 (SIMD 16-bit Signed Clip Value) More...
 
#define __RV_UCLIP16(a, b)
 UCLIP16 (SIMD 16-bit Unsigned Clip Value) More...
 

Functions

__STATIC_FORCEINLINE unsigned long __RV_CLRS16 (unsigned long a)
 CLRS16 (SIMD 16-bit Count Leading Redundant Sign) More...
 
__STATIC_FORCEINLINE unsigned long __RV_CLO16 (unsigned long a)
 CLO16 (SIMD 16-bit Count Leading One) More...
 
__STATIC_FORCEINLINE unsigned long __RV_CLZ16 (unsigned long a)
 CLZ16 (SIMD 16-bit Count Leading Zero) More...
 
__STATIC_FORCEINLINE unsigned long __RV_KABS16 (unsigned long a)
 KABS16 (SIMD 16-bit Saturating Absolute) More...
 
__STATIC_FORCEINLINE unsigned long __RV_SMAX16 (unsigned long a, unsigned long b)
 SMAX16 (SIMD 16-bit Signed Maximum) More...
 
__STATIC_FORCEINLINE unsigned long __RV_SMIN16 (unsigned long a, unsigned long b)
 SMIN16 (SIMD 16-bit Signed Minimum) More...
 
__STATIC_FORCEINLINE unsigned long __RV_UMAX16 (unsigned long a, unsigned long b)
 UMAX16 (SIMD 16-bit Unsigned Maximum) More...
 
__STATIC_FORCEINLINE unsigned long __RV_UMIN16 (unsigned long a, unsigned long b)
 UMIN16 (SIMD 16-bit Unsigned Minimum) More...
 

Detailed Description

SIMD 16-bit Miscellaneous Instructions.

there are 10 SIMD 16-bit Misc instructions.

Macro Definition Documentation

◆ __RV_SCLIP16

#define __RV_SCLIP16 (   a,
 
)

SCLIP16 (SIMD 16-bit Signed Clip Value)

Type: SIMD

Syntax:

SCLIP16 Rd, Rs1, imm4u[3:0]

Purpose:
Limit the 16-bit signed integer elements of a register into a signed range simultaneously.

Description:
This instruction limits the 16-bit signed integer elements stored in Rs1 into a signed integer range between 2imm4u-1 and -2imm4u, and writes the limited results to Rd. For example, if imm4u is 3, the 16-bit input values should be saturated between 7 and -8. If saturation is performed, set OV bit to 1.

Operations:

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

Definition at line 6965 of file core_feature_dsp.h.

◆ __RV_UCLIP16

#define __RV_UCLIP16 (   a,
 
)

UCLIP16 (SIMD 16-bit Unsigned Clip Value)

Type: SIMD

Syntax:

UCLIP16 Rt, Ra, imm4u

Purpose:
Limit the 16-bit signed elements of a register into an unsigned range simultaneously.

Description:
This instruction limits the 16-bit signed elements stored in Rs1 into an unsigned integer range between 2imm4u-1 and 0, and writes the limited results to Rd. For example, if imm4u is 3, the 16-bit input values should be saturated between 7 and 0. If saturation is performed, set OV bit to 1.

Operations:

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

Definition at line 11163 of file core_feature_dsp.h.

Function Documentation

◆ __RV_CLO16()

__STATIC_FORCEINLINE unsigned long __RV_CLO16 ( unsigned long  a)

CLO16 (SIMD 16-bit Count Leading One)

Type: SIMD

Syntax:

CLO16 Rd, Rs1

Purpose:
Count the number of leading one bits of the 16-bit elements of a general register.

Description:
Starting from the most significant bits of the 16-bit elements of Rs1, this instruction counts the number of leading one bits and writes the results to the corresponding 16-bit elements of Rd.

Operations:

snum[x] = Rs1.H[x];
cnt[x] = 0;
for (i = 15 to 0) {
if (snum[x](i) == 1) {
cnt[x] = cnt[x] + 1;
} else {
break;
}
}
Rd.H[x] = cnt[x];
for RV32: x=1...0
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
Returns
value stored in unsigned long type

Definition at line 964 of file core_feature_dsp.h.

965 {
966  unsigned long result;
967  __ASM volatile("clo16 %0, %1" : "=r"(result) : "r"(a));
968  return result;
969 }

References __ASM.

◆ __RV_CLRS16()

__STATIC_FORCEINLINE unsigned long __RV_CLRS16 ( unsigned long  a)

CLRS16 (SIMD 16-bit Count Leading Redundant Sign)

Type: SIMD

Syntax:

CLRS16 Rd, Rs1

Purpose:
Count the number of redundant sign bits of the 16-bit elements of a general register.

Description:
Starting from the bits next to the sign bits of the 16-bit elements of Rs1, this instruction counts the number of redundant sign bits and writes the result to the corresponding 16- bit elements of Rd.

Operations:

snum[x] = Rs1.H[x];
cnt[x] = 0;
for (i = 14 to 0) {
if (snum[x](i) == snum[x](15)) {
cnt[x] = cnt[x] + 1;
} else {
break;
}
}
Rd.H[x] = cnt[x];
for RV32: x=1...0
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
Returns
value stored in unsigned long type

Definition at line 823 of file core_feature_dsp.h.

824 {
825  unsigned long result;
826  __ASM volatile("clrs16 %0, %1" : "=r"(result) : "r"(a));
827  return result;
828 }

References __ASM.

◆ __RV_CLZ16()

__STATIC_FORCEINLINE unsigned long __RV_CLZ16 ( unsigned long  a)

CLZ16 (SIMD 16-bit Count Leading Zero)

Type: SIMD

Syntax:

CLZ16 Rd, Rs1

Purpose:
Count the number of leading zero bits of the 16-bit elements of a general register.

Description:
Starting from the most significant bits of the 16-bit elements of Rs1, this instruction counts the number of leading zero bits and writes the results to the corresponding 16-bit elements of Rd.

Operations:

snum[x] = Rs1.H[x];
cnt[x] = 0;
for (i = 15 to 0) {
if (snum[x](i) == 0) {
cnt[x] = cnt[x] + 1;
} else {
break;
}
}
Rd.H[x] = cnt[x];
for RV32: x=1...0
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
Returns
value stored in unsigned long type

Definition at line 1105 of file core_feature_dsp.h.

1106 {
1107  unsigned long result;
1108  __ASM volatile("clz16 %0, %1" : "=r"(result) : "r"(a));
1109  return result;
1110 }

References __ASM.

◆ __RV_KABS16()

__STATIC_FORCEINLINE unsigned long __RV_KABS16 ( unsigned long  a)

KABS16 (SIMD 16-bit Saturating Absolute)

Type: SIMD

Syntax:

KABS16 Rd, Rs1

Purpose:
Get the absolute value of 16-bit signed integer elements simultaneously.

Description:
This instruction calculates the absolute value of 16-bit signed integer elements stored in Rs1 and writes the element results to Rd. If the input number is 0x8000, this instruction generates 0x7fff as the output and sets the OV bit to 1.

Operations:

src = Rs1.H[x];
if (src == 0x8000) {
src = 0x7fff;
OV = 1;
} else if (src[15] == 1)
src = -src;
}
Rd.H[x] = src;
for RV32: x=1...0,
for RV64: x=3...0
Parameters
[in]aunsigned long type of value stored in a
Returns
value stored in unsigned long type

Definition at line 1459 of file core_feature_dsp.h.

1460 {
1461  unsigned long result;
1462  __ASM volatile("kabs16 %0, %1" : "=r"(result) : "r"(a));
1463  return result;
1464 }

References __ASM.

◆ __RV_SMAX16()

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

SMAX16 (SIMD 16-bit Signed Maximum)

Type: SIMD

Syntax:

SMAX16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer elements finding maximum operations simultaneously.

Description:
This instruction compares the 16-bit signed integer elements in Rs1 with the 16-bit signed integer elements in Rs2 and selects the numbers that is greater than the other one. The selected results are written to Rd.

Operations:

Rd.H[x] = (Rs1.H[x] > Rs2.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 8303 of file core_feature_dsp.h.

8304 {
8305  unsigned long result;
8306  __ASM volatile("smax16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
8307  return result;
8308 }

References __ASM.

◆ __RV_SMIN16()

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

SMIN16 (SIMD 16-bit Signed Minimum)

Type: SIMD

Syntax:

SMIN16 Rd, Rs1, Rs2

Purpose:
Do 16-bit signed integer elements finding minimum operations simultaneously.

Description:
This instruction compares the 16-bit signed integer elements in Rs1 with the 16-bit signed integer elements in Rs2 and selects the numbers that is less than the other one. The selected results are written to Rd.

Operations:

Rd.H[x] = (Rs1.H[x] < Rs2.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 8714 of file core_feature_dsp.h.

8715 {
8716  unsigned long result;
8717  __ASM volatile("smin16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
8718  return result;
8719 }

References __ASM.

◆ __RV_UMAX16()

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

UMAX16 (SIMD 16-bit Unsigned Maximum)

Type: SIMD

Syntax:

UMAX16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer elements finding maximum operations simultaneously.

Description:
This instruction compares the 16-bit unsigned integer elements in Rs1 with the 16-bit unsigned integer elements in Rs2 and selects the numbers that is greater than the other one. The selected results are written to Rd.

Operations:

Rd.H[x] = (Rs1.H[x] >u Rs2.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 12378 of file core_feature_dsp.h.

12379 {
12380  unsigned long result;
12381  __ASM volatile("umax16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
12382  return result;
12383 }

References __ASM.

◆ __RV_UMIN16()

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

UMIN16 (SIMD 16-bit Unsigned Minimum)

Type: SIMD

Syntax:

UMIN16 Rd, Rs1, Rs2

Purpose:
Do 16-bit unsigned integer elements finding minimum operations simultaneously.

Description:
This instruction compares the 16-bit unsigned integer elements in Rs1 with the 16-bit unsigned integer elements in Rs2 and selects the numbers that is less than the other one. The selected results are written to Rd.

Operations:

Rd.H[x] = (Rs1.H[x] <u Rs2.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 12456 of file core_feature_dsp.h.

12457 {
12458  unsigned long result;
12459  __ASM volatile("umin16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
12460  return result;
12461 }

References __ASM.

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