Partial-SIMD Miscellaneous Instructions

__STATIC_FORCEINLINE unsigned long __RV_CLRS32 (unsigned long a)
__STATIC_FORCEINLINE unsigned long __RV_CLO32 (unsigned long a)
__STATIC_FORCEINLINE unsigned long __RV_CLZ32 (unsigned long a)
__STATIC_FORCEINLINE unsigned long __RV_PBSAD (unsigned long a, unsigned long b)
__STATIC_FORCEINLINE unsigned long __RV_PBSADA (unsigned long t, unsigned long a, unsigned long b)
__RV_SCLIP32(a, b)
__RV_UCLIP32(a, b)
group NMSIS_Core_DSP_Intrinsic_PART_SIMD_MISC

Partial-SIMD Miscellaneous Instructions.

there are 7 Partial-SIMD Miscellaneous Instructions

Defines

__RV_SCLIP32(a, b)

SCLIP32 (SIMD 32-bit Signed Clip Value)

Type: DSP

Syntax:

SCLIP32 Rd, Rs1, imm5u[4:0]

Purpose

:

Limit the 32-bit signed integer elements of a register into a signed range simultaneously.

Description

:

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

Operations:

src = Rs1.W[x];
if (src > (2^imm5u)-1) {
  src = (2^imm5u)-1;
  OV = 1;
} else if (src < -2^imm5u) {
  src = -2^imm5u;
  OV = 1;
}
Rd.W[x] = src
for RV32: x=0,
for RV64: x=1...0

Parameters
  • a[in] long type of value stored in a

  • b[in] unsigned int type of value stored in b

Returns

value stored in long type

__RV_UCLIP32(a, b)

UCLIP32 (SIMD 32-bit Unsigned Clip Value)

Type: SIMD

Syntax:

UCLIP32 Rd, Rs1, imm5u[4:0]

Purpose

:

Limit the 32-bit signed integer elements of a register into an unsigned range simultaneously.

Description

:

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

Operations:

src = Rs1.W[x];
if (src > (2^imm5u)-1) {
  src = (2^imm5u)-1;
  OV = 1;
} else if (src < 0) {
  src = 0;
  OV = 1;
}
Rd.W[x] = src
for RV32: x=0,
for RV64: x=1...0

Parameters
  • a[in] unsigned long type of value stored in a

  • b[in] unsigned int type of value stored in b

Returns

value stored in unsigned long type

Functions

__STATIC_FORCEINLINE unsigned long __RV_CLRS32 (unsigned long a)

CLRS32 (SIMD 32-bit Count Leading Redundant Sign)

Type: SIMD

Syntax:

CLRS32 Rd, Rs1

Purpose

:

Count the number of redundant sign bits of the 32-bit elements of a general register.

Description

:

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

Operations:

snum[x] = Rs1.W[x];
cnt[x] = 0;
for (i = 30 to 0) {
  if (snum[x](i) == snum[x](31)) {
    cnt[x] = cnt[x] + 1;
  } else {
    break;
  }
}
Rd.W[x] = cnt[x];
for RV32: x=0
for RV64: x=1...0

Parameters

a[in] unsigned long type of value stored in a

Returns

value stored in unsigned long type

__STATIC_FORCEINLINE unsigned long __RV_CLO32 (unsigned long a)

CLO32 (SIMD 32-bit Count Leading One)

Type: SIMD

Syntax:

CLO32 Rd, Rs1

Purpose

:

Count the number of leading one bits of the 32-bit elements of a general register.

Description

:

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

Operations:

snum[x] = Rs1.W[x];
cnt[x] = 0;
for (i = 31 to 0) {
  if (snum[x](i) == 1) {
    cnt[x] = cnt[x] + 1;
  } else {
    break;
  }
}
Rd.W[x] = cnt[x];
for RV32: x=0
for RV64: x=1...0

Parameters

a[in] unsigned long type of value stored in a

Returns

value stored in unsigned long type

__STATIC_FORCEINLINE unsigned long __RV_CLZ32 (unsigned long a)

CLZ32 (SIMD 32-bit Count Leading Zero)

Type: SIMD

Syntax:

CLZ32 Rd, Rs1

Purpose

:

Count the number of leading zero bits of the 32-bit elements of a general register.

Description

:

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

Operations:

snum[x] = Rs1.W[x];
cnt[x] = 0;
for (i = 31 to 0) {
  if (snum[x](i) == 0) {
    cnt[x] = cnt[x] + 1;
  } else {
    break;
  }
}
Rd.W[x] = cnt[x];
for RV32: x=0
for RV64: x=1...0

Parameters

a[in] unsigned long type of value stored in a

Returns

value stored in unsigned long type

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

PBSAD (Parallel Byte Sum of Absolute Difference)

Type: DSP

Syntax:

PBSAD Rd, Rs1, Rs2

Purpose

:

Calculate the sum of absolute difference of unsigned 8-bit data elements.

Description

:

This instruction subtracts the un-signed 8-bit elements of Rs2 from those of Rs1. Then it adds the absolute value of each difference together and writes the result to Rd.

Operations:

absdiff[x] = ABS(Rs1.B[x] - Rs2.B[x]);
Rd = SUM(absdiff[x]);
for RV32: x=3...0,
for RV64: x=7...0

Parameters
  • a[in] unsigned long type of value stored in a

  • b[in] unsigned long type of value stored in b

Returns

value stored in unsigned long type

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

PBSADA (Parallel Byte Sum of Absolute Difference Accum)

Type: DSP

Syntax:

PBSADA Rd, Rs1, Rs2

Purpose

:

Calculate the sum of absolute difference of four unsigned 8-bit data elements and accumulate it into a register.

Description

:

This instruction subtracts the un-signed 8-bit elements of Rs2 from those of Rs1. It then adds the absolute value of each difference together along with the content of Rd and writes the accumulated result back to Rd.

Operations:

absdiff[x] = ABS(Rs1.B[x] - Rs2.B[x]);
Rd = Rd + SUM(absdiff[x]);
for RV32: x=3...0,
for RV64: x=7...0

Parameters
  • t[in] unsigned long type of value stored in t

  • a[in] unsigned long type of value stored in a

  • b[in] unsigned long type of value stored in b

Returns

value stored in unsigned long type