Skip to content

Commit

Permalink
Merge pull request #2844 from o1-labs/sai/set_less_than_immediate_ris…
Browse files Browse the repository at this point in the history
…cv32im

implementation for set less than immediate
  • Loading branch information
dannywillems authored Dec 17, 2024
2 parents 52724ac + 31f2ab4 commit 04aea4e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion o1vm/src/interpreters/riscv32im/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,16 @@ pub fn interpret_itype<Env: InterpreterEnv>(env: &mut Env, instr: IInstruction)
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
IInstruction::SetLessThanImmediate => {
unimplemented!("SetLessThanImmediate")
// slti: x[rd] = (x[rs1] < sext(immediate)) ? 1 : 0
let local_rs1 = env.read_register(&rs1);
let local_imm = env.sign_extend(&imm, 12);
let local_rd = {
let pos = env.alloc_scratch();
unsafe { env.test_less_than_signed(&local_rs1, &local_imm, pos) }
};
env.write_register(&rd, local_rd);
env.set_instruction_pointer(next_instruction_pointer.clone());
env.set_next_instruction_pointer(next_instruction_pointer + Env::constant(4u32));
}
IInstruction::SetLessThanImmediateUnsigned => {
unimplemented!("SetLessThanImmediateUnsigned")
Expand Down

0 comments on commit 04aea4e

Please sign in to comment.