Loading...
Searching...
No Matches
cxx::Bitfield< T, LSB, MSB > Class Template Reference

Definition for a member (part) of a bit field. More...

`#include <bitfield>`

Inheritance diagram for cxx::Bitfield< T, LSB, MSB >:
Collaboration diagram for cxx::Bitfield< T, LSB, MSB >:

## Data Structures

class | Value_base
| Internal helper type. More...
class | Value
| Internal helper type. More...
class | Value_unshifted
| Internal helper type. More...

## Public Types

enum | { Bits = MSB + 1 - LSB , Lsb = LSB , Msb = MSB }
enum | Masks : Base_type { Low_mask = static_cast<Base_type>(~0ULL) >> (sizeof(Base_type)*8 - Bits) , Mask = Low_mask << Lsb }
| Masks for bitswise operation on internal parts of a bitfield. More...
typedef Best_type< Bits >::Type | Bits_type
| Type to hold at least Bits bits.
typedef Best_type< Bits+Lsb >::Type | Shift_type
| Type to hold at least Bits + Lsb bits.
typedef Value< Base_type & > | Ref
| Reference type to access the bits inside a raw bit field.
typedef Value< Base_type volatile & > | Ref_volatile
| Volatile reference type to access the bits inside a raw bit field.
typedef Value< Base_type const > | Val
| Value type to access the bits inside a raw bit field.
typedef Value_unshifted< Base_type & > | Ref_unshifted
| Reference type to access the bits inside a raw bit field (in place).
typedef Value_unshifted< Base_type volatile & > | Ref_unshifted_volatile
| Volatile reference type to access the bits inside a raw bit field (in place).
typedef Value_unshifted< Base_type const > | Val_unshifted
| Value type to access the bits inside a raw bit field (in place).

## Static Public Member Functions

static constexpr Bits_type | get (Shift_type val)
| Get the bits out of val.
static constexpr Base_type | get_unshifted (Shift_type val)
| Get the bits in place out of val.
static constexpr Base_type | set_dirty (Base_type dest, Shift_type val)
| Set the bits corresponding to val.
static constexpr Base_type | set_unshifted_dirty (Base_type dest, Shift_type val)
| Set the bits corresponding to val.
static Base_type | set (Base_type dest, Bits_type val)
| Set the bits corresponding to val.
static Base_type | set_unshifted (Base_type dest, Shift_type val)
| Set the bits corresponding to val.
static constexpr Base_type | val_dirty (Shift_type val)
| Get the shifted bits for val.
static constexpr Base_type | val (Bits_type val)
| Get the shifted bits for val.
static constexpr Base_type | val_unshifted (Shift_type val)
| Get the shifted bits for val.

## Detailed Description

template<typename T, unsigned LSB, unsigned MSB>
class cxx::Bitfield< T, LSB, MSB >

Definition for a member (part) of a bit field.

Parameters

  T | The underlying type of the bit field.
  LSB | The least significant bit of our bits.
  MSB | The most significant bit of our bits.

Definition at line 24 of file bitfield.

## Member Typedef Documentation

## Bits_type

template<typename T, unsigned LSB, unsigned MSB>

typedef Best_type<Bits>::Type cxx::Bitfield< T, LSB, MSB >::Bits_type

Type to hold at least Bits bits.

This type can handle all values that can be stored in this part of the bit field.

Definition at line 74 of file bitfield.

## Shift_type

template<typename T, unsigned LSB, unsigned MSB>

typedef Best_type<Bits+Lsb>::Type cxx::Bitfield< T, LSB, MSB >::Shift_type

Type to hold at least Bits + Lsb bits.

This type can handle all values that can be stored in this part of the bit field when they are at the target location (Lsb bits shifted to the left).

Definition at line 82 of file bitfield.

## Member Enumeration Documentation

## anonymous enum

template<typename T, unsigned LSB, unsigned MSB>

anonymous enum

Enumerator
Bits | Number of bits.
Lsb | index of the LSB
Msb | index of the MSB

Definition at line 52 of file bitfield.

## Masks

template<typename T, unsigned LSB, unsigned MSB>

enum cxx::Bitfield::Masks : Base_type

Masks for bitswise operation on internal parts of a bitfield.

Enumerator
Low_mask | Mask value to get Bits bits.
Mask | Mask value to the bits out of a T.

Definition at line 60 of file bitfield.

## Member Function Documentation

## get()

template<typename T, unsigned LSB, unsigned MSB>

constexpr Bits_type cxx::Bitfield< T, LSB, MSB >::get | ( | Shift_type | val | ) |

