sp1_core_machine/syscall/instructions/
columns.rs

1use sp1_derive::AlignedBorrow;
2use sp1_stark::{air::PV_DIGEST_NUM_WORDS, Word};
3use std::mem::size_of;
4
5use crate::{
6    memory::MemoryReadWriteCols,
7    operations::{BabyBearWordRangeChecker, IsZeroOperation},
8};
9
10pub const NUM_SYSCALL_INSTR_COLS: usize = size_of::<SyscallInstrColumns<u8>>();
11
12#[derive(AlignedBorrow, Default, Debug, Clone, Copy)]
13#[repr(C)]
14pub struct SyscallInstrColumns<T> {
15    /// The program counter of the instruction.
16    pub pc: T,
17    /// The next program counter.
18    pub next_pc: T,
19
20    /// The shard number.
21    pub shard: T,
22    /// The clock cycle number.
23    pub clk: T,
24
25    /// The number of extra cycles to add to the clk for a syscall instruction.
26    pub num_extra_cycles: T,
27
28    /// Whether the current instruction is a halt instruction.  This is verified by the
29    /// is_halt_check operation.
30    pub is_halt: T,
31
32    /// The access columns for the first operand.
33    pub op_a_access: MemoryReadWriteCols<T>,
34    /// The value of the second operand.
35    pub op_b_value: Word<T>,
36    /// The value of the third operand.
37    pub op_c_value: Word<T>,
38
39    /// Whether the current ecall is ENTER_UNCONSTRAINED.
40    pub is_enter_unconstrained: IsZeroOperation<T>,
41
42    /// Whether the current ecall is HINT_LEN.
43    pub is_hint_len: IsZeroOperation<T>,
44
45    /// Whether the current ecall is HALT.
46    pub is_halt_check: IsZeroOperation<T>,
47
48    /// Whether the current ecall is a COMMIT.
49    pub is_commit: IsZeroOperation<T>,
50
51    /// Whether the current ecall is a COMMIT_DEFERRED_PROOFS.
52    pub is_commit_deferred_proofs: IsZeroOperation<T>,
53
54    /// Field to store the word index passed into the COMMIT ecall.  index_bitmap[word index]
55    /// should be set to 1 and everything else set to 0.
56    pub index_bitmap: [T; PV_DIGEST_NUM_WORDS],
57
58    /// Columns to babybear range check the halt/commit_deferred_proofs operand.
59    pub operand_range_check_cols: BabyBearWordRangeChecker<T>,
60
61    /// The operand value to babybear range check.
62    pub operand_to_check: Word<T>,
63
64    /// The result of is_real * (is_halt || is_commit_deferred_proofs)
65    pub ecall_range_check_operand: T,
66
67    /// Whether the current instruction is a real instruction.
68    pub is_real: T,
69}