4 releases

0.1.3 Oct 17, 2023
0.1.2 Oct 14, 2023
0.1.1 Oct 13, 2023
0.1.0 Oct 12, 2023

#844 in Parser implementations


Used in l2r0-profiler-host

MIT license

83KB
2K SLoC

raki

Rust
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::Isa;
use raki::decode::Decode;
use raki::instruction::Instruction;

let inst: u32 = 0b1110_1110_1100_0010_1000_0010_1001_0011;
let inst: Instruction = match inst.decode(Isa::Rv32) {
    Ok(inst) => inst,
    Err(e) => panic!("decoding failed due to {e:?}"),
};
println!("{inst}");
// --output--
// addi t0, t0, -276

License

This crate is licensed under MIT.
See LICENSE for details.


lib.rs:

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::Isa;
use raki::decode::Decode;
use raki::instruction::Instruction;

let inst: u32 = 0b1110_1110_1100_0010_1000_0010_1001_0011;
let inst: Instruction = match inst.decode(Isa::Rv32) {
    Ok(inst) => inst,
    Err(e) => panic!("decoding failed due to {e:?}"),
};
println!("{inst}");
// --output--
// addi t0, t0, -276

No runtime deps