Xmega Application Note | |||||
CLZ/CTZ C implemetation. More...
Go to the source code of this file.
Defines | |
#define | clz(x) compiler_demux_size(sizeof(x), clz, (x)) |
Count leading zeros in unsigned integer. | |
#define | ctz(x) compiler_demux_size(sizeof(x), ctz, (x)) |
Count trailing zeros in unsigned integer. | |
Functions | |
static __always_inline uint8_t | clz16 (uint16_t x) |
Count leading zeros in unsigned, 16-bit integer. | |
static __always_inline uint8_t | clz32 (uint32_t x) |
Count leading zeros in unsigned, 32-bit integer. | |
static __always_inline uint8_t | clz8 (uint8_t x) |
Count leading zeros in unsigned, 8-bit integer. | |
static __always_inline uint8_t | ctz16 (uint16_t x) |
Count trailing zeros in unsigned, 16-bit integer. | |
static __always_inline uint8_t | ctz32 (uint32_t x) |
Count trailing zeros in unsigned, 32-bit integer. | |
static __always_inline uint8_t | ctz8 (uint8_t x) |
Count trailing zeros in unsigned, 8-bit integer. |
CLZ/CTZ C implemetation.
Copyright (C) 2009 Atmel Corporation. All rights reserved.
Definition in file clz_ctz.h.
#define clz | ( | x | ) | compiler_demux_size(sizeof(x), clz, (x)) |
Count leading zeros in unsigned integer.
This macro takes unsigned integers of any size, and evaluates to a call to the clz-function for its size. These functions count the number of zeros, starting with the MSB, before a one occurs in the integer.
x | Unsigned integer to count the leading zeros in. |
Definition at line 51 of file clz_ctz.h.
Referenced by ilog2().
#define ctz | ( | x | ) | compiler_demux_size(sizeof(x), ctz, (x)) |
Count trailing zeros in unsigned integer.
This macro takes unsigned integers of any size, and evaluates to a call to the ctz-function for its size. These functions count the number of zeros, starting with the LSB, before a one occurs in the integer.
x | Unsigned integer to count the trailing zeros in. |
Definition at line 138 of file clz_ctz.h.
Referenced by fifo_init_malloc(), and fifo_init_no_malloc().
static __always_inline uint8_t clz16 | ( | uint16_t | x | ) | [static] |
Count leading zeros in unsigned, 16-bit integer.
For internal use only.
x | Unsigned word to count the leading zeros in. |
Definition at line 93 of file clz_ctz.h.
References clz8().
Referenced by clz32().
00094 { 00095 uint8_t bit = 0; 00096 00097 if (x & 0xff00) { 00098 x >>= 8; 00099 } else { 00100 bit += 8; 00101 } 00102 00103 return bit + clz8(x); 00104 }
static __always_inline uint8_t clz32 | ( | uint32_t | x | ) | [static] |
Count leading zeros in unsigned, 32-bit integer.
For internal use only.
x | Unsigned double word to count the leading zeros in. |
Definition at line 114 of file clz_ctz.h.
References clz16().
00115 { 00116 uint8_t bit = 0; 00117 00118 if (x & 0xffff0000) { 00119 x >>= 16; 00120 } else { 00121 bit += 16; 00122 } 00123 00124 return bit + clz16(x); 00125 }
static __always_inline uint8_t clz8 | ( | uint8_t | x | ) | [static] |
static __always_inline uint8_t ctz16 | ( | uint16_t | x | ) | [static] |
Count trailing zeros in unsigned, 16-bit integer.
For internal use only.
x | Unsigned word to count the trailing zeros in. |
Definition at line 174 of file clz_ctz.h.
References ctz8().
Referenced by ctz32().
00175 { 00176 uint8_t bit = 0; 00177 00178 if (!(x & 0x00ff)) { 00179 bit += 8; 00180 x >>= 8; 00181 } 00182 00183 return bit + ctz8(x); 00184 }
static __always_inline uint8_t ctz32 | ( | uint32_t | x | ) | [static] |
Count trailing zeros in unsigned, 32-bit integer.
For internal use only.
x | Unsigned double word to count the trailing zeros in. |
Definition at line 194 of file clz_ctz.h.
References ctz16().
00195 { 00196 uint8_t bit = 0; 00197 00198 if (!(x & 0x0000ffff)) { 00199 bit += 16; 00200 x >>= 16; 00201 } 00202 00203 return bit + ctz16(x); 00204 }
Generated on Fri Oct 22 12:15:25 2010 for AVR1300 Using the Xmega ADC by ![]() |