From 71998583ef838e5deecd86c6f67e311d96495ffc Mon Sep 17 00:00:00 2001 From: Ayaka Yorihiro Date: Fri, 7 Mar 2025 16:57:04 -0500 Subject: [PATCH] Some tests for simplify-invoke-with. found bugs --- .../passes/simplify-invoke-with/basic.expect | 1 - tests/passes/simplify-invoke-with/basic.futil | 1 - .../conflicting-invokes.expect | 33 +++++++++++ .../conflicting-invokes.futil | 30 ++++++++++ .../conflicting-with-while.expect | 55 +++++++++++++++++++ .../conflicting-with-while.futil | 54 ++++++++++++++++++ .../two_dup_invokes.expect | 41 ++++++++++++++ .../two_dup_invokes.futil | 35 ++++++++++++ 8 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 tests/passes/simplify-invoke-with/conflicting-invokes.expect create mode 100644 tests/passes/simplify-invoke-with/conflicting-invokes.futil create mode 100644 tests/passes/simplify-invoke-with/conflicting-with-while.expect create mode 100644 tests/passes/simplify-invoke-with/conflicting-with-while.futil create mode 100644 tests/passes/simplify-invoke-with/two_dup_invokes.expect create mode 100644 tests/passes/simplify-invoke-with/two_dup_invokes.futil diff --git a/tests/passes/simplify-invoke-with/basic.expect b/tests/passes/simplify-invoke-with/basic.expect index 3ea9f4047..b0cc73b61 100644 --- a/tests/passes/simplify-invoke-with/basic.expect +++ b/tests/passes/simplify-invoke-with/basic.expect @@ -11,7 +11,6 @@ component main(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) { x2 = std_reg(32); y2 = std_reg(32); mul2 = std_mult_pipe(32); - mul3 = std_mult_pipe(32); @control @generated @protected mul_active = std_wire(1); @control @generated @protected mul2_active = std_wire(1); } diff --git a/tests/passes/simplify-invoke-with/basic.futil b/tests/passes/simplify-invoke-with/basic.futil index e6987a7ff..2d22ee48a 100644 --- a/tests/passes/simplify-invoke-with/basic.futil +++ b/tests/passes/simplify-invoke-with/basic.futil @@ -13,7 +13,6 @@ component main() -> () { x2 = std_reg(32); y2 = std_reg(32); mul2 = std_mult_pipe(32); - mul3 = std_mult_pipe(32); @control @generated @protected mul_active = std_wire(1); @control @generated @protected mul2_active = std_wire(1); diff --git a/tests/passes/simplify-invoke-with/conflicting-invokes.expect b/tests/passes/simplify-invoke-with/conflicting-invokes.expect new file mode 100644 index 000000000..d0ac1ddd6 --- /dev/null +++ b/tests/passes/simplify-invoke-with/conflicting-invokes.expect @@ -0,0 +1,33 @@ +import "primitives/core.futil"; +import "primitives/memories/seq.futil"; +import "primitives/binary_operators.futil"; +component main(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) { + cells { + r = std_reg(32); + x = std_reg(32); + y = std_reg(32); + mul = std_mult_pipe(32); + r2 = std_reg(32); + x2 = std_reg(32); + y2 = std_reg(32); + mul2 = std_mult_pipe(32); + @control @generated @protected mul_active = std_wire(1); + } + wires { + comb group comb_invoke { + mul_active.in = !mul.done ? 1'd1; + } + } + control { + seq { + invoke mul( + left = x.out, + right = y.out + )() with comb_invoke; + invoke mul2( + left = x2.out, + right = y2.out + )() with comb_invoke; + } + } +} diff --git a/tests/passes/simplify-invoke-with/conflicting-invokes.futil b/tests/passes/simplify-invoke-with/conflicting-invokes.futil new file mode 100644 index 000000000..d2aed9cd9 --- /dev/null +++ b/tests/passes/simplify-invoke-with/conflicting-invokes.futil @@ -0,0 +1,30 @@ +// -p simplify-invoke-with + +import "primitives/core.futil"; +import "primitives/memories/seq.futil"; +import "primitives/binary_operators.futil"; +component main() -> () { + cells { + r = std_reg(32); + x = std_reg(32); + y = std_reg(32); + mul = std_mult_pipe(32); + r2 = std_reg(32); + x2 = std_reg(32); + y2 = std_reg(32); + mul2 = std_mult_pipe(32); + + @control @generated @protected mul_active = std_wire(1); + } + wires { + comb group comb_invoke { + mul_active.in = !mul.done ? 1'd1; + } + } + control { + seq { + invoke mul(left = x.out, right = y.out)() with comb_invoke; + invoke mul2(left = x2.out, right = y2.out)() with comb_invoke; + } + } +} \ No newline at end of file diff --git a/tests/passes/simplify-invoke-with/conflicting-with-while.expect b/tests/passes/simplify-invoke-with/conflicting-with-while.expect new file mode 100644 index 000000000..1ebaeff60 --- /dev/null +++ b/tests/passes/simplify-invoke-with/conflicting-with-while.expect @@ -0,0 +1,55 @@ +import "primitives/core.futil"; +import "primitives/memories/seq.futil"; +import "primitives/binary_operators.futil"; +component main(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) { + cells { + r = std_reg(32); + x = std_reg(32); + y = std_reg(32); + mul = std_mult_pipe(32); + r2 = std_reg(32); + x2 = std_reg(32); + y2 = std_reg(32); + mul2 = std_mult_pipe(32); + lt = std_lt(32); + lt_reg = std_reg(1); + @control @generated @protected mul_active = std_wire(1); + } + wires { + group init_x { + x.in = 32'd3; + x.write_en = 1'd1; + init_x[done] = x.done; + } + group init_y { + y.in = 32'd5; + y.write_en = 1'd1; + init_y[done] = y.done; + } + group write_r { + r.in = mul.out; + r.write_en = 1'd1; + write_r[done] = r.done; + } + comb group comb_group { + lt.left = r.out; + lt.right = 32'd25; + mul_active.in = !mul.done ? 1'd1; + } + } + control { + seq { + init_x; + init_y; + while lt.out with comb_group { + seq { + invoke mul( + left = x.out, + right = y.out + )() with comb_group; + write_r; + } + } + } + } +} diff --git a/tests/passes/simplify-invoke-with/conflicting-with-while.futil b/tests/passes/simplify-invoke-with/conflicting-with-while.futil new file mode 100644 index 000000000..70d5eefff --- /dev/null +++ b/tests/passes/simplify-invoke-with/conflicting-with-while.futil @@ -0,0 +1,54 @@ +// -p simplify-invoke-with + +import "primitives/core.futil"; +import "primitives/memories/seq.futil"; +import "primitives/binary_operators.futil"; +component main() -> () { + cells { + r = std_reg(32); + x = std_reg(32); + y = std_reg(32); + mul = std_mult_pipe(32); + r2 = std_reg(32); + x2 = std_reg(32); + y2 = std_reg(32); + mul2 = std_mult_pipe(32); + lt = std_lt(32); + lt_reg = std_reg(1); + + + @control @generated @protected mul_active = std_wire(1); + } + wires { + comb group comb_group { + lt.left = r.out; + lt.right = 32'd25; + mul_active.in = !mul.done ? 1'd1; + } + group init_x { + x.in = 32'd3; + x.write_en = 1'd1; + init_x[done] = x.done; + } + group init_y { + y.in = 32'd5; + y.write_en = 1'd1; + init_y[done] = y.done; + } + group write_r { + r.in = mul.out; + r.write_en = 1'd1; + write_r[done] = r.done; + } + } + control { + seq { + init_x; + init_y; + while lt.out with comb_group { + invoke mul(left = x.out, right = y.out)() with comb_group; + write_r; + } + } + } +} \ No newline at end of file diff --git a/tests/passes/simplify-invoke-with/two_dup_invokes.expect b/tests/passes/simplify-invoke-with/two_dup_invokes.expect new file mode 100644 index 000000000..b8276c84a --- /dev/null +++ b/tests/passes/simplify-invoke-with/two_dup_invokes.expect @@ -0,0 +1,41 @@ +import "primitives/core.futil"; +import "primitives/memories/seq.futil"; +import "primitives/binary_operators.futil"; +component main(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) { + cells { + r = std_reg(32); + x = std_reg(32); + y = std_reg(32); + mul = std_mult_pipe(32); + r2 = std_reg(32); + x2 = std_reg(32); + y2 = std_reg(32); + mul2 = std_mult_pipe(32); + @control @generated @protected mul_active = std_wire(1); + @control @generated @protected mul2_active = std_wire(1); + } + wires { + comb group comb_invoke { + mul_active.in = !mul.done ? 1'd1; + } + comb group comb_invoke1 { + mul2_active.in = !1'd0 ? 1'd1; + } + } + control { + seq { + invoke mul( + left = x.out, + right = y.out + )() with comb_invoke; + invoke mul2( + left = x2.out, + right = y2.out + )() with comb_invoke1; + invoke mul( + left = x.out, + right = y.out + )() with comb_invoke; + } + } +} diff --git a/tests/passes/simplify-invoke-with/two_dup_invokes.futil b/tests/passes/simplify-invoke-with/two_dup_invokes.futil new file mode 100644 index 000000000..6f350862c --- /dev/null +++ b/tests/passes/simplify-invoke-with/two_dup_invokes.futil @@ -0,0 +1,35 @@ +// -p simplify-invoke-with + +import "primitives/core.futil"; +import "primitives/memories/seq.futil"; +import "primitives/binary_operators.futil"; +component main() -> () { + cells { + r = std_reg(32); + x = std_reg(32); + y = std_reg(32); + mul = std_mult_pipe(32); + r2 = std_reg(32); + x2 = std_reg(32); + y2 = std_reg(32); + mul2 = std_mult_pipe(32); + + @control @generated @protected mul_active = std_wire(1); + @control @generated @protected mul2_active = std_wire(1); + } + wires { + comb group comb_invoke { + mul_active.in = !mul.done ? 1'd1; + } + comb group comb_invoke1 { + mul2_active.in = !mul2.done ? 1'd1; + } + } + control { + seq { + invoke mul(left = x.out, right = y.out)() with comb_invoke; + invoke mul2(left = x2.out, right = y2.out)() with comb_invoke1; + invoke mul(left = x.out, right = y.out)() with comb_invoke; + } + } +} \ No newline at end of file