Skip to main content

sp1_core_machine/bytes/
columns.rs

1use sp1_derive::AlignedBorrow;
2use std::mem::size_of;
3use struct_reflection::{StructReflection, StructReflectionHelper};
4
5use super::NUM_BYTE_OPS;
6
7/// The number of main trace columns for `ByteChip`.
8pub const NUM_BYTE_PREPROCESSED_COLS: usize = size_of::<BytePreprocessedCols<u8>>();
9
10/// The number of multiplicity columns for `ByteChip`.
11pub const NUM_BYTE_MULT_COLS: usize = size_of::<ByteMultCols<u8>>();
12
13#[derive(Debug, Clone, Copy, AlignedBorrow, StructReflection)]
14#[repr(C)]
15pub struct BytePreprocessedCols<T> {
16    /// The first byte operand.
17    pub b: T,
18
19    /// The second byte operand.
20    pub c: T,
21
22    /// The result of the `AND` operation on `b` and `c`
23    pub and: T,
24
25    /// The result of the `OR` operation on `b` and `c`
26    pub or: T,
27
28    /// The result of the `XOR` operation on `b` and `c`
29    pub xor: T,
30
31    /// The result of the `LTU` operation on `b` and `c`.
32    pub ltu: T,
33
34    /// The most significant bit of `b`.
35    pub msb: T,
36}
37
38/// For each byte operation in the preprocessed table, a corresponding ByteMultCols row tracks the
39/// number of times the operation is used.
40#[derive(Debug, Clone, Copy, AlignedBorrow)]
41#[repr(C)]
42pub struct ByteMultCols<T> {
43    /// The multiplicities of each byte operation.
44    pub multiplicities: [T; NUM_BYTE_OPS],
45}