aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJannis Harder <me@jix.one>2023-03-20 12:50:14 +0100
committerJannis Harder <me@jix.one>2023-03-20 12:52:46 +0100
commitfb1c2be76ba065a3da04f279b11e1ed2e59c75c5 (patch)
treef452376b633c339d43d7e2e16cc991465ebeef25 /tests
parent61da330a38812a0a394131f9f434c736cb2239cf (diff)
downloadyosys-fb1c2be76ba065a3da04f279b11e1ed2e59c75c5.tar.gz
yosys-fb1c2be76ba065a3da04f279b11e1ed2e59c75c5.tar.bz2
yosys-fb1c2be76ba065a3da04f279b11e1ed2e59c75c5.zip
verilog: Support void functions
The difference between void functions and tasks is that always_comb's implicit sensitivity list behaves as if functions were inlined, but ignores signals read only in tasks. This only matters for event based simulation, and for synthesis we can treat a void function like a task.
Diffstat (limited to 'tests')
-rw-r--r--tests/verilog/void_func.ys37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/verilog/void_func.ys b/tests/verilog/void_func.ys
new file mode 100644
index 000000000..6fb7b4b56
--- /dev/null
+++ b/tests/verilog/void_func.ys
@@ -0,0 +1,37 @@
+read_verilog -sv <<EOF
+module top_func(input [7:0] a, output [7:0] b);
+ function automatic void clear_b; b = 0; endfunction
+ function automatic void increment_b; b += a; endfunction
+ always_comb begin
+ clear_b;
+ increment_b;
+ increment_b;
+ end
+endmodule
+
+module top_task(input [7:0] a, output [7:0] b);
+ task automatic clear_b; b = 0; endtask
+ task automatic increment_b; b += a; endtask
+ always_comb begin
+ clear_b;
+ increment_b;
+ increment_b;
+ end
+endmodule
+
+module top_inline(input [7:0] a, output [7:0] b);
+ always_comb begin
+ b = 0;
+ b += a;
+ b += a;
+ end
+endmodule
+EOF
+
+prep
+
+miter -equiv -flatten -make_assert top_inline top_task miter_task
+sat -verify -prove-asserts miter_task
+
+miter -equiv -flatten -make_assert top_inline top_func miter_func
+sat -verify -prove-asserts miter_func