Skip to content

Commit

Permalink
fix constraints for maddu
Browse files Browse the repository at this point in the history
  • Loading branch information
weilzkm committed Aug 25, 2024
1 parent 04b63ca commit 78b775a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions prover/src/cpu/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ pub fn eval_packed_maddu<P: PackedField>(
let lo = lv.mem_channels[3].value;
let hi_result: P = lv.mem_channels[4].value;
let lo_result = lv.mem_channels[5].value;
let carry = lv.mem_channels[6].value;
let carry = lv.general.misc().auxm;
let scale = P::Scalar::from_canonical_usize(1 << 32);
let result = hi_result * scale + lo_result;
let mul = rs * rt;
Expand Down Expand Up @@ -744,7 +744,7 @@ pub fn eval_ext_circuit_maddu<F: RichField + Extendable<D>, const D: usize>(
let lo = lv.mem_channels[3].value;
let hi_result = lv.mem_channels[4].value;
let lo_result = lv.mem_channels[5].value;
let carry = lv.mem_channels[6].value;
let carry = lv.general.misc().auxm;
let scale = builder.constant_extension(F::Extension::from_canonical_usize(1 << 32));
let result = builder.mul_extension(hi_result, scale);
let result = builder.add_extension(result, lo_result);
Expand Down
4 changes: 1 addition & 3 deletions prover/src/witness/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,15 +1453,13 @@ pub(crate) fn generate_maddu<F: Field>(
let (result, overflow) = (mul as u64).overflowing_add(addend as u64);
let log_out0 = reg_write_with_log(33, 4, (result >> 32) as usize, state, &mut row)?;
let log_out1 = reg_write_with_log(32, 5, (result as u32) as usize, state, &mut row)?;
let log_out2 = reg_write_with_log(0, 6, ((overflow as u64) << 32) as usize, state, &mut row)?;

row.general.misc_mut().auxm = F::from_canonical_usize((overflow as usize) << 32);
state.traces.push_memory(log_in0);
state.traces.push_memory(log_in1);
state.traces.push_memory(log_in2);
state.traces.push_memory(log_in3);
state.traces.push_memory(log_out0);
state.traces.push_memory(log_out1);
state.traces.push_memory(log_out2);
state.traces.push_cpu(row);
Ok(())
}
Expand Down

0 comments on commit 78b775a

Please sign in to comment.