diff --git a/CHANGELOG.md b/CHANGELOG.md index 34f493f6..5947100d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] +- Fix calculating `modifiedWriteValues` bitmasks with field arrays - Fix building without `yaml` feature - Compatibility with `riscv` 0.12 and `riscv-rt` 0.13 - Add `riscv_config` section in `settings.yaml` diff --git a/src/generate/register.rs b/src/generate/register.rs index 0747b9a4..62984d3a 100644 --- a/src/generate/register.rs +++ b/src/generate/register.rs @@ -1343,15 +1343,23 @@ pub fn fields( } // Update register modify bit masks - let bitmask = (u64::MAX >> (64 - width)) << offset; - use ModifiedWriteValues::*; - match mwv { - Modify | Set | Clear => {} - OneToSet | OneToClear | OneToToggle => { - one_to_modify_fields_bitmap |= bitmask; - } - ZeroToClear | ZeroToSet | ZeroToToggle => { - zero_to_modify_fields_bitmap |= bitmask; + let offsets = match f { + MaybeArray::Array(info, dim) => (0..dim.dim) + .map(|i| i * dim.dim_increment + info.bit_offset()) + .collect(), + MaybeArray::Single(info) => vec![info.bit_offset()], + }; + for o in offsets { + let bitmask = (u64::MAX >> (64 - width)) << o; + use ModifiedWriteValues::*; + match mwv { + Modify | Set | Clear => {} + OneToSet | OneToClear | OneToToggle => { + one_to_modify_fields_bitmap |= bitmask; + } + ZeroToClear | ZeroToSet | ZeroToToggle => { + zero_to_modify_fields_bitmap |= bitmask; + } } } }