Skip to main content

sp1_core_machine/control_flow/jal/
columns.rs

1use crate::{
2    adapter::{register::j_type::JTypeReader, state::CPUState},
3    operations::AddOperation,
4    SupervisorMode, TrustMode, UserMode,
5};
6use sp1_derive::AlignedBorrow;
7use std::mem::size_of;
8use struct_reflection::{StructReflection, StructReflectionHelper};
9
10/// The number of main trace columns for `JalChip` in Supervisor mode.
11pub const NUM_JAL_COLS_SUPERVISOR: usize = size_of::<JalColumns<u8, SupervisorMode>>();
12/// The number of main trace columns for `JalChip` in User mode.
13pub const NUM_JAL_COLS_USER: usize = size_of::<JalColumns<u8, UserMode>>();
14
15#[derive(AlignedBorrow, Default, Debug, Clone, Copy, StructReflection)]
16#[repr(C)]
17pub struct JalColumns<T, M: TrustMode> {
18    /// The current shard, timestamp, program counter of the CPU.
19    pub state: CPUState<T>,
20
21    /// The adapter to read program and register information.
22    pub adapter: JTypeReader<T>,
23
24    /// AddOperation to get `imm_b + imm_c` as the next program counter.
25    pub add_operation: AddOperation<T>,
26
27    /// AddOperation to get `op_a` as `pc + 4` if `op_a_0` is false.
28    pub op_a_operation: AddOperation<T>,
29
30    /// Whether or not the current row is a real row.
31    pub is_real: T,
32
33    /// Adapter columns for trust mode specific data.
34    pub adapter_cols: M::AdapterCols<T>,
35}