L4Re - L4 Runtime Environment
cxx::Bitfield< T, LSB, MSB > Class Template Reference

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

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

Data Structures

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

Public Types

enum  { Bits = MSB + 1 - LSB, Lsb = LSB, Msb = MSB }
 
enum  Masks : T { Low_mask = ((T)~0ULL) >> (sizeof(T)*8 - Bits), Mask = Low_mask << Lsb }
 
typedef Best_type< Bits >::Type Bits_type
 Type to hold at least Bits bits. More...
 
typedef Best_type< Bits+Lsb >::Type Shift_type
 Type to hold at least Bits + Lsb bits. More...
 
typedef Value< T & > Ref
 Reference type to access the bits inside a raw bit field. More...
 
typedef Value< T const > Val
 Value type to access the bits inside a raw bit field. More...
 
typedef Value_unshifted< T & > Ref_unshifted
 Reference type to access the bits inside a raw bit field (in place). More...
 
typedef Value_unshifted< T const > Val_unshifted
 Value type to access the bits inside a raw bit field (in place). More...
 

Static Public Member Functions

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

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
Tthe underlying type of the bit field.
LSBthe least significant bit of our bits.
MSBthe mos significant bit if our bits.

Definition at line 34 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 78 of file bitfield.

◆ Ref

template<typename T , unsigned LSB, unsigned MSB>
typedef Value<T&> cxx::Bitfield< T, LSB, MSB >::Ref

Reference type to access the bits inside a raw bit field.

Definition at line 218 of file bitfield.

◆ Ref_unshifted

template<typename T , unsigned LSB, unsigned MSB>
typedef Value_unshifted<T&> cxx::Bitfield< T, LSB, MSB >::Ref_unshifted

Reference type to access the bits inside a raw bit field (in place).

Definition at line 223 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 86 of file bitfield.

◆ Val

template<typename T , unsigned LSB, unsigned MSB>
typedef Value<T const> cxx::Bitfield< T, LSB, MSB >::Val

Value type to access the bits inside a raw bit field.

Definition at line 220 of file bitfield.

◆ Val_unshifted

template<typename T , unsigned LSB, unsigned MSB>
typedef Value_unshifted<T const> cxx::Bitfield< T, LSB, MSB >::Val_unshifted

Value type to access the bits inside a raw bit field (in place).

Definition at line 225 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 58 of file bitfield.

◆ Masks

template<typename T , unsigned LSB, unsigned MSB>
enum cxx::Bitfield::Masks : T
Enumerator
Low_mask 

Mask value to get Bits bits.

Mask 

Mask value to the bits out of a T.

Definition at line 65 of file bitfield.

Member Function Documentation

◆ get()

template<typename T , unsigned LSB, unsigned MSB>
static Bits_type cxx::Bitfield< T, LSB, MSB >::get ( Shift_type  val)
inlinestatic

Get the bits out of val.

Parameters
valthe raw value of the whole bit field.
Returns
the bits form Lsb to Msb shifted to the right.

Definition at line 100 of file bitfield.

◆ get_unshifted()

template<typename T , unsigned LSB, unsigned MSB>
static T cxx::Bitfield< T, LSB, MSB >::get_unshifted ( Shift_type  val)
inlinestatic

Get the bits in place out of val.

Parameters
valthe 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 110 of file bitfield.

◆ set()

template<typename T , unsigned LSB, unsigned MSB>
static T cxx::Bitfield< T, LSB, MSB >::set ( dest,
Bits_type  val 
)
inlinestatic

Set the bits corresponding to val.

Parameters
destthe current value of the whole bit field.
valthe value to set into the bits.
Returns
the new value of the whole bit field.

Definition at line 146 of file bitfield.

◆ set_dirty()

template<typename T , unsigned LSB, unsigned MSB>
static T cxx::Bitfield< T, LSB, MSB >::set_dirty ( dest,
Shift_type  val 
)
inlinestatic

Set the bits corresponding to val.

Parameters
destthe current value of the whole bit field.
valthe value to set into the bits.
Returns
the new value of the whole bit field.
Precondition
val must contain not more than bits than Bits.
Note
This function does not mask val to the right number of bits.

Definition at line 120 of file bitfield.

◆ set_unshifted()

template<typename T , unsigned LSB, unsigned MSB>
static T cxx::Bitfield< T, LSB, MSB >::set_unshifted ( dest,
Shift_type  val 
)
inlinestatic

Set the bits corresponding to val.

Parameters
destthe current value of the whole bit field.
valthe value shifted Lsb bits to the left that shall be set into the bits.
Returns
the new value of the whole bit field.

Definition at line 155 of file bitfield.

◆ set_unshifted_dirty()

template<typename T , unsigned LSB, unsigned MSB>
static T cxx::Bitfield< T, LSB, MSB >::set_unshifted_dirty ( dest,
Shift_type  val 
)
inlinestatic

Set the bits corresponding to val.

Parameters
destthe current value of the whole bit field.
valthe 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 contain not more than bits than Bits shifted Lsb bits to the left.
Note
This function does not mask val to the right number of bits.

Definition at line 135 of file bitfield.

◆ val()

template<typename T , unsigned LSB, unsigned MSB>
static T cxx::Bitfield< T, LSB, MSB >::val ( Bits_type  val)
inlinestatic

Get the shifted bits for val.

Parameters
valthe value to set into the bits.
Returns
the raw bit field value containing.

Definition at line 170 of file bitfield.

◆ val_dirty()

template<typename T , unsigned LSB, unsigned MSB>
static T cxx::Bitfield< T, LSB, MSB >::val_dirty ( Shift_type  val)
inlinestatic

Get the shifted bits for val.

Parameters
valthe value to set into the bits.
Returns
the raw bit field value containing.
Precondition
val must contain not more than bits than Bits.
Note
This function does not mask val to the right number of bits.

Definition at line 164 of file bitfield.

◆ val_unshifted()

template<typename T , unsigned LSB, unsigned MSB>
static T cxx::Bitfield< T, LSB, MSB >::val_unshifted ( Shift_type  val)
inlinestatic

Get the shifted bits for val.

Parameters
valthe value shifted Lsb bits to the left that shall be set into the bits.
Returns
the raw bit field value containing.

Definition at line 177 of file bitfield.


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