Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: trim unused registers from components #214

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions crates/brainfuck_prover/src/components/processor/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ impl FrameworkEval for ProcessorEval {
let mvi = eval.next_trace_mask();
let d = eval.next_trace_mask();
let next_clk = eval.next_trace_mask();
let _next_ip = eval.next_trace_mask();
let _next_ci = eval.next_trace_mask();
let _next_ni = eval.next_trace_mask();
let _next_mp = eval.next_trace_mask();
let _next_mv = eval.next_trace_mask();
let _next_mvi = eval.next_trace_mask();
let _next_d = eval.next_trace_mask();

// ┌──────────────────────────┐
// │ Boundary Constraints │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ impl FrameworkEval for InputInstructionEval {
let mv = eval.next_trace_mask();
let mvi = eval.next_trace_mask();
let d = eval.next_trace_mask();
let _next_clk = eval.next_trace_mask();
let next_ip = eval.next_trace_mask();
let _next_ci = eval.next_trace_mask();
let _next_ni = eval.next_trace_mask();
let next_mp = eval.next_trace_mask();
let _next_mv = eval.next_trace_mask();
let _next_mvi = eval.next_trace_mask();
let _next_d = eval.next_trace_mask();

// ┌─────────────────────────────┐
// │ Consistency Constraints │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ impl FrameworkEval for JumpIfNotZeroEval {
let mvi = eval.next_trace_mask();
let next_clk = eval.next_trace_mask();
let next_ip = eval.next_trace_mask();
let _next_ci = eval.next_trace_mask();
let _next_ni = eval.next_trace_mask();
let next_mp = eval.next_trace_mask();
let next_mv = eval.next_trace_mask();
let _next_mvi = eval.next_trace_mask();
let d = eval.next_trace_mask();
let is_mv_zero = eval.next_trace_mask();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ impl FrameworkEval for JumpIfZeroEval {
let mvi = eval.next_trace_mask();
let next_clk = eval.next_trace_mask();
let next_ip = eval.next_trace_mask();
let _next_ci = eval.next_trace_mask();
let _next_ni = eval.next_trace_mask();
let next_mp = eval.next_trace_mask();
let next_mv = eval.next_trace_mask();
let _next_mvi = eval.next_trace_mask();
let d = eval.next_trace_mask();
let is_mv_zero = eval.next_trace_mask();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,8 @@ impl<const N: u32> JumpTable<N> {
trace[JumpColumn::D.index()].data[index] = row.d.into();
trace[JumpColumn::NextClk.index()].data[index] = row.next_clk.into();
trace[JumpColumn::NextIp.index()].data[index] = row.next_ip.into();
trace[JumpColumn::NextCi.index()].data[index] = row.next_ci.into();
trace[JumpColumn::NextNi.index()].data[index] = row.next_ni.into();
trace[JumpColumn::NextMp.index()].data[index] = row.next_mp.into();
trace[JumpColumn::NextMv.index()].data[index] = row.next_mv.into();
trace[JumpColumn::NextMvi.index()].data[index] = row.next_mvi.into();
trace[JumpColumn::IsMvZero.index()].data[index] = row.is_mv_zero.into();
}

Expand Down Expand Up @@ -179,16 +176,10 @@ pub struct JumpRow {
next_clk: BaseField,
/// Next Instruction pointer
next_ip: BaseField,
/// Next Current instruction
next_ci: BaseField,
/// Next Next instruction
next_ni: BaseField,
/// Next Memory pointer
next_mp: BaseField,
/// Next Memory value
next_mv: BaseField,
/// Next Memory value inverse
next_mvi: BaseField,
/// Dummy: Flag whether the current row is dummy or not.
d: BaseField,
/// Flag to indicate whether `mv` equals zero or not.
Expand All @@ -212,11 +203,8 @@ impl JumpRow {
mvi: entry_1.mvi,
next_clk: entry_2.clk,
next_ip: entry_2.ip,
next_ci: entry_2.ci,
next_ni: entry_2.ni,
next_mp: entry_2.mp,
next_mv: entry_2.mv,
next_mvi: entry_2.mvi,
d: entry_1.d,
is_mv_zero: BaseField::one() - entry_1.mv * entry_1.mvi,
}
Expand Down Expand Up @@ -396,11 +384,8 @@ pub enum JumpColumn {
Mvi,
NextClk,
NextIp,
NextCi,
NextNi,
NextMp,
NextMv,
NextMvi,
D,
IsMvZero,
}
Expand All @@ -418,20 +403,17 @@ impl JumpColumn {
Self::Mvi => 6,
Self::NextClk => 7,
Self::NextIp => 8,
Self::NextCi => 9,
Self::NextNi => 10,
Self::NextMp => 11,
Self::NextMv => 12,
Self::NextMvi => 13,
Self::D => 14,
Self::IsMvZero => 15,
Self::NextMp => 9,
Self::NextMv => 10,
Self::D => 11,
Self::IsMvZero => 12,
}
}
}

impl TraceColumn for JumpColumn {
fn count() -> (usize, usize) {
(16, 1)
(13, 1)
}
}

Expand Down Expand Up @@ -566,8 +548,6 @@ mod tests {
mvi: BaseField::one(),
next_clk: BaseField::from(2),
next_ip: BaseField::from(4),
next_ci: BaseField::from(91),
next_ni: BaseField::from(6),
next_mp: BaseField::one(),
is_mv_zero: BaseField::zero(),
..Default::default()
Expand Down Expand Up @@ -822,9 +802,10 @@ mod tests {
let expected_mvi_col = vec![BaseField::zero(); 1 << LOG_N_LANES];
let expected_next_clk_col = vec![BaseField::from(2); 1 << LOG_N_LANES];
let expected_next_ip_col = vec![BaseField::from(3); 1 << LOG_N_LANES];
let expected_next_ci_col = vec![BaseField::zero(); 1 << LOG_N_LANES];
let expected_next_mp_col = vec![BaseField::from(5); 1 << LOG_N_LANES];
let expected_next_mv_col = vec![BaseField::zero(); 1 << LOG_N_LANES];
let expected_d_col = vec![BaseField::zero(); 1 << LOG_N_LANES];
let expected_is_mv_zero_col = vec![BaseField::one(); 1 << LOG_N_LANES];

assert_eq!(trace[JumpColumn::Clk.index()].to_cpu().values, expected_clk_col);
assert_eq!(trace[JumpColumn::Ip.index()].to_cpu().values, expected_ip_col);
Expand All @@ -835,9 +816,10 @@ mod tests {
assert_eq!(trace[JumpColumn::Mvi.index()].to_cpu().values, expected_mvi_col);
assert_eq!(trace[JumpColumn::NextClk.index()].to_cpu().values, expected_next_clk_col);
assert_eq!(trace[JumpColumn::NextIp.index()].to_cpu().values, expected_next_ip_col);
assert_eq!(trace[JumpColumn::NextCi.index()].to_cpu().values, expected_next_ci_col);
assert_eq!(trace[JumpColumn::NextMp.index()].to_cpu().values, expected_next_mp_col);
assert_eq!(trace[JumpColumn::NextMv.index()].to_cpu().values, expected_next_mv_col);
assert_eq!(trace[JumpColumn::D.index()].to_cpu().values, expected_d_col);
assert_eq!(trace[JumpColumn::IsMvZero.index()].to_cpu().values, expected_is_mv_zero_col);
}

#[test]
Expand Down Expand Up @@ -908,11 +890,8 @@ mod tests {
let mut mvi_col = BaseColumn::zeros(expected_size);
let mut next_clk_col = BaseColumn::zeros(expected_size);
let mut next_ip_col = BaseColumn::zeros(expected_size);
let mut next_ci_col = BaseColumn::zeros(expected_size);
let mut next_ni_col = BaseColumn::zeros(expected_size);
let mut next_mp_col = BaseColumn::zeros(expected_size);
let mut next_mv_col = BaseColumn::zeros(expected_size);
let mut next_mvi_col = BaseColumn::zeros(expected_size);
let mut d_col = BaseColumn::zeros(expected_size);
let mut is_mv_zero_col = BaseColumn::zeros(expected_size);

Expand Down Expand Up @@ -943,21 +922,12 @@ mod tests {
next_ip_col.data[0] = BaseField::from(7).into();
next_ip_col.data[1] = BaseField::from(14).into();

next_ci_col.data[0] = InstructionType::Right.to_base_field().into();
next_ci_col.data[1] = BaseField::zero().into();

next_ni_col.data[0] = InstructionType::Plus.to_base_field().into();
next_ni_col.data[1] = BaseField::zero().into();

next_mp_col.data[0] = BaseField::zero().into();
next_mp_col.data[1] = BaseField::zero().into();

next_mv_col.data[0] = BaseField::one().into();
next_mv_col.data[1] = BaseField::zero().into();

next_mvi_col.data[0] = BaseField::one().into();
next_mvi_col.data[1] = BaseField::zero().into();

d_col.data[0] = BaseField::zero().into();
d_col.data[1] = BaseField::zero().into();

Expand All @@ -978,11 +948,8 @@ mod tests {
mvi_col,
next_clk_col,
next_ip_col,
next_ci_col,
next_ni_col,
next_mp_col,
next_mv_col,
next_mvi_col,
d_col,
is_mv_zero_col,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ impl FrameworkEval for LeftInstructionEval {
let mv = eval.next_trace_mask();
let mvi = eval.next_trace_mask();
let d = eval.next_trace_mask();
let _next_clk = eval.next_trace_mask();
let next_ip = eval.next_trace_mask();
let _next_ci = eval.next_trace_mask();
let _next_ni = eval.next_trace_mask();
let next_mp = eval.next_trace_mask();
let _next_mv = eval.next_trace_mask();
let _next_mvi = eval.next_trace_mask();
let _next_d = eval.next_trace_mask();

// ┌─────────────────────────────┐
// │ Consistency Constraints │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ impl FrameworkEval for MinusInstructionEval {
let mv = eval.next_trace_mask();
let mvi = eval.next_trace_mask();
let d = eval.next_trace_mask();
let _next_clk = eval.next_trace_mask();
let next_ip = eval.next_trace_mask();
let _next_ci = eval.next_trace_mask();
let _next_ni = eval.next_trace_mask();
let next_mp = eval.next_trace_mask();
let next_mv = eval.next_trace_mask();
let _next_mvi = eval.next_trace_mask();
let _next_d = eval.next_trace_mask();

// ┌─────────────────────────────┐
// │ Consistency Constraints │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ impl FrameworkEval for OutputInstructionEval {
let mv = eval.next_trace_mask();
let mvi = eval.next_trace_mask();
let d = eval.next_trace_mask();
let _next_clk = eval.next_trace_mask();
let next_ip = eval.next_trace_mask();
let _next_ci = eval.next_trace_mask();
let _next_ni = eval.next_trace_mask();
let next_mp = eval.next_trace_mask();
let next_mv = eval.next_trace_mask();
let _next_mvi = eval.next_trace_mask();
let _next_d = eval.next_trace_mask();

// ┌─────────────────────────────┐
// │ Consistency Constraints │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ impl FrameworkEval for PlusInstructionEval {
let mv = eval.next_trace_mask();
let mvi = eval.next_trace_mask();
let d = eval.next_trace_mask();
let _next_clk = eval.next_trace_mask();
let next_ip = eval.next_trace_mask();
let _next_ci = eval.next_trace_mask();
let _next_ni = eval.next_trace_mask();
let next_mp = eval.next_trace_mask();
let next_mv = eval.next_trace_mask();
let _next_mvi = eval.next_trace_mask();
let _next_d = eval.next_trace_mask();

// ┌─────────────────────────────┐
// │ Consistency Constraints │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ impl FrameworkEval for RightInstructionEval {
let mv = eval.next_trace_mask();
let mvi = eval.next_trace_mask();
let d = eval.next_trace_mask();
let _next_clk = eval.next_trace_mask();
let next_ip = eval.next_trace_mask();
let _next_ci = eval.next_trace_mask();
let _next_ni = eval.next_trace_mask();
let next_mp = eval.next_trace_mask();
let _next_mv = eval.next_trace_mask();
let _next_mvi = eval.next_trace_mask();
let _next_d = eval.next_trace_mask();

// ┌─────────────────────────────┐
// │ Consistency Constraints │
Expand Down
Loading
Loading