NMSIS-Core  Version 1.2.0
NMSIS-Core support for Nuclei processor-based devices
ARM Compatiable Functions

A few functions that compatiable with ARM CMSIS-Core. More...

Macros

#define __ISB()   __RWMB()
 Instruction Synchronization Barrier, compatiable with ARM. More...
 
#define __DSB()   __RWMB()
 Data Synchronization Barrier, compatiable with ARM. More...
 
#define __DMB()   __RWMB()
 Data Memory Barrier, compatiable with ARM. More...
 
#define __LDRBT(ptr)   __LB((ptr))
 LDRT Unprivileged (8 bit), ARM Compatiable. More...
 
#define __LDRHT(ptr)   __LH((ptr))
 LDRT Unprivileged (16 bit), ARM Compatiable. More...
 
#define __LDRT(ptr)   __LW((ptr))
 LDRT Unprivileged (32 bit), ARM Compatiable. More...
 
#define __STRBT(val, ptr)   __SB((ptr), (val))
 STRT Unprivileged (8 bit), ARM Compatiable. More...
 
#define __STRHT(val, ptr)   __SH((ptr), (val))
 STRT Unprivileged (16 bit), ARM Compatiable. More...
 
#define __STRT(val, ptr)   __SW((ptr), (val))
 STRT Unprivileged (32 bit), ARM Compatiable. More...
 
#define __SSAT(val, sat)   __RV_SCLIP32((val), (sat-1))
 Signed Saturate. More...
 
#define __USAT(val, sat)   __RV_UCLIP32((val), (sat))
 Unsigned Saturate. More...
 
#define __RBIT(value)   __RV_BITREVI((value), 31)
 Reverse bit order of value. More...
 
#define __CLZ(data)   __RV_CLZ32(data)
 Count leading zeros. More...
 
#define __EXPD_BYTE(x)
 Expand byte to unsigned long value. More...
 

Functions

__STATIC_FORCEINLINE uint32_t __REV (uint32_t value)
 Reverse byte order (32 bit) More...
 
__STATIC_FORCEINLINE uint32_t __REV16 (uint32_t value)
 Reverse byte order (16 bit) More...
 
__STATIC_FORCEINLINE int16_t __REVSH (int16_t value)
 Reverse byte order (16 bit) More...
 
__STATIC_FORCEINLINE uint32_t __ROR (uint32_t op1, uint32_t op2)
 Rotate Right in unsigned value (32 bit) More...
 
__STATIC_FORCEINLINE unsigned long __CTZ (unsigned long data)
 Count tailing zero. More...
 

Detailed Description

A few functions that compatiable with ARM CMSIS-Core.

Here we provided a few functions that compatiable with ARM CMSIS-Core, mostly used in the DSP and NN library.

Macro Definition Documentation

◆ __CLZ

#define __CLZ (   data)    __RV_CLZ32(data)

Count leading zeros.

Counts the number of leading zeros of a data value.

Parameters
[in]dataValue to count the leading zeros
Returns
number of leading zeros in value

Definition at line 215 of file core_compatiable.h.

◆ __DMB

#define __DMB ( )    __RWMB()

Data Memory Barrier, compatiable with ARM.

Definition at line 48 of file core_compatiable.h.

◆ __DSB

#define __DSB ( )    __RWMB()

Data Synchronization Barrier, compatiable with ARM.

Definition at line 45 of file core_compatiable.h.

◆ __EXPD_BYTE

#define __EXPD_BYTE (   x)

Expand byte to unsigned long value.

Expand byte value x to unsigned long value's each byte.

Parameters
[in]xthe byte value to be expand, the input must be uint8_t type
Returns
Expanded value in unsigned long

Definition at line 254 of file core_compatiable.h.

◆ __ISB

#define __ISB ( )    __RWMB()

Instruction Synchronization Barrier, compatiable with ARM.

Definition at line 42 of file core_compatiable.h.

◆ __LDRBT

#define __LDRBT (   ptr)    __LB((ptr))

LDRT Unprivileged (8 bit), ARM Compatiable.

Definition at line 51 of file core_compatiable.h.

◆ __LDRHT

#define __LDRHT (   ptr)    __LH((ptr))

LDRT Unprivileged (16 bit), ARM Compatiable.

Definition at line 53 of file core_compatiable.h.

◆ __LDRT

#define __LDRT (   ptr)    __LW((ptr))

