From 5a5a0006fe9623f3887d273bc235b861d63c27af Mon Sep 17 00:00:00 2001 From: Jie Xu Date: Wed, 12 Aug 2015 19:29:06 -0400 Subject: [PATCH] Fix parameters with function parameter arguments, bug952. Signed-off-by: Wilson Snyder --- Changes | 2 ++ src/V3Simulate.h | 6 ++++-- test_regress/t/t_param_func.pl | 14 ++++++++++++++ test_regress/t/t_param_func.v | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100755 test_regress/t/t_param_func.pl create mode 100644 test_regress/t/t_param_func.v diff --git a/Changes b/Changes index f39183019..252eff867 100644 --- a/Changes +++ b/Changes @@ -25,6 +25,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix coverage documentation, bug954. [Thomas J Whatson] +**** Fix parameters with function parameter arguments, bug952. [Jie Xu] + * Verilator 3.874 2015-06-06 diff --git a/src/V3Simulate.h b/src/V3Simulate.h index a61b25b00..2114c8ff3 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -260,7 +260,9 @@ private: // We can't have non-delayed assignments with same value on LHS and RHS // as we don't figure out variable ordering. // Delayed is OK though, as we'll decode the next state separately. - if (!nodep->varp()->dtypeSkipRefp()->castBasicDType()) clearOptimizable(nodep,"Array references/not basic"); + if (!nodep->varp()->dtypeSkipRefp()->castBasicDType() + && !nodep->varp()->dtypeSkipRefp()->castPackArrayDType()) + clearOptimizable(nodep,"Array references/not basic"); if (nodep->lvalue()) { if (m_inDlyAssign) { if (!(vscp->user1() & VU_LVDLY)) { @@ -450,7 +452,7 @@ private: if (!m_params) { clearOptimizable(nodep, "LHS has select"); return; } checkNodeInfo(selp); AstVarRef* varrefp = selp->fromp()->castVarRef(); - if (!varrefp) { + if (!varrefp) { clearOptimizable(nodep, "Select LHS isn't simple variable"); return; } diff --git a/test_regress/t/t_param_func.pl b/test_regress/t/t_param_func.pl new file mode 100755 index 000000000..385b6a57e --- /dev/null +++ b/test_regress/t/t_param_func.pl @@ -0,0 +1,14 @@ +#!/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 ( + ); + +ok(1); +1; diff --git a/test_regress/t/t_param_func.v b/test_regress/t/t_param_func.v new file mode 100644 index 000000000..98fa4ed03 --- /dev/null +++ b/test_regress/t/t_param_func.v @@ -0,0 +1,34 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This test examines Verilator against paramter definition with functions. +// Particularly the function takes in argument which is multi-dimentional. +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2015 by Roland Kruse and Jie Xu. + +module test#( + parameter size = 4, + parameter p = sum({32'h1,32'h2,32'h3,32'h4}, size)) + + (input clk, + input logic sel, + output [p:0] res); + + logic [p:0] cc = 'h45; + + assign res = sel ? cc : {(p+1){1'b1}}; + + function integer sum; + input [3:0][31:0] values; + input int size; + + sum = 0; + + begin + for (int i = 0; i < size; i ++) + sum += values[i]; + end + endfunction + +endmodule +