byteman  1.3 (Build #225)
Bitstream relocation and manipulation tool
Functions
Endian Namespace Reference

Functions

uint16_t BigEndianToNative16 (uint16_t x)
 
uint32_t BigEndianToNative32 (uint32_t x)
 
uint64_t BigEndianToNative64 (uint64_t x)
 
uint8_t BigEndianToNative8 (uint8_t x)
 
uint16_t BitSwap16 (uint16_t x)
 
uint32_t BitSwap32 (uint32_t x)
 
uint64_t BitSwap64 (uint64_t x)
 
uint8_t BitSwap8 (uint8_t x)
 
Endianness diff (Endianness e1, Endianness e2)
 
bool isBE (Endianness e)
 
bool isBitSwap (Endianness e)
 
bool isLE (Endianness e)
 
uint16_t LittleEndianToNative16 (uint16_t x)
 
uint32_t LittleEndianToNative32 (uint32_t x)
 
uint64_t LittleEndianToNative64 (uint64_t x)
 
uint8_t LittleEndianToNative8 (uint8_t x)
 
uint16_t NativeToAnyEndianness16 (uint16_t x, Endianness e)
 
uint32_t NativeToAnyEndianness32 (uint32_t x, Endianness e)
 
uint64_t NativeToAnyEndianness64 (uint64_t x, Endianness e)
 
uint8_t NativeToAnyEndianness8 (uint8_t x, Endianness e)
 
uint16_t NativeToBigEndian16 (uint16_t x)
 
uint32_t NativeToBigEndian32 (uint32_t x)
 
uint64_t NativeToBigEndian64 (uint64_t x)
 
uint8_t NativeToBigEndian8 (uint8_t x)
 
uint16_t NativeToLittleEndian16 (uint16_t x)
 
uint32_t NativeToLittleEndian32 (uint32_t x)
 
uint64_t NativeToLittleEndian64 (uint64_t x)
 
uint8_t NativeToLittleEndian8 (uint8_t x)
 
uint16_t swapbytes16 (uint16_t x)
 
uint32_t swapbytes32 (uint32_t x)
 
uint64_t swapbytes64 (uint64_t x)
 
std::string to_string (Endianness e)
 
Endianness toggleEndianBitSwap (Endianness e, bool toggle=true)
 
Endianness toggleEndianness (Endianness e, bool toggle=true)
 

Function Documentation

◆ BigEndianToNative16()

uint16_t Endian::BigEndianToNative16 ( uint16_t  x)
inline

Definition at line 182 of file Endianness.h.

183  {
184  return NativeToBigEndian16(x);
185  }
uint16_t NativeToBigEndian16(uint16_t x)
Definition: Endianness.h:148

References NativeToBigEndian16().

Referenced by FileIO::writeBigEndian16(), and FileIO::writeBitSwappedBigEndian16().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BigEndianToNative32()

uint32_t Endian::BigEndianToNative32 ( uint32_t  x)
inline

Definition at line 186 of file Endianness.h.

187  {
188  return NativeToBigEndian32(x);
189  }
uint32_t NativeToBigEndian32(uint32_t x)
Definition: Endianness.h:152

References NativeToBigEndian32().

Referenced by FileIO::writeBigEndian32(), and FileIO::writeBitSwappedBigEndian32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BigEndianToNative64()

uint64_t Endian::BigEndianToNative64 ( uint64_t  x)
inline

Definition at line 190 of file Endianness.h.

191  {
192  return NativeToBigEndian64(x);
193  }
uint64_t NativeToBigEndian64(uint64_t x)
Definition: Endianness.h:156

References NativeToBigEndian64().

Referenced by FileIO::writeBigEndian64(), and FileIO::writeBitSwappedBigEndian64().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BigEndianToNative8()

uint8_t Endian::BigEndianToNative8 ( uint8_t  x)
inline

Definition at line 178 of file Endianness.h.

179  {
180  return ((uint8_t)(x));
181  }

Referenced by FileIO::writeBigEndian8(), and FileIO::writeBitSwappedBigEndian8().

Here is the caller graph for this function:

◆ BitSwap16()

uint16_t Endian::BitSwap16 ( uint16_t  x)
inline

Definition at line 216 of file Endianness.h.

217  {
218  return (((x & 0x8080)>>7) | ((x & 0x4040)>>5) | ((x & 0x2020)>>3) | ((x & 0x1010)>>1) | ((x & 0x0808) << 1) | ((x & 0x0404) << 3) | ((x & 0x0202) << 5) | ((x & 0x0101) << 7));
219  }

Referenced by NativeToAnyEndianness16(), FileIO::readBitSwappedBigEndian16(), FileIO::readBitSwappedLittleEndian16(), FileIO::writeBitSwappedBigEndian16(), and FileIO::writeBitSwappedLittleEndian16().

Here is the caller graph for this function:

◆ BitSwap32()

uint32_t Endian::BitSwap32 ( uint32_t  x)
inline

Definition at line 220 of file Endianness.h.

221  {
222  return (((x & 0x80808080)>>7) | ((x & 0x40404040)>>5) | ((x & 0x20202020)>>3) | ((x & 0x10101010)>>1) | ((x & 0x08080808) << 1) | ((x & 0x04040404) << 3) | ((x & 0x02020202) << 5) | ((x & 0x01010101) << 7));
223  }

Referenced by ensureSelectedEndianness(), NativeToAnyEndianness32(), parseBitstreamEndianness(), FileIO::readBitSwappedBigEndian32(), FileIO::readBitSwappedLittleEndian32(), FileIO::writeBitSwappedBigEndian32(), and FileIO::writeBitSwappedLittleEndian32().

Here is the caller graph for this function:

◆ BitSwap64()

uint64_t Endian::BitSwap64 ( uint64_t  x)
inline

Definition at line 224 of file Endianness.h.

225  {
226  return (((x & 0x8080808080808080)>>7) | ((x & 0x4040404040404040)>>5) | ((x & 0x2020202020202020)>>3) | ((x & 0x1010101010101010)>>1) | ((x & 0x0808080808080808) << 1) | ((x & 0x0404040404040404) << 3) | ((x & 0x0202020202020202) << 5) | ((x & 0x0101010101010101) << 7));
227  }

Referenced by NativeToAnyEndianness64(), FileIO::readBitSwappedBigEndian64(), FileIO::readBitSwappedLittleEndian64(), FileIO::writeBitSwappedBigEndian64(), and FileIO::writeBitSwappedLittleEndian64().

Here is the caller graph for this function:

◆ BitSwap8()

uint8_t Endian::BitSwap8 ( uint8_t  x)
inline

Definition at line 212 of file Endianness.h.

213  {
214  return (((x & 0x80)>>7) | ((x & 0x40)>>5) | ((x & 0x20)>>3) | ((x & 0x10)>>1) | ((x & 0x08) << 1) | ((x & 0x04) << 3) | ((x & 0x02) << 5) | ((x & 0x01) << 7));
215  }

Referenced by FileIO::readBitSwappedBigEndian8(), FileIO::readBitSwappedLittleEndian8(), FileIO::readBitSwappedStringIntoCharArray(), FileIO::writeBitSwappedBigEndian8(), FileIO::writeBitSwappedCharArray(), FileIO::writeBitSwappedLittleEndian8(), and FileIO::writeBitSwappedString().

Here is the caller graph for this function:

◆ diff()

Endianness Endian::diff ( Endianness  e1,
Endianness  e2 
)
inline

Returns what endianess operation is needed to convert between two endianesses. The returned endianess represents the operation needed to be done between host system's endianess and returned one, to achieve the same conversion as between the two given endianesses. For example, will return Endianness::NATIVE if no conversion is needed.

Definition at line 117 of file Endianness.h.

118  {
119  Endianness accumulatedEndiannessDiff = Endianness::NATIVE;
120 
121  accumulatedEndiannessDiff = toggleEndianBitSwap(accumulatedEndiannessDiff, isBitSwap(e1));
122  accumulatedEndiannessDiff = toggleEndianBitSwap(accumulatedEndiannessDiff, isBitSwap(e2));
123 
124  accumulatedEndiannessDiff = toggleEndianness(accumulatedEndiannessDiff, isLE(e1));
125  accumulatedEndiannessDiff = toggleEndianness(accumulatedEndiannessDiff, isLE(e2));
126 
127  return accumulatedEndiannessDiff;
128  }
Endianness
< Endianness in byteman is represented not only by big/little endian, but also by potential bit swapp...
Definition: Endianness.h:47
@ NATIVE
System native will always be the fastest endianess to process.
bool isBitSwap(Endianness e)
Definition: Endianness.h:98
bool isLE(Endianness e)
Definition: Endianness.h:102
Endianness toggleEndianBitSwap(Endianness e, bool toggle=true)
Definition: Endianness.h:84
Endianness toggleEndianness(Endianness e, bool toggle=true)
Definition: Endianness.h:70

References isBitSwap(), isLE(), NATIVE, toggleEndianBitSwap(), and toggleEndianness().

Referenced by ensureSelectedEndianness(), XilinxSeries7::merge(), XilinxUltraScale::merge(), and XilinxUltraScalePlus::merge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isBE()

bool Endian::isBE ( Endianness  e)
inline

Definition at line 106 of file Endianness.h.

107  {
108  return (Endianness::BE == e || Endianness::BE_BS == e);
109  }
@ BE_BS
Big endian with bit swaps inside each byte.
@ BE
Big endian ("BE" instead of full-er name, so it does not conflict with linux's reserved endianess wor...

References BE, and BE_BS.

◆ isBitSwap()

bool Endian::isBitSwap ( Endianness  e)
inline

Definition at line 98 of file Endianness.h.

99  {
100  return (Endianness::BE_BS == e || Endianness::LE_BS == e);
101  }
@ LE_BS
Little endian with bit swaps inside each byte.

References BE_BS, and LE_BS.

Referenced by diff().

Here is the caller graph for this function:

◆ isLE()

bool Endian::isLE ( Endianness  e)
inline

Definition at line 102 of file Endianness.h.

103  {
104  return (Endianness::LE == e || Endianness::LE_BS == e);
105  }
@ LE
Little endian ("LE" instead of full-er name, so it does not conflict with linux's reserved endianess ...

References LE, and LE_BS.

Referenced by diff().

Here is the caller graph for this function:

◆ LittleEndianToNative16()

uint16_t Endian::LittleEndianToNative16 ( uint16_t  x)
inline

Definition at line 198 of file Endianness.h.

199  {
200  return NativeToLittleEndian16(x);
201  }
uint16_t NativeToLittleEndian16(uint16_t x)
Definition: Endianness.h:165

References NativeToLittleEndian16().

Referenced by FileIO::writeBitSwappedLittleEndian16(), and FileIO::writeLittleEndian16().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LittleEndianToNative32()

uint32_t Endian::LittleEndianToNative32 ( uint32_t  x)
inline

Definition at line 202 of file Endianness.h.

203  {
204  return NativeToLittleEndian32(x);
205  }
uint32_t NativeToLittleEndian32(uint32_t x)
Definition: Endianness.h:169

References NativeToLittleEndian32().

Referenced by FileIO::writeBitSwappedLittleEndian32(), and FileIO::writeLittleEndian32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LittleEndianToNative64()

uint64_t Endian::LittleEndianToNative64 ( uint64_t  x)
inline

Definition at line 206 of file Endianness.h.

207  {
208  return NativeToLittleEndian64(x);
209  }
uint64_t NativeToLittleEndian64(uint64_t x)
Definition: Endianness.h:173

References NativeToLittleEndian64().

Referenced by FileIO::writeBitSwappedLittleEndian64(), and FileIO::writeLittleEndian64().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LittleEndianToNative8()

uint8_t Endian::LittleEndianToNative8 ( uint8_t  x)
inline

Definition at line 194 of file Endianness.h.

195  {
196  return ((uint8_t)(x));
197  }

Referenced by FileIO::writeBitSwappedLittleEndian8(), and FileIO::writeLittleEndian8().

Here is the caller graph for this function:

◆ NativeToAnyEndianness16()

uint16_t Endian::NativeToAnyEndianness16 ( uint16_t  x,
Endianness  e 
)
inline

Definition at line 233 of file Endianness.h.

234  {
235  if(Endianness::BE == e)
236  return NativeToBigEndian16(x);
237  if(Endianness::LE == e)
238  return NativeToLittleEndian16(x);
239  if(Endianness::BE_BS == e)
240  return BitSwap16(NativeToBigEndian16(x));
241  if(Endianness::LE_BS == e)
243  //Native then
244  return ((uint16_t)(x));
245  }
uint16_t BitSwap16(uint16_t x)
Definition: Endianness.h:216

References BE, BE_BS, BitSwap16(), LE, LE_BS, NativeToBigEndian16(), and NativeToLittleEndian16().

Here is the call graph for this function:

◆ NativeToAnyEndianness32()

uint32_t Endian::NativeToAnyEndianness32 ( uint32_t  x,
Endianness  e 
)
inline

Definition at line 246 of file Endianness.h.

247  {
248  if(Endianness::BE == e)
249  return NativeToBigEndian32(x);
250  if(Endianness::LE == e)
251  return NativeToLittleEndian32(x);
252  if(Endianness::BE_BS == e)
253  return BitSwap32(NativeToBigEndian32(x));
254  if(Endianness::LE_BS == e)
256  //Native then
257  return ((uint32_t)(x));
258  }
uint32_t BitSwap32(uint32_t x)
Definition: Endianness.h:220

References BE, BE_BS, BitSwap32(), LE, LE_BS, NativeToBigEndian32(), and NativeToLittleEndian32().

Referenced by flexiMerge(), readBitstreamRBDMain(), and setBitstreamWord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NativeToAnyEndianness64()

uint64_t Endian::NativeToAnyEndianness64 ( uint64_t  x,
Endianness  e 
)
inline

Definition at line 259 of file Endianness.h.

260  {
261  if(Endianness::BE == e)
262  return NativeToBigEndian64(x);
263  if(Endianness::LE == e)
264  return NativeToLittleEndian64(x);
265  if(Endianness::BE_BS == e)
266  return BitSwap64(NativeToBigEndian64(x));
267  if(Endianness::LE_BS == e)
269  //Native then
270  return ((uint64_t)(x));
271  }
uint64_t BitSwap64(uint64_t x)
Definition: Endianness.h:224

References BE, BE_BS, BitSwap64(), LE, LE_BS, NativeToBigEndian64(), and NativeToLittleEndian64().

Here is the call graph for this function:

◆ NativeToAnyEndianness8()

uint8_t Endian::NativeToAnyEndianness8 ( uint8_t  x,
Endianness  e 
)
inline

Definition at line 229 of file Endianness.h.

230  {
231  return ((uint8_t)(x));
232  }

◆ NativeToBigEndian16()

uint16_t Endian::NativeToBigEndian16 ( uint16_t  x)
inline

Definition at line 148 of file Endianness.h.

149  {
150  return (Endianness::NATIVE == Endianness::BE)?((uint16_t)(x)):swapbytes16(x);
151  }
uint16_t swapbytes16(uint16_t x)
Definition: Endianness.h:130

References BE, NATIVE, and swapbytes16().

Referenced by BigEndianToNative16(), NativeToAnyEndianness16(), and FileIO::readBigEndian16().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NativeToBigEndian32()

uint32_t Endian::NativeToBigEndian32 ( uint32_t  x)
inline

Definition at line 152 of file Endianness.h.

153  {
154  return (Endianness::NATIVE == Endianness::BE)?((uint32_t)(x)):swapbytes32(x);
155  }
uint32_t swapbytes32(uint32_t x)
Definition: Endianness.h:134

References BE, NATIVE, and swapbytes32().

Referenced by BigEndianToNative32(), ensureSelectedEndianness(), NativeToAnyEndianness32(), parseBitstreamEndianness(), and FileIO::readBigEndian32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NativeToBigEndian64()

uint64_t Endian::NativeToBigEndian64 ( uint64_t  x)
inline

Definition at line 156 of file Endianness.h.

157  {
158  return (Endianness::NATIVE == Endianness::BE)?((uint64_t)(x)):swapbytes64(x);
159  }
uint64_t swapbytes64(uint64_t x)
Definition: Endianness.h:138

References BE, NATIVE, and swapbytes64().

Referenced by BigEndianToNative64(), NativeToAnyEndianness64(), and FileIO::readBigEndian64().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NativeToBigEndian8()

uint8_t Endian::NativeToBigEndian8 ( uint8_t  x)
inline

Definition at line 144 of file Endianness.h.

145  {
146  return ((uint8_t)(x));
147  }

◆ NativeToLittleEndian16()

uint16_t Endian::NativeToLittleEndian16 ( uint16_t  x)
inline

Definition at line 165 of file Endianness.h.

166  {
167  return (Endianness::NATIVE == Endianness::LE)?((uint16_t)(x)):swapbytes16(x);
168  }

References LE, NATIVE, and swapbytes16().

Referenced by LittleEndianToNative16(), NativeToAnyEndianness16(), and FileIO::readLittleEndian16().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NativeToLittleEndian32()

uint32_t Endian::NativeToLittleEndian32 ( uint32_t  x)
inline

Definition at line 169 of file Endianness.h.

170  {
171  return (Endianness::NATIVE == Endianness::LE)?((uint32_t)(x)):swapbytes32(x);
172  }

References LE, NATIVE, and swapbytes32().

Referenced by ensureSelectedEndianness(), LittleEndianToNative32(), NativeToAnyEndianness32(), parseBitstreamEndianness(), and FileIO::readLittleEndian32().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NativeToLittleEndian64()

uint64_t Endian::NativeToLittleEndian64 ( uint64_t  x)
inline

Definition at line 173 of file Endianness.h.

174  {
175  return (Endianness::NATIVE == Endianness::LE)?((uint64_t)(x)):swapbytes64(x);
176  }

References LE, NATIVE, and swapbytes64().

Referenced by LittleEndianToNative64(), NativeToAnyEndianness64(), and FileIO::readLittleEndian64().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NativeToLittleEndian8()

uint8_t Endian::NativeToLittleEndian8 ( uint8_t  x)
inline

Definition at line 161 of file Endianness.h.

162  {
163  return ((uint8_t)(x));
164  }

◆ swapbytes16()

uint16_t Endian::swapbytes16 ( uint16_t  x)
inline

Definition at line 130 of file Endianness.h.

131  {
132  return (uint16_t)(((uint16_t)(x) & 0xFFU) << 8 | ((uint16_t)(x) & 0xFF00U) >> 8);
133  }

Referenced by NativeToBigEndian16(), and NativeToLittleEndian16().

Here is the caller graph for this function:

◆ swapbytes32()

uint32_t Endian::swapbytes32 ( uint32_t  x)
inline

Definition at line 134 of file Endianness.h.

135  {
136  return (uint32_t)(((uint32_t)(x) & 0xFF) << 24 | ((uint32_t)(x) & 0xFF00) << 8 | ((uint32_t)(x) & 0xFF0000) >> 8 | ((uint32_t)(x) & 0xFF000000) >> 24);
137  }

Referenced by NativeToBigEndian32(), and NativeToLittleEndian32().

Here is the caller graph for this function:

◆ swapbytes64()

uint64_t Endian::swapbytes64 ( uint64_t  x)
inline

Definition at line 138 of file Endianness.h.

139  {
140  return (uint64_t)((((uint64_t)(x) & 0xFF) << 56) | ((uint64_t)(x) & 0xFF00ULL) << 40 |((uint64_t)(x) & 0xFF0000ULL) << 24 |((uint64_t)(x) & 0xFF000000ULL) << 8 |((uint64_t)(x) & 0xFF00000000ULL) >> 8 |((uint64_t)(x) & 0xFF0000000000ULL) >> 24 | ((uint64_t)(x) & 0xFF000000000000ULL) >> 40 | ((uint64_t)(x) & 0xFF00000000000000ULL) >> 56);
141  }

Referenced by NativeToBigEndian64(), and NativeToLittleEndian64().

Here is the caller graph for this function:

◆ to_string()

std::string Endian::to_string ( Endianness  e)
inline

◆ toggleEndianBitSwap()

Endianness Endian::toggleEndianBitSwap ( Endianness  e,
bool  toggle = true 
)
inline

Definition at line 84 of file Endianness.h.

85  {
86  if(!toggle)
87  return e;
88  if(Endianness::BE == e)
89  return Endianness::BE_BS;
90  if(Endianness::LE == e)
91  return Endianness::LE_BS;
92  if(Endianness::BE_BS == e)
93  return Endianness::BE;
94  if(Endianness::LE_BS == e)
95  return Endianness::LE;
96  return Endianness::NATIVE; //should not be reached.
97  }

References BE, BE_BS, LE, LE_BS, and NATIVE.

Referenced by diff().

Here is the caller graph for this function:

◆ toggleEndianness()

Endianness Endian::toggleEndianness ( Endianness  e,
bool  toggle = true 
)
inline

Definition at line 70 of file Endianness.h.

71  {
72  if(!toggle)
73  return e;
74  if(Endianness::BE == e)
75  return Endianness::LE;
76  if(Endianness::LE == e)
77  return Endianness::BE;
78  if(Endianness::BE_BS == e)
79  return Endianness::LE_BS;
80  if(Endianness::LE_BS == e)
81  return Endianness::BE_BS;
82  return Endianness::NATIVE; //should not be reached.
83  }

References BE, BE_BS, LE, LE_BS, and NATIVE.

Referenced by diff().

Here is the caller graph for this function: