Skip to content

Commit fcbb24b

Browse files
committed
tests: add senvcfg unit tests
Adds basic unit tests for the `senvcfg` CSR.
1 parent dbef76c commit fcbb24b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

riscv/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- CSR helper macro `write_composite_csr` for writing 64-bit CSRs on 32-bit targets.
1313
- Write utilities for `mcycle`, `minstret`
14+
- Add `senvcfg` CSR
1415

1516
## [v0.13.0] - 2025-02-18
1617

riscv/src/register/senvcfg.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,35 @@ read_write_csr_field! {
8686
pmm,
8787
Pmm: [32:33],
8888
}
89+
90+
#[cfg(test)]
91+
mod tests {
92+
use super::*;
93+
94+
#[test]
95+
fn test_senvcfg() {
96+
let mut senvcfg = Senvcfg::from_bits(0);
97+
98+
test_csr_field!(senvcfg, fiom);
99+
test_csr_field!(senvcfg, lpe);
100+
101+
#[cfg(not(target_arch = "riscv32"))]
102+
test_csr_field!(senvcfg, sse);
103+
104+
[Cbie::IllegalInstruction, Cbie::Flush, Cbie::Invalidate]
105+
.into_iter()
106+
.for_each(|cbie| {
107+
test_csr_field!(senvcfg, cbie: cbie);
108+
});
109+
110+
test_csr_field!(senvcfg, cbcfe);
111+
test_csr_field!(senvcfg, cbze);
112+
113+
#[cfg(not(target_arch = "riscv32"))]
114+
[Pmm::Disabled, Pmm::Mask7bit, Pmm::Mask16bit]
115+
.into_iter()
116+
.for_each(|pmm| {
117+
test_csr_field!(senvcfg, pmm: pmm);
118+
});
119+
}
120+
}

0 commit comments

Comments
 (0)