Skip to content

Commit df041e7

Browse files
authored
chore: Fix constraints typos in RV32IM extension (#1406)
Removed unnecessary or duplicated constraints in the RV32IM extension.
1 parent 9f360e5 commit df041e7

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

extensions/rv32im/circuit/src/adapters/alu.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,7 @@ impl<AB: InteractionBuilder> VmAdapterAir<AB> for Rv32BaseAluAdapterAir {
155155
);
156156
self.bitwise_lookup_bus
157157
.send_range(rs2_limbs[0].clone(), rs2_limbs[1].clone())
158-
.eval(
159-
builder,
160-
not(local.rs2_as) * ctx.instruction.is_valid.clone(),
161-
);
158+
.eval(builder, ctx.instruction.is_valid.clone() - local.rs2_as);
162159

163160
self.memory_bridge
164161
.read(

extensions/rv32im/circuit/src/adapters/loadstore.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ impl<AB: InteractionBuilder> VmAdapterAir<AB> for Rv32LoadStoreAdapterAir {
216216
// This constraint ensures that the memory write only occurs when `is_valid == 1`.
217217
builder.assert_bool(write_count);
218218
builder.when(write_count).assert_one(is_valid.clone());
219+
220+
// Constrain that if `is_valid == 1` and `write_count == 0`, then `is_load == 1` and `rd_rs2_ptr == x0`
219221
builder
220222
.when(is_valid.clone() - write_count)
221223
.assert_one(is_load.clone());

extensions/rv32im/circuit/src/divrem/core.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ where
232232
// Note:
233233
// - q_sum is guaranteed to be non-zero if q is non-zero since we've range checked each
234234
// limb of q to be within [0, 2^LIMB_BITS) already.
235-
// - If q is zero and q_ext satisfies the constraint b = c * q + r, then q_sign must be 0.
235+
// - If q is zero and q_ext satisfies the constraint
236+
// sign_extend(b) = sign_extend(c) * sign_extend(q) + sign_extend(r), then q_sign must be 0.
236237
// Thus, we do not need additional constraints in case q is zero.
237238
let nonzero_q = q.iter().fold(AB::Expr::ZERO, |acc, q| acc + *q);
238239
builder.assert_bool(cols.q_sign);

extensions/rv32im/circuit/src/loadstore/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ where
197197
prev_data[i]
198198
}
199199
+ opcode_when(&[StoreH2])
200-
* if i + 2 < NUM_CELLS / 2 {
200+
* if i - 2 < NUM_CELLS / 2 {
201201
read_data[i - 2]
202202
} else {
203203
prev_data[i]

0 commit comments

Comments
 (0)