LDRT Unprivileged (32 bit), ARM Compatiable.

Definition at line 55 of file core_compatiable.h.

◆ __RBIT

#define __RBIT (   value)    __RV_BITREVI((value), 31)

Reverse bit order of value.

Reverses the bit order of the given value.

Parameters
[in]valueValue to reverse
Returns
Reversed value

Definition at line 190 of file core_compatiable.h.

◆ __SSAT

#define __SSAT (   val,
  sat 
)    __RV_SCLIP32((val), (sat-1))

Signed Saturate.

Saturates a signed value.

Parameters
[in]valueValue to be saturated
[in]satBit position to saturate to (1..32)
Returns
Saturated value

Definition at line 73 of file core_compatiable.h.

◆ __STRBT

#define __STRBT (   val,
  ptr 
)    __SB((ptr), (val))

STRT Unprivileged (8 bit), ARM Compatiable.

Definition at line 58 of file core_compatiable.h.

◆ __STRHT

#define __STRHT (   val,
  ptr 
)    __SH((ptr), (val))

STRT Unprivileged (16 bit), ARM Compatiable.

Definition at line 60 of file core_compatiable.h.

◆ __STRT

#define __STRT (   val,
  ptr 
)    __SW((ptr), (val))

STRT Unprivileged (32 bit), ARM Compatiable.

Definition at line 62 of file core_compatiable.h.

◆ __USAT

#define __USAT (   val,
  sat 
)    __RV_UCLIP32((val), (sat))

Unsigned Saturate.

Saturates an unsigned value.

Parameters
[in]valueValue to be saturated
[in]satBit position to saturate to (0..31)
Returns
Saturated value

Definition at line 98 of file core_compatiable.h.

Function Documentation

◆ __CTZ()

__STATIC_FORCEINLINE unsigned long __CTZ ( unsigned long  data)

Count tailing zero.

Return the count of least-significant bit zero.for example, return 3 if x=0bxxx1000

Parameters
[in]dataValue to count the tailing zeros
Returns
number of tailing zeros in value

Definition at line 235 of file core_compatiable.h.

236 {
237  unsigned long ret = 0;
238 
239  while (!(data & 1UL)) {
240  ret++;
241  data = data >> 1;
242  }
243 
244  return ret;
245 }

Referenced by __get_PMPENTRYx(), and __get_sPMPENTRYx().

◆ __REV()

__STATIC_FORCEINLINE uint32_t __REV ( uint32_t  value)

Reverse byte order (32 bit)

Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.

Parameters
[in]valueValue to reverse
Returns
Reversed value

Definition at line 122 of file core_compatiable.h.

123 {
124  uint32_t result;
125 
126  result = ((value & 0xff000000) >> 24)
127  | ((value & 0x00ff0000) >> 8 )
128  | ((value & 0x0000ff00) << 8 )
129  | ((value & 0x000000ff) << 24);
130  return result;
131 }

◆ __REV16()

__STATIC_FORCEINLINE uint32_t __REV16 ( uint32_t  value)

Reverse byte order (16 bit)

Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.

Parameters
[in]valueValue to reverse
Returns
Reversed value

Definition at line 140 of file core_compatiable.h.

141 {
142  uint32_t result;
143  result = ((value & 0xff000000) >> 8)
144  | ((value & 0x00ff0000) << 8 )
145  | ((value & 0x0000ff00) >> 8 )
146  | ((value & 0x000000ff) << 8) ;
147 
148  return result;
149 }

◆ __REVSH()

__STATIC_FORCEINLINE int16_t __REVSH ( int16_t  value)

Reverse byte order (16 bit)

Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.

Parameters
[in]valueValue to reverse
Returns
Reversed value

Definition at line 159 of file core_compatiable.h.

160 {
161  int16_t result;
162  result = ((value & 0xff00) >> 8) | ((value & 0x00ff) << 8);
163  return result;
164 }

◆ __ROR()

__STATIC_FORCEINLINE uint32_t __ROR ( uint32_t  op1,
uint32_t  op2 
)

Rotate Right in unsigned value (32 bit)

Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.

Parameters
[in]op1Value to rotate
[in]op2Number of Bits to rotate(0-31)
Returns
Rotated value

Definition at line 174 of file core_compatiable.h.

175 {
176  op2 = op2 & 0x1F;
177  if (op2 == 0U) {
178  return op1;
179  }
180  return (op1 >> op2) | (op1 << (32U - op2));
181 }