From 53cd9d24033042b907241620ea74606eb6002eda Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 10 May 2013 21:02:48 -0400 Subject: [PATCH] Fix nested union crash, bug643. --- Changes | 24 ++++++++++-------- src/V3Width.cpp | 2 +- test_regress/t/t_struct_nest.pl | 18 +++++++++++++ test_regress/t/t_struct_nest.v | 45 +++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 12 deletions(-) create mode 100755 test_regress/t/t_struct_nest.pl create mode 100644 test_regress/t/t_struct_nest.v diff --git a/Changes b/Changes index 465c62ded..ab6a8abd3 100644 --- a/Changes +++ b/Changes @@ -5,17 +5,19 @@ indicates the contributor was also the author of the fix; Thanks! * Verilator 3.847 devel -*** Add ALWCOMBORDER warning. [KC Buckenmaier] - -*** Add --pins-sc-uint and --pins-sc-biguint, bug638. [Alex Hornung] - -**** Support "signal[vec]++". - -**** Fix simulation error when inputs and MULTIDRIVEN, bug634. [Ted Campbell] - -**** Fix module resolution with __, bug631. [Jason McMullan] - -**** Fix packed array non-zero right index select crash, bug642. [Krzysztof Jankowski] +*** Add ALWCOMBORDER warning. [KC Buckenmaier] + +*** Add --pins-sc-uint and --pins-sc-biguint, bug638. [Alex Hornung] + +**** Support "signal[vec]++". + +**** Fix simulation error when inputs and MULTIDRIVEN, bug634. [Ted Campbell] + +**** Fix module resolution with __, bug631. [Jason McMullan] + +**** Fix packed array non-zero right index select crash, bug642. [Krzysztof Jankowski] + +**** Fix nested union crash, bug643. [Krzysztof Jankowski] * Verilator 3.846 2013-03-09 diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 7dbb607ac..34a03d426 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1135,7 +1135,7 @@ private: } else { AstSel* newp = new AstSel(nodep->fileline(), nodep->fromp()->unlinkFrBack(), memberp->lsb(), memberp->width()); - newp->dtypep(memberp); + newp->dtypep(memberp->skipRefp()); // Must skip over the member to find the union; as the member may disappear later newp->didWidth(true); // Don't replace dtype with basic type UINFO(9," MEMBERSEL -> "<replaceWith(newp); diff --git a/test_regress/t/t_struct_nest.pl b/test_regress/t/t_struct_nest.pl new file mode 100755 index 000000000..1774aab4f --- /dev/null +++ b/test_regress/t/t_struct_nest.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 ( + v_flags2 => ["--lint-only"], + verilator_make_gcc => 0, + make_top_shell => 0, + make_main => 0, + ); + +ok(1); +1; diff --git a/test_regress/t/t_struct_nest.v b/test_regress/t/t_struct_nest.v new file mode 100644 index 000000000..8c57b98e3 --- /dev/null +++ b/test_regress/t/t_struct_nest.v @@ -0,0 +1,45 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2013 by Wilson Snyder. + +typedef struct packed { + logic [1:0] b1; + logic [1:0] b2; + logic [1:0] b3; + logic [1:0] b4; +} t__aa_bbbbbbb_ccccc_dddddd_eee; + +typedef struct packed { + logic [31:0] a; + union packed { + logic [7:0] fbyte; + t__aa_bbbbbbb_ccccc_dddddd_eee pairs; + } b1; + logic [23:0] b2; + logic [7:0] c1; + logic [23:0] c2; + logic [31:0] d; +} t__aa_bbbbbbb_ccccc_dddddd; + +typedef struct packed { + logic [31:0] a; + logic [31:0] b; + logic [31:0] c; + logic [31:0] d; +} t__aa_bbbbbbb_ccccc_eee; + +typedef union packed { + t__aa_bbbbbbb_ccccc_dddddd dddddd; + t__aa_bbbbbbb_ccccc_eee eee; +} t__aa_bbbbbbb_ccccc; + + +module t ( + input t__aa_bbbbbbb_ccccc xxxxxxx_yyyyy_zzzz, + output logic [15:0] datao_pre +); + always_comb datao_pre = { xxxxxxx_yyyyy_zzzz.dddddd.b1.fbyte, xxxxxxx_yyyyy_zzzz.dddddd.c1 }; + +endmodule +