diff --git a/circuits/src/cpu/columns.rs b/circuits/src/cpu/columns.rs index 1631f2d9c..edb63cf62 100644 --- a/circuits/src/cpu/columns.rs +++ b/circuits/src/cpu/columns.rs @@ -359,6 +359,8 @@ impl> OpSelectors { pub fn halfword_mem_ops(self) -> T { self.sh + self.lh } pub fn fullword_mem_ops(self) -> T { self.sw + self.lw } + + pub fn is_mem_ops(self) -> T { self.sb + self.lb + self.sh + self.lh + self.sw + self.lw } } /// Columns containing the data to be matched against `Bitshift` stark. diff --git a/circuits/src/cpu/memory.rs b/circuits/src/cpu/memory.rs index 1ef346f64..76807b93d 100644 --- a/circuits/src/cpu/memory.rs +++ b/circuits/src/cpu/memory.rs @@ -39,6 +39,15 @@ pub(crate) fn signed_constraints( ); } +pub(crate) fn constraints( + lv: &CpuState

, + yield_constr: &mut ConstraintConsumer

, +) { + // memory address is equal to rs2-value + imm (wrapping) + yield_constr.constraint(lv.inst.ops.is_mem_ops() * (lv.mem_addr - lv.op2_value)); + // signed memory constraints + signed_constraints(lv, yield_constr); +} #[cfg(test)] #[allow(clippy::cast_possible_wrap)] mod tests { diff --git a/circuits/src/cpu/stark.rs b/circuits/src/cpu/stark.rs index d0b4f7831..b92c1addf 100644 --- a/circuits/src/cpu/stark.rs +++ b/circuits/src/cpu/stark.rs @@ -238,7 +238,7 @@ impl, const D: usize> Stark for CpuStark