inlinestaticconstexpr

Get the bits out of val.

Parameters

  val | The raw value of the whole bit field.

Returns
  The bits form Lsb to Msb shifted to the right.

Definition at line 99 of file bitfield.

## get_unshifted()

template<typename T, unsigned LSB, unsigned MSB>

constexpr Base_type cxx::Bitfield< T, LSB, MSB >::get_unshifted | ( | Shift_type | val | ) |

inlinestaticconstexpr

Get the bits in place out of val.

Parameters

  val | The raw value of the whole bit field.

Returns
  The bits from Lsb to Msb (unshifted).

This means other bits are masked out, however the result is not shifted to the right.

Definition at line 112 of file bitfield.

## set()

template<typename T, unsigned LSB, unsigned MSB>

Base_type cxx::Bitfield< T, LSB, MSB >::set | ( | Base_type | dest,
|  | Bits_type | val )

inlinestatic

Set the bits corresponding to val.

Parameters

  dest | The current value of the whole bit field.
  val | The value to set into the bits.

Returns
  The new value of the whole bit field.

Definition at line 161 of file bitfield.

## set_dirty()

template<typename T, unsigned LSB, unsigned MSB>

constexpr Base_type cxx::Bitfield< T, LSB, MSB >::set_dirty | ( | Base_type | dest,
|  | Shift_type | val )

inlinestaticconstexpr

Set the bits corresponding to val.

Parameters

  dest | The current value of the whole bit field.
  val | The value to set into the bits.

Returns
  The new value of the whole bit field.

Precondition
  val must not contain more than Bits bits.

Note
  This function does not mask val to the right number of bits.

Definition at line 127 of file bitfield.

Referenced by cxx::Bitfield< decltype(raw), 0, 0 >::set().

Here is the caller graph for this function:

## set_unshifted()

template<typename T, unsigned LSB, unsigned MSB>

Base_type cxx::Bitfield< T, LSB, MSB >::set_unshifted | ( | Base_type | dest,
|  | Shift_type | val )

inlinestatic

Set the bits corresponding to val.

Parameters

  dest | The current value of the whole bit field.
  val | The value shifted Lsb bits to the left that shall be set into the bit field.

Returns
  the new value of the whole bit field.

Definition at line 173 of file bitfield.

## set_unshifted_dirty()

template<typename T, unsigned LSB, unsigned MSB>

constexpr Base_type cxx::Bitfield< T, LSB, MSB >::set_unshifted_dirty | ( | Base_type | dest,
|  | Shift_type | val )

inlinestaticconstexpr

Set the bits corresponding to val.

Parameters

  dest | The current value of the whole bit field.
  val | The value shifted Lsb bits to the left that shall be set into the bits.

Returns
  The new value of the whole bit field.

Precondition
  val must not contain more than Bits bits shifted Lsb bits to the left.

Note
  This function does not mask val to the right number of bits.

Definition at line 147 of file bitfield.

Referenced by cxx::Bitfield< decltype(raw), 0, 0 >::set_unshifted().

Here is the caller graph for this function:

## val()

template<typename T, unsigned LSB, unsigned MSB>

constexpr Base_type cxx::Bitfield< T, LSB, MSB >::val | ( | Bits_type | val | ) |

inlinestaticconstexpr

Get the shifted bits for val.

Parameters

  val | The value to set into the bits.

Returns
  The raw bit field value.

Definition at line 196 of file bitfield.

## val_dirty()

template<typename T, unsigned LSB, unsigned MSB>

constexpr Base_type cxx::Bitfield< T, LSB, MSB >::val_dirty | ( | Shift_type | val | ) |

inlinestaticconstexpr

Get the shifted bits for val.

Parameters

  val | The value to set into the bits.

Returns
  The raw bit field value.

Precondition
  val must not contain more than Bits bits.

Note
  This function does not mask val to the right number of bits.

Definition at line 187 of file bitfield.

Referenced by cxx::Bitfield< decltype(raw), 0, 0 >::val().

Here is the caller graph for this function:

## val_unshifted()

template<typename T, unsigned LSB, unsigned MSB>

constexpr Base_type cxx::Bitfield< T, LSB, MSB >::val_unshifted | ( | Shift_type | val | ) |

inlinestaticconstexpr

Get the shifted bits for val.

Parameters

  val | The value shifted Lsb bits to the left that shall be set into the bits.

Returns
  The raw bit field value.

Definition at line 206 of file bitfield.

The documentation for this class was generated from the following file:

- l4/cxx/bitfield