Skip to content

Commit

Permalink
extend trace generation to fix immediate value constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
morganthomas committed Feb 14, 2024
1 parent e4c4ece commit 15842da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions cpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,12 @@ impl CpuChip {
});
}

fn set_imm_value<F: Field>(&self, cols: &mut CpuCols<F>, imm: Option<Word<u8>>) {
fn set_imm_value<F: PrimeField>(&self, cols: &mut CpuCols<F>, imm: Option<Word<u8>>) {
if let Some(imm) = imm {
cols.opcode_flags.is_imm_op = F::one();
cols.mem_channels[1].value = imm.transform(F::from_canonical_u8);
let imm = imm.transform(F::from_canonical_u8);
cols.mem_channels[1].value = imm;
cols.instruction.operands.0[2] = imm.reduce();
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions cpu/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ where

// Immediate value constraints (TODO: we'd need to range check read_value_2 in
// this case)
// builder.when(local.opcode_flags.is_imm_op).assert_eq(
// local.instruction.operands.c(),
// reduce::<AB>(&base, local.read_value_2()),
// );
builder.when(local.opcode_flags.is_imm_op).assert_eq(
local.instruction.operands.c(),
reduce::<AB>(&base, local.read_value_2()),
);

// "Stop" constraints (to check that program execution was not stopped prematurely)
builder
Expand Down

0 comments on commit 15842da

Please sign in to comment.