-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_function.sv
53 lines (42 loc) · 1.09 KB
/
task_function.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//===========================================================================
// Simple task and function
//===========================================================================
module this_task_func;
int a,b,c;
// Error in below function prototype
//function void my_task(aa,bb,cc);
//--> No direction specified for args SUM will be wrong
//Input ,output and inout args needs to be specified for SUM
//function void my_task(int aa,int bb,int cc); -try this
function void my_task(input int aa,bb,output int cc);
a=aa;
b=bb;
c=a+b;
cc=c;
$display("a=%0d b=%0d c=%0d",aa,bb,c);
endfunction
initial
begin
int x;
my_task(1,4,x);
my_task(2,4,x);
my_task(3,4,x);
$display("**d**=%0d",x);
end
/*
task automatic my_task(input int aa,bb,output int cc);
a=aa;
b=bb;
c=a+b;
cc=c;
$display("a=%0d b=%0d c=%0d",aa,bb,c);
endtask
initial
begin
int x;
my_task(1,4,x);
my_task(2,4,x);
my_task(3,4,x);
$display("**d**=%0d",x);
end*/
endmodule