MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / writeback_csrrc_clear_bits

Function writeback_csrrc_clear_bits

crates/virtual-machine/tests/vm_writeback.rs:169–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

167 assert_eq!(regs.read_x(5), 0x100);
168 // Bits set: 0x100 | 0x800 = 0x900
169 assert_eq!(
170 csrs.read(addr::MIE).expect("writeback should succeed"),
171 0x900
172 );
173 assert_eq!(next_pc, 0x8000_0004);
174}
175
176#[test]
177fn writeback_csrrc_clear_bits() {
178 let mut regs = Registers::new();
179 let mut csrs = CsrFile::new();
180
181 // Use MIE instead of MIP: MIE has no WARL restrictions so all bits round-trip
182 csrs.write(addr::MIE, 0xF00)
183 .expect("writeback should succeed");
184
185 let mem_result = MemResult::Csr {
186 funct3: 3, // CSRRC
187 rd: 5,
188 rs1_uimm: 12, // a2 register (non-zero means do write)
189 csr: addr::MIE,
190 operand: 0x800, // Clear MEIE bit
191 old_val: 0xF00,
192 next_pc: 0x8000_0004,
193 };
194
195 let next_pc = writeback(mem_result, &mut regs, &mut csrs).expect("writeback should succeed");
196

Callers

nothing calls this directly

Calls 2

writebackFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected