Expand description
raki
raki
is a RISC-V instruction decoder written in Rust.
- Both 32/64bit support.
- Support
rv32/64imac
,Zicsr
,Zifencei
extensions. - Implement Display trait for formatting.
§Usage
Call the decode
as u16/u32 method.
use raki::{BaseIOpcode, Decode, Instruction, Isa, OpcodeKind};
fn example() {
let inst_bytes: u32 = 0b1110_1110_1100_0010_1000_0010_1001_0011;
let inst: Instruction = match inst_bytes.decode(Isa::Rv32) {
Ok(inst) => inst,
Err(e) => panic!("decoding failed due to {e:?}"),
};
assert_eq!(inst.opc, OpcodeKind::BaseI(BaseIOpcode::ADDI));
println!("{inst}");
}
// --output--
// addi t0, t0, -276
Structs§
- Instruction
- Instruction
Enums§
- AOpcode
- Insturctions in A Extension.
- BaseI
Opcode - Insturctions in Base-I.
- COpcode
- Insturctions in C Extension.
- Decoding
Error - Cause of decoding error.
- Inst
Format - Instruction format See: The RISC-V Instruction Set Manual: Volume II Version 20240411 p.23,141
- Isa
- Target isa.
- MOpcode
- Insturctions in M Extension.
- Opcode
Kind - Extension type and Instruction name.
- Priv
Opcode - Privileged Insturctions.
- Zicboz
Opcode - Insturctions in Zicboz Extension.
- Zicfiss
Opcode - Insturctions in Zicntr Extension.
- Zicntr
Opcode - Insturctions in Zicntr Extension.
- Zicsr
Opcode - Insturctions in Zicsr Extension.
- Zifencei
Opcode - Insturctions in Zifencei Extension.
Traits§
- Decode
- A trait to decode an instruction from u16/u32. This trait provides public api.