diff --git a/Changes b/Changes index bf21d1ed3..50fbf7ae4 100644 --- a/Changes +++ b/Changes @@ -13,6 +13,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix internal error on unique casez with --assert, bug1117. [Enzo Chi] +**** Fix bad code when tracing array of structs, bug1122. [Andrew Bardsley] + * Verilator 3.890 2016-11-25 diff --git a/src/V3Const.cpp b/src/V3Const.cpp index e5ee24985..61be6d91d 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1435,7 +1435,12 @@ private: if (!m_selp) { nodep->v3error("Illegal assignment of constant to unpacked array"); } else { - nodep->replaceWith(nodep->fromp()->unlinkFrBack()); + AstNode* fromp = nodep->fromp()->unlinkFrBack(); + nodep->replaceWith(fromp); + if (fromp->dtypep()->skipRefp()->castNodeArrayDType()) { + // Strip off array to find what array references + fromp->dtypeFrom(fromp->dtypep()->skipRefp()->castNodeArrayDType()->subDTypep()); + } } } m_selp = NULL; diff --git a/test_regress/t/t_EXAMPLE.v b/test_regress/t/t_EXAMPLE.v index 10a006518..9a8fca418 100644 --- a/test_regress/t/t_EXAMPLE.v +++ b/test_regress/t/t_EXAMPLE.v @@ -13,7 +13,7 @@ // please note it here, otherwise:** // // This file ONLY is placed into the Public Domain, for any use, -// without warranty, 2016 by ____YOUR_NAME_HERE____. +// without warranty, 2017 by ____YOUR_NAME_HERE____. module t (/*AUTOARG*/ // Inputs diff --git a/test_regress/t/t_trace_packed_struct.pl b/test_regress/t/t_trace_packed_struct.pl new file mode 100755 index 000000000..f1d1f6c41 --- /dev/null +++ b/test_regress/t/t_trace_packed_struct.pl @@ -0,0 +1,19 @@ +#!/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 ( + v_flags2 => ["--trace"] + ); + +execute ( + check_finished=>1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_trace_packed_struct.v b/test_regress/t/t_trace_packed_struct.v new file mode 100644 index 000000000..4caac627c --- /dev/null +++ b/test_regress/t/t_trace_packed_struct.v @@ -0,0 +1,29 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2017 by Andrew Bardsley. + +module t (/*AUTOARG*/ + // Inputs + clk + ); + + input clk; + + // This won't compile with tracing as an incorrect declaration is made for + // the temp variables used to represent the elements of localparam v + typedef struct packed { + logic [2:0][31:0] a; + } t; + + localparam t v[2:0] = '{ + '{'{32'h10000002, 32'h10000001, 32'h10000000}}, + '{'{32'h20000002, 32'h20000001, 32'h20000000}}, + '{'{32'h30000002, 32'h30000001, 32'h30000000}} + }; + + initial begin + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule