Fix bad code when tracing array of structs, bug1122.

This commit is contained in:
Wilson Snyder 2017-01-06 18:44:37 -05:00
parent 663b2be065
commit 2f34132275
5 changed files with 57 additions and 2 deletions

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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