Skip to content

Commit a033e55

Browse files
author
jeanmon
committed
Add exec_opcode into pil and witness generation
1 parent 53535ff commit a033e55

File tree

7 files changed

+36
-24
lines changed

7 files changed

+36
-24
lines changed

barretenberg/cpp/pil/vm2/instr_fetching.pil

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pol commit indirect;
2828
// Operands.
2929
pol commit op1, op2, op3, op4, op5, op6, op7;
3030
// Wire to execution opcodes translation.
31-
pol commit ex_opcode;
31+
pol commit exec_opcode;
3232

3333
// Bring in the bytes from the bytecode columns.
3434
#[BYTES_FROM_BC_DEC]
@@ -81,6 +81,7 @@ pol commit sel_op_dc_17;
8181
#[WIRE_INSTRUCTION_INFO]
8282
sel {
8383
bd0,
84+
exec_opcode,
8485
sel_op_dc_0, sel_op_dc_1, sel_op_dc_2, sel_op_dc_3,
8586
sel_op_dc_4, sel_op_dc_5, sel_op_dc_6, sel_op_dc_7,
8687
sel_op_dc_8, sel_op_dc_9, sel_op_dc_10, sel_op_dc_11,
@@ -89,6 +90,7 @@ sel {
8990
} in
9091
precomputed.sel_range_wire_opcode {
9192
precomputed.clk,
93+
precomputed.exec_opcode,
9294
precomputed.sel_op_dc_0, precomputed.sel_op_dc_1, precomputed.sel_op_dc_2, precomputed.sel_op_dc_3,
9395
precomputed.sel_op_dc_4, precomputed.sel_op_dc_5, precomputed.sel_op_dc_6, precomputed.sel_op_dc_7,
9496
precomputed.sel_op_dc_8, precomputed.sel_op_dc_9, precomputed.sel_op_dc_10, precomputed.sel_op_dc_11,

barretenberg/cpp/pil/vm2/precomputed.pil

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ pol constant sel_op_dc_15;
7171
pol constant sel_op_dc_16;
7272
pol constant sel_op_dc_17;
7373

74+
pol constant exec_opcode;
75+
7476
// Toggle the rows which index (clk) is equal to a wire opcode
75-
// Is used to select the operand decomposition selectors (pre-computed values)
76-
// for any given wire opcode.
77+
// Is used to lookup into the wire instruction spec table which contains the operand decomposition
78+
// selectors as well as exec_opcode
7779
pol constant sel_range_wire_opcode;

barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

barretenberg/cpp/src/barretenberg/vm2/generated/flavor.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ class AvmFlavor {
7878
// This flavor would not be used with ZK Sumcheck
7979
static constexpr bool HasZK = false;
8080

81-
static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 35;
81+
static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 36;
8282
static constexpr size_t NUM_WITNESS_ENTITIES = 721;
8383
static constexpr size_t NUM_SHIFTED_ENTITIES = 84;
8484
static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES;
8585
// We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for
8686
// the unshifted and one for the shifted
87-
static constexpr size_t NUM_ALL_ENTITIES = 840;
87+
static constexpr size_t NUM_ALL_ENTITIES = 841;
8888

8989
// Need to be templated for recursive verifier
9090
template <typename FF_>
@@ -378,6 +378,7 @@ class AvmFlavor {
378378
this->precomputed_bitwise_op_id = verification_key->precomputed_bitwise_op_id;
379379
this->precomputed_bitwise_output = verification_key->precomputed_bitwise_output;
380380
this->precomputed_clk = verification_key->precomputed_clk;
381+
this->precomputed_exec_opcode = verification_key->precomputed_exec_opcode;
381382
this->precomputed_first_row = verification_key->precomputed_first_row;
382383
this->precomputed_integral_tag_length = verification_key->precomputed_integral_tag_length;
383384
this->precomputed_power_of_2 = verification_key->precomputed_power_of_2;

barretenberg/cpp/src/barretenberg/vm2/generated/relations/lookups_instr_fetching.hpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class lookup_instr_fetching_wire_instruction_info_settings {
232232
static constexpr size_t WRITE_TERMS = 1;
233233
static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 };
234234
static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 };
235-
static constexpr size_t LOOKUP_TUPLE_SIZE = 19;
235+
static constexpr size_t LOOKUP_TUPLE_SIZE = 20;
236236
static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4;
237237
static constexpr size_t READ_TERM_DEGREE = 0;
238238
static constexpr size_t WRITE_TERM_DEGREE = 0;
@@ -243,22 +243,22 @@ class lookup_instr_fetching_wire_instruction_info_settings {
243243
static constexpr Column COUNTS = Column::lookup_instr_fetching_wire_instruction_info_counts;
244244
static constexpr Column INVERSES = Column::lookup_instr_fetching_wire_instruction_info_inv;
245245
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> SRC_COLUMNS = {
246-
Column::instr_fetching_bd0, Column::instr_fetching_sel_op_dc_0, Column::instr_fetching_sel_op_dc_1,
247-
Column::instr_fetching_sel_op_dc_2, Column::instr_fetching_sel_op_dc_3, Column::instr_fetching_sel_op_dc_4,
248-
Column::instr_fetching_sel_op_dc_5, Column::instr_fetching_sel_op_dc_6, Column::instr_fetching_sel_op_dc_7,
249-
Column::instr_fetching_sel_op_dc_8, Column::instr_fetching_sel_op_dc_9, Column::instr_fetching_sel_op_dc_10,
250-
Column::instr_fetching_sel_op_dc_11, Column::instr_fetching_sel_op_dc_12, Column::instr_fetching_sel_op_dc_13,
251-
Column::instr_fetching_sel_op_dc_14, Column::instr_fetching_sel_op_dc_15, Column::instr_fetching_sel_op_dc_16,
252-
Column::instr_fetching_sel_op_dc_17
246+
Column::instr_fetching_bd0, Column::instr_fetching_exec_opcode, Column::instr_fetching_sel_op_dc_0,
247+
Column::instr_fetching_sel_op_dc_1, Column::instr_fetching_sel_op_dc_2, Column::instr_fetching_sel_op_dc_3,
248+
Column::instr_fetching_sel_op_dc_4, Column::instr_fetching_sel_op_dc_5, Column::instr_fetching_sel_op_dc_6,
249+
Column::instr_fetching_sel_op_dc_7, Column::instr_fetching_sel_op_dc_8, Column::instr_fetching_sel_op_dc_9,
250+
Column::instr_fetching_sel_op_dc_10, Column::instr_fetching_sel_op_dc_11, Column::instr_fetching_sel_op_dc_12,
251+
Column::instr_fetching_sel_op_dc_13, Column::instr_fetching_sel_op_dc_14, Column::instr_fetching_sel_op_dc_15,
252+
Column::instr_fetching_sel_op_dc_16, Column::instr_fetching_sel_op_dc_17
253253
};
254254
static constexpr std::array<Column, LOOKUP_TUPLE_SIZE> DST_COLUMNS = {
255-
Column::precomputed_clk, Column::precomputed_sel_op_dc_0, Column::precomputed_sel_op_dc_1,
256-
Column::precomputed_sel_op_dc_2, Column::precomputed_sel_op_dc_3, Column::precomputed_sel_op_dc_4,
257-
Column::precomputed_sel_op_dc_5, Column::precomputed_sel_op_dc_6, Column::precomputed_sel_op_dc_7,
258-
Column::precomputed_sel_op_dc_8, Column::precomputed_sel_op_dc_9, Column::precomputed_sel_op_dc_10,
259-
Column::precomputed_sel_op_dc_11, Column::precomputed_sel_op_dc_12, Column::precomputed_sel_op_dc_13,
260-
Column::precomputed_sel_op_dc_14, Column::precomputed_sel_op_dc_15, Column::precomputed_sel_op_dc_16,
261-
Column::precomputed_sel_op_dc_17
255+
Column::precomputed_clk, Column::precomputed_exec_opcode, Column::precomputed_sel_op_dc_0,
256+
Column::precomputed_sel_op_dc_1, Column::precomputed_sel_op_dc_2, Column::precomputed_sel_op_dc_3,
257+
Column::precomputed_sel_op_dc_4, Column::precomputed_sel_op_dc_5, Column::precomputed_sel_op_dc_6,
258+
Column::precomputed_sel_op_dc_7, Column::precomputed_sel_op_dc_8, Column::precomputed_sel_op_dc_9,
259+
Column::precomputed_sel_op_dc_10, Column::precomputed_sel_op_dc_11, Column::precomputed_sel_op_dc_12,
260+
Column::precomputed_sel_op_dc_13, Column::precomputed_sel_op_dc_14, Column::precomputed_sel_op_dc_15,
261+
Column::precomputed_sel_op_dc_16, Column::precomputed_sel_op_dc_17
262262
};
263263

264264
template <typename AllEntities> static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in)
@@ -292,6 +292,7 @@ class lookup_instr_fetching_wire_instruction_info_settings {
292292
in._instr_fetching_sel(),
293293
in._precomputed_sel_range_wire_opcode(),
294294
in._instr_fetching_bd0(),
295+
in._instr_fetching_exec_opcode(),
295296
in._instr_fetching_sel_op_dc_0(),
296297
in._instr_fetching_sel_op_dc_1(),
297298
in._instr_fetching_sel_op_dc_2(),
@@ -311,6 +312,7 @@ class lookup_instr_fetching_wire_instruction_info_settings {
311312
in._instr_fetching_sel_op_dc_16(),
312313
in._instr_fetching_sel_op_dc_17(),
313314
in._precomputed_clk(),
315+
in._precomputed_exec_opcode(),
314316
in._precomputed_sel_op_dc_0(),
315317
in._precomputed_sel_op_dc_1(),
316318
in._precomputed_sel_op_dc_2(),

barretenberg/cpp/src/barretenberg/vm2/tracegen/bytecode_trace.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ void BytecodeTraceBuilder::process_instruction_fetching(
247247
// TODO: add the rest.
248248
// Single bytes.
249249
{ C::instr_fetching_bd0, wire_opcode },
250+
{ C::instr_fetching_exec_opcode,
251+
static_cast<uint32_t>(WIRE_INSTRUCTION_SPEC.at(w_opcode).exec_opcode) },
250252
{ C::instr_fetching_bd1, bytecode_at(event.pc + 1) },
251253
{ C::instr_fetching_bd2, bytecode_at(event.pc + 2) },
252254
{ C::instr_fetching_bd3, bytecode_at(event.pc + 3) },

barretenberg/cpp/src/barretenberg/vm2/tracegen/precomputed_trace.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ void PrecomputedTraceBuilder::process_wire_instruction_spec(TraceContainer& trac
203203
trace.set(
204204
sel_op_dc_columns[i], static_cast<uint32_t>(wire_opcode), wire_instruction_spec.op_dc_selectors[i]);
205205
}
206+
trace.set(C::precomputed_exec_opcode,
207+
static_cast<uint32_t>(wire_opcode),
208+
static_cast<uint32_t>(wire_instruction_spec.exec_opcode));
206209
}
207210
}
208211

0 commit comments

Comments
 (0)