template<typename mutability_policy_t, unsigned address, unsigned offset, unsigned width>
struct reg_t< mutability_policy_t, address, offset, width >
Model an MMIO register.
Allows policy-based configuration of hardware registers to give compile-time assurances. For example, your policy may not implement read() if it wants to prevent read access.
Enhances correctness by constraining register access to the specific subregisters it contains. Compile time calculation constrains the all access to within the subregister.
Performance of register access is exactly the same as traditional *reg = *reg | (1 << offset) style access due to the compiler's ability to inline static function calls which depend only on compile time values. As such, use this with compiler optimization enabled.
- Template Parameters
-
| mutability_policy_t | a duck-typed static monostate which implements the actual mechanics of register access. |
| address | the memory location of the register |
| offset | the bit position of the least significant bit within the register for the subregister |
| width | the width of the subregister in bits |