aboutsummaryrefslogtreecommitdiffstats
path: root/tests/simple/task_func.v
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-01-05 11:13:26 +0100
committerClifford Wolf <clifford@clifford.at>2013-01-05 11:13:26 +0100
commit7764d0ba1dcf064ae487ee985c43083a0909e7f4 (patch)
tree18c05b8729df381af71b707748ce1d605e0df764 /tests/simple/task_func.v
downloadyosys-7764d0ba1dcf064ae487ee985c43083a0909e7f4.tar.gz
yosys-7764d0ba1dcf064ae487ee985c43083a0909e7f4.tar.bz2
yosys-7764d0ba1dcf064ae487ee985c43083a0909e7f4.zip
initial import
Diffstat (limited to 'tests/simple/task_func.v')
-rw-r--r--tests/simple/task_func.v35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/simple/task_func.v b/tests/simple/task_func.v
new file mode 100644
index 000000000..3a09cbc35
--- /dev/null
+++ b/tests/simple/task_func.v
@@ -0,0 +1,35 @@
+
+module test01(clk, a, b, c, x, y, z, w);
+
+input clk;
+input [7:0] a, b, c;
+output reg [7:0] x, y, z, w;
+
+function [7:0] sum_shift;
+input [3:0] s1, s2, s3;
+sum_shift = s1 + (s2 << 2) + (s3 << 4);
+endfunction
+
+task reset_w;
+w = 0;
+endtask
+
+task add_to;
+output [7:0] out;
+input [7:0] in;
+out = out + in;
+endtask
+
+always @(posedge clk) begin
+ x = sum_shift(a, b, c);
+ y = sum_shift(a[7:4], b[5:2], c[3:0]);
+ z = sum_shift(a[0], b[5:4], c >> 5) ^ sum_shift(1, 2, 3);
+
+ reset_w;
+ add_to(w, x);
+ add_to(w, y);
+ add_to(w, z);
+end
+
+endmodule
+