ab_riscv_interpreter/rv64/zk/zkn/
zkne.rs1pub mod rv64_zkne_helpers;
4#[cfg(not(all(miri, target_arch = "aarch64")))]
7#[cfg(test)]
8mod tests;
9
10use crate::rv64::zk::zkn::zknd::rv64_zknd_helpers;
11use crate::{ExecutableInstruction, ExecutionError, RegisterFile};
12use ab_riscv_macros::instruction_execution;
13use ab_riscv_primitives::prelude::*;
14use core::ops::ControlFlow;
15
16#[instruction_execution]
17impl<Reg, Regs, ExtState, Memory, PC, InstructionHandler, CustomError>
18 ExecutableInstruction<Regs, ExtState, Memory, PC, InstructionHandler, CustomError>
19 for Rv64ZkneInstruction<Reg>
20where
21 Reg: Register<Type = u64>,
22 Regs: RegisterFile<Reg>,
23{
24 #[inline(always)]
25 fn execute(
26 self,
27 regs: &mut Regs,
28 _ext_state: &mut ExtState,
29 _memory: &mut Memory,
30 _program_counter: &mut PC,
31 _system_instruction_handler: &mut InstructionHandler,
32 ) -> Result<ControlFlow<()>, ExecutionError<Reg::Type, CustomError>> {
33 match self {
34 Self::Aes64Es { rd, rs1, rs2 } => {
35 let v1 = regs.read(rs1);
36 let v2 = regs.read(rs2);
37 regs.write(rd, rv64_zkne_helpers::aes64es(v1, v2));
38 }
39 Self::Aes64Esm { rd, rs1, rs2 } => {
40 let v1 = regs.read(rs1);
41 let v2 = regs.read(rs2);
42 regs.write(rd, rv64_zkne_helpers::aes64esm(v1, v2));
43 }
44 }
45
46 Ok(ControlFlow::Continue(()))
47 }
48}