|
|
|
|
|
|
|
|
|
|
|
|
Optional argument list
|
|
|
When a task or function specifies no arguments, the empty parenthesis, (), following the task/function name shall be optional. This is also true for tasks or functions that require arguments, when all arguments have defaults specified. |
|
|
|
|
|
|
|
|
|
|
|
Example - Optional argument list
|
|
|
|
|
|
1 module function_optional_list ();
2
3 reg [7:0] data ;
4 reg parity_out;
5 time ltime;
6
7 function reg parity (reg [7:0] a = 8'hAA, time b = 0, time c = 0);
8 parity = 0;
9 for (int i= 0; i < 8; i ++) begin
10 parity = parity ^ a[i];
11 end
12 endfunction
13
14 initial begin
15 parity_out = parity();
16 $display ("Data = %00000000b, Parity = %b", 8'hAA, parity_out);
17 parity_out = parity();
18 $display ("Data = %00000000b, Parity = %b", 8'hAA, parity_out);
19 #10 $finish;
20 end
21
22 endmodule
You could download file function_optional_list.sv here
|
|
|
|
|
|
Simulation Output
|
|
|
|
|
|
Data = 10101010, Parity = 0
Data = 10101010, Parity = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|