Skip to main content

ab_riscv_primitives/
instruction.rs

1//! This module defines the RISC-V instruction set for the RV64 architecture
2
3pub mod rv64;
4#[cfg(test)]
5mod test_utils;
6
7use crate::registers::Register;
8use core::fmt;
9use core::marker::Destruct;
10
11/// Generic instruction
12pub const trait Instruction:
13    fmt::Display + fmt::Debug + [const] Destruct + Copy + Sized
14{
15    /// A register type used by the instruction
16    type Reg: Register;
17
18    /// Try to decode a single valid instruction
19    fn try_decode(instruction: u32) -> Option<Self>;
20
21    /// Instruction alignment in bytes
22    fn alignment() -> u8;
23
24    /// Instruction size in bytes
25    fn size(&self) -> u8;
26}