Implement SRLI

This commit is contained in:
2025-12-23 18:42:50 +01:00
parent 23392a55df
commit 0c6a540a85
2 changed files with 11 additions and 0 deletions

View File

@@ -25,6 +25,11 @@ pub(crate) fn find_and_exec(instr: Instruction, core: &mut Core) -> Option<Instr
// OP_IMM // OP_IMM
0b000 => Some(rvi::addi(core, instr)), 0b000 => Some(rvi::addi(core, instr)),
0b001 => (instr.funct6() == 0).then(|| rvi::slli(core, instr)), 0b001 => (instr.funct6() == 0).then(|| rvi::slli(core, instr)),
0b101 => match instr.funct6() {
// immediate right-shift
0b000000 => Some(rvi::srli(core, instr)),
_ => None,
},
0b111 => Some(rvi::andi(core, instr)), 0b111 => Some(rvi::andi(core, instr)),
_ => None, _ => None,
}, },

View File

@@ -79,6 +79,12 @@ pub fn slli(core: &mut Core, instr: Instruction) -> InstructionResult {
InstructionResult::Normal InstructionResult::Normal
} }
pub fn srli(core: &mut Core, instr: Instruction) -> InstructionResult {
core.reg_write(instr.rd(), core.reg_read(instr.rs1()) >> instr.imm_shamt());
core.advance_pc();
InstructionResult::Normal
}
pub fn lui(core: &mut Core, instr: Instruction) -> InstructionResult { pub fn lui(core: &mut Core, instr: Instruction) -> InstructionResult {
core.reg_write(instr.rd(), instr.imm_u()); core.reg_write(instr.rd(), instr.imm_u());
core.advance_pc(); core.advance_pc();