Tests: Update recursive function tests
This commit is contained in:
parent
ebf5c11e03
commit
78052f87bd
|
|
@ -1,6 +0,0 @@
|
|||
%Error-UNSUPPORTED: t/t_func_bad2.v:8:13: Unsupported: Recursive function or task call
|
||||
: ... In instance t
|
||||
8 | function recurse;
|
||||
| ^~~~~~~
|
||||
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
|
||||
%Error: Exiting due to
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t;
|
||||
function recurse;
|
||||
input i;
|
||||
recurse = recurse2(i);
|
||||
endfunction
|
||||
|
||||
function recurse2;
|
||||
input i;
|
||||
recurse2 = recurse(i);
|
||||
endfunction
|
||||
|
||||
endmodule
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
%Error-UNSUPPORTED: t/t_func_bad3.v:12:27: Unsupported: Recursive function call 'recurse_self'
|
||||
12 | else recurse_self = recurse_self(i - 1) + 1;
|
||||
| ^~~~~~~~~~~~
|
||||
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
|
||||
%Error: Exiting due to
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
%Error-UNSUPPORTED: t/t_func_recurse.v:12:31: Unsupported: Recursive function call 'recurse_self'
|
||||
12 | else recurse_self = i + recurse_self(i - 1) * 2;
|
||||
| ^~~~~~~~~~~~
|
||||
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
|
||||
%Error: Exiting due to
|
||||
|
|
@ -15,5 +15,9 @@ compile(
|
|||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
execute(
|
||||
check_finished => 1,
|
||||
) if !$Self->{vlt_all};
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t;
|
||||
|
||||
function automatic int recurse_self;
|
||||
input int i;
|
||||
if (i == 0) recurse_self = 0;
|
||||
else recurse_self = i + recurse_self(i - 1) * 2;
|
||||
endfunction
|
||||
|
||||
initial begin
|
||||
if (recurse_self(0) != 0) $stop;
|
||||
if (recurse_self(3) != (3 + 2*(2 + 2*(1)))) $stop;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
%Error-UNSUPPORTED: t/t_func_recurse2.v:9:27: Unsupported: Recursive function or task call
|
||||
: ... In instance t
|
||||
9 | function automatic int recurse_1;
|
||||
| ^~~~~~~~~
|
||||
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
|
||||
%Error: Exiting due to
|
||||
|
|
@ -15,5 +15,9 @@ compile(
|
|||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
execute(
|
||||
check_finished => 1,
|
||||
) if !$Self->{vlt_all};
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t;
|
||||
|
||||
function automatic int recurse_1;
|
||||
input int i;
|
||||
if (i == 0) recurse_1 = 0;
|
||||
else recurse_1 = i + recurse_2(i);
|
||||
endfunction
|
||||
|
||||
function automatic int recurse_2;
|
||||
input int i;
|
||||
return recurse_1(i - 1) * 2;
|
||||
endfunction
|
||||
|
||||
initial begin
|
||||
if (recurse_1(0) != 0) $stop;
|
||||
if (recurse_1(3) != (3 + 2*(2 + 2*(1)))) $stop;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
%Error-UNSUPPORTED: t/t_func_recurse_param.v:12:31: Unsupported: Recursive function call 'recurse_self'
|
||||
12 | else recurse_self = i + recurse_self(i - 1) * 2;
|
||||
| ^~~~~~~~~~~~
|
||||
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
|
||||
%Error: Exiting due to
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003 by Wilson Snyder. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
compile(
|
||||
fails => $Self->{vlt_all},
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
execute(
|
||||
check_finished => 1,
|
||||
) if !$Self->{vlt_all};
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t;
|
||||
|
||||
function automatic int recurse_self;
|
||||
input int i;
|
||||
if (i == 0) recurse_self = 0;
|
||||
else recurse_self = i + recurse_self(i - 1) * 2;
|
||||
endfunction
|
||||
|
||||
localparam int ZERO = recurse_self(0);
|
||||
localparam int ELEVEN = recurse_self(3);
|
||||
|
||||
initial begin
|
||||
if (ZERO != 0) $stop;
|
||||
if (ELEVEN != 11) $stop;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
%Error-UNSUPPORTED: t/t_func_recurse_param_bad.v:12:31: Unsupported: Recursive function call 'recurse_self'
|
||||
12 | else recurse_self = i + recurse_self(i - 1) * 2;
|
||||
| ^~~~~~~~~~~~
|
||||
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
|
||||
%Error: Exiting due to
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003 by Wilson Snyder. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(vlt => 1);
|
||||
|
||||
lint(
|
||||
fails => 1,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
@ -6,10 +6,18 @@
|
|||
|
||||
module t;
|
||||
|
||||
function recurse_self;
|
||||
input i;
|
||||
function automatic int recurse_self;
|
||||
input int i;
|
||||
if (i == 0) recurse_self = 0;
|
||||
else recurse_self = recurse_self(i - 1) + 1;
|
||||
else recurse_self = i + recurse_self(i - 1) * 2;
|
||||
endfunction
|
||||
|
||||
localparam int HUGE = recurse_self(10000); // too much recursion
|
||||
|
||||
initial begin
|
||||
$display(HUGE);
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -10,8 +10,6 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
|
|||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
#!$Self->{vcs} or unsupported("VCS does ** wrong, fixed in 2014");
|
||||
|
||||
compile(
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue