Skip to content

Commit

Permalink
Fix calculating mwv bitmasks with field arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Oct 24, 2024
1 parent 89af369 commit 5572cbd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
26 changes: 17 additions & 9 deletions src/generate/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit 5572cbd

Please sign in to comment.