Skip to main content

ab_riscv_primitives/instructions/rv32/zk/
zkn.rs

1//! RV32 Zkn extension
2
3pub mod zknd;
4pub mod zkne;
5pub mod zknh;
6
7use crate::hart::HartConfig;
8use crate::instructions::rv32::b::zbb::Rv32ZbbZbkbSharedInstruction;
9use crate::instructions::rv32::zk::zbkb::Rv32ZbkbInstruction;
10use crate::instructions::rv32::zk::zbkc::Rv32ZbkcInstruction;
11use crate::instructions::rv32::zk::zbkx::Rv32ZbkxInstruction;
12use crate::instructions::rv32::zk::zkn::zknd::{Rv32AesBs, Rv32ZkndInstruction};
13use crate::instructions::rv32::zk::zkn::zkne::Rv32ZkneInstruction;
14use crate::instructions::rv32::zk::zkn::zknh::Rv32ZknhInstruction;
15use crate::instructions::utils::Shamt;
16use crate::instructions::{ImplementedExtension, Instruction, IsaExtension};
17use crate::registers::general_purpose::Register;
18use ab_riscv_macros::instruction;
19use core::fmt;
20
21/// RISC-V RV32 Zkn (Zbkb + Zbkc + Zbkx + Zknd + Zkne + Zknh) instruction
22#[instruction(
23    inherit = [
24        Rv32ZbkbInstruction,
25        Rv32ZbkcInstruction,
26        Rv32ZbkxInstruction,
27        Rv32ZkndInstruction,
28        Rv32ZkneInstruction,
29        Rv32ZknhInstruction,
30    ]
31)]
32#[derive(Debug, Clone, Copy)]
33#[derive_const(PartialEq, Eq)]
34pub enum Rv32ZknInstruction<Hart>
35where
36    Hart: HartConfig, {}
37
38#[instruction]
39const impl<Reg, Hart> Instruction for Rv32ZknInstruction<Hart>
40where
41    Reg: [const] Register<Type = u32>,
42    Hart: [const] HartConfig<Reg = Reg>,
43{
44    const OWN_ISA_EXTENSIONS: &'static [IsaExtension] = &[IsaExtension::new("zkn", 1, 0)];
45
46    const ALIGNMENT: u8 = align_of::<u32>() as u8;
47
48    type Hart = Hart;
49
50    #[inline(always)]
51    #[cfg_attr(feature = "no-panic", no_panic_const::no_panic(const))]
52    fn try_decode(instruction: u32) -> Option<Self> {
53        None
54    }
55
56    #[inline(always)]
57    fn size(&self) -> u8 {
58        size_of::<u32>() as u8
59    }
60}
61
62#[instruction]
63impl<Reg, Hart> fmt::Display for Rv32ZknInstruction<Hart>
64where
65    Reg: fmt::Display + Copy,
66    Hart: HartConfig<Reg = Reg>,
67{
68    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
69        match self {}
70    }
71}