@@ -76,28 +76,15 @@ impl Mtopi {
7676mod tests {
7777 use super :: * ;
7878
79- macro_rules! test_ro_csr_field {
80- // test a multi-bit bitfield for read-only CSR - matches test_csr_field! pattern
81- ( $reg: ident, $field: ident: [ $start: expr, $end: expr] ) => { {
82- let bits = $reg. bits( ) ;
83- let shift = $end - $start + 1 ;
84- let mask = ( 1usize << shift) - 1 ;
85- let exp_val = ( bits >> $start) & mask;
86-
87- // Test field extraction matches expected value (same as test_csr_field! macro)
88- assert_eq!( $reg. $field( ) , exp_val) ;
89- } } ;
90- }
91-
9279 #[ test]
9380 fn test_mtopi_fields ( ) {
9481 // Test using helper macros as requested - follows mcounteren.rs pattern
9582 let mut mtopi = Mtopi :: from_bits ( 0 ) ;
9683
9784 // Test iid field [16:27] - using test helper macro
98- test_ro_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
85+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
9986 // Test ipid field [0:7] - using test helper macro
100- test_ro_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
87+ test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
10188
10289 // Test helper methods
10390 assert ! ( !mtopi. has_interrupt( ) ) ;
@@ -106,26 +93,26 @@ mod tests {
10693
10794 // Test with some interrupt pending (IID = 11, IPID = 5)
10895 mtopi = Mtopi :: from_bits ( ( 11 << 16 ) | 5 ) ;
109- test_ro_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
110- test_ro_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
96+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
97+ test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
11198 assert ! ( mtopi. has_interrupt( ) ) ;
11299 assert_eq ! ( mtopi. priority( ) , 5 ) ;
113100 assert_eq ! ( mtopi. interrupt_id( ) , 11 ) ;
114101
115102 // Test maximum values for each field
116103 mtopi = Mtopi :: from_bits ( ( 0xFFF << 16 ) | 0xFF ) ;
117- test_ro_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
118- test_ro_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
104+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
105+ test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
119106 assert ! ( mtopi. has_interrupt( ) ) ;
120107
121108 // Test field boundaries
122109 mtopi = Mtopi :: from_bits ( 1 << 16 ) ;
123- test_ro_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
124- test_ro_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
110+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
111+ test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
125112
126113 mtopi = Mtopi :: from_bits ( 1 ) ;
127- test_ro_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
128- test_ro_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
114+ test_csr_field ! ( mtopi, iid: [ 16 , 27 ] ) ;
115+ test_csr_field ! ( mtopi, ipid: [ 0 , 7 ] ) ;
129116 }
130117
131118 #[ test]
0 commit comments