//! This module defines the RISC-V instruction set instructions

pub mod rv32;
pub mod rv64;
#[cfg(test)]
mod test_utils;
pub mod v;
pub mod zicond;
pub mod zicsr;

use crate::registers::general_purpose::Register;
use core::fmt;
use core::marker::Destruct;

/// Generic instruction
pub const trait Instruction:
    fmt::Display + fmt::Debug + [const] Destruct + Copy + Send + Sync + Sized
{
    /// A register type used by the instruction
    type Reg: Register;

    /// Try to decode a single valid instruction
    fn try_decode(instruction: u32) -> Option<Self>;

    /// Instruction alignment in bytes
    fn alignment() -> u8;

    /// Instruction size in bytes
    fn size(&self) -> u8;
}
