NMSIS-Core  Version 1.2.0
NMSIS-Core support for Nuclei processor-based devices
Nuclei N1 SIMD DSP Additional Instructions

(RV32 only)Nuclei Customized N1 DSP Instructions More...

Functions

__STATIC_FORCEINLINE unsigned long long __RV_DKHM8 (unsigned long long a, unsigned long long b)
 DKHM8 (64-bit SIMD Signed Saturating Q7 Multiply) More...
 
__STATIC_FORCEINLINE unsigned long long __RV_DKHM16 (unsigned long long a, unsigned long long b)
 DKHM16 (64-bit SIMD Signed Saturating Q15 Multiply) More...
 
__STATIC_FORCEINLINE unsigned long long __RV_DKABS8 (unsigned long long a)
 DKABS8 (64-bit SIMD 8-bit Saturating Absolute) More...
 
__STATIC_FORCEINLINE unsigned long long __RV_DKABS16 (unsigned long long a)
 DKABS16 (64-bit SIMD 16-bit Saturating Absolute) More...
 
__STATIC_FORCEINLINE unsigned long long __RV_DKSLRA8 (unsigned long long a, int b)
 DKSLRA8 (64-bit SIMD 8-bit Shift Left Logical with Saturation or Shift Right Arithmetic) More...
 
__STATIC_FORCEINLINE unsigned long long __RV_DKSLRA16 (unsigned long long a, int b)
 DKSLRA16 (64-bit SIMD 16-bit Shift Left Logical with Saturation or Shift Right Arithmetic) More...
 
__STATIC_FORCEINLINE unsigned long long __RV_DKADD8 (unsigned long long a, unsigned long long b)
 DKADD8 (64-bit SIMD 8-bit Signed Saturating Addition) More...
 
__STATIC_FORCEINLINE unsigned long long __RV_DKADD16 (unsigned long long a, unsigned long long b)
 DKADD16 (64-bit SIMD 16-bit Signed Saturating Addition) More...
 
__STATIC_FORCEINLINE unsigned long long __RV_DKSUB8 (unsigned long long a, unsigned long long b)
 DKSUB8 (64-bit SIMD 8-bit Signed Saturating Subtraction) More...
 
__STATIC_FORCEINLINE unsigned long long __RV_DKSUB16 (unsigned long long a, unsigned long long b)
 DKSUB16 (64-bit SIMD 16-bit Signed Saturating Subtraction) More...
 

Detailed Description

(RV32 only)Nuclei Customized N1 DSP Instructions

This is Nuclei customized DSP N1 instructions only for RV32

Function Documentation

◆ __RV_DKABS16()

__STATIC_FORCEINLINE unsigned long long __RV_DKABS16 ( unsigned long long  a)

DKABS16 (64-bit SIMD 16-bit Saturating Absolute)

Type: SIMD

Syntax:

DKABS16 Rd, Rs1
# Rd, Rs1 are all even/odd pair of registers

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=3...0,
Parameters
[in]aunsigned long long type of value stored in a
Returns
value stored in unsigned long long type

Definition at line 18396 of file core_feature_dsp.h.

18397 {
18398  unsigned long long result;
18399  __ASM volatile("dkabs16 %0, %1" : "=r"(result) : "r"(a));
18400  return result;
18401 }

References __ASM.

◆ __RV_DKABS8()

__STATIC_FORCEINLINE unsigned long long __RV_DKABS8 ( unsigned long long  a)

DKABS8 (64-bit SIMD 8-bit Saturating Absolute)

Type: SIMD

Syntax:

DKABS8 Rd, Rs1
# Rd, Rs1 are all even/odd pair of registers

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

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

Operations:

src = Rs1.B[x];
if (src == 0x80) {
src = 0x7f;
OV = 1;
} else if (src[7] == 1)
src = -src;
}
Rd.B[x] = src;
for RV32: x=7...0,
Parameters
[in]aunsigned long long type of value stored in a
Returns
value stored in unsigned long long type

Definition at line 18351 of file core_feature_dsp.h.

