Tidying RISC-V register structs

- Removed unnecessary bit fields
- Added default values to members
- Removed all user-defined constructors to make the structs aggregate, replacing the from-value constructor with a `fromValue()` status member function.
- Made use of designated initialisation
- Changed unscoped enums to scoped
- Other small bits of tidying
This commit is contained in:
Nav
2024-10-16 21:22:16 +01:00
parent 17b90e3c08
commit 348ec19c1b
16 changed files with 338 additions and 378 deletions

View File

@@ -17,29 +17,19 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
SIZE_128 = 0x04,
};
bool write:1;
bool postIncrement:1;
MemorySize size:3;
bool virtualAddress:1;
bool write = false;
bool postIncrement = false;
MemorySize size = MemorySize::SIZE_8;
bool virtualAddress = false;
constexpr MemoryAccessControlField(
bool write,
bool postIncrement,
MemorySize size,
bool virtualAddress
)
: write(write)
, postIncrement(postIncrement)
, size(size)
, virtualAddress(virtualAddress)
{}
constexpr explicit MemoryAccessControlField(std::uint32_t controlValue)
: write(static_cast<bool>(controlValue & (0x01 << 16)))
, postIncrement(static_cast<bool>(controlValue & (0x01 << 19)))
, size(static_cast<MemorySize>((controlValue >> 20) & 0x07))
, virtualAddress(static_cast<bool>(controlValue & (0x01 << 23)))
{}
static constexpr auto fromValue(std::uint32_t value) {
return MemoryAccessControlField{
.write = static_cast<bool>(value & (0x01 << 16)),
.postIncrement = static_cast<bool>(value & (0x01 << 19)),
.size = static_cast<MemorySize>((value >> 20) & 0x07),
.virtualAddress = static_cast<bool>(value & (0x01 << 23)),
};
}
[[nodiscard]] constexpr std::uint32_t value() const {
return std::uint32_t{0}