openvm_sha256_circuit/sha256_chip/
columns.rsuse openvm_circuit::{
arch::ExecutionState,
system::memory::offline_checker::{MemoryReadAuxCols, MemoryWriteAuxCols},
};
use openvm_circuit_primitives::AlignedBorrow;
use openvm_instructions::riscv::RV32_REGISTER_NUM_LIMBS;
use openvm_sha256_air::{Sha256DigestCols, Sha256RoundCols};
use super::{SHA256_REGISTER_READS, SHA256_WRITE_SIZE};
#[repr(C)]
#[derive(Clone, Copy, Debug, AlignedBorrow)]
pub struct Sha256VmRoundCols<T> {
pub control: Sha256VmControlCols<T>,
pub inner: Sha256RoundCols<T>,
pub read_aux: MemoryReadAuxCols<T>,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, AlignedBorrow)]
pub struct Sha256VmDigestCols<T> {
pub control: Sha256VmControlCols<T>,
pub inner: Sha256DigestCols<T>,
pub from_state: ExecutionState<T>,
pub rd_ptr: T,
pub rs1_ptr: T,
pub rs2_ptr: T,
pub dst_ptr: [T; RV32_REGISTER_NUM_LIMBS],
pub src_ptr: [T; RV32_REGISTER_NUM_LIMBS],
pub len_data: [T; RV32_REGISTER_NUM_LIMBS],
pub register_reads_aux: [MemoryReadAuxCols<T>; SHA256_REGISTER_READS],
pub writes_aux: MemoryWriteAuxCols<T, SHA256_WRITE_SIZE>,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, AlignedBorrow)]
pub struct Sha256VmControlCols<T> {
pub len: T,
pub cur_timestamp: T,
pub read_ptr: T,
pub pad_flags: [T; 6],
pub padding_occurred: T,
}
pub const SHA256VM_CONTROL_WIDTH: usize = Sha256VmControlCols::<u8>::width();
pub const SHA256VM_ROUND_WIDTH: usize = Sha256VmRoundCols::<u8>::width();
pub const SHA256VM_DIGEST_WIDTH: usize = Sha256VmDigestCols::<u8>::width();
pub const SHA256VM_WIDTH: usize = if SHA256VM_ROUND_WIDTH > SHA256VM_DIGEST_WIDTH {
SHA256VM_ROUND_WIDTH
} else {
SHA256VM_DIGEST_WIDTH
};