18352 {
18353  unsigned long long result;
18354  __ASM volatile("dkabs8 %0, %1" : "=r"(result) : "r"(a));
18355  return result;
18356 }

References __ASM.

◆ __RV_DKADD16()

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

DKADD16 (64-bit SIMD 16-bit Signed Saturating Addition)

Type: SIMD

Syntax:

DKADD16 Rd, Rs1, Rs2
# Rd, Rs1, Rs2 are all even/odd pair of registers

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=3...0,
Parameters
[in]aunsigned long long type of value stored in a
[in]bunsigned long long type of value stored in b
Returns
value stored in unsigned long long type

Definition at line 18607 of file core_feature_dsp.h.

18608 {
18609  unsigned long long result;
18610  __ASM volatile("dkadd16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
18611  return result;
18612 }

References __ASM.

◆ __RV_DKADD8()

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

DKADD8 (64-bit SIMD 8-bit Signed Saturating Addition)

Type: SIMD

Syntax:

DKADD8 Rd, Rs1, Rs2
# Rd, Rs1, Rs2 are all even/odd pair of registers

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

Description:
This instruction adds the 8-bit signed integer elements in Rs1 with the 8-bit signed integer elements in Rs2. If any of the results are beyond the Q7 number range (-2^7 <= Q7 <= 2^7-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.B[x] + Rs2.B[x];
if (res[x] > 127) {
res[x] = 127;
OV = 1;
} else if (res[x] < -128) {
res[x] = -128;
OV = 1;
}
Rd.B[x] = res[x];
for RV32: x=7...0,
Parameters
[in]aunsigned long long type of value stored in a
[in]bunsigned long long type of value stored in b
Returns
value stored in unsigned long long type

Definition at line 18560 of file core_feature_dsp.h.

18561 {
18562  unsigned long long result;
18563  __ASM volatile("dkadd8 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
18564  return result;
18565 }

References __ASM.

◆ __RV_DKHM16()

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

DKHM16 (64-bit SIMD Signed Saturating Q15 Multiply)

Type: SIMD

Syntax:

DKHM16 Rd, Rs1, Rs2
# Rd, Rs1, Rs2 are all even/odd pair of registers

Purpose:
Do Q15xQ15 element multiplications simultaneously. The Q30 results are then reduced to Q15 numbers again.

Description:
For the DKHM16 instruction, multiply the top 16-bit Q15 content of 32-bit chunks in Rs1 with the top 16-bit Q15 content of 32-bit chunks in Rs2. At the same time, multiply the bottom 16-bit Q15 content of 32-bit chunks in Rs1 with the bottom 16-bit Q15 content of 32-bit chunks in Rs2.

The Q30 results are then right-shifted 15-bits and saturated into Q15 values. The Q15 results are then written into Rd. When both the two Q15 inputs of a multiplication are 0x8000, saturation will happen. The result will be saturated to 0x7FFF and the overflow flag OV will be set.

Operations:

op1t = Rs1.H[x+1]; op2t = Rs2.H[x+1]; // top
op1b = Rs1.H[x]; op2b = Rs2.H[x]; // bottom
for ((aop,bop,res) in [(op1t,op2t,rest), (op1b,op2b,resb)]) {
if (0x8000 != aop | 0x8000 != bop) {
res = (aop s* bop) >> 15;
} else {
res= 0x7FFF;
OV = 1;
}
}
Rd.W[x/2] = concat(rest, resb);
for RV32: x=0, 2
Parameters
[in]aunsigned long long type of value stored in a
[in]bunsigned long long type of value stored in b
Returns
value stored in unsigned long long type

Definition at line 18306 of file core_feature_dsp.h.

18307 {
18308  unsigned long long result;
18309  __ASM volatile("dkhm16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
18310  return result;
18311 }

References __ASM.

◆ __RV_DKHM8()

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

DKHM8 (64-bit SIMD Signed Saturating Q7 Multiply)

Type: SIMD

Syntax:

DKHM8 Rd, Rs1, Rs2
# Rd, Rs1, Rs2 are all even/odd pair of registers

Purpose:
Do Q7xQ7 element multiplications simultaneously. The Q14 results are then reduced to Q7 numbers again.

Description:
For the DKHM8 instruction, multiply the top 8-bit Q7 content of 16-bit chunks in Rs1 with the top 8-bit Q7 content of 16-bit chunks in Rs2. At the same time, multiply the bottom 8-bit Q7 content of 16-bit chunks in Rs1 with the bottom 8-bit Q7 content of 16-bit chunks in Rs2.

The Q14 results are then right-shifted 7-bits and saturated into Q7 values. The Q7 results are then written into Rd. When both the two Q7 inputs of a multiplication are 0x80, saturation will happen. The result will be saturated to 0x7F and the overflow flag OV will be set.

Operations:

op1t = Rs1.B[x+1]; op2t = Rs2.B[x+1]; // top
op1b = Rs1.B[x]; op2b = Rs2.B[x]; // bottom
for ((aop,bop,res) in [(op1t,op2t,rest), (op1b,op2b,resb)]) {
if (0x80 != aop | 0x80 != bop) {
res = (aop s* bop) >> 7;
} else {
res= 0x7F;
OV = 1;
}
}
Rd.H[x/2] = concat(rest, resb);
for RV32, x=0,2,4,6
Parameters
[in]aunsigned long long type of value stored in a
[in]bunsigned long long type of value stored in b
Returns
value stored in unsigned long long type

Definition at line 18251 of file core_feature_dsp.h.

18252 {
18253  unsigned long long result;
18254  __ASM volatile("dkhm8 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
18255  return result;
18256 }

References __ASM.

◆ __RV_DKSLRA16()

__STATIC_FORCEINLINE unsigned long long __RV_DKSLRA16 ( unsigned long long  a,
int  b 
)

DKSLRA16 (64-bit SIMD 16-bit Shift Left Logical with Saturation or Shift Right Arithmetic)

Type: SIMD

Syntax:

DKSLRA16 Rd, Rs1, Rs2
# Rd, Rs1 are all even/odd pair of registers

Purpose:
Do 16-bit elements logical left (positive) or arithmetic right (negative) shift operation with Q15 saturation for the left shift.

Description:
The 16-bit data elements of Rs1 are left-shifted logically or right-shifted arithmetically based on the value of Rs2[4:0]. Rs2[4:0] is in the signed range of [-2^4, 2^4-1]. A positive Rs2[4:0] means logical left shift and a negative Rs2[4:0] means arithmetic right shift. The shift amount is the absolute value of Rs2[4:0]. However, the behavior of Rs2[4:0]==-2^4 (0x10) is defined to be equivalent to the behavior of Rs2[4:0]==-(2^4-1) (0x11). The left-shifted results are saturated to the 16-bit signed integer range of [-2^15, 2^15-1]. After the shift, saturation, or rounding, the final results are written to Rd. If any saturation happens, this instruction sets the OV flag. The value of Rs2[31:5] will not affect this instruction.

Operations:

if (Rs2[4:0] < 0) {
sa = -Rs2[4:0];
sa = (sa == 16)? 15 : sa;
Rd.H[x] = SE16(Rs1.H[x][15:sa]);
} else {
sa = Rs2[3:0];
res[(15+sa):0] = Rs1.H[x] <<(logic) sa;
if (res > (2^15)-1) {
res[15:0] = 0x7fff; OV = 1;
} else if (res < -2^15) {
res[15:0] = 0x8000; OV = 1;
}
d.H[x] = res[15:0];
}
for RV32: x=3...0,
Parameters
[in]aunsigned long long type of value stored in a
[in]bint type of value stored in b
Returns
value stored in unsigned long long type

Definition at line 18513 of file core_feature_dsp.h.

18514 {
18515  unsigned long long result;
18516  __ASM volatile("dkslra16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
18517  return result;
18518 }

References __ASM.

◆ __RV_DKSLRA8()

__STATIC_FORCEINLINE unsigned long long __RV_DKSLRA8 ( unsigned long long  a,
int  b 
)

DKSLRA8 (64-bit SIMD 8-bit Shift Left Logical with Saturation or Shift Right Arithmetic)

Type: SIMD

Syntax:

DKSLRA8 Rd, Rs1, Rs2
# Rd, Rs1 are all even/odd pair of registers

Purpose:
Do 8-bit elements logical left (positive) or arithmetic right (negative) shift operation with Q7 saturation for the left shift.

Description:
The 8-bit data elements of Rs1 are left-shifted logically or right-shifted arithmetically based on the value of Rs2[3:0]. Rs2[3:0] is in the signed range of [-2^3, 2^3-1]. A positive Rs2[3:0] means logical left shift and a negative Rs2[3:0] means arithmetic right shift. The shift amount is the absolute value of Rs2[3:0]. However, the behavior of Rs2[3:0]==-2^3 (0x8) is defined to be equivalent to the behavior of Rs2[3:0]==-(2^3-1) (0x9). The left-shifted results are saturated to the 8-bit signed integer range of [-2^7, 2^7-1]. If any saturation happens, this instruction sets the OV flag. The value of Rs2[31:4] will not affect this instruction.

Operations:

if (Rs2[3:0] < 0) {
sa = -Rs2[3:0];
sa = (sa == 8)? 7 : sa;
Rd.B[x] = SE8(Rs1.B[x][7:sa]);
} else {
sa = Rs2[2:0];
res[(7+sa):0] = Rs1.B[x] <<(logic) sa;
if (res > (2^7)-1) {
res[7:0] = 0x7f; OV = 1;
} else if (res < -2^7) {
res[7:0] = 0x80; OV = 1;
}
Rd.B[x] = res[7:0];
}
for RV32: x=7...0,
Parameters
[in]aunsigned long long type of value stored in a
[in]bint type of value stored in b
Returns
value stored in unsigned long long type

Definition at line 18454 of file core_feature_dsp.h.

18455 {
18456  unsigned long long result;
18457  __ASM volatile("dkslra8 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
18458  return result;
18459 }

References __ASM.

◆ __RV_DKSUB16()

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

DKSUB16 (64-bit SIMD 16-bit Signed Saturating Subtraction)

Type: SIMD

Syntax:

DKSUB16 Rd, Rs1, Rs2
# Rd, Rs1, Rs2 are all even/odd pair of registers

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=3...0,
Parameters
[in]aunsigned long long type of value stored in a
[in]bunsigned long long type of value stored in b
Returns
value stored in unsigned long long type

Definition at line 18702 of file core_feature_dsp.h.

18703 {
18704  unsigned long long result;
18705  __ASM volatile("dksub16 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
18706  return result;
18707 }

References __ASM.

◆ __RV_DKSUB8()

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

DKSUB8 (64-bit SIMD 8-bit Signed Saturating Subtraction)

Type: SIMD

Syntax:

DKSUB8 Rd, Rs1, Rs2
# Rd, Rs1, Rs2 are all even/odd pair of registers

Purpose:
Do 8-bit signed elements saturating subtractions simultaneously.

Description:
This instruction subtracts the 8-bit signed integer elements in Rs2 from the 8-bit signed integer elements in Rs1. If any of the results are beyond the Q7 number range (-2^7 <= Q7 <= 2^7-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.B[x] - Rs2.B[x];
if (res[x] > (2^7)-1) {
res[x] = (2^7)-1;
OV = 1;
} else if (res[x] < -2^7) {
res[x] = -2^7;
OV = 1;
}
Rd.B[x] = res[x];
for RV32: x=7...0,
Parameters
[in]aunsigned long long type of value stored in a
[in]bunsigned long long type of value stored in b
Returns
value stored in unsigned long long type

Definition at line 18654 of file core_feature_dsp.h.

18655 {
18656  unsigned long long result;
18657  __ASM volatile("dksub8 %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
18658  return result;
18659 }

References __ASM.

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