Skip to content

Commit

Permalink
passes four bus interaction case
Browse files Browse the repository at this point in the history
  • Loading branch information
qwang98 committed Feb 6, 2025
1 parent 50ca1b1 commit 96747e0
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions test_data/asm/static_bus_multi_2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::protocols::bus::bus_multi_send_2;

let ADD_BUS_ID = 123;
let MUL_BUS_ID = 456;
let SUB_BUS_ID = 789;
let DOUBLE_BUS_ID = 234;

machine Main with
degree: 8,
Expand All @@ -23,16 +25,29 @@ machine Main with
std::utils::force_bool(mul_sel);
mul_c = mul_a * mul_b;

// Sub block machine
col witness sub_a, sub_b, sub_c, sub_sel;
std::utils::force_bool(sub_sel);
sub_c = sub_a - sub_b;

// Double block machine
col witness double_a, double_b, double_c, double_sel;
std::utils::force_bool(double_sel);
double_c = 2 * double_a + 2 * double_b;

// Multi bus receive
bus_multi_receive_2(
[ADD_BUS_ID, MUL_BUS_ID],
[[add_a, add_b, add_c], [mul_a, mul_b, mul_c]],
[add_sel, mul_sel],
[add_sel, mul_sel]
[ADD_BUS_ID, MUL_BUS_ID, SUB_BUS_ID, DOUBLE_BUS_ID],
[[add_a, add_b, add_c], [mul_a, mul_b, mul_c], [sub_a, sub_b, sub_c], [double_a, double_b, double_c]],
[add_sel, mul_sel, sub_sel, double_sel],
[add_sel, mul_sel, sub_sel, double_sel]
);

// Main machine
col fixed is_mul = [0, 1]*;
col fixed is_add = [1, 0, 0, 0]*;
col fixed is_mul = [0, 1, 0, 0]*;
col fixed is_sub = [0, 0, 1, 0]*;
col fixed is_double = [0, 0, 0, 1]*;
col fixed x(i) {i * 42};
col fixed y(i) {i + 12345};
col witness z;
Expand All @@ -41,8 +56,8 @@ machine Main with
// a bus send for each receiver, even though at most one send will be
// active in each row.
bus_multi_send_2(
[MUL_BUS_ID, ADD_BUS_ID],
[[x, y, z], [x, y, z]],
[is_mul, 1 - is_mul]
[MUL_BUS_ID, ADD_BUS_ID, DOUBLE_BUS_ID, SUB_BUS_ID],
[[x, y, z], [x, y, z], [x, y, z], [x, y, z]],
[is_mul, is_add, is_double, is_sub]
);
}

0 comments on commit 96747e0

Please sign in to comment.