From b92f57eacb1340ae9a79c59cb9f8a5b3626f17d0 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 20 Jul 2009 15:08:50 -0400 Subject: [PATCH] Support constant function calls for parameters - missed adding tests --- test_regress/t/t_func_const.pl | 18 +++++++++ test_regress/t/t_func_const.v | 69 ++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100755 test_regress/t/t_func_const.pl create mode 100644 test_regress/t/t_func_const.v diff --git a/test_regress/t/t_func_const.pl b/test_regress/t/t_func_const.pl new file mode 100755 index 000000000..7058e622f --- /dev/null +++ b/test_regress/t/t_func_const.pl @@ -0,0 +1,18 @@ +#!/usr/bin/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. + +compile ( + ); + +execute ( + check_finished=>1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_func_const.v b/test_regress/t/t_func_const.v new file mode 100644 index 000000000..65f9662a0 --- /dev/null +++ b/test_regress/t/t_func_const.v @@ -0,0 +1,69 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2009 by Wilson Snyder. + +module t; + + localparam P4 = f_add(P3,1); + localparam P8 = f_add2(P3,P3,f_add(1,1)); + localparam P5 = f_while(7); + localparam P16 = f_for(P4); + localparam P18 = f_case(P4); + localparam P3 = 3; + + initial begin +`ifdef TEST_VERBOSE + $display("P5=%0d P8=%0d P16=%0d P18=%0d",P5,P8,P16,P18); +`endif + if (P3 !== 3) $stop; + if (P4 !== 4) $stop; + if (P5 !== 5) $stop; + if (P8 !== 8) $stop; + if (P16 !== 16) $stop; + if (P18 !== 18) $stop; + $write("*-* All Finished *-*\n"); + $finish; + end + + function integer f_add(input [31:0] a, input [31:0] b); + f_add = a+b; + endfunction + + // Speced ok: function called from function + function integer f_add2(input [31:0] a, input [31:0] b, input [31:0] c); + f_add2 = f_add(a,b)+c; + endfunction + + // Speced ok: local variables + function integer f_for(input [31:0] a); + integer i; + integer times; + begin + times = 1; + for (i=0; i