File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
1
//! mcounteren register
2
2
3
+ use crate :: bits:: bf_extract;
4
+
3
5
/// mcounteren register
4
6
#[ derive( Clone , Copy , Debug ) ]
5
7
pub struct Mcounteren {
@@ -10,26 +12,26 @@ impl Mcounteren {
10
12
/// Supervisor "cycle\[h\]" Enable
11
13
#[ inline]
12
14
pub fn cy ( & self ) -> bool {
13
- self . bits & ( 1 << 0 ) != 0
15
+ bf_extract ( self . bits , 0 , 1 ) != 0
14
16
}
15
17
16
18
/// Supervisor "time\[h\]" Enable
17
19
#[ inline]
18
20
pub fn tm ( & self ) -> bool {
19
- self . bits & ( 1 << 1 ) != 0
21
+ bf_extract ( self . bits , 1 , 1 ) != 0
20
22
}
21
23
22
24
/// Supervisor "instret\[h\]" Enable
23
25
#[ inline]
24
26
pub fn ir ( & self ) -> bool {
25
- self . bits & ( 1 << 2 ) != 0
27
+ bf_extract ( self . bits , 2 , 1 ) != 0
26
28
}
27
29
28
30
/// Supervisor "hpm\[x\]" Enable (bits 3-31)
29
31
#[ inline]
30
32
pub fn hpm ( & self , index : usize ) -> bool {
31
33
assert ! ( ( 3 ..32 ) . contains( & index) ) ;
32
- self . bits & ( 1 << index ) != 0
34
+ bf_extract ( self . bits , index , 1 ) != 0
33
35
}
34
36
}
35
37
You can’t perform that action at this time.
0 commit comments