openvm_rv32im_guest/
lib.rs

1#![no_std]
2
3/// Library functions for user input/output.
4#[cfg(target_os = "zkvm")]
5mod io;
6#[cfg(target_os = "zkvm")]
7pub use io::*;
8use strum_macros::FromRepr;
9
10/// This is custom-0 defined in RISC-V spec document
11pub const SYSTEM_OPCODE: u8 = 0x0b;
12pub const CSR_OPCODE: u8 = 0b1110011;
13pub const RV32_ALU_OPCODE: u8 = 0b0110011;
14pub const RV32M_FUNCT7: u8 = 0x01;
15
16pub const TERMINATE_FUNCT3: u8 = 0b000;
17pub const HINT_FUNCT3: u8 = 0b001;
18pub const HINT_STOREW_IMM: u32 = 0;
19pub const HINT_BUFFER_IMM: u32 = 1;
20pub const REVEAL_FUNCT3: u8 = 0b010;
21pub const PHANTOM_FUNCT3: u8 = 0b011;
22pub const CSRRW_FUNCT3: u8 = 0b001;
23
24/// imm options for system phantom instructions
25#[derive(Debug, Copy, Clone, PartialEq, Eq, FromRepr)]
26#[repr(u16)]
27pub enum PhantomImm {
28    HintInput = 0,
29    PrintStr,
30    HintRandom,
31}