Skip to content

Commit

Permalink
riscv: add mip unit tests
Browse files Browse the repository at this point in the history
Adds basic unit tests for the `mip` register.
  • Loading branch information
rmsyn committed Nov 26, 2024
1 parent ffe20a5 commit 803a68c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions riscv/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Use CSR helper macros to define `mie` register
- Use CSR helper macros to define `mimpid` register
- Use CSR helper macros to define `misa` register
- Use CSR helper macros to define `mip` register

## [v0.12.1] - 2024-10-20

Expand Down
22 changes: 22 additions & 0 deletions riscv/src/register/mip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,25 @@ set_clear_csr!(
set_clear_csr!(
/// Supervisor External Interrupt Pending
, set_sext, clear_sext, 1 << 9);

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_mip() {
let mut m = Mip::from_bits(0);

test_csr_field!(m, ssoft);
test_csr_field!(m, stimer);
test_csr_field!(m, sext);

assert!(!m.msoft());
assert!(!m.mtimer());
assert!(!m.mext());

assert!(Mip::from_bits(1 << 3).msoft());
assert!(Mip::from_bits(1 << 7).mtimer());
assert!(Mip::from_bits(1 << 11).mext());
}
}

0 comments on commit 803a68c

Please sign in to comment.