From c87c66efb1f5f746710995a68aa0c53c96afb252 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 12 Aug 2015 19:37:25 -0400 Subject: [PATCH] Fix size casts as second argument of cast item, bug950. --- Changes | 2 ++ src/V3AstNodes.h | 1 + src/V3Width.cpp | 3 ++- test_regress/t/t_case_group.pl | 18 ++++++++++++++++++ test_regress/t/t_case_group.v | 25 +++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100755 test_regress/t/t_case_group.pl create mode 100644 test_regress/t/t_case_group.v diff --git a/Changes b/Changes index 252eff867..86aece810 100644 --- a/Changes +++ b/Changes @@ -27,6 +27,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix parameters with function parameter arguments, bug952. [Jie Xu] +**** Fix size casts as second argument of cast item, bug950. [Jonathon Donaldson] + * Verilator 3.874 2015-06-06 diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index eb40e6bd8..22a1dc3c7 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -3514,6 +3514,7 @@ public: setOp1p(lhsp); setOp2p(rhsp); } ASTNODE_NODE_FUNCS(CastSize, CASTSIZE) + // No hasDType because widthing removes this node before the hasDType check virtual string emitVerilog() { return "((%r)'(%l))"; } virtual string emitC() { V3ERROR_NA; return ""; } virtual bool cleanOut() { V3ERROR_NA; return true;} virtual bool cleanLhs() {return true;} diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 1ee35ec80..51e2ef489 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1825,7 +1825,8 @@ private: // Apply width iterateCheck(nodep,"Case expression",nodep->exprp(),CONTEXT,FINAL,subDTypep,EXTEND_LHS); for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) { - for (AstNode* condp = itemp->condsp(); condp; condp=condp->nextp()) { + for (AstNode* nextcp, *condp = itemp->condsp(); condp; condp=nextcp) { + nextcp = condp->nextp(); // Final may cause the node to get replaced iterateCheck(nodep,"Case Item",condp,CONTEXT,FINAL,subDTypep,EXTEND_LHS); } } diff --git a/test_regress/t/t_case_group.pl b/test_regress/t/t_case_group.pl new file mode 100755 index 000000000..f91289753 --- /dev/null +++ b/test_regress/t/t_case_group.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_case_group.v b/test_regress/t/t_case_group.v new file mode 100644 index 000000000..32cb99ed2 --- /dev/null +++ b/test_regress/t/t_case_group.v @@ -0,0 +1,25 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2014 by Jonathon Donaldson. + +module t + ( + input i_clk, + input [6:0] i_input, + output logic o_output + ); + + always_ff @(posedge i_clk) + // verilator lint_off CASEINCOMPLETE + case (i_input) + 7'(92+2), + 7'(92+3): o_output <= 1'b1; + endcase + + initial begin + $write("*-* All Finished *-*\n"); + $finish; + end + +endmodule