Skip to content

Commit

Permalink
chore: Introduce selectors to enable range checks of 8-bit and 16-bit…
Browse files Browse the repository at this point in the history
… sizes (#5465)
  • Loading branch information
jeanmon authored Mar 26, 2024
1 parent 19ad2bb commit ef44674
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 239 deletions.
5 changes: 5 additions & 0 deletions barretenberg/cpp/pil/avm/avm_main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace avm_main(256);
pol constant first = [1] + [0]*; // Used mostly to toggle off the first row consisting
// only in first element of shifted polynomials.

//===== Fix Range Checks Selectors=============================================
// We re-use the clk column for the lookup values of 8-bit resp. 16-bit range check.
pol commit sel_rng_8; // Boolean selector for the 8-bit range check lookup
pol commit sel_rng_16; // Boolean selector for the 16-bit range check lookup

//===== CONTROL FLOW ==========================================================
// Program counter
pol commit pc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,77 +7,77 @@
namespace bb::Avm_vm {

template <typename FF> struct Avm_aluRow {
FF avm_alu_alu_in_tag{};
FF avm_alu_alu_ff_tag{};
FF avm_alu_alu_u16_r1_shift{};
FF avm_alu_alu_u16_r3_shift{};
FF avm_alu_alu_u16_r4{};
FF avm_alu_alu_u8_r1{};
FF avm_alu_alu_u16_r7{};
FF avm_alu_alu_u16_r2_shift{};
FF avm_alu_alu_op_eq{};
FF avm_alu_alu_u8_tag{};
FF avm_alu_alu_u16_r5_shift{};
FF avm_alu_alu_u16_tag{};
FF avm_alu_alu_u16_r4_shift{};
FF avm_alu_alu_u16_r6_shift{};
FF avm_alu_alu_u64_r0{};
FF avm_alu_alu_u16_r0_shift{};
FF avm_alu_alu_u16_r3_shift{};
FF avm_alu_alu_u16_r0{};
FF avm_alu_alu_cf{};
FF avm_alu_alu_op_mul{};
FF avm_alu_alu_op_add{};
FF avm_alu_alu_ic{};
FF avm_alu_alu_u32_tag{};
FF avm_alu_alu_op_sub{};
FF avm_alu_alu_u16_r6{};
FF avm_alu_alu_u64_tag{};
FF avm_alu_alu_u16_r1{};
FF avm_alu_alu_u16_r1_shift{};
FF avm_alu_alu_u16_r4_shift{};
FF avm_alu_alu_u64_r0{};
FF avm_alu_alu_u16_r7{};
FF avm_alu_alu_u8_r0{};
FF avm_alu_alu_ib{};
FF avm_alu_alu_u16_r1{};
FF avm_alu_alu_u16_r3{};
FF avm_alu_alu_u16_r0{};
FF avm_alu_alu_cf{};
FF avm_alu_alu_u16_r7_shift{};
FF avm_alu_alu_ia{};
FF avm_alu_alu_op_sub{};
FF avm_alu_alu_u8_r0{};
FF avm_alu_alu_op_not{};
FF avm_alu_alu_ff_tag{};
FF avm_alu_alu_u16_r5{};
FF avm_alu_alu_u16_r2{};
FF avm_alu_alu_u16_r4{};
FF avm_alu_alu_u8_r1{};
FF avm_alu_alu_u16_r6_shift{};
FF avm_alu_alu_op_eq{};
FF avm_alu_alu_op_add{};
FF avm_alu_alu_op_eq_diff_inv{};
FF avm_alu_alu_u16_r5_shift{};
FF avm_alu_alu_u16_tag{};
FF avm_alu_alu_u128_tag{};
FF avm_alu_alu_u16_r6{};
FF avm_alu_alu_u16_r3{};
FF avm_alu_alu_u16_r5{};
FF avm_alu_alu_ic{};
FF avm_alu_alu_sel{};
FF avm_alu_alu_op_not{};
FF avm_alu_alu_op_mul{};
FF avm_alu_alu_in_tag{};
FF avm_alu_alu_ia{};
};

inline std::string get_relation_label_avm_alu(int index)
{
switch (index) {
case 13:
return "ALU_MUL_COMMON_2";

case 20:
return "ALU_OP_EQ";

case 11:
return "ALU_MULTIPLICATION_FF";
case 9:
return "ALU_ADD_SUB_1";

case 19:
return "ALU_RES_IS_BOOL";

case 9:
return "ALU_ADD_SUB_1";

case 16:
return "ALU_MULTIPLICATION_OUT_U128";

case 12:
return "ALU_MUL_COMMON_1";

case 10:
return "ALU_ADD_SUB_2";

case 17:
return "ALU_FF_NOT_XOR";
case 12:
return "ALU_MUL_COMMON_1";

case 18:
return "ALU_OP_NOT";

case 11:
return "ALU_MULTIPLICATION_FF";

case 13:
return "ALU_MUL_COMMON_2";

case 20:
return "ALU_OP_EQ";

case 17:
return "ALU_FF_NOT_XOR";
}
return std::to_string(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@
namespace bb::Avm_vm {

template <typename FF> struct Avm_binaryRow {
FF avm_binary_mem_tag_ctr_inv{};
FF avm_binary_bin_ic_bytes{};
FF avm_binary_acc_ia{};
FF avm_binary_acc_ib{};
FF avm_binary_acc_ic{};
FF avm_binary_mem_tag_ctr_shift{};
FF avm_binary_acc_ia_shift{};
FF avm_binary_acc_ic_shift{};
FF avm_binary_op_id_shift{};
FF avm_binary_acc_ib_shift{};
FF avm_binary_bin_sel{};
FF avm_binary_mem_tag_ctr_shift{};
FF avm_binary_mem_tag_ctr_inv{};
FF avm_binary_mem_tag_ctr{};
FF avm_binary_acc_ib{};
FF avm_binary_bin_ib_bytes{};
FF avm_binary_acc_ia{};
FF avm_binary_bin_ic_bytes{};
FF avm_binary_op_id{};
FF avm_binary_bin_ia_bytes{};
FF avm_binary_acc_ib_shift{};
FF avm_binary_mem_tag_ctr{};
FF avm_binary_acc_ic_shift{};
FF avm_binary_acc_ia_shift{};
FF avm_binary_acc_ic{};
};

inline std::string get_relation_label_avm_binary(int index)
{
switch (index) {
case 8:
return "ACC_REL_B";

case 9:
return "ACC_REL_C";

case 2:
return "MEM_TAG_REL";

case 7:
return "ACC_REL_A";

case 1:
return "OP_ID_REL";

case 2:
return "MEM_TAG_REL";

case 8:
return "ACC_REL_B";

case 3:
return "BIN_SEL_CTR_REL";
}
Expand Down
106 changes: 53 additions & 53 deletions barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,90 +7,90 @@
namespace bb::Avm_vm {

template <typename FF> struct Avm_mainRow {
FF avm_main_w_in_tag{};
FF avm_main_sel_op_add{};
FF avm_main_bin_sel{};
FF avm_main_ind_op_a{};
FF avm_main_sel_internal_call{};
FF avm_main_mem_op_c{};
FF avm_main_internal_return_ptr_shift{};
FF avm_main_mem_idx_a{};
FF avm_main_r_in_tag{};
FF avm_main_mem_op_a{};
FF avm_main_sel_op_add{};
FF avm_main_rwc{};
FF avm_main_ind_op_c{};
FF avm_main_sel_op_and{};
FF avm_main_sel_op_mul{};
FF avm_main_mem_op_b{};
FF avm_main_mem_idx_b{};
FF avm_main_alu_sel{};
FF avm_main_sel_op_or{};
FF avm_main_mem_op_c{};
FF avm_main_sel_halt{};
FF avm_main_inv{};
FF avm_main_pc{};
FF avm_main_sel_op_not{};
FF avm_main_rwa{};
FF avm_main_ia{};
FF avm_main_first{};
FF avm_main_ib{};
FF avm_main_sel_internal_return{};
FF avm_main_ind_op_b{};
FF avm_main_inv{};
FF avm_main_sel_op_div{};
FF avm_main_sel_op_not{};
FF avm_main_mem_op_b{};
FF avm_main_ind_op_a{};
FF avm_main_rwb{};
FF avm_main_pc_shift{};
FF avm_main_op_err{};
FF avm_main_sel_op_mul{};
FF avm_main_sel_op_xor{};
FF avm_main_sel_op_sub{};
FF avm_main_internal_return_ptr{};
FF avm_main_sel_op_eq{};
FF avm_main_ind_op_c{};
FF avm_main_ia{};
FF avm_main_rwa{};
FF avm_main_bin_op_id{};
FF avm_main_sel_jump{};
FF avm_main_sel_internal_call{};
FF avm_main_op_err{};
FF avm_main_rwb{};
FF avm_main_sel_internal_return{};
FF avm_main_tag_err{};
FF avm_main_mem_idx_b{};
FF avm_main_sel_op_eq{};
FF avm_main_pc{};
FF avm_main_w_in_tag{};
FF avm_main_sel_halt{};
FF avm_main_sel_mov{};
FF avm_main_ic{};
FF avm_main_rwc{};
FF avm_main_pc_shift{};
FF avm_main_ind_op_b{};
FF avm_main_ib{};
FF avm_main_sel_op_sub{};
FF avm_main_mem_idx_a{};
FF avm_main_mem_op_a{};
FF avm_main_alu_sel{};
FF avm_main_internal_return_ptr_shift{};
FF avm_main_sel_op_xor{};
FF avm_main_tag_err{};
FF avm_main_bin_sel{};
};

inline std::string get_relation_label_avm_main(int index)
{
switch (index) {
case 28:
return "SUBOP_DIVISION_ZERO_ERR2";

case 43:
return "INTERNAL_RETURN_POINTER_CONSISTENCY";

case 45:
return "MOV_MAIN_SAME_TAG";

case 44:
return "MOV_SAME_VALUE";

case 27:
return "SUBOP_DIVISION_ZERO_ERR1";

case 31:
return "RETURN_POINTER_INCREMENT";

case 42:
return "PC_INCREMENT";
case 29:
return "SUBOP_ERROR_RELEVANT_OP";

case 37:
return "RETURN_POINTER_DECREMENT";
case 43:
return "INTERNAL_RETURN_POINTER_CONSISTENCY";

case 25:
return "EQ_OUTPUT_U8";

case 47:
return "BIN_SEL_1";
case 37:
return "RETURN_POINTER_DECREMENT";

case 48:
return "BIN_SEL_2";
case 44:
return "MOV_SAME_VALUE";

case 26:
return "SUBOP_DIVISION_FF";

case 29:
return "SUBOP_ERROR_RELEVANT_OP";
case 28:
return "SUBOP_DIVISION_ZERO_ERR2";

case 45:
return "MOV_MAIN_SAME_TAG";

case 47:
return "BIN_SEL_1";

case 42:
return "PC_INCREMENT";

case 48:
return "BIN_SEL_2";
}
return std::to_string(index);
}
Expand Down
Loading

0 comments on commit ef44674

Please sign in to comment.