← back

fork/raki

git clone https://git.julia.blue/fork/raki

Julia Ryandon't bail on unknown opcodes3f23830

master
2 folders5 files
languages

files

.github/workflows/
src/
.gitignore454 B
CONTRIBUTING.md7.7 KiB
Cargo.toml515 B
LICENSE1.0 KiB
README.md1.2 KiB

raki

Rust
RISC-V instruction decoder written in Rust.

Usage

Call the decode as u16/u32 method.

use raki::{BaseIOpcode, Decode, Instruction, Isa, OpcodeKind};

fn main() {
    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

Support

License

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

Contribution

All contributions are welcome, including issues, pull requests, questions, etc... See CONTRIBUTING.md for details.