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

Function writeback_csrrs_set_bits

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

Source from the content-addressed store, hash-verified

140 0x4678
141 );
142 assert_eq!(next_pc, 0x8000_0004);
143}
144
145#[test]
146fn writeback_csrrs_set_bits() {
147 let mut regs = Registers::new();
148 let mut csrs = CsrFile::new();
149
150 // Initial MIE = 0x100
151 csrs.write(addr::MIE, 0x100)
152 .expect("writeback should succeed");
153
154 let mem_result = MemResult::Csr {
155 funct3: 2, // CSRRS
156 rd: 5,
157 rs1_uimm: 11, // a1 register (non-zero means do write)
158 csr: addr::MIE,
159 operand: 0x800, // Set MTIE bit
160 old_val: 0x100,
161 next_pc: 0x8000_0004,
162 };
163
164 let next_pc = writeback(mem_result, &mut regs, &mut csrs).expect("writeback should succeed");
165
166 // Old value returned
167 assert_eq!(regs.read_x(5), 0x100);
168 // Bits set: 0x100 | 0x800 = 0x900
169 assert_eq!(

Callers

nothing calls this directly

Calls 2

writebackFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected