sp1_core_machine/bytes/
columns.rs

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