Skip to content

Commit

Permalink
refactor: make kernel procedure table inclusions part of virtual tabl…
Browse files Browse the repository at this point in the history
…e column builder (#1258)
  • Loading branch information
Al-Kindi-0 authored May 22, 2024
1 parent 0ac5412 commit 97669a4
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 153 deletions.
33 changes: 25 additions & 8 deletions air/src/trace/main_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ impl MainTrace {
self.columns.get_column(CHIPLETS_OFFSET + 4)[i]
}

/// Returns `true` if a row is part of the hash chiplet.
pub fn is_hash_row(&self, i: usize) -> bool {
self.chiplet_selector_0(i) == ZERO
}

/// Returns the (full) state of the hasher chiplet at row i.
pub fn chiplet_hasher_state(&self, i: usize) -> [Felt; STATE_WIDTH] {
let mut state = [ZERO; STATE_WIDTH];
Expand All @@ -306,6 +311,11 @@ impl MainTrace {
self.columns.get(HASHER_NODE_INDEX_COL_IDX, i)
}

/// Returns `true` if a row is part of the bitwise chiplet.
pub fn is_bitwise_row(&self, i: usize) -> bool {
self.chiplet_selector_0(i) == ONE && self.chiplet_selector_1(i) == ZERO
}

/// Returns the bitwise column holding the aggregated value of input `a` at row i.
pub fn chiplet_bitwise_a(&self, i: usize) -> Felt {
self.columns.get_column(BITWISE_A_COL_IDX)[i]
Expand All @@ -321,6 +331,13 @@ impl MainTrace {
self.columns.get_column(BITWISE_OUTPUT_COL_IDX)[i]
}

/// Returns `true` if a row is part of the memory chiplet.
pub fn is_memory_row(&self, i: usize) -> bool {
self.chiplet_selector_0(i) == ONE
&& self.chiplet_selector_1(i) == ONE
&& self.chiplet_selector_2(i) == ZERO
}

/// Returns the i-th row of the chiplet column containing memory context.
pub fn chiplet_memory_ctx(&self, i: usize) -> Felt {
self.columns.get_column(MEMORY_CTX_COL_IDX)[i]
Expand Down Expand Up @@ -356,6 +373,14 @@ impl MainTrace {
self.columns.get_column(MEMORY_V_COL_RANGE.start + 3)[i]
}

/// Returns `true` if a row is part of the kernel chiplet.
pub fn is_kernel_row(&self, i: usize) -> bool {
self.chiplet_selector_0(i) == ONE
&& self.chiplet_selector_1(i) == ONE
&& self.chiplet_selector_2(i) == ONE
&& self.chiplet_selector_3(i) == ZERO
}

/// Returns the i-th row of the kernel chiplet `addr` column.
pub fn chiplet_kernel_addr(&self, i: usize) -> Felt {
self.columns.get_column(CHIPLETS_OFFSET + 5)[i]
Expand Down Expand Up @@ -385,14 +410,6 @@ impl MainTrace {
self.columns.get_column(CHIPLETS_OFFSET + 9)[i]
}

/// Returns `true` if a row is part of the kernel chiplet.
pub fn is_kernel_row(&self, i: usize) -> bool {
self.chiplet_selector_0(i) == ONE
&& self.chiplet_selector_1(i) == ONE
&& self.chiplet_selector_2(i) == ONE
&& self.chiplet_selector_3(i) == ZERO
}

// MERKLE PATH HASHING SELECTORS
// --------------------------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 97669a4

Please sign in to comment.