feat: rvr extention for rv64 riscv#2876
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
This comment has been minimized.
This comment has been minimized.
shuklaayush
left a comment
There was a problem hiding this comment.
some comments - primarily pc should become u64 even if at the moment we don't support pc above 30 bits
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Note: cells_used metrics omitted because CUDA tracegen does not expose unpadded trace heights. Commit: 125023d |
gdmlcjs
left a comment
There was a problem hiding this comment.
Same comment changes ("RV32" -> "RV64") in
- crates/vm/src/arch/rvr/debug.rs:58
- crates/vm/src/arch/rvr/execute.rs:97
| } | ||
| } | ||
|
|
||
| /// HINT_RANDOM phantom: fill the hint stream with `reg[num_words_reg] * 4` |
shuklaayush
left a comment
There was a problem hiding this comment.
some comments but we can address in a follow up
| assert!( | ||
| t < (1u64 << PC_BITS), | ||
| "JumpDyn target {t:#x} exceeds PC address space" | ||
| ); | ||
| let pc32 = t as u32; |
There was a problem hiding this comment.
let's try to avoid converting pc to u32 altogether if possible. also better to emit errors instead of panicing
| @@ -79,10 +79,10 @@ pub fn init_rvr_state<F: PrimeField32>( | |||
| vm_state: &mut VmState<F, GuestMemory>, | |||
| pc: u32, | |||
There was a problem hiding this comment.
we should change it to u64
| vm_state.set_pc( | ||
| u32::try_from(state.pc).expect("PC must be within u32 range after C bounds check"), | ||
| ); |
There was a problem hiding this comment.
not the most ideal, we should change pc to u64 but check that it's within PC_BITS
RVR extension for RV64 RISCV. The current implementation was tested on `openvm-riscv-integration-tests` tests. The RVR extension required following changes on top of `rvr-rv32`: 1) Adding new `W` ALU and Mult/Div instructions, new `lwu` instruction. 2) Updating lifter to lift new instructions. 3) Updating instruction simulation done in block generation phase to 64bit. 4) Updating `C` code emission to emit 64bit instructions (`MULH` instruction uses `__int128` to avoid overflow of `64bit` multiplication to get upper 64bit of the result). Adding 64bit and 32bit sign extended reads in rvr. 5) Updating `RvState` registers to 64bit. 6) Updating `bridge.rs` - the buffer access between `VmState` and `rvr:ffi`, to 64bit. towards INT-8107
RVR extension for RV64 RISCV. The current implementation was tested on `openvm-riscv-integration-tests` tests. The RVR extension required following changes on top of `rvr-rv32`: 1) Adding new `W` ALU and Mult/Div instructions, new `lwu` instruction. 2) Updating lifter to lift new instructions. 3) Updating instruction simulation done in block generation phase to 64bit. 4) Updating `C` code emission to emit 64bit instructions (`MULH` instruction uses `__int128` to avoid overflow of `64bit` multiplication to get upper 64bit of the result). Adding 64bit and 32bit sign extended reads in rvr. 5) Updating `RvState` registers to 64bit. 6) Updating `bridge.rs` - the buffer access between `VmState` and `rvr:ffi`, to 64bit. towards INT-8107
RVR extension for RV64 RISCV. The current implementation was tested on
openvm-riscv-integration-teststests.The RVR extension required following changes on top of
rvr-rv32:WALU and Mult/Div instructions, newlwuinstruction.Ccode emission to emit 64bit instructions (MULHinstruction uses__int128to avoid overflow of64bitmultiplication to get upper 64bit of the result). Adding 64bit and 32bit sign extended reads in rvr.RvStateregisters to 64bit.bridge.rs- the buffer access betweenVmStateandrvr:ffi, to 64bit.towards INT-8107