File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
1010### Added
1111
12+ - Add ` dpc ` CSR support for RISC-V
1213- Add Mtopi
1314- Added DCSR (Debug Control and Status Register) CSR support for the RISC-V
1415- Add ` miselect ` CSR
Original file line number Diff line number Diff line change @@ -131,3 +131,4 @@ mod tests;
131131
132132// TODO: Debug Mode Registers
133133pub mod dcsr;
134+ pub mod dpc;
Original file line number Diff line number Diff line change 1+ //! dpc register — Debug PC (0x7b1)
2+
3+ read_write_csr ! {
4+ /// Debug PC Register
5+ Dpc : 0x7b1 ,
6+ mask: !1usize ,
7+ }
8+
9+ #[ cfg( test) ]
10+ mod tests {
11+ use super :: * ;
12+
13+ #[ test]
14+ fn test_dpc_alignment_mask ( ) {
15+ let dpc = Dpc :: from_bits ( 0x1 ) ;
16+ assert_eq ! ( dpc. bits( ) & 1 , 0 ) ;
17+ }
18+
19+ #[ test]
20+ fn test_dpc_bits_roundtrip ( ) {
21+ ( 0 ..=usize:: BITS )
22+ . map ( |r| ( ( 1u128 << r) - 1 ) as usize )
23+ . for_each ( |pc| {
24+ // ensure lowest bit is cleared
25+ let exp_pc = pc & !1usize ;
26+ let dpc = Dpc :: from_bits ( pc) ;
27+ assert_eq ! ( dpc. bits( ) , exp_pc) ;
28+ assert_eq ! ( Dpc :: from_bits( dpc. bits( ) ) . bits( ) , dpc. bits( ) ) ;
29+ } ) ;
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments