Add regression tests for constant recursive functions
Check that constant recursive functions are supported. Check both Verilog style using assignments to the implicit function return signal and SystemVerilog style using `return`. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
5b6d8e968d
commit
338516bc55
|
|
@ -0,0 +1,3 @@
|
|||
factorial 3 = 6
|
||||
factorial 4 = 24
|
||||
factorial 5 = 120
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// Check that constant recursive functions are supported.
|
||||
|
||||
module recursive_func();
|
||||
|
||||
function automatic [15:0] factorial;
|
||||
|
||||
input [15:0] n;
|
||||
|
||||
begin
|
||||
factorial = (n > 1) ? factorial(n - 1) * n : n;
|
||||
end
|
||||
|
||||
endfunction
|
||||
|
||||
localparam F3 = factorial(3);
|
||||
localparam F4 = factorial(4);
|
||||
localparam F5 = factorial(5);
|
||||
|
||||
initial begin
|
||||
$display("factorial 3 = %0d", F3);
|
||||
$display("factorial 4 = %0d", F4);
|
||||
$display("factorial 5 = %0d", F5);
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// Check that constant recursive functions are supported when the `return`
|
||||
// statement is used.
|
||||
|
||||
module recursive_func();
|
||||
|
||||
function automatic [15:0] factorial(input [15:0] n);
|
||||
if (n > 1) begin
|
||||
return factorial(n - 1) * n;
|
||||
end
|
||||
return n;
|
||||
endfunction
|
||||
|
||||
localparam F3 = factorial(3);
|
||||
localparam F4 = factorial(4);
|
||||
localparam F5 = factorial(5);
|
||||
|
||||
initial begin
|
||||
$display("factorial 3 = %0d", F3);
|
||||
$display("factorial 4 = %0d", F4);
|
||||
$display("factorial 5 = %0d", F5);
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -403,6 +403,7 @@ program5b CE,-g2009 ivltests
|
|||
program_hello normal,-g2009 ivltests
|
||||
program_hello2 CE,-g2009 ivltests
|
||||
recursive_func2 normal,-g2005-sv ivltests gold=recursive_func.gold
|
||||
recursive_func_const2 normal,-g2005-sv ivltests gold=recursive_func_const.gold
|
||||
sbyte_test normal,-g2005-sv ivltests
|
||||
scalar_vector normal,-g2005-sv ivltests
|
||||
sf_countbits normal,-g2012 ivltests
|
||||
|
|
|
|||
|
|
@ -1470,6 +1470,7 @@ real_invalid_ops CE ivltests gold=real_invalid_ops.gold
|
|||
real_logical normal ivltests
|
||||
real_reg_force_rel normal ivltests
|
||||
recursive_func1 normal ivltests gold=recursive_func.gold
|
||||
recursive_func_const1 normal ivltests gold=recursive_func_const.gold
|
||||
recursive_task normal ivltests gold=recursive_task.gold
|
||||
redef_net_error CE ivltests
|
||||
redef_reg_error CE ivltests
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ pr2929913 CE ivltests
|
|||
real_events CE ivltests
|
||||
recursive_func1 CE ivltests
|
||||
recursive_func2 CE ivltests
|
||||
recursive_func_const1 CE ivltests
|
||||
recursive_func_const2 CE ivltests
|
||||
recursive_task CE ivltests
|
||||
task_init_var1 CE,-pallowsigned=1 ivltests
|
||||
task_init_var2 CE,-pallowsigned=1 ivltests
|
||||
|
|
|
|||
Loading…
Reference in New Issue