Skip to main content

miden_air/trace/chiplets/
bitwise.rs

1use super::{Felt, ONE, Range, ZERO, create_range};
2
3// CONSTANTS
4// ================================================================================================
5
6/// Number of selector columns in the trace.
7pub const NUM_SELECTORS: usize = 1;
8
9/// Number of columns needed to record an execution trace of the bitwise chiplet.
10pub const TRACE_WIDTH: usize = NUM_SELECTORS + 12;
11
12/// The number of rows required to compute an operation in the Bitwise chiplet.
13pub const OP_CYCLE_LEN: usize = 8;
14
15// --- OPERATION SELECTORS ------------------------------------------------------------------------
16
17/// Specifies a bitwise AND operation.
18pub const BITWISE_AND: Felt = ZERO;
19/// Unique label computed as 1 plus the full chiplet selector with the bits reversed.
20/// `selector = [1, 0 | 0]`, `flag = rev(selector) + 1 = [0 | 0, 1] + 1 = 2`
21pub const BITWISE_AND_LABEL: Felt = Felt::new(0b001 + 1);
22
23/// Specifies a bitwise XOR operation.
24pub const BITWISE_XOR: Felt = ONE;
25/// Unique label computed as 1 plus the full chiplet selector with the bits reversed.
26/// `selector = [1, 0 | 1]`, `flag = rev(selector) + 1 = [1 | 0, 1] + 1 = 6`
27pub const BITWISE_XOR_LABEL: Felt = Felt::new(0b101 + 1);
28
29// --- INPUT DECOMPOSITION ------------------------------------------------------------------------
30
31/// The number of bits decomposed per row per input parameter `a` or `b`.
32pub const NUM_DECOMP_BITS: usize = 4;
33
34// --- COLUMN ACCESSOR INDICES WITHIN THE CHIPLET -------------------------------------------------
35
36/// The index of the column holding the aggregated value of input `a` within the bitwise chiplet
37/// execution trace.
38pub const A_COL_IDX: usize = NUM_SELECTORS;
39
40/// The index of the column holding the aggregated value of input `b` within the bitwise chiplet
41/// execution trace.
42pub const B_COL_IDX: usize = A_COL_IDX + 1;
43
44/// The index range for the bit decomposition of `a` within the bitwise chiplet's trace.
45pub const A_COL_RANGE: Range<usize> = create_range(B_COL_IDX + 1, NUM_DECOMP_BITS);
46
47/// The index range for the bit decomposition of `b` within the bitwise chiplet's trace.
48pub const B_COL_RANGE: Range<usize> = create_range(A_COL_RANGE.end, NUM_DECOMP_BITS);
49
50/// The index of the column containing the aggregated output value within the bitwise chiplet
51/// execution trace.
52pub const PREV_OUTPUT_COL_IDX: usize = B_COL_IDX + 1 + 2 * NUM_DECOMP_BITS;
53
54/// The index of the column containing the aggregated output value within the bitwise chiplet
55/// execution trace.
56pub const OUTPUT_COL_IDX: usize = PREV_OUTPUT_COL_IDX + 1;
57
58// TYPE ALIASES
59// ================================================================================================
60
61pub type Selectors = [Felt; NUM_SELECTORS];